coze-bridge 0.1.99 → 0.1.100-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +74 -73
- 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 Jp=Object.create;var _a=Object.defineProperty;var Yp=Object.getOwnPropertyDescriptor;var Zp=Object.getOwnPropertyNames;var Xp=Object.getPrototypeOf,Qp=Object.prototype.hasOwnProperty;var de=(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 se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ya=(t,e)=>{for(var r in e)_a(t,r,{get:e[r],enumerable:!0})},eg=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zp(e))!Qp.call(t,o)&&o!==r&&_a(t,o,{get:()=>e[o],enumerable:!(i=Yp(e,o))||i.enumerable});return t};var St=(t,e,r)=>(r=t!=null?Jp(Xp(t)):{},eg(e||!t||!t.__esModule?_a(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 tg,mkdirSync as ng,readdirSync as rg,unlinkSync as ig}from"node:fs";import{join as ll}from"node:path";function In(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Qn(t,e){return`${t}-${e}.log`}function Ea(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function sg(t,e,r){let i=c=>{let[d,u,x]=c.split("-").map(Number);return Date.UTC(d??0,(u??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function es(t,e,r,i){let o;try{o=rg(t)}catch{return}for(let c of o){let d=Ea(c,e);if(d&&sg(d,r,i))try{ig(ll(t,c))}catch{}}}var Kr,ba=Je(()=>{"use strict";Kr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>In(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{ng(this.dir,{recursive:!0});let r=tg(ll(this.dir,Qn(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:
|
|
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 og,mkdirSync as ag}from"node:fs";import{join as cg}from"node:path";function fl(t){let e=t.retentionDays??ug,r=t.clock??(()=>In(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 fg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function xl(t){va=t}function hl(t){return er[va]<=er[t]}function pl(t,e){let r=er[t];return r===void 0?!0:r>=er[e]}function rs(t){ul={...t}}function gl(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),d=e(o%60);return`${In(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${d}`}function $r(t,e,r,i,o){try{let c=`${JSON.stringify({ts:gl(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;ag(t,{recursive:!0}),og(cg(t,Qn("bridge",In(new Date))),c)}catch{}}function xg(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(er[t]<er[va])return;let c=`${JSON.stringify({ts:gl(new Date),level:t,module:e,msg:r,...ul,...i})}
|
|
12
|
+
`;if(ns){let d=xg(o,i),u=d?fg(ns,d):ns.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?lg.write(c):dg.write(c)}function H(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=>H(`${t}.${r}`,e),forAgent:r=>H(t,r)}}var er,va,dg,lg,ul,ug,ns,ne=Je(()=>{"use strict";Wr();ba();er={debug:10,info:20,warn:30,error:40},va=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),dg=process.stdout,lg=process.stderr,ul={},ug=Ye("COZE_BRIDGE_LOG_RETENTION_DAYS",30),ns=null});var D,je=Je(()=>{"use strict";D=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var yl={};ya(yl,{ACP_WRAPPER_NPM_PACKAGES:()=>Vr,_resetAcpInstallerForTests:()=>_g,_setBinaryPathCacheForTests:()=>yg,buildAcpSpawn:()=>Jr,ensureAcpInstalled:()=>nr,getAcpBinaryPath:()=>ss,pickWhichLine:()=>Ia,probeAcpVersion:()=>wg,resolveAcpCommand:()=>_l});import{readFileSync as ml}from"node:fs";import{createRequire as hg}from"node:module";import{dirname as pg,resolve as gg}from"node:path";function Aa(t){if(t!=="codex")return;let e=process.env.COZE_BRIDGE_CODEX_ACP_BIN?.trim();return e||void 0}function Ia(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 mg(t){let e=wl.resolve(`${t.npmPackage}/package.json`),r=pg(e),i=JSON.parse(ml(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 gg(r,o)}async function nr(t,e){let r=Sa[t];if(!r)throw new D("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=tr.get(t);if(i)return i;let o=Aa(t);if(o)return tr.set(t,o),is.info("acp wrapper overridden by env",{framework:t,path:o}),o;try{let c=mg(r);return tr.set(t,c),is.info("acp wrapper resolved",{framework:t,binary:r.binary,path:c}),c}catch(c){throw is.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(c)}),new D("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:c})}}async function wg(t){let e=Sa[t];if(e)try{let r=wl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(ml(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){is.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ss(t){return tr.get(t)}function _l(t,e){if(e)return e;let r=Aa(t);if(r)return r;let i=ss(t);if(!i)throw new D("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return i}function Jr(t,e,r){if(e)return{command:e,args:[...r]};let i=Aa(t);if(i)return{command:i,args:[...r]};let o=_l(t);return{command:process.execPath,args:[o,...r]}}function _g(){tr.clear()}function yg(t,e){tr.set(t,e)}var is,Sa,Vr,wl,tr,en=Je(()=>{"use strict";je();ne();is=H("agents.acp-installer"),Sa={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Vr=Object.values(Sa).filter(t=>t!==void 0).map(t=>t.npmPackage),wl=hg(import.meta.url),tr=new Map});import{chmod as bg,mkdir as vg,readFile as Sg,rename as vl,writeFile as Sl}from"node:fs/promises";import{dirname as Ag}from"node:path";async function tn(t){try{let e=await Sg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nn(t,e,r){await vg(Ag(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 Sl(o,i,{encoding:"utf8",mode:r.mode}):await Sl(o,i,"utf8"),await vl(o,t),r?.mode!==void 0&&await bg(t,r.mode)}catch(c){await vl(o,o).catch(()=>{});let{rm:d}=await import("node:fs/promises");throw await d(o,{force:!0}).catch(()=>{}),c}}var Yr=Je(()=>{"use strict"});import{promises as Al,readdirSync as Ig}from"node:fs";import{homedir as Tg}from"node:os";import{sep as Cg,join as Ae,resolve as Il}from"node:path";function Y(t){let e=t??Tg(),r=Ae(e,".coze"),i=Ae(r,"bridge"),o=Ae(i,"lib"),c=Ae(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ae(o,"index.js"),binDir:Ae(i,"bin"),pidFile:Ae(i,"bridge.pid"),portFile:Ae(i,"bridge.port"),tokenFile:Ae(i,"bridge.token"),patTokenFile:Ae(i,"pat-token"),agentEnvFile:Ae(i,"agent-env.json"),logFile:Ae(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ae(c,"daemon-stdio.log"),installLock:Ae(i,"install.lock"),configFile:Ae(i,"config.json"),agentsRoot:Ae(r,"agents")}}function We(t,e=Y()){let r=Ae(e.agentsRoot,t);return{root:r,config:Ae(r,"config.json"),workspace:Ae(r,"workspace"),logs:Ae(r,"logs")}}function os(t=Y()){try{return Ig(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Zr(t,e){let r=await Al.realpath(Il(t)).catch(()=>null);if(!r)return!1;let i=await Al.realpath(Il(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+Cg)}var Ie=Je(()=>{"use strict"});var ds={};ya(ds,{AGENT_CONFIG_FILE_MODE:()=>as,enforceAgentConfigMode:()=>kg,loadAgentConfig:()=>He,persistAgentSessions:()=>Xr,persistAgentSkills:()=>cs,saveAgentConfig:()=>Ze});import{chmod as Dg,stat as Rg}from"node:fs/promises";function He(t,e){return tn(We(t,e).config)}function Ze(t,e){return nn(We(t.agentId,e).config,t,{mode:as})}async function kg(t,e){if(process.platform==="win32")return;let r=We(t,e).config;try{let i=await Rg(r);if(!i.isFile())return;let o=i.mode&511;o!==as&&(await Dg(r,as),Tl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Tl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Xr(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await Ze(i,r))}async function cs(t,e,r){let i=await He(t,r);i&&(i.skills=e,await Ze(i,r))}var Tl,as,rn=Je(()=>{"use strict";Yr();ne();Ie();Tl=H("agent-config"),as=384});var Ca=se((E2,kl)=>{kl.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var us=se(Ol=>{var Pl={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 Mg(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(Pl))Ol[t]=Mg(Pl[t])});var Fl=se((v2,Bl)=>{var Bg=de("fs"),Pe=de("path"),Nl=Ca(),Fg=us(),zg=typeof process=="object"&&process.platform==="win32",Ll=t=>typeof t=="object"&&t!==null,Ml=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=Pe.sep,this.fs=Bg,Ll(t)&&Ll(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Bl.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 d;try{d=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(d&&d.isFile())throw Fg.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 d=Pe.dirname(t);o.fs.existsSync(d)||o.makeDir(d);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};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(d){if(d&&!r)return o(!1);c.fs.stat(t,function(u,x){if(d&&x.isDirectory())return o(!1);var h=Pe.dirname(t);c.fs.exists(h,function(w){w||c.makeDir(h),c.fs.open(t,"w",438,function(y,A){y?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(E,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let d=[];return e.fs.readdirSync(i).forEach(function(u){let x=Pe.join(i,u),h=e.fs.statSync(x);(!o||o.test(x))&&d.push(Pe.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(d=d.concat(r(x,o,c)))}),d}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 d=c.length;if(!d)return e(null,i);c.forEach(function(u){u=Pe.join(t,u),r.fs.stat(u,function(x,h){if(x)return e(x);h&&(i.push(Pe.normalize(u)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(u,function(w,y){if(w)return e(w);i=i.concat(y),--d||e(null,i)}):--d||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Ml[(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 Nl.STORED:return"STORED ("+t+")";case Nl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.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=Pe.resolve(Pe.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Pe.normalize(Pe.join(t,r.slice(i,o).join(Pe.sep)));if(c.indexOf(t)===0)return c}return Pe.normalize(Pe.join(t,Pe.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=zg;Ee.crcTable=Ml});var Ul=se((S2,zl)=>{var Ug=de("path");zl.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=Ug.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 Gl=se((A2,Hl)=>{Hl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=se((I2,ir)=>{ir.exports=Fl();ir.exports.Constants=Ca();ir.exports.Errors=us();ir.exports.FileAttr=Ul();ir.exports.decoder=Gl()});var jl=se((T2,ql)=>{var sn=sr(),z=sn.Constants;ql.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,d=0,u=0,x=0,h=0,w=0,y=0,A=0,E=0,v=0;t|=sn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},S=_=>Math.max(0,_)>>>0,R=_=>Math.max(0,_)&65535,N=_=>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&z.FLG_EFS)>0},set flags_efs(_){_?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(_){_?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(_){switch(_){case z.STORED:this.version=10;case z.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 N(o>>>8)},get crc(){return c},set crc(_){c=S(_)},get compressedSize(){return d},set compressedSize(_){d=S(_)},get size(){return u},set size(_){u=S(_)},get fileNameLength(){return x},set fileNameLength(_){x=_},get extraLength(){return h},set extraLength(_){h=_},get extraLocalLength(){return I.extraLen},set extraLocalLength(_){I.extraLen=_},get commentLength(){return w},set commentLength(_){w=_},get diskNumStart(){return y},set diskNumStart(_){y=S(_)},get inAttr(){return A},set inAttr(_){A=S(_)},get attr(){return E},set attr(_){E=S(_)},get fileAttr(){return(E||0)>>16&4095},get offset(){return v},set offset(_){v=S(_)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+x+h+w},get realDataOffset(){return v+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(_){var k=_.slice(v,v+z.LOCHDR);if(k.readUInt32LE(0)!==z.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=k.readUInt16LE(z.LOCVER),I.flags=k.readUInt16LE(z.LOCFLG),I.flags_desc=(I.flags&z.FLG_DESC)>0,I.method=k.readUInt16LE(z.LOCHOW),I.time=k.readUInt32LE(z.LOCTIM),I.crc=k.readUInt32LE(z.LOCCRC),I.compressedSize=k.readUInt32LE(z.LOCSIZ),I.size=k.readUInt32LE(z.LOCLEN),I.fnameLen=k.readUInt16LE(z.LOCNAM),I.extraLen=k.readUInt16LE(z.LOCEXT);let P=v+z.LOCHDR+I.fnameLen,B=P+I.extraLen;return _.slice(P,B)},loadFromBinary:function(_){if(_.length!==z.CENHDR||_.readUInt32LE(0)!==z.CENSIG)throw sn.Errors.INVALID_CEN();t=_.readUInt16LE(z.CENVEM),e=_.readUInt16LE(z.CENVER),r=_.readUInt16LE(z.CENFLG),i=_.readUInt16LE(z.CENHOW),o=_.readUInt32LE(z.CENTIM),c=_.readUInt32LE(z.CENCRC),d=_.readUInt32LE(z.CENSIZ),u=_.readUInt32LE(z.CENLEN),x=_.readUInt16LE(z.CENNAM),h=_.readUInt16LE(z.CENEXT),w=_.readUInt16LE(z.CENCOM),y=_.readUInt16LE(z.CENDSK),A=_.readUInt16LE(z.CENATT),E=_.readUInt32LE(z.CENATX),v=_.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(z.LOCHDR);return _.writeUInt32LE(z.LOCSIG,0),_.writeUInt16LE(e,z.LOCVER),_.writeUInt16LE(r,z.LOCFLG),_.writeUInt16LE(i,z.LOCHOW),_.writeUInt32LE(o,z.LOCTIM),_.writeUInt32LE(c,z.LOCCRC),_.writeUInt32LE(d,z.LOCSIZ),_.writeUInt32LE(u,z.LOCLEN),_.writeUInt16LE(x,z.LOCNAM),_.writeUInt16LE(I.extraLen,z.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(z.CENHDR+x+h+w);return _.writeUInt32LE(z.CENSIG,0),_.writeUInt16LE(t,z.CENVEM),_.writeUInt16LE(e,z.CENVER),_.writeUInt16LE(r,z.CENFLG),_.writeUInt16LE(i,z.CENHOW),_.writeUInt32LE(o,z.CENTIM),_.writeUInt32LE(c,z.CENCRC),_.writeUInt32LE(d,z.CENSIZ),_.writeUInt32LE(u,z.CENLEN),_.writeUInt16LE(x,z.CENNAM),_.writeUInt16LE(h,z.CENEXT),_.writeUInt16LE(w,z.CENCOM),_.writeUInt16LE(y,z.CENDSK),_.writeUInt16LE(A,z.CENATT),_.writeUInt32LE(E,z.CENATX),_.writeUInt32LE(v,z.CENOFF),_},toJSON:function(){let _=function(k){return k+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(d),size:_(u),fileNameLength:_(x),extraLength:_(h),commentLength:_(w),diskNumStart:y,inAttr:A,attr:E,offset:v,centralHeaderSize:_(z.CENHDR+x+h+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Kl=se((C2,Wl)=>{var or=sr(),me=or.Constants;Wl.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 me.ENDHDR+o},loadFromBinary:function(c){if((c.length!==me.ENDHDR||c.readUInt32LE(0)!==me.ENDSIG)&&(c.length<me.ZIP64HDR||c.readUInt32LE(0)!==me.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===me.ENDSIG?(t=c.readUInt16LE(me.ENDSUB),e=c.readUInt16LE(me.ENDTOT),r=c.readUInt32LE(me.ENDSIZ),i=c.readUInt32LE(me.ENDOFF),o=c.readUInt16LE(me.ENDCOM)):(t=or.readBigUInt64LE(c,me.ZIP64SUB),e=or.readBigUInt64LE(c,me.ZIP64TOT),r=or.readBigUInt64LE(c,me.ZIP64SIZE),i=or.readBigUInt64LE(c,me.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(me.ENDHDR+o);return c.writeUInt32LE(me.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,me.ENDSUB),c.writeUInt16LE(e,me.ENDTOT),c.writeUInt32LE(r,me.ENDSIZ),c.writeUInt32LE(i,me.ENDOFF),c.writeUInt16LE(o,me.ENDCOM),c.fill(" ",me.ENDHDR),c},toJSON:function(){let c=function(d,u){let x=d.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ra=se(Da=>{Da.EntryHeader=jl();Da.MainHeader=Kl()});var Vl=se((R2,$l)=>{$l.exports=function(t){var e=de("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],d=0;o.on("data",function(u){c.push(u),d+=u.length}),o.on("end",function(){var u=Buffer.alloc(d),x=0;u.fill(0);for(var h=0;h<c.length;h++){var w=c[h];w.copy(u,x),x+=w.length}i&&i(u)}),o.end(t)}}}});var Yl=se((k2,Jl)=>{var Hg=+(process.versions?process.versions.node:"").split(".")[0]||0;Jl.exports=function(t,e){var r=de("zlib");let i=Hg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),d=[],u=0;c.on("data",function(x){d.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),h=0;x.fill(0);for(var w=0;w<d.length;w++){var y=d[w];y.copy(x,h),h+=y.length}o&&o(x)}),c.end(t)}}}});var tu=se((P2,eu)=>{"use strict";var{randomFillSync:Zl}=de("crypto"),Gg=us(),qg=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}),Ql=(t,e)=>Math.imul(t,e)>>>0,Xl=(t,e)=>qg[(t^e)&255]^t>>>8,Qr=()=>typeof Zl=="function"?Zl(Buffer.alloc(12)):Qr.node();Qr.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 fs={genSalt:Qr};function xs(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])}xs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Xl(e[0],t),e[1]+=e[0]&255,e[1]=Ql(e[1],134775813)+1,e[2]=Xl(e[2],e[1]>>>24),t};xs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ql(t,t^1)>>8&255};function jg(t){let e=new xs(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 Wg(t){let e=new xs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let d=e.next();i[o++]=c^d,e.updateKeys(c)}return i}}function Kg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=jg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Gg.WRONG_PASSWORD();return i(t.slice(12))}function $g(t){Buffer.isBuffer(t)&&t.length>=12?fs.genSalt=function(){return t.slice(0,12)}:t==="node"?fs.genSalt=Qr.node:fs.genSalt=Qr}function Vg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Wg(r),c=fs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return o(c,d),o(t,d,12)}eu.exports={decrypt:Kg,encrypt:Vg,_salter:$g}});var nu=se(hs=>{hs.Deflater=Vl();hs.Inflater=Yl();hs.ZipCrypto=tu()});var Pa=se((N2,ru)=>{var oe=sr(),Jg=Ra(),be=oe.Constants,ka=nu();ru.exports=function(t,e){var r=new Jg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let w=t,y=typeof w.decoder=="object"?w.decoder:oe.decoder;h=y.hasOwnProperty("efs")?y.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function E(_){if(!r.flags_desc&&!r.localHeader.flags_desc){if(oe.crc32(_)!==r.localHeader.crc)return!1}else{let k={},P=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(P)==be.LOCSIG||e.readUInt32LE(P)==be.CENSIG)throw oe.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(P)==be.EXTSIG)k.crc=e.readUInt32LE(P+be.EXTCRC),k.compressedSize=e.readUInt32LE(P+be.EXTSIZ),k.size=e.readUInt32LE(P+be.EXTLEN);else if(e.readUInt16LE(P+12)===19280)k.crc=e.readUInt32LE(P+be.EXTCRC-4),k.compressedSize=e.readUInt32LE(P+be.EXTSIZ-4),k.size=e.readUInt32LE(P+be.EXTLEN-4);else throw oe.Errors.DESCRIPTOR_UNKNOWN();if(k.compressedSize!==r.compressedSize||k.size!==r.size||k.crc!==r.crc)throw oe.Errors.DESCRIPTOR_FAULTY();if(oe.crc32(_)!==k.crc)return!1}return!0}function v(_,k,P){if(typeof k>"u"&&typeof _=="string"&&(P=_,_=void 0),c)return _&&k&&k(Buffer.alloc(0),oe.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=A();if(B.length===0)return _&&k&&k(B),B;if(r.encrypted){if(typeof P!="string"&&!Buffer.isBuffer(P))throw oe.Errors.INVALID_PASS_PARAM();B=ka.ZipCrypto.decrypt(B,r,P)}var F=Buffer.alloc(r.size);switch(r.method){case oe.Constants.STORED:if(B.copy(F),E(F))return _&&k&&k(F),F;throw _&&k&&k(F,oe.Errors.BAD_CRC()),oe.Errors.BAD_CRC();case oe.Constants.DEFLATED:var V=new ka.Inflater(B,r.size);if(_)V.inflateAsync(function(J){J.copy(J,0),k&&(E(J)?k(J):k(J,oe.Errors.BAD_CRC()))});else{if(V.inflate(F).copy(F,0),!E(F))throw oe.Errors.BAD_CRC(`"${y.decode(i)}"`);return F}break;default:throw _&&k&&k(Buffer.alloc(0),oe.Errors.UNKNOWN_METHOD()),oe.Errors.UNKNOWN_METHOD()}}function I(_,k){if((!d||!d.length)&&Buffer.isBuffer(e))return _&&k&&k(A()),A();if(d.length&&!c){var P;switch(r.method){case oe.Constants.STORED:return r.compressedSize=r.size,P=Buffer.alloc(d.length),d.copy(P),_&&k&&k(P),P;default:case oe.Constants.DEFLATED:var B=new ka.Deflater(d);if(_)B.deflateAsync(function(V){P=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(P),k&&k(P)});else{var F=B.deflate();return r.compressedSize=F.length,F}B=null;break}}else if(_&&k)k(Buffer.alloc(0));else return Buffer.alloc(0)}function S(_,k){return oe.readBigUInt64LE(_,k)}function R(_){try{for(var k=0,P,B,F;k+4<_.length;)P=_.readUInt16LE(k),k+=2,B=_.readUInt16LE(k),k+=2,F=_.slice(k,k+B),k+=B,be.ID_ZIP64===P&&N(F)}catch{throw oe.Errors.EXTRA_FIELD_PARSE_ERROR()}}function N(_){var k,P,B,F;_.length>=be.EF_ZIP64_SCOMP&&(k=S(_,be.EF_ZIP64_SUNCOMP),r.size===be.EF_ZIP64_OR_32&&(r.size=k)),_.length>=be.EF_ZIP64_RHO&&(P=S(_,be.EF_ZIP64_SCOMP),r.compressedSize===be.EF_ZIP64_OR_32&&(r.compressedSize=P)),_.length>=be.EF_ZIP64_DSN&&(B=S(_,be.EF_ZIP64_RHO),r.offset===be.EF_ZIP64_OR_32&&(r.offset=B)),_.length>=be.EF_ZIP64_DSN+4&&(F=_.readUInt32LE(be.EF_ZIP64_DSN),r.diskNumStart===be.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return y.decode(i)},get rawEntryName(){return i},set entryName(_){i=oe.toBuffer(_,y.encode);var k=i[i.length-1];c=k===47||k===92,r.fileNameLength=i.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return u},set extra(_){u=_,r.extraLength=_.length,R(_)},get comment(){return y.decode(o)},set comment(_){if(o=oe.toBuffer(_,y.encode),r.commentLength=o.length,o.length>65535)throw oe.Errors.COMMENT_TOO_LONG()},get name(){var _=y.decode(i);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(_){I(!0,_)},setData:function(_){d=oe.toBuffer(_,oe.decoder.encode),!c&&d.length?(r.size=d.length,r.method=oe.Constants.DEFLATED,r.crc=oe.crc32(_),r.changed=!0):r.method=oe.Constants.STORED},getData:function(_){return r.changed?d:v(!1,null,_)},getDataAsync:function(_,k){r.changed?_(d):v(!0,_,k)},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(),k=oe.Constants.CENHDR;return i.copy(_,k),k+=i.length,u.copy(_,k),k+=r.extraLength,o.copy(_,k),_},packLocalHeader:function(){let _=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let k=r.localHeaderToBinary(),P=Buffer.alloc(k.length+i.length+r.extraLocalLength);return k.copy(P,_),_+=k.length,i.copy(P,_),_+=i.length,x.copy(P,_),_+=x.length,P},toJSON:function(){let _=function(k){return"<"+(k&&k.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:_(e),data:_(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ou=se((L2,su)=>{var iu=Pa(),Yg=Ra(),Ge=sr();su.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Yg.MainHeader,d=!1,u=null;let x=new Set,h=e,{noSort:w,decoder:y}=h;t?v(h.readEntries):d=!0;function A(){let S=new Set;for(let R of Object.keys(i)){let N=R.split("/");if(N.pop(),!!N.length)for(let _=0;_<N.length;_++){let k=N.slice(0,_+1).join("/")+"/";S.add(k)}}for(let R of S)if(!(R in i)){let N=new iu(h);N.entryName=R,N.attr=16,N.temporary=!0,r.push(N),i[N.entryName]=N,x.add(N)}}function E(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/Ge.Constants.CENHDR)throw Ge.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,R=0;R<r.length;R++){var N=S,_=new iu(h,t);_.header=t.slice(N,N+=Ge.Constants.CENHDR),_.entryName=t.slice(N,N+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(N,N+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(N,N+_.header.commentLength)),S+=_.header.centralHeaderSize,r[R]=_,i[_.entryName]=_}x.clear(),A()}function v(S){var R=t.length-Ge.Constants.ENDHDR,N=Math.max(0,R-65535),_=N,k=t.length,P=-1,B=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(N=0),R;R>=_;R--)if(t[R]===80){if(t.readUInt32LE(R)===Ge.Constants.ENDSIG){P=R,B=R,k=R+Ge.Constants.ENDHDR,_=R-Ge.Constants.END64HDR;continue}if(t.readUInt32LE(R)===Ge.Constants.END64SIG){_=N;continue}if(t.readUInt32LE(R)===Ge.Constants.ZIP64SIG){P=R,k=R+Ge.readBigUInt64LE(t,R+Ge.Constants.ZIP64SIZE)+Ge.Constants.ZIP64LEAD;break}}if(P==-1)throw Ge.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(P,k)),c.commentLength&&(o=t.slice(B+Ge.Constants.ENDHDR)),S&&E()}function I(){r.length>1&&!w&&r.sort((S,R)=>S.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return d||E(),r.filter(S=>!x.has(S))},get comment(){return y.decode(o)},set comment(S){o=Ge.toBuffer(S,y.encode),c.commentLength=o.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return d||E(),i[S]||null},setEntry:function(S){d||E(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,R=!0){d||E();let N=i[S];this.getEntryChildren(N,R).map(k=>k.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){d||E();let R=i[S],N=r.indexOf(R);N>=0&&(r.splice(N,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,R=!0){if(d||E(),typeof S=="object")if(S.isDirectory&&R){let N=[],_=S.entryName;for(let k of r)k.entryName.startsWith(_)&&N.push(k);return N}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(){d||E(),I();let S=[],R=[],N=0,_=0;c.size=0,c.offset=0;let k=0;for(let F of this.entries){let V=F.getCompressedData();F.header.offset=_;let J=F.packLocalHeader(),te=J.length+V.length;_+=te,S.push(J),S.push(V);let X=F.packCentralHeader();R.push(X),c.size+=X.length,N+=te+X.length,k++}N+=c.mainHeaderSize,c.offset=_,c.totalEntries=k,_=0;let P=Buffer.alloc(N);for(let F of S)F.copy(P,_),_+=F.length;for(let F of R)F.copy(P,_),_+=F.length;let B=c.toBinary();return o&&o.copy(B,Ge.Constants.ENDHDR),B.copy(P,_),t=P,d=!1,P},toAsyncBuffer:function(S,R,N,_){try{d||E(),I();let k=[],P=[],B=0,F=0,V=0;c.size=0,c.offset=0;let J=function(te){if(te.length>0){let X=te.shift(),ye=X.entryName+X.extra.toString();N&&N(ye),X.getCompressedDataAsync(function(he){_&&_(ye),X.header.offset=F;let O=X.packLocalHeader(),G=O.length+he.length;F+=G,k.push(O),k.push(he);let W=X.packCentralHeader();P.push(W),c.size+=W.length,B+=G+W.length,V++,J(te)})}else{B+=c.mainHeaderSize,c.offset=F,c.totalEntries=V,F=0;let X=Buffer.alloc(B);k.forEach(function(he){he.copy(X,F),F+=he.length}),P.forEach(function(he){he.copy(X,F),F+=he.length});let ye=c.toBinary();o&&o.copy(ye,Ge.Constants.ENDHDR),ye.copy(X,F),t=X,d=!1,S(X)}};J(Array.from(this.entries))}catch(k){R(k)}}}}});var du=se((M2,cu)=>{var _e=sr(),we=de("path"),Zg=Pa(),Xg=ou(),Tn=(...t)=>_e.findLast(t,e=>typeof e=="boolean"),au=(...t)=>_e.findLast(t,e=>typeof e=="string"),Qg=(...t)=>_e.findLast(t,e=>typeof e=="function"),em={noSort:!1,readEntries:!1,method:_e.Constants.NONE,fs:null};cu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),em);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=_e.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new _e(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=_e.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=_e.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw _e.Errors.INVALID_FILENAME();let c=new Xg(r,i),{canonical:d,sanitize:u,zipnamefix:x}=_e;function h(E){if(E&&c){var v;if(typeof E=="string"&&(v=c.getEntry(we.posix.normalize(E))),typeof E=="object"&&typeof E.entryName<"u"&&typeof E.header<"u"&&(v=c.getEntry(E.entryName)),v)return v}return null}function w(E){let{join:v,normalize:I,sep:S}=we.posix;return v(we.isAbsolute(E)?"/":".",I(S+E.split("\\").join(S)+S))}function y(E){return E instanceof RegExp?(function(v){return function(I){return v.test(I)}})(E):typeof E!="function"?()=>!0:E}let A=(E,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",we.relative(E,v)+I};return{readFile:function(E,v){var I=h(E);return I&&I.getData(v)||null},childCount:function(E){let v=h(E);if(v)return c.getChildCount(v)},readFileAsync:function(E,v){var I=h(E);I?I.getDataAsync(v):v(null,"getEntry failed for:"+E)},readAsText:function(E,v){var I=h(E);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(E,v,I){var S=h(E);S?S.getDataAsync(function(R,N){if(N){v(R,N);return}R&&R.length?v(R.toString(I||"utf8")):v("")}):v("")},deleteFile:function(E,v=!0){var I=h(E);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(E){var v=h(E);v&&c.deleteEntry(v.entryName)},addZipComment:function(E){c.comment=E},getZipComment:function(){return c.comment||""},addZipEntryComment:function(E,v){var I=h(E);I&&(I.comment=v)},getZipEntryComment:function(E){var v=h(E);return v&&v.comment||""},updateFile:function(E,v){var I=h(E);I&&I.setData(v)},addLocalFile:function(E,v,I,S){if(o.fs.existsSync(E)){v=v?w(v):"";let R=we.win32.basename(we.win32.normalize(E));v+=I||R;let N=o.fs.statSync(E),_=N.isFile()?o.fs.readFileSync(E):Buffer.alloc(0);N.isDirectory()&&(v+=o.sep),this.addFile(v,_,S,N)}else throw _e.Errors.FILE_NOT_FOUND(E)},addLocalFileAsync:function(E,v){E=typeof E=="object"?E:{localPath:E};let I=we.resolve(E.localPath),{comment:S}=E,{zipPath:R,zipName:N}=E,_=this;o.fs.stat(I,function(k,P){if(k)return v(k,!1);R=R?w(R):"";let B=we.win32.basename(we.win32.normalize(I));if(R+=N||B,P.isFile())o.fs.readFile(I,function(F,V){return F?v(F,!1):(_.addFile(R,V,S,P),setImmediate(v,void 0,!0))});else if(P.isDirectory())return R+=o.sep,_.addFile(R,Buffer.alloc(0),S,P),setImmediate(v,void 0,!0)})},addLocalFolder:function(E,v,I){if(I=y(I),v=v?w(v):"",E=we.normalize(E),o.fs.existsSync(E)){let S=o.findFiles(E),R=this;if(S.length)for(let N of S){let _=we.join(v,A(E,N));I(_)&&R.addLocalFile(N,we.dirname(_))}}else throw _e.Errors.FILE_NOT_FOUND(E)},addLocalFolderAsync:function(E,v,I,S){S=y(S),I=I?w(I):"",E=we.normalize(E);var R=this;o.fs.open(E,"r",function(N){if(N&&N.code==="ENOENT")v(void 0,_e.Errors.FILE_NOT_FOUND(E));else if(N)v(void 0,N);else{var _=o.findFiles(E),k=-1,P=function(){if(k+=1,k<_.length){var B=_[k],F=A(E,B).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(F)?o.fs.stat(B,function(V,J){V&&v(void 0,V),J.isFile()?o.fs.readFile(B,function(te,X){te?v(void 0,te):(R.addFile(I+F,X,"",J),P())}):(R.addFile(I+F+"/",Buffer.alloc(0),"",J),P())}):process.nextTick(()=>{P()})}else v(!0,void 0)};P()}})},addLocalFolderAsync2:function(E,v){let I=this;E=typeof E=="object"?E:{localPath:E},localPath=we.resolve(w(E.localPath));let{zipPath:S,filter:R,namefix:N}=E;R instanceof RegExp?R=(function(P){return function(B){return P.test(B)}})(R):typeof R!="function"&&(R=function(){return!0}),S=S?w(S):"",N=="latin1"&&(N=P=>P.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof N!="function"&&(N=P=>P);let _=P=>we.join(S,N(A(localPath,P))),k=P=>we.win32.basename(we.win32.normalize(N(P)));o.fs.open(localPath,"r",function(P){P&&P.code==="ENOENT"?v(void 0,_e.Errors.FILE_NOT_FOUND(localPath)):P?v(void 0,P):o.findFilesAsync(localPath,function(B,F){if(B)return v(B);F=F.filter(V=>R(_(V))),F.length||v(void 0,!1),setImmediate(F.reverse().reduce(function(V,J){return function(te,X){if(te||X===!1)return setImmediate(V,te,!1);I.addLocalFileAsync({localPath:J,zipPath:we.dirname(_(J)),zipName:k(J)},V)}},v))})})},addLocalFolderPromise:function(E,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:E},v),(R,N)=>{R&&S(R),N&&I(this)})})},addFile:function(E,v,I,S){E=x(E);let R=h(E),N=R!=null;N||(R=new Zg(i),R.entryName=E),R.comment=I||"";let _=typeof S=="object"&&S instanceof o.fs.Stats;_&&(R.header.time=S.mtime);var k=R.isDirectory?16:0;let P=R.isDirectory?16384:32768;return _?P|=4095&S.mode:typeof S=="number"?P|=4095&S:P|=R.isDirectory?493:420,k=(k|P<<16)>>>0,R.attr=k,R.setData(v),N||c.setEntry(R),R},getEntries:function(E){return c.password=E,c?c.entries:[]},getEntry:function(E){return h(E)},getEntryCount:function(){return c.getEntryCount()},forEach:function(E){return c.forEach(E)},extractEntryTo:function(E,v,I,S,R,N){S=Tn(!1,S),R=Tn(!1,R),I=Tn(!0,I),N=au(R,N);var _=h(E);if(!_)throw _e.Errors.NO_ENTRY();var k=d(_.entryName),P=u(v,N&&!_.isDirectory?N:I?k:we.basename(k));if(_.isDirectory){var B=c.getEntryChildren(_);return B.forEach(function(J){if(J.isDirectory)return;var te=J.getData();if(!te)throw _e.Errors.CANT_EXTRACT_FILE();var X=d(J.entryName),ye=u(v,I?X:we.basename(X));let he=R?J.header.fileAttr:void 0;o.writeFileTo(ye,te,S,he)}),!0}var F=_.getData(c.password);if(!F)throw _e.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(P)&&!S)throw _e.Errors.CANT_OVERRIDE();let V=R?E.header.fileAttr:void 0;return o.writeFileTo(P,F,S,V),!0},test:function(E){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(E);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(E,v,I,S){if(I=Tn(!1,I),S=au(I,S),v=Tn(!1,v),!c)throw _e.Errors.NO_ZIP();c.entries.forEach(function(R){var N=u(E,d(R.entryName));if(R.isDirectory){o.makeDir(N);return}var _=R.getData(S);if(!_)throw _e.Errors.CANT_EXTRACT_FILE();let k=I?R.header.fileAttr:void 0;o.writeFileTo(N,_,v,k);try{o.fs.utimesSync(N,R.header.time,R.header.time)}catch{throw _e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(E,v,I,S){if(S=Qg(v,I,S),I=Tn(!1,I),v=Tn(!1,v),!S)return new Promise((P,B)=>{this.extractAllToAsync(E,v,I,function(F){F?B(F):P(this)})});if(!c){S(_e.Errors.NO_ZIP());return}E=we.resolve(E);let R=P=>u(E,we.normalize(d(P.entryName))),N=(P,B)=>new Error(P+': "'+B+'"'),_=[],k=[];c.entries.forEach(P=>{P.isDirectory?_.push(P):k.push(P)});for(let P of _){let B=R(P),F=I?P.header.fileAttr:void 0;try{o.makeDir(B),F&&o.fs.chmodSync(B,F),o.fs.utimesSync(B,P.header.time,P.header.time)}catch{S(N("Unable to create folder",B))}}k.reverse().reduce(function(P,B){return function(F){if(F)P(F);else{let V=we.normalize(d(B.entryName)),J=u(E,V);B.getDataAsync(function(te,X){if(X)P(X);else if(!te)P(_e.Errors.CANT_EXTRACT_FILE());else{let ye=I?B.header.fileAttr:void 0;o.writeFileToAsync(J,te,v,ye,function(he){he||P(N("Unable to write file",J)),o.fs.utimes(J,B.header.time,B.header.time,function(O){O?P(N("Unable to set times",J)):P()})})}})}}},S)()},writeZip:function(E,v){if(arguments.length===1&&typeof E=="function"&&(v=E,E=""),!E&&i.filename&&(E=i.filename),!!E){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(E,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(E,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((R,N)=>{!E&&i.filename&&(E=i.filename),E||N("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let k=P=>P?R(P):N("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(E,_,I,S,k)},N)})},toBufferPromise:function(){return new Promise((E,v)=>{c.toAsyncBuffer(E,v)})},toBuffer:function(E,v,I,S){return typeof E=="function"?(c.toAsyncBuffer(E,v,I,S),null):c.compressToBuffer()}}}});import{execFile as j_,spawn as W_,spawnSync as JI}from"node:child_process";import{promisify as K_}from"node:util";function V_(t){if(process.platform!=="win32")return!1;if(r0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(r0,"").toLowerCase();return $_.has(r)}function i0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return V_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function ct(t,e=[],r={}){return W_(t,e,i0(t,r))}function s0(t,e=[],r={}){return J_(t,e,i0(t,r))}var $_,r0,J_,yn=Je(()=>{"use strict";$_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),r0=/\.(cmd|bat|ps1)$/i;J_=K_(j_)});var cx=se(De=>{"use strict";var L=j;(function(t,e){let r=j,i=t();for(;;)try{if(-parseInt(r(1141))/1*(-parseInt(r(991))/2)+parseInt(r(1929))/3*(-parseInt(r(1562))/4)+parseInt(r(1958))/5+parseInt(r(1162))/6+-parseInt(r(1487))/7+parseInt(r(1422))/8+-parseInt(r(1320))/9===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(To,537954);function To(){let t=["B25LCNjVCG","C2fNzq","B1rouhy","CMvHzhLtDge","z0fku2i","EvjWrfy","uK9drgO","tgr0D1a","BMDLza","B3jpBMXPBMu","rvPNueC","Ew9Zsve","EMvLvwO","q0noAxm","vgzLAMS","zNjVBujPDhm","EMfhAvO","zNviC2G","u1LcrvG","y3jLyxrLtwu","yvPLtKG","vgzYseS","x2vUzhbVAw4","CMfTzq","r05ir1a","CeDYtw0","vgfN","EgTvDgS","Ew9Rtgy","uMz5B0y","txbfDgS","v1nKBLK","tMfTzq","tw9KDwXL","uwPPzNC","Ae11EgW","B3bLBG","zxmGCMvHy2G","zg5bBKq","zgvMAw5Luhi","BLPqwuW","CMfUzg9T","x3bHDgHlzxK","CMvZzxrdB3u","CMvQzwn0","BfHMBgy","yxbWzw5Kq2G","pxv0zI04","Evvls0i","qvz0AMO","weToy2m","ywnRx2nVzgu","EvDfwwm","z2vtEw5J","DeLUDgvYy2u","DNrLwLe","tufyx1jfvfi","z2v0q3vYCMu","DLPMuKG","BgLUzw5V","we9Yww0","tNPNuwG","C3rLBMvYCW","yMXVy2TLza","ufjWAhi","y3HWBwy","C3vIC3rYAw4","vvLgt1e","BwvZC2fNzv8","zw5HyMXLuw8","DMfSDwvZ","thPLwMO","quvYv04","B0LWDLK","Bhm6ia","ihn1y2nLC3m","B3nQzhi","uM1oBNu","AMH4t3q","Aw1LCYbPBIa","rvbSv20","y29UC3rYDwm","swfyr2u","yMfSu2nVCgu","ywHAuMS","DhbizwfKzxi","BwfUDwfSihi","zgfZuu4","Dxrjza","Ec1TC2CTCw8","Axnby2TdBgu","rvDjuu4","uuHMqMW","qwLHwvK","zgvJB2rLzey","DgLTzw91Da","zgvSzxrLrge","EfzTwMm","shf6EM0","vwLcAKC","yNLL","rxLJvvK","CgLUz09Uy2u","thv6tKG","AwrI","Dg9cExrLC0i","t0fqs2K","t05swvK","zfDVCMTLCKC","re5Ltvy","BML0AwfSAxO","ChjVy2vZCW","x19LC01Vzhu","tNPHBuK","uhzIDg8","CgnywgS","EfD4yLi","tgfNCNi","A3HJExi","AeToBfG","uhbIze8","x2DLBMvYyxq","AergtNu","AxnAzxjV","r01WrLC","uMnRC1y","u0f5u1C","CYbPBNn0yw4","BLrMvuW","B25dBg9Zzq","r0ftEKq","CK11vKG","yxKSig5LDhC","ChvZAa","A2PgzLi","s3rqC2e","y2vZC0HHBMq","tvnguLm","ChjVDg9JB2W","mdaWma","x21LC3nHz2u","twDQr2S","vxbKyxrLq28","wvrQquu","yxrHlcbKyxq","x2rItMfTzq","swztsLq","vMPpBNa","verSuLu","DhPfA0G","x3DHAxq","Ahr1BNe","B2LUDfjLywm","uK1pDMm","vu1sue8","sxPztxu","D2XYDNm","nNW0Fdn8mNW","t1bftG","zNjHBwvuExa","zgnlqve","D1vTreu","CMvHzhDYAxq","zurLA2u","yuXHwvC","BNzmy1e","C3nHz2vfDMu","z3rqAw0","B3v0sw50zxi","D21nEMG","ufPxrLi","EMTKBeu","D2vhz3O","C2vUDa","mxWXmxW0Fdy","DgjiC28","ign1CNnVCIa","tuHJuwm","sKDOAxC","yw5Hz2vY","BMv3vMvYC2K","C3rVCMu","zwXVAxi","yKfOwgO","teHiC0e","CuH5ANi","sKPVEee","B25SAw5L","D2zvDuy","EvnsAvq","s2rzvKm","zLvdreC","yxKSihrYEsa","rLjptLrjrvi","ywnOzwqSihC","y2XVC2uSihC","wfPcDgK","y3jLyxrLt3a","vgjYrvu","DgLTzw91DcW","Ag1YAxC","m3WWFdr8mxW","seDXreS","zwnVBM5Ly3q","zwXpzeW","ruvcCve","zNjVBuj5Dgu","sMfPwgm","y0vMBM0","ywXSzwqGBxu","wKnzv3e","zw5XDwv1zq","rg1yufC","zw5JB2rLrNi","BMvY","zvr3Agu","A3bNzfq","x3bYzwzPEa","wvLZrM4","z1rPBwvVDxq","r3bcAgK","CNnVCL92ywW","DhjPzxmGCMu","y0jyvw8","BuX6D0i","B25tDgfYDfi","u0jYB0O","y05PtvC","thDouxG","rgvduem","y0Tjufa","yw1Lu3bHy2u","zu1wq3K","CMvHC29U","qw1VDw50","qvjMvg8","qur3yMS","A0DbBMW","yxbWBgLJyxq","CgfNzxnOB3C","shHsteu","seLOD1e","BNHRvhy","Ahr0Chm6","CMvJB25Uzwm","twfvD0e","BxrLqvu","x2XPC3rLBMu","x2fKzfDZtgK","Dfnfv2q","s3LmD2K","B0Dly1C","yKD0vgS","rvn0r2i","m3WXFdv8na","zhfPzvi","C3rYAw5NAwy","C3jJ","zgzcrLG","DhLWzq","ywnRpwzYB24","r2HPyKq","BwvKAwf0zwW","t2LAA3K","uuzNthe","DKrvv2W","ChfIsxy","suH3uMS","ywnyDKW","zw5NDgG","sLD4vvy","BM93","swvjvgi","q29Kzq","BMn2s2C","q2zJtMS","z2v0u3rVCMe","suzkvK0","x2nVBM5Ly3q","Bg93","z2v0qwXSs2u","DgTfrK0","BMnvrum","qwPQzvu","v1rRDKO","BMCGB3iGyw4","uwf2qNa","x3jLywr5q2W","zw5fDMvUDa","qLjYrw0","B1n5C2u","y3vYC29Yx2y","DwvZv0G","sLPUEwy","zen6ALC","Cg93","tuvTCxq","u2rLD0G","CgLUz1rPBwu","BvblD0m","ufLgqwe","u2vXsuq","Cg9PBNrdB24","yuXizK8","wM5bDwK","reXgzgK","EvjLy29UBMu","B2nRzxrgywK","yKnTqNq","ywnOzwq","CNfps1C","s1jQwNm","x2TLEvbHDgG","wu9Vy3G","v3Hpq1a","r2fqu1K","rerbDva","C2v0q3vYC28","rxzLBNq","yMXiEhm","AxfVzgC","DxHUrKW","qw9xv2y","CYbHBhjLywq","BgLTAxq","B3jRzxjhBg8","t0vsDeu","ihbYB3rVy28","su15Cw0","ALzkExq","y2HLy2Tszwe","qNP2wNK","yu5iAKW","wNbxr3m","x3vYBa","vNDJwKW","C2vYDMLJzq","BhDfCem","CMvTB3zLq2G","C0nVDw50zxi","rhvbr04","C05YCe8","Aw5JBhvKzxm","mdaWmdaWmda","x2n1CNnVCKy","BMvLzf9Hy2S","zMLSzw5HBwu","mteXvMLzAxrf","q29UzMLN","zgDbwLC","vKvQshq","AxnFywnR","CgLUz19VBMm","C2v0u3rVCMe","mxWZFdj8nhW","zcWGDw5RBM8","AgvHzgvYCW","DxbKyxrLq3u","BxnN","zw50tgLZDgu","Cg9PBNrbBMq","yxzqDhm","vM9ute4","BNruCMLLC0m","BIWGAg9ZDg4","nhWYFdb8mxW","DKDesfC","uKjwzem","B25VCgvU","vvfvqwC","CMvZzxrfBMq","CMX5A1a","vezWrhu","zw50zwqGDhK","rhzRBfa","A0jPzem","mta5ndy1nwH3v3fhyG","ywrKt25L","EKLUEvG","y2HnyxHuCMK","s2vzEw4","B2zM","D0PwC3e","q0PpuKS","z01SAgy","Aw9UvgLTzw8","ANbqvMq","zfLQCvO","qMrQC3O","qvbUuvq","DujrvNe","zMLUza","tg9JAW","AenSB3nLrxy","yw9kBKq","yw1L","rfPfvvi","uKDYtuO","ENftrMy","vwnwA20","B1H4uxi","B2zMC2v0","yLDiwhi","rvjst1i","BLPcA2C","BLPeyLe","y3LhBLK","uLbfAvC","y3vYC29Y","t1bftL9fuLi","zM9Yy2u","AvbiB00","q2fOBwy","EMvLv1y","CKjwue4","z2v0q3vYC28","AeLiEwu","yMfJA3vWigu","q3zxvfO","EvPPvfG","tLLmzKS","C2vUzf9Hy2S","BgnTELC","Aw9Ul2PZB24","BezSDxnO","vePuufe","yw1LoIa","y29UBMvJDca","qvbNqw8","ru1Nsvq","y3vYDMfSDwu","Dg9mB3DLCKm","CMLLC0nVDw4","tNzQsw4","yM9KEq","A1r2uK8","t1b1vLK","B29WAhu","Dg9hzw5LCMe","BgvUz3rO","zK1Izxq","DcbSAw1PDa","ywrKq291BNq","ww1pEuq","Dw5Vv1G","u3HJz3y","qxvezNa","vw1KugW","DhjPzxm","z2v0sxrLBq","Aw5KzxGGB3u","CMvZDwX0","EKLVqNC","wuLyDMW","DMzky2u","ueL6EMu","teHbvxC","x2LZqNjVD3m","x29Ut3bLBG","Aw5Lza","zxLgAK4","yxGGCMv0CMK","zef3DNO","DvbZAvu","ENLht1a","CMvJzxzPzwq","Exf5sKO","veT1zM8","EufyzNO","D3PsBgS","ywLftKS","rKTqD1y","q0fvAMq","C2HPzNq","CMvHzg9UBhK","yvjWtei","suvtx0vsuK8","Dvr2Bg4","DKHjyLO","s0TTtNC","sKjZswu","CMfTugfYyw0","tMDMrfa","C2vYDMvYvgK","zxq9DxrMltG","y3vYCMvUDeu","uhDKrLq","rMnNBvm","tw1nALa","yKXXqK8","tuzysLq","zhjnA0O","EuHlv0O","EwHSELq","thbLwxu","DgXrq24","CgjICdi","sLf5yNa","x2nYzwf0zvm","wwLewKO","rMXZu3y","ue96Bva","AxnrB1nby2S","Dg9VigXHCMC","vhrUzvm","De1HBMfNzxi","AwjLCw4","C29YDa","A0rhveS","u0fQy0m","Dev2zw50","CMDmrvC","EKzfC3u","ue13wfy","Dg9cExrLC0W","uxLmvuy","C2nYAxb0","BMPhq2S","rwPOBgO","EeDLu1e","y29Kzq","B25nzxnZywC","zLfSrhm","tNnJz0W","t05Yt0O","ywnZCKG","q0fZtuO","x3bPBMDqB24","DgHHBIbSB2m","t1PUsNa","x2LUAxq","t29yvfK","x3jLy29UBMu","C3rYAw5N","yuvAr0W","CNzHBa","x2rPC3bHDgm","thfWExO","AwXLtMfTzq","sMr0zM4","zM5vA2u","v2T1Be4","C2v0","DfjkBMK","tuPYDK8","zwX3A3K","tuzyB08","tvHywNe","ENHxvNO","sufurwu","uhzjvu4","yNvcAMu","CgvYC2LZDgu","tuHsuMu","BNrLCG","EKPjtMq","AwXK","v2vIu29JA2u","CNnVCL9Uyw0","yMLUyxj5vhK","Dw5KzwzPBMu","uxfYAMW","vw1frM8","EsbJBg9Zzwq","wgTHr3q","x3jLBw92zvC","t0ruue0","t2XJEgq","qNLLv0e","r3bPywW","tNrSvLy","A3z0rgO","BwLUAvbYB2C","AgfZt3DUuhi","ywr4uNm","t3bLBKv2zw4","EfHXt2e","uMTVvKC","B2jQzwn0u3q","z2v0t3DUuhi","wNnOs1a","Aw5msgK","zxjFywnRx20","yvjWC1C","zw1ovge","v2jOq1e","EgTJu1O","zMX1C2HfEha","v3LMu1q","tfrKDNe","BwLZzq","uM9cv0e","BM5Ly3q","uhvUD1q","Ee5fBNi","x2LZtM9Kzq","yw5ZzM9YBvq","vvL1DxG","BMDOBeO","z2v0qwXS","zNjVBNrPzxi","AgTmt2q","zMHhqxy","ihzHBgLKihm","quj4y08","BMfTzq","t1bpDNm","C3bSAxq","vgLTzw91Da","ywDLrxzLBNq","qLvfuw8","qvbivei","zMLWsMq","Euzzzhm","EM1XEuS","CLHlwfa","zgvS","DLvkyKy","BwvZC2fNzq","txnRDKW","AuXvAvi","zeTLBuS","x2rLyNvN","zwrPyxrLBhK","CMvZB2X2zq","Aw5L","qwXvte0","rwDgB0u","B2nRzxq","zgvIDwC","rKToAfi","lcbOB3n0BMe","rNHlAw0","CvrbEuW","wxnoz1m","EK54D1y","A1jPyxu","AKrzrLu","x3bPBMC","C1fcDNu","q05Iuw0","y3jLyxrLrxi","CNrntxe","C2HJD1G","su1zAe0","tfflre8","DLjczwi","BLjSDwG","whPRsw4","Ce9Luu0","y1DXz0G","C2vUza","sMrUCg8","EhbrsxK","DLPiv2O","ue9REfe","t2jQzwn0","BwrSBxC","zxH0ugf5Bg8","zMrPB08","Dgv4Dc9Qyxy","x3nLCuLK","wgfXAfu","whHYu1G","vNLfAM4","q0Xpu0ve","mNWZFdf8mhW","BwrOq1y","BKXPBMu","Chv0","CMzIAw4","y3r4","y3vYC29YlNm","rwjMEvi","CM92AwrLihy","tgHtrxG","vK9QuKW","CIb0DhDjra","rKLmrv9ot1q","mxWYFdv8m3W","EgfSy3e","BuflvvC","AxPKtNu","swXTDgq","yxrHD24","CeHeBgi","Cg9W","x2nSzwfYvgK","v2jPseO","EfrVwhG","sKLrDgm","yNbsywq","ywnRtxnNswq","CM92AwrLigi","zw5HyMXLvhi","zxj2AwnL","mhWYFdz8n3W","zxHWB3j0CW","A3jHyKO","tgPqv20","y29Uy2f0","s2LquLy","y0jVyKO","y3vVuNC","yNrUzhm","D1beuuC","t0HJAhm","y1bhqK0","tefIqKi","zfvLruW","x194x21Zz18","BMrWB2LUDca","sxH0zLq","BM9Uzv9UB24","EuzPDLO","EM9vDva","B25Uzwn0Aw4","Dg9tDhjPBMC","Du9rwg0","s29eqNG","AMrxqM4","A0z4wgS","D2vfqKW","B1LLCNe","zK13Cue","yxnJCMLWDa","BwLUzW","CgLUz0LUDgu","vgTrBMK","Fdn8oxW3Fde","AgLNAa","zw1PDa","DNjwEfe","BvDsqxu","D2vI","tNHIAMG","x2HHBMrSzva","BMv4DcGPigm","yLPtrfi","C0XPC3rLBMu","qxLTrxe","B3jL","ywTtA28","rLfnq1e","CLPjtw0","vvr5sxG","ihrVihjLDhi","vKLzsKG","vuXouNm","zw5HyMXLqxu","C1HqBfC","Dw5RBM93BIa","zNDZxZeUmc4","ywDLu2HVDW","CfD5Efm","A1n0yxr1C0m","zLLuDw0","CfDdDxe","B3vUDa","vLbPBNC","x0rctMfTzq","CezwtM0","D24GCMvHC28","uKvhve8","y2XLyxjtDg8","s3jOy1K","Cw9Zx18","CMvUDevUzha","teT4tuu","rxbgD3G","D1nNuwe","y3nICge","v1nJswu","ihrPBwvVDxq","wuLbwey","B0rcyuG","x2LUAxrhBg8","z2vjBMzVu3K","wxzls2C","qNfbBeO","C3bSAwnL","qwfhBwe","DMXdsMW","wezOsgO","wvv0yuK","q09otKvdveK","tfvrq3a","Bg9NsurozxC","x3DZ","wLnzzK4","wejzuwW","Bw5OCwG","zLrhwha","BwfW","uhjPBwfYEuS","sK1SDhC","quXm","vLjLAvi","CevYuwG","D1PgD3a","qLDwr04","DMfS","DM11AKG","s1P5y1q","BeXTB1K","rvzgBM0","EM5fEvy","yNvMzMvYzwq","r2zTC3y","z2vY","B25pCgvU","t1vOBgu","id4G","ihzHBgLKigq","ExbL","tuP1rue","BeTpANu","AxmGDw5Kzwy","Cgu6ia","Eu9PBNG","De5MtK0","qLDkruG","q1zTEfO","ANrtzK4","s29UAhq","DxnLCKLW","zvvusgS","AK11BMy","AvbQDhi","BwvY","D3zjseu","sM1qqwm","uLvvreW","qxHdwei","DcbVzIbYyw4","CwLfzMO","ENb0ELi","yujlEg4","yLP5AgC","zxjHDg9Y","q3vZDg9Tq2W","ChrVCG","tLPwqve","DgPktMK","DNfHCNC","zNjVBu51Bwi","yKvAAgG","y3bttuS","uNHPzM0","zMzLCG","EvDLC00","x29UtwvZC2e","Cgf5Bg9Hzfq","uhr1CM8","CMvWBgfJzq","B3jNveC","CMvKDwnL","C1LNEu4","uxjTz2O","qw9lExq","C0jf","C2v0zgi","EgfezMy","Afzmv3y","AM5itwq","DhDVCMTdAge","rgTyv2W","EeHTs3m","BfbAqwi","wKfbAwC","BNrfBMrWB2K","t2TKA3C","uNvsufa","uwj4BgS","Bg9N","vxnYA0K","veTOA2e","D05MtMW","CM92AwrLige","rvHmtK8","ywXS","AufLsK0","yNL0zu9MzNm","B3nLrxzLBNq","DgfIyxnL","ve9zzMm","Evn4zxm","EKvOq1q","Bvn1tgO","aaaaaaaaaaa","AvLqy0u","Bg9Nsurhzw4","CNnVCKzPBgu","ExDpANm","ugTTA24","zMXYruG","Bwf4tg9ZC0m","BKTMrKK","vffADxO","AxnmB25N","vwfXAxu","vvPeDNO","z3P4sMe","Bwv0Ag9K","B25fCNjVCG","q09oveLovuu","A0rqt1u","x25HDMLNyxq","weLIwMq","CejZtwi","Dhr0C0e","s1ngrhq","C0HoueW","qxzIzum","rujRDgC","x2nSzwfYugK","ywjKteq","zw51A1y","txLQrha","B25tDg9Wsw0","x2LUAxrqCM8","AwDHDg9Yt24","svjUEeu","A2v0ignVBNm","ywnR","yMLUza","tfHzswe","DvvjCLm","yxv0B21HDgK","AuPLzKG","BKXzzwW","DeLK","z0vorhu","Efrurw52","y2XLyxi","r3DSAM8","v2LmCLq","Cfj2vM0","DxrVuMvJB24","y2f0y2G","ihrPBwvZ","vuDgDMe","y2XVC2u","AM1Yt08","DxDcweG","zxjYtM8","CLzHBhvLCW","Dg1Zu2y","CgfNzwHPzgu","s1D2q2e","AeXpz0C","CgfYC2u","zfbIuwK","EeDPvw4","BhD4zLi","C3vJy2vZCW","uLfsrKG","sLnptLa","x29UugfNzu4","A1jOBM8","ufD0qKC","refhywC","B3jLtMfTzxm","u2vYDMLJzvC","tg9Hv2G","CgPvC1e","weTPvM8","u3vStuW","yxnZAwDU","t3PgBeO","sgrkqKq","quzfvKq","sKvbzMy","CfHwuem","rK9VA3G","t0vWsLe","z3j5rKW","tu9kEKi","CgDdzMC","thP4z20","y2fSBa","uxvLDwu","uLzxv24","vfb1u2e","ywHWt2S","Cvf6DM4","v0HjyKG","AgfZ","qxPizfa","CvbLv2i","r0DsuKW","wKPtDfm","zv9ZDwnJzxm","mJmWq0ziCfbd","BMvJDa","y29UBMvJDeu","qKXmwLu","y0jMr1e","B3nLza","seHfDhG","ywrK","zgLZCgf0y2G","D3nZoI8V","CM9YrxzLBNq","zM9pBNu","s0fgveK","BMXNCMm","FdL8n3WY","EhLLrue","ufvqtM8","B3vRyxq","lcbxzwjtB2m","Cvj6Chy","ywXSq3vYC28","C3bkBeO","CMvTB3zLrxy","wxvwBve","zv90Aw1LB3u","zsbHihn0CMK","s0nzs3G","EgnyrNa","x2LUDgvYDMe","igzHAwWSig0","BNjequm","u21rsuO","v2HVuKS","quv2tw0","B1rQs1u","CMTLCKDSB2i","AevYCM9Yrxy","BxnNsuq","t1Ltwue","wufwBxq","uMvywui","AxjLza","tKHtruq","BMrWB2LUDfq","yunPuxK","BMrLEa","x2zVCM1HDeu","y3jLyxrLq2W","x29WDgLVBNm","C2v0y3vYC28","y3jLyxrLrwW","tNfgAui","z3LPsMS","ELr0wMC","zg9Uzq","u2TPCcbWyxm","wvrHCg8","AwXSihvZzsa","tMr1uNm","tLrkBem","BuvNt3a","BMnVzgLUzW","tLfftg8","yKfTqw8","t0Xztg4","yKD2weu","A2v5","DuH5BLu","B3r1C0W","BLDysfi","uwD2Axy","uLjpuG","y0Plz2e","DxjS","sfDHD0O","Aw5KzxG","zcWG","z2v0","r295quy","BKnlz1G","uLHHsfm","ywDL","BMnLq2XVC2u","BMDuAw1LCG","whPSv2q","r09xwfO","BgLZDgvUtMu","x3nLBMrby2S","x2n1CNnVCK0","B3bLBKrc","wLrXtK0","vfzYzhy","Ceftquu","x2LZtwLUAvC","igzPzwXKoIa","ELjsAwW","BeHHBMrSzxi","EfvZzuvUDG","vKnZtgO","C0Xf","Bg1zwLu","tfzjAMW","CwnYswu","y09Wzw4","rgPJywG","Bw5oBue","vxvqv08","su5owgO","sKrqtLO","rNrRDe0","CKrvDfq","CvHAAvC","ywnRDxbfBMq","x29UrxjYB3i","yxv0BW","r0n4C1G","vM9pDu4","CwTPCK4","ALfpq1G","y2XVC2veqG","r1bgqNG","z1PSz3q","BgvY","zgrjrcWGzgu","Au1YBK8","DgvHy3a","yw51Ce1LC3m","Au5zCfe","Bu16vgC","x0vysvnu","x1fVu01HBMe","z1f4Dum","nNWXFdv8nhW","AvDVAgO","AxHHu1q","u3rYyxrLz3K","ru9zuu8","BNPfzuu","Dhr3Awq","v0ziEvC","AwfJr0S","x2LZsw5PDa","CNvMDu8","B3zZr0W","CMPbu2C","o2nOyxjZzxq","x2LZtwLUAvq","x3bPBMDmB3m","tKDFrvjst1i","AeDYAwi","mJK1nvDnwuHTAG","uxHzExe","vgXItxm","sMfoCwW","EuHmEgG","zMLSDgvY","AvLiuuy","lcbTyxGGCMu","zufJAW","zMDsyxq","y0jwrwG","Afb1q28","ywjVCNq","zgHequK","Dwnxr3m","zNHZvvO","teTYCKy","t0zrCKe","DLfSC2y","BLbHq3m","y3jLyxrLuMu","mJmZotuWohnRz25lwG","rg9nq3C","CMv0CNLdB3u","AMXgq1i","igXHCMDLCIa","vLb2ruK","qLHxEKq","AfferKi","tKHRA0S","vejqt1q","zxzKq1m","B2rxAvu","x2HHBMrSzvi","C2PxzhK","zMzmAw5L","yuTJywe","ywXSB2nvBNm","s1bcrgy","Bez0B2q","yNL0zuXLBMC","y215B3m","Dw50","BfHWvNG","svP1t20","t1jJquu","EgfLrxy","vM5Zrxi","mxWYFdn8nhW","A0DpqLO","DxrMofDYAxq","AxnrB1nnzxm","EgPAv1C","rNfIAu4","AxfHCfi","v0XQC2C","A1PfDfi","Cgf5Bg9Hza","A0TSzNi","B25ozxr3B3i","Cw9Z","C2TLq0m","D0HZz1q","v3ntsKm","ywnRx2LK","C3vIyxjYyxK","Bhr0rM8","CgvvBuS","ugrwv1a","D3jPDgu","Cuv4uw8","ChbL","y3vZDg9Tshq","ywr2yw5Jzq","swP5DMm","Ahr0Ca","zMLN","uMvHzcbWyxm","rNnXvLa","ELr3y2O","sKLdz2G","AKLlCwK","s2rrruq","uvbRzMO","yMfSrxzLBNq","B25TzxnZywC","x2DLDeLUDgu","rNjVBNrPzxi","Evrqqvm","yxnL","tKP2swG","DMnut3y","vfDLqvy","y0Dfq1e","D3m6lY8","t1vPvw4","Dgv4DfbHEwW","rgXntxm","Dw5ZAwDUzwq","x2rYB3bhBg8","qxnzvLe","B25mAw5L","zNjVBunOyxi","sNLpsMW","zvvYBa","q0Xpu0LorW","yw16zw8","AgvHzgvY","zxH0zw5ZAw8","B3bLCNr5tMe","yNvMzMvY","vgTKtum","EvPxBKy","vKvcANm","revtwxu","qwfLrM4","twvZC2fNzuu","zvrZEwm","BgLUzq","BKjgyu0","DgTiCha","C2XPy2u","suPbvhK","De54qwO","mhW0","y1roBMK","A1PMwgG","t0Dvq0i","vM5Xzg8","vhHIr3i","x3nVy2TLDa","EgLWr3K","x2LZv29YA2u","u3rLr3i","x2n1CNnVCK4","CNjVCK1LC3m","BwvZC2fNztO","zu1HC1u","CMvHzfvjBNq","EKLJAg0","Cu5mD3i","z1HmrfK","z1b4txm","D3jPDgvvAw4","y29SBM8","Cu9iEeO","DNnOre8","ufDJuuO","yxbWBhK","suLMD0m","DhjHBNnHy3q","qxnvs2O","DMvY","rwzMA08","r3vivw0","r1zQtxy","DxbNCMfKzw4","svr2q0S","v0Xcyuq","sfDSq3K","CMvXDwLYzwq","B3bIA2y","B2fK","x21PBMLoyxy","y29UBMvJDgK","B25szwnLAxy","Ee1prM4","Cvj4sgK","C3rHCNq","wePLBui","AKnZyLa","wfb1sM4","tgLZDgvUzxi","zwjntLK","zen1teO","AurlzeC","AgjKANy","y29UDgv4Da","B25JBg9Zzq","mteZodu5rxfcCMvn","uNn1Bve","sxvLEfm","tejJreK","tg9Nsuq","ugPNqNO","y3vYC29Yx24","r1LewMC","rM1Svue","C1LPqwG","mhW1FdH8mhW","AvPZA0e","rKzcr0K","C0r2tvC","uxf2tKG","x29Uq2XVC2u","twTUr0G","Aw5N","z0LMyxe","ALHotK0","CxLdA3y","wLDHENa","Bej5z3i","y29TCgXLDgu","wgrMD0m","C2v0sxrLBq","qNHADgm","uerutMG","vw5PBxbSzw0","vLLJzuW","v2LUzg93","ywrKrxzLBNq","tKfusvzfx0u","tNbQtuu","vw5Oyw5KBgu","t0fUEgq","r0HJEuy","tMrqrwm","BxHNBNu","B2DrvNu","uKfqr2K","vvvvwhe","ANjmBMi","q3vZDg9Trxi","Ae9Wzw5fDMu","DgfYz2v0","re9XqMK","sxLzuhi","uMvJB25Uzwm","t0TzzMi","B3zMteG","qwjVCNrfCNi","EwLfzeO","tg9NsurozxC","u0D1rxO","zuHzBfC","Cgf5Bg9Hzeu","y1rUCwK","Bwf4uMv0CMK","vgLuyxm","twHlvha","EfP0te8","Ef9MCM9UDgK","tuvtu0fhrv8","zgvSzxrL","tgHHCuG","t0vVDfC","zNvUy3rPB24","shjSs1q","AwXLx25HBwu","wMz1CMW","y3vYCMvUDeK","DLfOCM4","B3jRig9MzMW","y29UBMvJDfm","zw9PsMu","B3bLBIa","D2LSBfjLy28","ywDLsgLKzq","BhrPCgXLihq","x3bYB3rVy28","r3nhuK8","uKrrv04","q01lqMC","yxrLq291BNq","A2zhEwG","DgP5q3u","CMfNzvn5BMm","DwXwz0C","y2HHCKnVzgu","AgvKtwf4uMu","AMvJDfn0B3i","wMjNBfy","rgDowM8","q2fPELy","reiGzMfPBgu","DfHrBgq","ywXty29Wzq","D21btvO","AfzIruK","rgvKAwnHDgu","zw5KCg9PBNq","mJe0otC4nfLVq2r2Aq","wLrMz2G","yMLUyxj5","DMfSDwu","A2v5CW","Dhj1y3rVCIa","DgHLBG","rxPcqwy","t1nsthG","x29UvgLTzw8","zxjYtxnN","zwn0","r1vyv0S","r3L3veG","BwvZ","x3fVC0rc","uurwDMS","CKLxvgK","zNjVBuHHC2G","DLHMu3O","uMXzAvO","q3DQDe8","tLPpBe8","qLLUyvm","zMzMzG","BNvTyMvY","tMPguw4","CNzHBfzHBhu","icSG","AgfUz2u","mhWZFdr8mxW","AMXkvxK","sLLZwey","z0Dqz1m","BeXRDgO","t1Hjy0O","B3bLCNr5","B2r5v2i","BMCGzMfPBgu","CfHlyue","yxrqtvu","zgf0yq","EhbMyu0","vLPYzgO","zgXxywK","BLnttMq","Aw9U","s25jzuu","Dg9oDw1Izxi","y291BNq","u3zjBe8","B0XNAfC","Bxv2ywO","tMnWEeK","qLL4qMO","s2fsuwe","vuPYCfy","rKDKyw8","rxLWy1C","whDMEuq","rKXQvgi","zgv2AwnLx2K","B0fXDuW","CMvWBgfJzui","C2DPza","mJq5nJa4ognJveDfua","Aw5KzxHpzG","C29Tzq","r05zEfO","B3DkzwC","zuHAqMO","Ae1LC3nHz2u","ChjVDg90Exa","r0v5q2W","wxrLq1e","DgvZDa","BfrPBwvVDxq","q0nTuuG","B2nRzxrtDwm","y0nHyKq","qK9ltNu","Dg9cExrLCW","nxWY","s1jbC0S","Burdzue","wffQBfG","rMzosLC","C25Tt3O","z2j1wgK","sMTqDNq","u1vSvKq","AxnszwfKEq","x2HHBMrSzu8","q1nszKi","DMvUDa","yxfHwNK","r1PrwNm","DhjPBq","D2TQDK0","BuHpEhe","yNL0zxm","DMvYC2LVBMm","x2rPC2nVBM4","BMCGDxjSoIa","Aw50zwDLCIa","zw50","BNnkrva","x2rLC3rYB3K","CLzoBuy","ihjLy29UBMu","twLZC2LUzYa","Dg9Y","thrhuxe","sgXxDeO","DgLLCKPtt04","q0Lyvha","BLrVrM4","mxW0Fdn8mNW","AM9PBG","CgXLyxnLiha","q291BNq","zw5JB2rPBMC","A09Wwfi","q21JwKC","D2fZq2XLyw4","Aw47y2HHCNm","y29UDgLUDwu","C0zQywi","y29UBMvJDa","ELb1uK0","s1HnreG","t2vbvLK","x2jPBMfYEvq","s0Lyu00","CeTRD2u","C3rVCcbPBw0","v2vPEgLUsLm","v2rLzuS","ywWGy3vYC28","zgLZywjSzue","mZm1mZz0qKTXueO","qKzWtfi","yw5Nzq","C1PYqum","zgXcD3u","Cfb4sey","zKfmz2m","zxjYB3i","yK5qAeG","uwP0B3K","BvnRuuS","su5tvefova","ue16rwW","A3jwrLC","q0P5r3m","A010s3e","AKLAEvC","zxjFBxnNAwq","Bg9IywXty28","rLDt"];return To=function(){return t},To()}var nb=Object[L(1621)+"operty"],rb=Object[L(577)+L(1250)+L(1436)],rx=(t,e)=>function(){return t&&(e=(0,t[{yhlzT:function(c,d){return c(d)}}[L(491)](rb,t)[0]])(t=0)),e},ib=(t,e)=>{let r=L,i={fYTum:function(c,d,u,x){return c(d,u,x)}};for(var o in e)i[r(754)](nb,t,o,{get:e[o],enumerable:!0})};function sb(){return X0||(X0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ob(){let t=L;return Q0||(Q0=[IDBCursor[t(1494)+"e"][t(1214)],IDBCursor.prototype[t(1548)],IDBCursor.prototype[t(1548)+t(792)+"ey"]])}function j(t,e){t=t-393;let r=To(),i=r[t];if(j.qQlcEw===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",y="";for(let A=0,E,v,I=0;v=x.charAt(I++);~v&&(E=A%4?E*64+v:v,A++%4)?w+=String.fromCharCode(255&E>>(-2*A&6)):0)v=h.indexOf(v);for(let A=0,E=w.length;A<E;A++)y+="%"+("00"+w.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(y)};j.caGWHE=o,j.xbLoAP={},j.qQlcEw=!0}let c=r[0],d=t+c,u=j.xbLoAP[d];return u?i=u:(i=j.caGWHE(i),j.xbLoAP[d]=i),i}function ab(t){let e=L,r={ypAuk:e(953),RGrMJ:e(1569),SYBEX:function(o,c){return o(c)},Uaqiu:function(o){return o()},Ijyvc:function(o,c){return o instanceof c},lmYZU:function(o,c){return o!==c}},i=new Promise((o,c)=>{let d=e,u={HxRLE:function(y,A){return r[j(1600)](y,A)},PjgBz:function(y){return r[j(898)](y)},lLktj:function(y){return y()}},x=()=>{let y=j;t.removeEventListener(r.ypAuk,h),t[y(1013)+y(1941)+y(1796)](r[y(395)],w)},h=()=>{let y=j;u[y(1822)](o,u[y(1822)](Lt,t[y(449)])),u[y(1325)](x)},w=()=>{let y=j;u.HxRLE(c,t[y(1569)]),u[y(1456)](x)};t[d(1351)+d(1313)](r.ypAuk,h),t[d(1351)+d(1313)]("error",w)});return i[e(1428)](o=>{let c=e,d={jIKqi:function(u,x){return u*x}};if(r[c(1215)](o,IDBCursor))if(r[c(1091)](c(1949),c(1186)))cd.set(o,t);else return d[c(1222)](1e4,_0x5a2e40[c(1853)]())+_0x3d5177.floor(1e4*_0x11886f.random())})[e(937)](()=>{}),Do[e(540)](i,t),i}function cb(t){let e=L,r={AymEq:e(1371)+"or",GGRRL:"error",ZbglV:function(o,c,d){return o(c,d)},iqapR:e(676)+e(1120),ixaST:e(1885),OiZky:e(1343),VoTLN:e(1153),UsrkI:function(o){return o()},rufuO:function(o){return o()},vDUWl:function(o,c){return o===c},cpSMK:"CsWup",Suown:e(468)};if(Co[e(985)](t))return;let i=new Promise((o,c)=>{let d=e,u={XxrSX:r[d(988)],LHHsA:function(x,h,w){return r[d(1412)](x,h,w)},XdfwC:r[d(1195)],FsqVP:function(x,h){return x!==h},gryFL:r[d(1125)],cCabD:d(465),YTjAE:r.OiZky,dhDAI:r[d(1944)],CSRfB:function(x){return r[d(873)](x)},FwmQU:function(x){return r[d(1133)](x)}};if(r[d(1847)](r[d(845)],r.Suown))this[d(729)](u[d(661)],u[d(1766)](_0x4a7237,u[d(661)],{message:this[d(1037)+d(1276)+d(1072)](_0x5998bb)}));else{let x=()=>{let y=d,A={TbrEU:u[y(1344)]};if(u[y(1219)](u[y(974)],u[y(1501)]))t[y(1013)+y(1941)+"ner"](u[y(1725)],h),t["removeEventListe"+y(1796)](u.XxrSX,w),t[y(1013)+y(1941)+"ner"](u[y(1154)],w);else return{frameType:_0x4186a3,headers:[{key:"cursor_f"+y(1389),value:A[y(1780)]}],payload:void 0}},h=()=>{u[d(1515)](o),u.FwmQU(x)},w=()=>{let y=d;c(t[y(1569)]||new DOMException(r[y(738)],r[y(738)])),x()};t[d(1351)+"Listener"](r[d(1845)],h),t[d(1351)+"Listener"](r[d(988)],w),t[d(1351)+d(1313)](r[d(1944)],w)}});Co[e(540)](t,i)}function db(t){Ro=t(Ro)}function lb(t){let e=L,r={REGTO:function(i,o){return i(o)},AEvMm:function(i,o){return i(o)},ZowQM:function(i,o){return i|o},sIJep:function(i,o){return i&o},IzUab:function(i,o){return i<o},NjVUD:function(i,o){return i>=o},ONRYY:function(i,o){return i!==o},CIXTp:"lFePa",jdbyX:function(i,o){return i===o},Konht:function(i,o){return i in o},GywTH:function(i){return i()}};return r.jdbyX(t,IDBDatabase[e(1494)+"e"][e(1291)+e(1468)])&&!r[e(822)](e(576)+"oreNames",IDBTransaction.prototype)?function(i,...o){let c=e,d=t[c(978)](Ui(this),i,...o);return ad[c(540)](d,i[c(505)]?i[c(505)]():[i]),r[c(761)](Lt,d)}:r[e(1435)](ob)[e(1924)](t)?function(...i){let o=e;return t[o(1289)](r[o(1024)](Ui,this),i),Lt(cd[o(1068)](this))}:function(...i){let o=e,c={NpjME:function(d,u){return r.ZowQM(d,u)},bWHXr:function(d,u){return d&u},EZgPG:function(d,u){return d<<u},IJATy:function(d,u){return r.sIJep(d,u)},rMuVH:function(d,u){return r.IzUab(d,u)},QtASL:function(d,u){return r.NjVUD(d,u)},UrOtS:function(d,u){return d<=u},yUKKB:function(d,u){return r[j(761)](d,u)}};if(r[o(1689)](r[o(1537)],r[o(1537)]))_0x4032ae=c[o(1353)](c[o(400)](15,_0x4af036)<<12,c[o(1592)](c[o(1263)](63,_0x3f6ed2),6))|63&_0x6d012c,c[o(1713)](_0x2dc641,2048)||c.QtASL(_0x2a53d5,55296)&&c.UrOtS(_0x29d0be,57343)?_0x458b25+=_0x5e6995:(_0x234127+=c[o(1630)](_0x567c3c,_0x95a942),_0xf3702f+=2);else return Lt(t[o(1289)](Ui(this),i))}}function ub(t){let e=L,r={YUtaI:e(1387),sYiAh:function(i,o){return i(o)},cBobJ:function(i,o,c){return i(o,c)},rDUtT:function(i){return i()}};return typeof t===r[e(782)]?lb(t):(t instanceof IDBTransaction&&r[e(1329)](cb,t),r[e(700)](ix,t,r[e(1101)](sb))?new Proxy(t,Ro):t)}function Lt(t){let e=L;if({dhTpk:function(o,c){return o instanceof c}}.dhTpk(t,IDBRequest))return ab(t);if(Ao.has(t))return Ao[e(1068)](t);let i=ub(t);return i!==t&&(Ao.set(t,i),Do[e(540)](i,t)),i}var ix,X0,Q0,cd,Co,ad,Ao,Do,Ro,Ui,ex=rx({"node_modules/idb/build/wrap-idb-value.js"(){let t=L,e={PMwXV:function(r,i){return r||i},fgxTu:function(r,i){return r instanceof i},QxYyq:function(r,i){return r===i},nghlJ:t(1962),WYXDD:t(910),NcpxI:function(r,i){return r===i},zIoBw:function(r,i){return r===i},UYuux:t(1763),FcgmS:function(r,i){return r instanceof i},fWKRh:t(1045),TKhka:function(r,i){return r in i}};ix=(r,i)=>i[t(1489)](o=>r instanceof o),cd=new WeakMap,Co=new WeakMap,ad=new WeakMap,Ao=new WeakMap,Do=new WeakMap,Ro={get(r,i,o){let c=t;if(e.fgxTu(r,IDBTransaction))if(e[c(1142)](e[c(596)],e.WYXDD)){let d=this[c(1437)]["getStora"+c(1635)](this._prefix),u=_0x11bfa5[c(949)](e[c(511)](d,"{}"));return u[_0xc08127||_0x33620f[this[c(1624)]]]=_0x3b58f0,this[c(1437)][c(1935)+c(1635)](this[c(1799)],_0xdfee49.stringify(u)),_0x247364||_0x27fb18[this._pathKey]}else{if(e[c(1475)](i,c(1045)))return Co.get(r);if(i===c(576)+c(960))return r[c(576)+c(960)]||ad[c(1068)](r);if(e[c(450)](i,e[c(595)]))return o["objectSt"+c(960)][1]?void 0:o[c(576)+c(739)](o[c(576)+"oreNames"][0])}return Lt(r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(485)](r,IDBTransaction)&&(e[o(450)](i,e.fWKRh)||e.zIoBw(i,e.UYuux))?!0:e[o(874)](i,r)}},Ui=r=>Do.get(r)}}),sx={};ib(sx,{deleteDB:()=>xb,openDB:()=>fb,unwrap:()=>Ui,wrap:()=>Lt});function fb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let d=L,u={Cahmf:function(w,y,A,E,v){return w(y,A,E,v)},ncUEC:function(w,y){return w(y)},CcWsw:function(w,y){return w(y)},iJefH:d(940),cmyos:d(1523)+"hange",EXLNO:d(1297)+"eeded",owJeg:d(1645)},x=indexedDB[d(1618)](t,e),h=u[d(1864)](Lt,x);return i&&x[d(1351)+d(1313)](u[d(877)],w=>{let y=d;u[y(410)](i,u[y(1864)](Lt,x.result),w.oldVersion,w[y(1762)+"on"],u.CcWsw(Lt,x[y(1291)+y(1468)]))}),r&&x["addEvent"+d(1313)](u[d(1491)],()=>r()),h.then(w=>{let y=d;c&&w[y(1351)+y(1313)](u[y(927)],()=>c()),o&&w["addEvent"+y(1313)](u[y(1182)],()=>o())}).catch(()=>{}),h}function xb(t,{blocked:e}={}){let r=L,i={OLYLn:function(c,d){return c(d)}},o=indexedDB[r(1678)+r(882)](t);return e&&o[r(1351)+r(1313)]("blocked",()=>e()),i[r(1055)](Lt,o)[r(1428)](()=>{})}function tx(t,e){let r=L,i={tXQld:r(472),OEotW:function(x,h){return x instanceof h},pHDlb:function(x,h){return x in h},mGKvj:function(x,h){return x!==h}};if(!(i[r(1386)](t,IDBDatabase)&&!i[r(683)](e,t)&&typeof e===r(531)))return;if(Io.get(e))return Io[r(1068)](e);let o=e[r(852)](/FromIndex$/,""),c=i.mGKvj(e,o),d=ax[r(1924)](o);if(!i[r(683)](o,(c?IDBIndex:IDBObjectStore)[r(1494)+"e"])||!(d||ox[r(1924)](o)))return;let u=async function(x,...h){let w=r,y=this[w(1291)+w(1468)](x,d?w(1744)+"e":i[w(1416)]),A=y[w(1763)];return c&&(A=A[w(1066)](h[w(471)]())),(await Promise[w(878)]([A[o](...h),d&&y[w(1045)]]))[0]};return Io[r(540)](e,u),u}var ox,ax,Io,hb=rx({"node_modules/idb/build/index.js"(){let t=L,e={yWesM:t(1783)+t(1504),dcKAQ:t(998),UGFva:t(932),VEbLa:function(o,c){return o(c)},yosIQ:function(o){return o()},eUTHk:"get",pErQh:"getKey",FsEWC:t(597),lhVqo:t(1862)+"ys",ZUtIf:t(1471)},r=e[t(848)][t(605)]("|"),i=0;for(;;){switch(r[i++]){case"0":ex();continue;case"1":ax=["put",e[t(1742)],t(1384),e[t(939)]];continue;case"2":e.VEbLa(db,o=>({...o,get:(c,d,u)=>tx(c,d)||o.get(c,d,u),has:(c,d)=>!!tx(c,d)||o[t(985)](c,d)}));continue;case"3":e[t(1593)](ex);continue;case"4":ox=[e[t(824)],e[t(796)],e.FsEWC,e.lhVqo,e.ZUtIf];continue;case"5":Io=new Map;continue}break}}}),pb={idb:function(t){let e=L;t[e(695)]=Promise.resolve()[e(1428)](()=>(hb(),sx)).then(function(r){return r})}},nx={};function Nt(t){let e=L,r={INNXj:function(u,x){return u!==x}},i=(e(1947)+"3").split("|"),o=0;for(;;){switch(i[o++]){case"0":var c=nx[t]={exports:{}};continue;case"1":pb[t](c,c[e(695)],Nt);continue;case"2":if(r[e(1098)](void 0,d))return d[e(695)];continue;case"3":return c.exports;case"4":var d=nx[t];continue}break}}(()=>{let t=L,e={TfrHK:function(r){return r()},dGQVb:function(r,i){return r===i},AvbeC:t(599)};Nt.d=(r,i)=>{let o=t,c={nxkTv:function(u){return e[j(1603)](u)}};if(e.dGQVb(e[o(911)],e[o(911)]))for(var d in i)Nt.o(i,d)&&!Nt.o(r,d)&&Object[o(1621)+o(1458)](r,d,{enumerable:!0,get:i[d]});else GcXGcE.nxkTv(_0x382e69),GcXGcE[o(1824)](_0x2a0d27)}})(),(()=>{let t=L;Nt.o=(e,r)=>Object[t(1494)+"e"][t(571)+t(1458)][t(978)](e,r)})(),(()=>{let t=L,e={BXWzD:t(1111),Pturo:function(r,i){return r!=i},ZAAig:t(558)+"d",xQQhZ:t(1615)};Nt.r=r=>{let i=t;if(e[i(1168)]!==i(404))e[i(851)](e[i(867)],typeof Symbol)&&Symbol["toString"+i(1608)]&&Object[i(1621)+i(1458)](r,Symbol["toString"+i(1608)],{value:e.xQQhZ}),Object[i(1621)+"operty"](r,"__esModule",{value:!0});else return De._qosDB.clear()}})();var Ce={};(()=>{let t=L,e={vRBeb:function(a,n){return a(n)},NHkkK:function(a,n){return a+n},dqieR:function(a,n){return a+n},AErWN:function(a,n){return a+n},ahZRk:function(a,n){return a*n},LwNQx:function(a,n){return a(n)},EWIQN:function(a,n,s){return a(n,s)},AoKyt:function(a,n){return a(n)},DAGag:function(a,n,s){return a(n,s)},krVFW:function(a,n){return a(n)},dCuLJ:function(a,n){return a+n},SUlVD:function(a,n){return a+n},gAJSb:t(1721),BOKNu:t(1446),MgjGk:function(a,n){return a(n)},SdewH:t(1925)+"00000000"+t(1925)+t(1925),xaDff:function(a,n){return a+n},evdCS:function(a,n){return a<<n},nTfUL:function(a,n){return a<<n},LoaWh:function(a,n){return a&n},LHAUw:function(a,n){return a>n},eMasU:function(a,n){return a>>n},uTvln:function(a,n){return a>n},xkUtk:function(a,n){return a===n},twrdO:"KnMgn",hMuxl:t(1207),pWyxS:function(a,n){return a<n},xaeEv:function(a,n){return a>n},adxRs:function(a,n){return a!==n},GUXWK:"NxJWr",EStGb:function(a,n){return a-n},LQKDO:function(a,n){return a===n},tNxAj:function(a,n){return a<n},MSFRS:function(a,n){return a!==n},IIfwC:function(a,n){return a-n},JIQtc:function(a,n){return a===n},gMlhf:t(701),aRpsW:function(a,n,s){return a(n,s)},qQzvn:function(a,n,s){return a(n,s)},jrLnb:function(a,n){return a!==n},CJORK:function(a,n){return a(n)},ABxcO:function(a,n){return a+n},eHZBj:t(448)+t(832)+"ge: ",abdLD:t(1450),shcwX:function(a,n){return a||n},LTdvq:t(810),VEBjs:t(1043),cBXUo:function(a,n){return a>>>n},vfJce:function(a,n,s){return a(n,s)},KldQB:function(a,n,s){return a(n,s)},zqSFf:function(a,n){return a&n},KdYVC:t(1532)+t(1301)+t(1085)+t(1057),uUIrS:function(a,n){return a===n},oXxQr:function(a){return a()},zEhCT:function(a,n,s){return a(n,s)},ySxes:function(a,n){return a<n},RVWWn:function(a,n){return a>>n},HlWtJ:function(a,n){return a===n},BYnaS:function(a,n){return a&n},JYsXF:function(a,n){return a+n},yqyJJ:function(a,n){return a+n},hPuCo:function(a,n){return a&n},FKNhR:function(a,n){return a|n},TkQni:function(a,n){return a|n},ncvKg:function(a,n){return a&n},MFXoO:function(a,n){return a|n},BxZtc:function(a,n){return a|n},tbHso:function(a,n){return a|n},NJvIh:function(a,n){return a<<n},ZCYWq:function(a,n){return a<<n},vcTOv:function(a,n){return a|n},dlWai:function(a,n){return a<<n},EpFwx:function(a,n){return a<<n},XFhHj:function(a,n){return a!=n},XJemB:t(531),WSdnY:function(a,n){return a instanceof n},RuRPP:t(1820)+t(421),odyWb:function(a,n){return a==n},skeCC:"text/pla"+t(1547)+t(482),tjJNi:function(a,n){return a!==n},JaNql:function(a,n,s){return a(n,s)},tttsA:function(a,n){return a!==n},yWEYc:function(a,n,s){return a(n,s)},kFxXk:function(a,n,s){return a(n,s)},YIXvl:function(a,n,s){return a(n,s)},ySRiT:function(a,n){return a(n)},acXvL:function(a,n,s){return a(n,s)},PUPNo:function(a){return a()},XQjlX:function(a,n,s){return a(n,s)},NduRs:function(a,n,s){return a(n,s)},gQxuC:function(a,n){return a(n)},Lagrr:function(a,n,s){return a(n,s)},TJTPQ:function(a,n){return a===n},TDlRU:t(1298),KPBDf:function(a,n,s){return a(n,s)},KRjZs:function(a,n){return a===n},vZfRH:t(1738),MskvL:function(a,n){return a!==n},GpBhi:function(a,n,s){return a(n,s)},Hqzzm:function(a,n,s){return a(n,s)},njGCk:function(a,n){return a===n},atPMU:t(1071),WLSrM:t(1767),iPjtr:function(a,n){return a|n},RPEiW:function(a,n){return a===n},encVn:t(1341),nToFn:t(748),wmAMZ:function(a,n){return a(n)},RUUDL:function(a,n){return a(n)},ovsGL:function(a,n){return a>>>n},vHIbZ:function(a,n,s){return a(n,s)},OzNqC:function(a,n,s){return a(n,s)},wzRlk:function(a,n,s){return a(n,s)},VOjRL:function(a,n,s){return a(n,s)},QFgLq:function(a,n,s){return a(n,s)},XkaGt:function(a,n){return a(n)},uesWH:function(a,n,s){return a(n,s)},iqodg:t(1532)+"required"+t(1085)+t(1883),UiBjG:function(a,n){return a===n},UQUAg:t(1532)+t(1301)+t(1085)+t(1324),gZlgt:t(1532)+"required"+t(1085)+t(901),Lzxgm:"xYdsA",vshDO:t(1765),NYLfK:function(a,n){return a&n},sFjab:function(a,n,s){return a(n,s)},MaUwA:function(a,n){return a+n},GuHUm:t(1348)+t(1955)+t(816),ewpLm:function(a,n){return a>>n},CAsMJ:function(a,n){return a&n},fMbet:function(a,n){return a>>n},KSFDt:function(a,n){return a!==n},Pvbto:t(795),GEyCl:t(1046)+"t limit",OERtE:function(a,n){return a>=n},oDBaH:function(a,n){return a*n},ZTfgh:function(a,n){return a>n},yZiTX:function(a,n){return a>n},GNYxZ:function(a,n){return a+n},rlykP:t(1218)+t(439),ahpOk:function(a,n,s){return a(n,s)},tSEWd:function(a,n){return a<n},gIRHa:function(a,n){return a&n},bZSDR:function(a,n){return a&n},gXLDY:function(a,n){return a+n},xVmZc:function(a,n){return a+n},yOinx:function(a,n){return a&n},Qgviv:function(a,n){return a|n},nsJEP:function(a,n){return a&n},ZpWGs:function(a,n){return a<n},BWVGN:function(a,n){return a(n)},uwBXH:function(a,n){return a===n},pFVNm:t(825),xToXx:function(a,n){return a+n},ARfTo:function(a,n){return a&n},PYFAa:function(a,n){return a<<n},uBQVq:function(a,n){return a&n},GaPSY:function(a,n){return a<=n},OzFlJ:function(a,n){return a(n)},OXIcJ:function(a,n){return a&n},MEmqt:t(1602),rtMMq:t(1188),CNbQm:function(a,n){return a+n},peUmK:function(a,n){return a+n},bZyhg:function(a,n){return a+n},uOQXm:function(a,n){return a|n},DvklP:function(a,n){return a|n},aKcaa:function(a,n){return a|n},fxsUZ:function(a,n){return a<<n},zRRil:function(a,n){return a&n},lwxfR:function(a,n){return a<<n},eHYlW:function(a,n){return a<<n},AoWWf:function(a,n){return a&n},dtAGF:"IsiIq",rZIMm:function(a,n,s){return a(n,s)},YTapo:function(a,n){return a+n},FxjAN:function(a,n){return a>>n},QavBp:function(a,n){return a+n},GZQZs:function(a,n){return a&n},aEZGL:function(a,n){return a+n},wZFwp:function(a,n){return a+n},mPKwC:function(a,n){return a<<n},kRiau:function(a,n,s){return a(n,s)},JQybp:function(a,n){return a<n},iNYpQ:function(a,n){return a-n},qkirN:function(a,n){return a+n},HGqDK:function(a,n){return a<<n},Olcxd:function(a,n){return a<n},EOYQO:function(a,n){return a&n},lwhUs:function(a,n){return a>>n},wmMzh:function(a,n){return a|n},rgLEW:function(a,n){return a&n},vteZQ:function(a,n){return a>>n},xpfaM:function(a,n){return a&n},VZrdj:function(a,n){return a&n},DDAuP:t(1669),FdoIi:function(a,n,s){return a(n,s)},TOYfc:t(1645),RMOvc:function(a,n){return a!==n},xNEnr:"iaQzG",oSyse:t(1014),dwpBY:function(a,n){return a>=n},blHxs:function(a,n){return a|n},jFOcK:function(a,n){return a&n},unoWX:function(a,n,s){return a(n,s)},cGECQ:function(a,n){return a instanceof n},Jdnpo:t(1569),oywPG:"WyfST",yAXfz:function(a,n){return a(n)},IATEe:function(a,n){return a(n)},kzGrr:function(a,n){return a<<n},Lqpyz:function(a,n){return a<<n},OUiUn:function(a,n){return a&n},bBQPr:function(a,n){return a(n)},cKIPP:function(a,n){return a&n},Gwljo:function(a,n){return a(n)},VDiAz:function(a,n){return a&n},PunwT:function(a,n){return a(n)},OFQrA:function(a,n){return a(n)},OZnJp:function(a,n){return a<<n},pjUsQ:function(a,n){return a>>>n},WbhCQ:function(a,n){return a<n},qGHIh:function(a,n){return a<n},jhxOt:function(a,n,s){return a(n,s)},nrDAC:function(a,n){return a&n},IuexS:function(a,n){return a|n},PDTNh:function(a,n){return a&n},TFpDu:function(a,n){return a!==n},xalcq:function(a,n){return a>>>n},kfGyh:function(a,n){return a>>>n},YIAXF:function(a,n){return a|n},snmOz:function(a,n){return a&n},KAFTI:function(a,n){return a+n},HdJBD:function(a,n){return a!==n},DLFdi:function(a,n){return a|n},LzeZj:function(a,n){return a&n},xpQIy:function(a,n){return a!==n},SulML:function(a,n){return a|n},GASzD:function(a,n){return a+n},IPzZK:function(a,n){return a>>>n},FOokx:function(a,n){return a>>>n},SAySW:function(a,n){return a&n},MaQMe:function(a,n){return a!==n},dIsSx:function(a,n){return a|n},NtlVV:function(a,n){return a>>>n},hDFNu:function(a,n){return a|n},qNLwr:t(1283),AiaYY:function(a,n){return a|n},lBygr:function(a,n){return a|n},dKemK:function(a,n){return a===n},KaRQa:t(1808),DSCrH:t(976),weEBL:function(a,n){return a|n},GAtWt:function(a,n){return a<<n},UmdPl:function(a,n){return a<<n},BLLZU:function(a,n){return a|n},EbfyR:function(a,n){return a<<n},ibeqn:function(a,n){return a|n},odWiU:function(a,n){return a<<n},aNHjL:function(a,n){return a|n},YsNgS:function(a,n){return a|n},AuDfp:function(a,n){return a<<n},IxtfT:function(a,n){return a===n},acsrH:function(a,n){return a>>>n},KiPRV:function(a,n){return a|n},Pkmkn:function(a,n){return a|n},qPeWb:function(a,n){return a<<n},vZHWj:function(a,n){return a|n},vlCJl:function(a,n){return a|n},PjnSD:function(a,n){return a<<n},cBfGQ:function(a,n){return a<<n},AaGma:t(616),dfBFX:"jAlZh",foOnu:function(a,n){return a&n},UJrpV:function(a,n){return a>>>n},Gpial:function(a,n){return a>>>n},AlULM:function(a,n){return a>>>n},jQOCX:function(a,n){return a(n)},KKmNw:function(a,n){return a>=n},OPuVY:function(a,n){return a+n},mSuLj:function(a,n){return a|n},rowDy:function(a,n){return a/n},WxOCP:function(a,n){return a>>>n},xZtLO:function(a,n){return a>>>n},vmJdj:function(a,n){return a&n},rIWTi:function(a,n){return a+n},KnIeE:function(a,n){return a+n},JmPAc:function(a,n){return a>>>n},akSko:function(a,n){return a<<n},dgAZW:function(a,n){return a<<n},sYgyN:function(a,n){return a===n},vmujH:function(a,n){return a===n},ToSGl:function(a,n){return a+n},OKYfb:function(a,n){return a&n},oTjKU:function(a,n){return a>>>n},LHatB:function(a,n){return a&n},SteGr:function(a,n){return a>>>n},csbpa:function(a,n){return a>>>n},bPYjl:function(a,n){return a>>>n},xipGy:function(a,n){return a>>>n},VoOuN:function(a,n){return a&n},MHcQc:function(a,n){return a>>>n},rfbin:function(a,n){return a>>>n},NscgL:t(407)+"OR",iZskA:"NATIVE_E"+t(1062),zmqyK:"MESSAGE_"+t(401),WbiHJ:"MAX_RETRIES_ERROR",JyCQw:t(783)+t(1139),FKPwV:t(1430),quHer:"sSdtV",ZHEAk:function(a,n){return a-n},ucWGs:function(a,n){return a===n},DNeMV:function(a,n){return a>n},orgTG:t(1193),wNfNl:t(1060),EEBqQ:function(a,n){return a+n},fQlDs:t(1354)+"d error.",vqarw:function(a,n){return a===n},FuudH:function(a,n){return a===n},FmlUA:t(1922),hVLWv:t(907),MmMjP:function(a,n){return a<n},tlQCn:function(a,n){return a===n},GMpFW:t(1755),rXKXP:t(646),PlJmn:function(a,n,s){return a(n,s)},DmUtT:function(a,n,s){return a(n,s)},rjASg:t(1618),QxFKD:t(1035),kZEtR:function(a,n,s){return a(n,s)},JMltw:t(1677),RcksV:t(953),tkEFM:t(1934)+t(990)+"s",QgdKE:t(1934)+t(1015)+"t",wPDQG:t(1010),nZDbQ:function(a,n,s){return a(n,s)},NzgQh:t(1568),BUEQo:"uQKEn",GHcyF:function(a,n,s){return a(n,s)},fhGAv:function(a,n){return a>>>n},WdeeK:function(a,n){return a instanceof n},Ejhlj:t(702),QueSS:"gSObs",RlYiZ:t(802),CvWTZ:"XLYVh",MJuEA:function(a,n){return a||n},CMKBg:t(558)+"d",kTvRO:function(a,n){return a!=n},lcmzW:"fwhsK",yFivZ:t(1658),mrmVM:t(735)+t(1791)+t(1399)+t(1661)+t(1693),YmOyD:function(a,n){return a(n)},SmQIJ:function(a,n){return a>n},Fhzad:function(a,n){return a(n)},PpbdO:t(1508),GdFWD:t(1006),fdioO:function(a,n){return a===n},PJVup:function(a,n){return a<=n},dnAnD:function(a,n){return a|n},FQMCQ:function(a,n){return a%n},cnsBX:function(a,n){return a|n},xXqOa:function(a,n){return a<n},kjFfR:function(a,n){return a>=n},JyOJl:function(a,n){return a>=n},vQhrn:function(a,n){return a|n},vGDHW:function(a,n){return a<<n},pqbIv:function(a,n){return a&n},WScIe:function(a,n){return a&n},ogPXU:function(a,n){return a&n},gGPgS:t(866),fTGXp:function(a,n){return a-n},EMgIT:function(a,n){return a|n},xSXJT:function(a,n){return a<<n},IAzqr:function(a,n){return a&n},wkjvM:t(718),kGAnl:function(a,n){return a<n},MknGH:function(a,n){return a|n},qoqNj:function(a,n){return a&n},FlsSv:function(a,n){return a===n},AjjeU:function(a,n){return a&n},Okdkw:t(677)+t(1265),ovfLH:function(a,n){return a|n},zxWVz:function(a,n){return a>>n},VIYJH:function(a,n){return a+n},JJoxA:function(a,n){return a+n},fUCDG:function(a,n){return a&n},DRtmC:function(a,n){return a|n},BugHe:function(a,n){return a&n},gzxJa:function(a,n){return a>>n},mDCeA:function(a,n){return a>>n},sNrpO:function(a,n){return a>>n},nbLPC:function(a,n){return a|n},HbyBw:function(a,n){return a-n},APgAo:function(a,n,s,l){return a(n,s,l)},IRZRf:function(a,n){return a instanceof n},Qjifw:function(a,n){return a!=n},AsYVQ:"boe",YvKKg:t(1212),srRIg:function(a,n){return a>=n},IHwRk:t(749)+t(1815),drMkJ:t(514),PIzze:function(a,n){return a+n},tNfNM:t(1216),DlMMs:"&jscallb"+t(1842)+t(1536)+"P",mLzwB:t(1481),xGeSQ:t(1686),yRpDV:t(704),pXKaA:function(a){return a()},eTwhe:function(a,n,s,l){return a(n,s,l)},mnNmA:t(507),OLVvr:t(1076),HWawJ:t(1326)+t(393),TkdMC:function(a,n){return a!==n},ODTPM:t(1093),oHCiw:t(1147),SPqoT:function(a,n){return a===n},wSgQa:t(915),Zfurl:function(a,n){return a!==n},lXpVx:t(948),wfUuF:function(a,n,s){return a(n,s)},qTAyL:function(a,n){return a===n},OxmCY:t(819),Ilmtd:t(834),LKxME:function(a,n){return a===n},tZngy:"WuzqN",xwBZA:function(a,n,s){return a(n,s)},lKOju:"hOYIE",RAPGi:function(a,n){return a||n},pGrMm:function(a,n){return a||n},KdQED:t(1746),KtPsa:t(513),Sxcgv:function(a,n){return a instanceof n},KyLwi:function(a,n){return a===n},yFYds:t(1911),tjyCu:t(1662),kxcyr:function(a,n){return a||n},CaizV:function(a,n){return a||n},hQDFB:function(a,n){return a(n)},pASAE:t(545),YAVmt:"init QoS"+t(1415)+"d",NqFiB:t(1201),qCsQE:t(1650)+"id",aLEGx:function(a,n){return a===n},ENfvP:t(1332),FtktM:"vSeBb",XOrYm:"bEOEd",UUUXq:function(a,n){return a(n)},IZuOm:t(1694)+"le",NZVAQ:"SUzmt",znEyV:function(a,n,s,l){return a(n,s,l)},krabJ:t(1382)+"er_qos_ack",xHmKs:t(1382)+"er_is_ack",BzvZy:function(a,n,s){return a(n,s)},KZycT:t(1927),AsUKj:t(1933),WHIbH:function(a,n){return a&&n},inLHi:function(a,n){return a===n},tgcBB:"rIxnW",wvIHE:t(1205),OGUCB:function(a,n){return a||n},AaeFn:t(1633),VyplL:function(a){return a()},QHfBl:function(a,n){return a+n},qRxHi:t(989),Qqrjl:"received",oAquL:"applicat"+t(421)+t(1136)+t(1629),DmXPW:"none_none",NTJlC:t(1424),xWxbR:function(a){return a()},tkHpp:t(1731),EffkO:function(a,n){return a<n},MHRRe:function(a,n){return a>n},AzHdP:function(a,n){return a+n},ROCDj:function(a,n){return a&n},FxKim:function(a,n){return a|n},CCNis:function(a,n){return a||n},LVIjl:function(a,n){return a>>>n},oYerq:function(a,n){return a<n},TQZuz:function(a,n){return a===n},YzGkz:t(1224),mHOxq:function(a,n){return a&n},jdZYO:function(a,n,s,l){return a(n,s,l)},VEEOc:function(a,n){return a+n},GsGRO:function(a,n){return a+n},KUJmb:function(a,n){return a<n},OAnxd:function(a,n,s){return a(n,s)},RmNnu:function(a,n){return a>>>n},gENDu:t(1936)+"0",nKfFI:function(a,n){return a+n},LBcDI:function(a,n,s,l){return a(n,s,l)},cTNni:function(a,n){return a|n},ydeOj:function(a,n){return a|n},EBktg:function(a,n){return a|n},pXVPC:function(a,n){return a<<n},ByeWA:function(a,n){return a+n},SshrH:function(a,n){return a|n},LxJBD:function(a,n){return a+n},nPaCs:function(a,n){return a>>>n},ADwbk:function(a,n){return a+n},zJINd:function(a,n){return a&n},WsSJC:function(a,n){return a>>>n},mAKUW:function(a,n){return a>>>n},iMrnO:function(a,n){return a+n},kRhno:function(a,n){return a>>>n},dAwvz:function(a,n){return a+n},coLZQ:function(a,n){return a&n},xBGFF:function(a,n){return a+n},TKPba:function(a,n){return a+n},NjFQn:function(a,n){return a&n},tRJni:function(a,n){return a+n},nzEeE:t(1756)+t(727)+t(1330)+"2",uHynU:function(a,n){return a>>>n},nCKgX:function(a,n){return a>>>n},APHTB:function(a,n){return a&n},QqPuT:function(a,n){return a&n},UuPWO:function(a,n){return a<n},fuHsh:function(a,n){return a+n},JZnyf:t(1123)+"0|3|10|8"+t(1005),JEAff:t(1918),XzlWd:t(428),xxJFh:t(670)+t(693),YiDZJ:t(603),kZfXh:"service-"+t(603),LtGQq:function(a,n){return a(n)},tmsSf:t(1873)+t(1389),XIbZd:function(a,n){return a<n},UNzNE:function(a,n,s){return a(n,s)},POzmP:function(a,n,s){return a(n,s)},OYSYA:"FILE_NOT"+t(1120),oViIf:function(a,n,s,l,f){return a(n,s,l,f)},WiLrT:function(a,n){return a(n)},IfSJT:t(522),Djcah:function(a,n,s){return a(n,s)},XZBti:"WfpJd",BiIBC:t(1011)+t(944),WXXXR:function(a,n,s,l){return a(n,s,l)},nBFaM:t(1573),GjGlW:function(a,n,s,l){return a(n,s,l)},aHKSe:t(859),bGtTk:function(a,n){return a(n)},OAPKi:t(1040)+"r",eTsyc:t(1045),hGrib:function(a,n){return a===n},SGuEz:t(576)+t(960),atawn:function(a,n){return a===n},LjPWm:"calwD",kKsrG:function(a,n){return a<n},qExQo:function(a,n){return a!==n},YYsFn:t(394),dYjqZ:function(a,n){return a||n},nZBkg:function(a,n,s){return a(n,s)},sjWdy:t(940),XPuJn:t(1382)+t(1579),nZPYL:t(1671)+"s",eDeke:"x-msg-cu"+t(556)+"e",KYxSh:"x-msg-cu"+t(1803)+"ue",OoXTY:function(a,n){return a>n},BRrEm:t(1031),XoNdU:function(a){return a()},jlJUy:function(a,n){return a<n},sZrAC:function(a){return a()},KCYKx:function(a){return a()},htunq:function(a){return a()},RQRFH:function(a,n){return a===n},FMQre:function(a){return a()},mnhqh:t(1932),pjuXe:function(a,n){return a(n)},wIpZd:function(a){return a()},LhSEx:function(a,n){return a!==n},kDGTK:function(a,n){return a!==n},NHSED:t(1480),zeeWV:function(a,n,s){return a(n,s)},ZshKP:function(a){return a()},LUQCp:function(a){return a()},pOeQM:"uuTqg",mdhCV:function(a,n,s,l){return a(n,s,l)},jDYFU:function(a,n,s){return a(n,s)},alAiD:function(a,n){return a===n},eloir:"KnJeo",Tfejk:t(615),nRluh:function(a,n){return a!==n},Qrmgj:t(1682),iacGK:function(a,n){return a!==n},aoJnD:function(a,n,s){return a(n,s)},EycUY:function(a,n){return a===n},Nxbjh:"always",TBPOT:function(a,n,s){return a(n,s)},dCzjW:function(a,n){return a===n},qXZiW:function(a,n,s,l){return a(n,s,l)},qVOPo:function(a,n){return a===n},LuzNH:"arraybuffer",IMYhM:t(494),dlBwu:function(a,n){return a/n},avPts:t(903),LNWCn:"please p"+t(672)+"alid url",UmEFo:"please provide ws params"+t(1009)+t(921)+t(1427)+t(815)+t(457),PwdFT:"hTSUr",WhoRK:t(1270),aARoK:function(a,n,s){return a(n,s)},BqAlJ:"reconnect",JGhiw:t(1557)+t(621)+t(1531)+"ct",vTPEY:t(1769),QDVvk:"offline",zIchm:"pagehide",NZOlO:t(1821),muvaj:t(1825),aBKxn:t(1e3),DOqBi:t(1235),eoiJe:"bd_did",eyFjN:t(1129),yHLxh:"please p"+t(691)+t(1114)+"viceID o"+t(675),zInyX:t(1387),eaxzJ:t(732),GCxsX:t(750)+"0",VPinw:function(a,n){return a<<n},RcgGX:function(a,n){return a&n},hmriw:function(a,n){return a<<n},kydGw:function(a,n){return a&n},elOdL:t(1886),rBVPN:t(1269),ogugX:t(1143),IyYPr:t(1441),SzmzW:function(a,n){return a||n},YOocx:function(a,n,s){return a(n,s)},RoBWA:t(1309),jjdit:function(a,n,s){return a(n,s)},bEZhh:function(a,n){return a(n)},flrEH:t(1775)+">",nvLcQ:function(a,n){return a-n},RWBGu:function(a,n){return a-n},KRAsK:function(a,n){return a!==n},BYxBj:function(a,n,s){return a(n,s)},LhaqH:function(a,n){return a!==n},VwcZL:t(1056),opbkf:function(a,n){return a(n)},fFYNH:function(a,n){return a+n},UcVkm:"Pytgo",mMzTg:function(a,n){return a===n},JICgh:t(997),DgNZo:t(809),xsaHI:function(a,n){return a===n},SooES:"SGQdC",RfyoF:"GDjHf",cPGBM:t(1781)+" try rec"+t(714)+"g",kOpXR:function(a,n){return a===n},GoyAF:"send_ack",JkPvt:t(1452)+"2",mnxQM:"HehNE",poumR:t(806),zoUuP:function(a,n,s){return a(n,s)},zPuRM:function(a,n,s){return a(n,s)},lwEpC:"going aw"+t(1714)+t(1393)+t(623),VOtcw:t(922),qZxpF:function(a,n){return a!=n},fnUke:function(a,n){return a===n},VPvEI:t(731),Bjrjq:t(1553),zFEsu:function(a,n){return a!==n},EVFnm:"DlXmF",UhPOl:t(694)+t(1836),qOHxJ:t(1777)+t(1709)+"ce not i"+t(1692)+"ed",zkdlE:function(a,n){return a===n},CJyGs:t(1777)+t(1905)+t(561),aqaZy:function(a,n){return a==n},iYPcE:t(1447),nLYel:function(a,n){return a!=n},VyEjn:function(a,n){return a instanceof n},oIpvY:function(a,n){return a(n)},BFpLR:function(a,n){return a(n)},ihEXt:function(a,n){return a(n)},RkoVG:function(a,n){return a||n},AVtjj:function(a,n){return a(n)},EzBAf:function(a,n){return a===n},GhibD:function(a,n){return a<n},dkNwg:t(1793),SvIlO:function(a,n){return a===n},VCsLj:function(a,n){return a instanceof n},hIHye:t(1668)+t(1785)+t(1337),LpeYu:function(a,n){return a!==n},hVbEI:t(462),NdPEc:t(707),kAcfk:t(664)+"4",DkXWl:function(a,n){return a===n},Qbxlk:t(831),PvIUN:t(604),doBiP:t(1190),fipJd:t(887),mteAU:function(a,n){return a===n},iCsTv:t(1350),CfcNk:function(a,n){return a!=n},MOJzB:function(a,n){return a!=n},miByd:t(1420)+t(1690)+t(1580)+"pe",yokLf:function(a,n){return a===n},nlgrc:function(a,n){return a!=n},wUmDE:"SharedWo"+t(1026)+t(1417),zeeUj:function(a,n){return a===n},xMOFn:t(961)+t(1907)+t(1665),iLUiR:t(654),pKkwe:function(a,n){return a!=n},ZSYfN:function(a,n){return a!=n}};Nt.r(Ce),Nt.d(Ce,{FWS:()=>Wp,CustomErrorEvent:()=>Kd,createCloseEvent:()=>ft,ReconnectEvent:()=>Wd,createErrorEvent:()=>st,decodedFrame:()=>Yt,createOpenEvent:()=>Xd,CustomCloseEvent:()=>$d,createReconnectEvent:()=>ca,FrontierMessageEvent:()=>Jd,encodeFrame:()=>Bt,createMessageEvent:()=>Zd,OpenEvent:()=>Yd,ErrorCode:()=>Xt,Event:()=>Yn,MessageEvent:()=>Vd});let r="";function i(a=""){let n=t,s="02",l=""+Date[n(1853)](),f=r||(r=e[n(644)](x,a)),p=Math[n(1623)]()[n(715)](16)[n(1262)](-6);return e.NHkkK(e[n(1837)](e[n(1654)](s,l),f),p)}function o(){return e[t(1666)](1e4,Date.now())+Math.floor(1e4*Math.random())}function c(a){let n=t;return(e[n(1810)](Array,8)[n(1540)]("0")+e.EWIQN(parseInt,a,10).toString(2))[n(1262)](-8)}function d(a){let n=t;return e[n(1170)](e[n(857)](Array,4)[n(1540)]("0"),e[n(959)](parseInt,a,2)[n(715)](16)).slice(-4)}function u(a){let n=t,s=a[n(605)](/\./)[n(791)](p=>c(p)),l=[];return l[0]=e[n(1575)](d,e[n(1315)](s[0],s[1])),l[1]=d(e[n(1512)](s[2],s[3])),[e[n(1586)],e.gAJSb,e.gAJSb,e[n(1586)],e[n(1586)],e[n(1502)],l[0],l[1]][n(1540)]("")}function x(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(1497)](a),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(a);return s?e[n(1723)](u,a):l?h(a):e[n(1879)]}function h(a){let n=t,s={PMzEl:function(T,C){return T+C},XBYQl:function(T,C){return e[j(860)](T,C)},LdtwP:function(T,C){return e[j(1654)](T,C)},elwky:function(T,C){return e[j(1170)](T,C)},uxnFL:function(T,C){return T|C},oLghW:function(T,C){return e[j(1172)](T,C)},rjxvO:function(T,C){return e[j(1172)](T,C)},FqbiN:function(T,C){return T|C},fgRat:function(T,C){return e[j(1710)](T,C)},iDKdG:function(T,C){return e[j(962)](T,C)},kMtKq:function(T,C){return e[j(454)](T,C)},CwjtO:function(T,C){return e[j(1278)](T,C)}},l="",f=[],p=0,m=0,b=!0,g=e.gAJSb;if(e[n(475)](a.indexOf("::"),-1))if(e.xkUtk(e.twrdO,e[n(1617)]))_0x419fd6[n(1237)+n(1303)]="",_0x4c2638.log(_0x2fbd8a);else{let T=a.split("::");for(let M=0;e.pWyxS(M,T.length);M++){let K=T[M];if(e[n(1187)](K[n(1488)](":"),0)){let U=K[n(605)](":");b&&(p=U[n(437)]),m+=U[n(437)];for(let Q=0;e[n(752)](Q,U[n(437)]);Q++)if(e.adxRs(4,U[Q][n(437)]))if(e[n(572)](e[n(1434)],e.GUXWK))_0x35194c=_0x329727[s[n(1574)](_0x1066d1,_0x16a7b2)+1],_0x598884=_0x2158b1[s[n(788)](_0x2079de+_0x2db7d6,2)],_0x568cf1=_0x5e66b9[s[n(1589)](s[n(543)](_0x2e6bf9,_0x368b10),3)],(s[n(1903)](_0x5e4a4f|s[n(1473)](_0xa55cae,8),s.rjxvO(_0x142433,16))&12632256)!==8421504?_0x3f29a3+=_0x5bdf46:(_0x5dec64=s[n(1903)](s[n(1903)](s[n(1194)]((7&_0x4c8419)<<18,s[n(1150)](s[n(1316)](63,_0x21c46d),12)),s[n(1473)](63&_0x147474,6)),63&_0x34f5ba),_0x493f6f<65536||s[n(1577)](_0x5669c2,1114111)?_0x2808cf+=_0x5d0569:(_0x4c8c8a-=65536,_0x51a098+=_0x7dbdcd(s[n(1443)](_0x3b5b2b,10)+55296,s[n(788)](s.iDKdG(1023,_0x25616c),56320)),_0x459217+=3));else{let Ve=g.substring(0,e.EStGb(4,U[Q][n(437)])),xt=Ve[n(698)](U[Q]);f[n(1715)](xt)}else f[n(1715)](U[Q]);b=!1}else{if(e[n(572)](4,K[n(437)])){let U=g[n(1648)+"g"](0,4-K.length),Q=U.concat(K);f.push(Q)}else f[n(1715)](K);b&&(p+=1),m+=1,b=!1}}let C="";for(let M=0;e.pWyxS(M,e[n(1835)](8,m));M++)C=C[n(698)](g);for(let M=0;M<f[n(437)];M++)e[n(643)](M,p)&&(l=l[n(698)](C)),l=l[n(698)](f[M]);return l}{let T=a.split(":");for(let C=0;e[n(1264)](C,T[n(437)]);C++){let M=T[C];if(e[n(1719)](4,T[C][n(437)])){let K=g[n(1648)+"g"](0,e[n(1290)](4,T[C].length)),U=K[n(698)](M);l=l.concat(U)}else l=l.concat(M)}return l}}function w(a,n){let s=t;if(e[s(688)](e[s(1966)],"cuoRw")){let l=a.key;l!==void 0&&(e[s(581)](ue,n,10),e[s(983)](G,n,l));let f=a[s(1425)];e[s(1362)](void 0,f)&&(e[s(581)](ue,n,18),e[s(1673)](G,n,f))}else this[s(1304)+"igatorOn"+s(1259)]=_0x3a8e34,_0x1f8cd2?this[s(1514)+"nLine"]():this._handleOffLine()}function y(a){let n=t,s={ULNRs:function(l,f){return e[j(1965)](l,f)},JaiXc:function(l,f){return e[j(602)](l,f)},VjOnp:e.eHZBj,tcqmK:e.abdLD,XaqhU:function(l,f){return e[j(641)](l,f)},TPuSa:e[n(587)]};if(e[n(1254)]!==e[n(1254)])return s[n(746)](_0x67c7ed,s[n(1789)](s[n(1789)](s[n(1729)]+_0x38ca89+s.tcqmK,s[n(660)](_0x8cbd5c,1))+s[n(981)],_0x4d2f9b));{let l={};e:for(;!e[n(1723)](J,a);){let f=e[n(1723)](le,a);switch(e.cBXUo(f,3)){case 0:break e;case 1:l[n(1057)]=O(a,le(a));break;case 2:l.value=e[n(452)](O,a,le(a));break;default:e.KldQB(R,a,e[n(396)](7,f))}}if(e[n(1609)](void 0,l[n(1057)]))throw new Error(e[n(1772)]);if(e[n(925)](void 0,l.value))throw new Error("Missing "+n(1301)+n(1085)+"value");return l}}function A(a){let n=t,s=e[n(398)](k);return e.zEhCT(E,a,s),e.MgjGk(F,s)}function E(a,n){let s=t,l=a.SeqID;e[s(841)](void 0,l)&&(e[s(1144)](ue,n,8),e[s(1673)](ut,n,l));let f=a[s(1324)];e.tttsA(void 0,f)&&(e.yWEYc(ue,n,16),e[s(719)](ut,n,f));let p=a[s(1918)];e[s(572)](void 0,p)&&(e[s(452)](ue,n,24),e[s(451)](ut,n,e[s(1771)](N,p)));let m=a.method;e[s(841)](void 0,m)&&(e[s(959)](ue,n,32),e[s(451)](ut,n,N(m)));let b=a[s(1938)];if(b!==void 0)for(let Ve of b){e[s(1850)](ue,n,42);let xt=e[s(1007)](k);w(Ve,xt),e[s(1507)](ue,n,xt[s(1906)]),e[s(1049)](W,n,xt),e[s(1122)](P,xt)}let g=a[s(1376)+s(1052)];e[s(1719)](void 0,g)&&(e[s(1699)](ue,n,50),e[s(452)](G,n,g));let T=a["payloadT"+s(812)];T!==void 0&&(e[s(423)](e[s(1730)],"ITvCK")?(e[s(581)](ue,n,58),e[s(719)](G,n,T)):(_0x3188e8=_0x474c7c.charCodeAt(_0x2051f8),e[s(884)](_0x1f7771,128)?_0xb68ee5[_0x36a55b++]=_0x3930ef:e.pWyxS(_0x60d4aa,2048)?(_0x2a2c23[_0x48dd6a++]=e[s(980)](_0x369d8a,6)|192,_0x1450ec[_0x4697fc++]=e[s(962)](63,_0x1c38e2)|128):e[s(1535)](e[s(1445)](64512,_0x313058),55296)&&e[s(643)](e[s(962)](64512,_0x173a8a=_0xf2ce4d[s(1409)+"At"](e[s(1454)](_0x3efdaa,1))),56320)?(_0x4a6075=e[s(1170)](e[s(464)](65536,e[s(1172)](e[s(962)](1023,_0x3db19f),10)),e[s(1152)](1023,_0x523202)),++_0x15d367,_0x1e8381[_0x235b58++]=e[s(628)](_0x38fc97>>18,240),_0x11ae9b[_0x4c4066++]=e[s(628)](e[s(396)](e[s(980)](_0x56dda0,12),63),128),_0x66d237[_0x1ba21e++]=e[s(396)](e[s(980)](_0x3ff7c4,6),63)|128,_0x27740c[_0x15ae00++]=e[s(726)](e[s(1856)](63,_0x2be25a),128)):(_0x36ad6a[_0x13d39c++]=e[s(1278)](_0x389c94,12)|224,_0x334deb[_0x31d42a++]=e[s(544)](e[s(396)](e[s(1278)](_0x10bd55,6),63),128),_0x1b5879[_0x255980++]=e[s(1346)](e.zqSFf(63,_0x566235),128))));let C=a[s(1198)];C!==void 0&&(e[s(959)](ue,n,66),e[s(1179)](ue,n,C[s(437)]),e[s(451)](he,n,C));let M=a[s(1373)];if(M!==void 0){if(e[s(1893)](e[s(1640)],s(1555)))return new _0x5acedd(e[s(544)](e.tbHso(e.NJvIh(_0x55b663[4],24),e[s(1792)](_0x32fdf1[5],16))|e[s(1172)](_0x54b532[6],8),_0x334ab6[7]),e[s(1232)](e[s(1466)](_0x52ab27[0],24)|e.EpFwx(_0x2121a3[1],16)|e[s(1231)](_0x1a30cf[2],8),_0x13784e[3]),_0x628ba7);e.kFxXk(ue,n,74),G(n,M)}let K=a[s(481)+s(724)];e[s(617)](void 0,K)&&(e[s(1802)](ue,n,82),e[s(1680)](G,n,K));let U=a[s(1028)];e[s(908)](void 0,U)&&(ue(n,90),e[s(983)](G,n,U));let Q=a.frameType;if(Q!==void 0)if(e[s(515)](e[s(1462)],e.WLSrM))try{return e.XFhHj(e.XJemB,typeof _0x60752a)&&(e[s(1613)](_0x4e58f2,_0x41ee1d)||_0x4a78fa.buffer&&e[s(1613)](_0x730bdb[s(1251)],_0x4d0d9e))||e.XFhHj(e[s(1310)],typeof _0x39e2d4)?"":(_0x15d25d[s(949)](_0x475972),e[s(870)])}catch{return e[s(1459)](e.XJemB,typeof _0x546739)?e[s(1202)]:""}else e[s(1634)](ue,n,96),e[s(983)](ut,n,N(Q))}function v(a){let n=t,s={sXGMN:function(l,f){return e[j(826)](l,f)},cxpmf:function(l,f){return e[j(1757)](l,f)}};if(e[n(405)](e.encVn,e[n(1538)]))this.isLong=!0,this[n(1861)]=s.sXGMN(0,_0x49d0f9),this.high=s[n(1647)](0,_0x26e3e8),this[n(1239)]=!!_0x128e26;else return e.wmAMZ(I,e[n(1122)](B,a))}function I(a){let n=t,s={};e:for(;!e.RUUDL(J,a);){let l=e[n(1810)](le,a);switch(e[n(1134)](l,3)){case 0:break e;case 1:s.SeqID=vt(a,!0);break;case 2:s[n(1324)]=e[n(476)](vt,a,!0);break;case 3:s[n(1918)]=le(a);break;case 4:s[n(901)]=le(a);break;case 5:{let f=e[n(644)](S,a);(s[n(1938)]||(s.headers=[]))[n(1715)](e[n(1418)](y,a)),a.limit=f;break}case 6:s[n(1376)+n(1052)]=e.OzNqC(O,a,e[n(857)](le,a));break;case 7:s[n(850)+n(812)]=e[n(467)](O,a,le(a));break;case 8:s.payload=e[n(674)](ye,a,e[n(644)](le,a));break;case 9:s[n(1373)]=O(a,e.gQxuC(le,a));break;case 10:s.serverTiming=e[n(1846)](O,a,e[n(562)](le,a));break;case 11:s[n(1028)]=O(a,le(a));break;case 12:s[n(1741)+"e"]=le(a);break;default:e[n(1874)](R,a,e[n(1856)](7,l))}}if(e[n(1535)](void 0,s[n(1883)]))throw new Error(e[n(1902)]);if(e.UiBjG(void 0,s[n(1324)]))throw new Error(e[n(1951)]);if(e[n(1893)](void 0,s.service))throw new Error("Missing "+n(1301)+n(1085)+n(1918));if(s.method===void 0)throw new Error(e[n(1112)]);return s}function S(a){let n=t;if(e[n(977)]===e[n(1287)])return _0x20c653[n(872)](_0x1faf57),!1;{let s=le(a),l=a.limit;return a[n(1906)]=e[n(860)](a[n(399)],s),l}}function R(a,n){let s=t;switch(n){case 0:for(;e[s(418)](128,e[s(1122)](ie,a)););break;case 2:V(a,e[s(830)](le,a));break;case 5:e.sFjab(V,a,4);break;case 1:V(a,8);break;default:throw new Error(e[s(1827)](e[s(1295)],n))}}function N(a){return a|=0,{low:a,high:e.ewpLm(a,31),unsigned:a>=0}}let _=[];function k(){let a=t,n=_[a(684)]();return n?(n.offset=n[a(1906)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function P(a){let n=t,s={PZWFR:function(l,f){return l|f},ZTqNM:function(l,f){return l&f},JfIMj:function(l,f){return l|f},XKNcc:function(l,f){return e[j(524)](l,f)},uPsiU:function(l,f){return e[j(438)](l,f)}};e[n(909)](e[n(1696)],n(1018))?_[n(1715)](a):(_0x9489f4[_0x2dac1a++]=s[n(1752)](s[n(1081)](_0x1d8a04>>18,7),240),_0x28e80a[_0x3667a8++]=s.JfIMj(s[n(1632)](s[n(461)](_0x1fdf77,12),63),128))}function B(a){return{bytes:a,offset:0,limit:a[t(437)]}}function F(a){let n=t,s=a[n(1522)],l=a.limit;return s[n(437)]===l?s:s[n(1206)](0,l)}function V(a,n){let s=t;if(e.xaeEv(a.offset+n,a[s(1906)]))throw new Error(e[s(1495)]);a.offset+=n}function J(a){let n=t;return e[n(1908)](a[n(399)],a[n(1906)])}function te(a,n){let s=t,l=a[s(1522)],f=a[s(399)],p=a[s(1906)],m=e[s(1837)](f,n);if(e[s(454)](m,l[s(437)])){let b=new Uint8Array(e[s(773)](2,m));b[s(540)](l),a[s(1522)]=b}return a[s(399)]=m,e[s(1423)](m,p)&&(a[s(1906)]=m),f}function X(a,n){let s=t,l=a[s(399)];if(e.yZiTX(e[s(1490)](l,n),a[s(1906)]))throw new Error(e[s(1953)]);return a[s(399)]+=n,l}function ye(a,n){let s=t,l=e.yWEYc(X,a,n);return a[s(1522)].subarray(l,e[s(1490)](l,n))}function he(a,n){let s=t,l=e[s(983)](te,a,n[s(437)]);a[s(1522)][s(540)](n,l)}function O(a,n){let s=t,l=e[s(982)](X,a,n),f=String[s(1243)+s(1855)],p=a.bytes,m="\uFFFD",b="";for(let g=0;e[s(1831)](g,n);g++){let T=p[e[s(1512)](g,l)],C,M,K,U;if(e.gIRHa(128,T)===0)b+=f(T);else if(e[s(1681)](e[s(736)](224,T),192))e[s(1282)](g,1)>=n?b+=m:(C=p[e[s(1654)](e.xVmZc(g,l),1)],e[s(817)](192,C)!==128?b+=m:(U=e[s(1061)](e[s(1528)](31,T)<<6,63&C),e[s(1915)](U,128)?b+=m:(b+=e[s(798)](f,U),g++)));else if(e[s(817)](240,T)==224)if(e[s(1654)](g,2)>=n)b+=m;else{if(e[s(942)](e[s(759)],"yBpxN"))return _0x330494.errMsg||_0x42400a.errNo?(s(1277)+" "+(_0x524beb.errMsg||"")+" code: "+(_0x4b95bc.errNo||""))[s(1519)]():_0x20478b[s(1838)+"y"](_0x5bcbbd);C=p[e[s(1315)](g,l)+1],M=p[e[s(687)](g,l)+2],e[s(1817)](e.FKNhR(C,e.PYFAa(M,8)),49344)!==32896?b+=m:(U=e[s(1232)](e[s(1346)]((15&T)<<12,e[s(1231)](e[s(817)](63,C),6)),e.uBQVq(63,M)),U<2048||e[s(1908)](U,55296)&&e.GaPSY(U,57343)?b+=m:(b+=e[s(967)](f,U),g+=2))}else if(e[s(1457)](248,T)==240)if(e[s(1908)](g+3,n))b+=m;else{if(e[s(925)](e[s(1878)],e[s(640)]))return this._isMiniTT||this[s(1084)+"X"]?this[s(1304)+s(919)+s(1259)]:(this[s(455)+"er"]||this[s(1273)+"r"])&&this[s(1039)][s(1077)+s(863)+s(1590)]?_0x1d641f[s(1242)]:!0;C=p[e[s(638)](e[s(1208)](g,l),1)],M=p[e[s(1315)](e[s(1282)](g,l),2)],K=p[e[s(638)](e[s(836)](g,l),3)],e.tjJNi(e[s(418)](e[s(716)](e[s(1346)](C,M<<8),e.PYFAa(K,16)),12632256),8421504)?b+=m:(U=e[s(1956)](e.BxZtc(e[s(1177)](e[s(1156)](e[s(1086)](7,T),18),e[s(952)](63&C,12)),e.eHYlW(e[s(1904)](63,M),6)),e[s(1856)](63,K)),e[s(884)](U,65536)||U>1114111?b+=m:e[s(572)](e.dtAGF,s(488))?(U-=65536,b+=e[s(742)](f,e[s(1047)](e.FxjAN(U,10),55296),e[s(1868)](e[s(1518)](1023,U),56320)),g+=3):this[s(1471)]++)}else b+=m}return b}function G(a,n){let s=t,l=n.length,f=0;for(let b=0;b<l;b++){let g=n[s(1409)+"At"](b);e[s(1908)](g,55296)&&e[s(1897)](g,56319)&&e[s(532)](b,1)<l&&(g=e.EStGb(e[s(797)](e[s(1881)](g,10),n[s(1409)+"At"](++b)),56613888)),f+=e.tNxAj(g,128)?1:e.ySxes(g,2048)?2:e[s(1264)](g,65536)?3:4}e[s(634)](ue,a,f);let p=e[s(1673)](te,a,f),m=a[s(1522)];for(let b=0;b<l;b++){let g=n.charCodeAt(b);g>=55296&&g<=56319&&e[s(495)](b+1,l)&&(g=e[s(1118)](e[s(1108)](e[s(1784)](g,10),n.charCodeAt(++b)),56613888)),e[s(565)](g,128)?m[p++]=g:(g<2048?m[p++]=e[s(1061)](e[s(1127)](e.lwhUs(g,6),31),192):(g<65536?m[p++]=e[s(1751)](e[s(980)](g,12)&15,224):(m[p++]=e[s(826)](e[s(509)](g>>18,7),240),m[p++]=e[s(1061)](e[s(1637)](g,12)&63,128)),m[p++]=e[s(628)](e[s(1464)](e[s(1637)](g,6),63),128)),m[p++]=e[s(628)](e[s(1465)](63,g),128))}}function W(a,n){let s=t,l=e[s(452)](te,a,n.limit),f=a[s(1522)],p=n[s(1522)];for(let m=0,b=n.limit;m<b;m++)f[m+l]=p[m]}function ie(a){return a[t(1522)][e.uesWH(X,a,1)]}function $e(a,n){let s=t;if(e[s(1898)]==="dasQN"){let l=e.FdoIi(te,a,1);a.bytes[l]=n}else _0x29bac1[s(432)][s(1628)+s(554)](_0x2c1c54)}function le(a){let n=t;if(e[n(1735)](e[n(592)],e[n(1872)])){let s=0,l=0,f;do f=e[n(1965)](ie,a),e.JQybp(s,32)&&(l|=e[n(1881)](127&f,s)),s+=7;while(e[n(418)](128,f));return l}else{let s=_0x575bfb["deleteDa"+n(882)](_0x5e2d11);return _0x42ec34&&s[n(1351)+n(1313)](UqIFIN[n(883)],()=>_0xad1927()),UqIFIN[n(1965)](_0x1d7b65,s).then(()=>{})}}function ue(a,n){let s=t;for(n>>>=0;e.dwpBY(n,128);)$e(a,e[s(1901)](e.jFOcK(127,n),128)),n>>>=7;e[s(442)]($e,a,n)}function vt(a,n){let s=t,l={hKNlX:e[s(650)],GVjMv:function(f,p,m){return e[s(476)](f,p,m)}};if(s(586)===e.oywPG){let f=0,p=0,m=0,b;return b=e[s(1575)](ie,a),f=e[s(1817)](127,b),e.OXIcJ(128,b)&&(b=e[s(466)](ie,a),f|=e[s(1881)](127&b,7),e.hPuCo(128,b)&&(b=e[s(547)](ie,a),f|=e.kzGrr(e.LoaWh(127,b),14),128&b&&(b=e[s(830)](ie,a),f|=e[s(535)](e[s(1236)](127,b),21),e[s(1972)](128,b)&&(b=e.bBQPr(ie,a),p=e[s(418)](127,b),128&b&&(b=ie(a),p|=e[s(1375)](e.cKIPP(127,b),7),e[s(962)](128,b)&&(b=e.Gwljo(ie,a),p|=e[s(767)](e.VDiAz(127,b),14),128&b&&(b=e[s(591)](ie,a),p|=(127&b)<<21,e.rgLEW(128,b)&&(b=e[s(1158)](ie,a),m=e[s(1817)](127,b),128&b&&(b=ie(a),m|=e.ZCYWq(e.OXIcJ(127,b),7)))))))))),{low:e.uOQXm(f,e.evdCS(p,28)),high:e[s(1134)](p,4)|e[s(527)](m,24),unsigned:n}}else if(e[s(1234)](_0x2e0a58,_0x26425e)){let f=_0x843421.buffer.slice(_0x281196.byteOffset,_0x25d9c1[s(1181)+"th"]+_0x3a51bb[s(880)+"et"]);this[s(1271)]&&this._socket.send({data:f,fail:p=>{let m=s;this[m(729)](l[m(1701)],_0x11a7fb(l.hKNlX,{message:this[m(1037)+m(1276)+"age"](p)}))}})}else this._socket&&this[s(1271)][s(649)]({data:_0x1c83eb,fail:f=>{let p=s;this[p(729)](l.hKNlX,l[p(1296)](_0x45a92f,l[p(1701)],{message:this[p(1037)+p(1276)+p(1072)](f)}))}})}function ut(a,n){let s=t,l=e.cBXUo(n.low,0),f=e[s(963)](e.MFXoO(e[s(1805)](n[s(1861)],28),e[s(1881)](n[s(728)],4)),0),p=n[s(728)]>>>24,m=e[s(515)](0,p)?e.xkUtk(0,f)?l<16384?e[s(565)](l,128)?1:2:e.pWyxS(l,2097152)?3:4:e[s(583)](f,16384)?e[s(495)](f,128)?5:6:e[s(1264)](f,2097152)?7:8:e.qGHIh(p,128)?9:10,b=e[s(1660)](te,a,m),g=a[s(1522)];switch(m){case 10:g[e[s(860)](b,9)]=e[s(1021)](e[s(1134)](p,7),1);case 9:g[b+8]=e.tttsA(9,m)?e[s(1322)](128,p):e[s(1347)](127,p);case 8:g[b+7]=e[s(1954)](8,m)?e.FKNhR(e.xalcq(f,21),128):e[s(1405)](f,21)&127;case 7:g[e.AErWN(b,6)]=e[s(841)](7,m)?e[s(772)](e[s(963)](f,14),128):e[s(1509)](f>>>14,127);case 6:g[e[s(1003)](b,5)]=e.HdJBD(6,m)?e[s(1887)](f>>>7,128):e[s(1653)](f>>>7,127);case 5:g[b+4]=e.xpQIy(5,m)?e[s(965)](128,f):127&f;case 4:g[e[s(1712)](b,3)]=e[s(1362)](4,m)?e.IPzZK(l,21)|128:e[s(817)](e[s(972)](l,21),127);case 3:g[e.dqieR(b,2)]=e[s(909)](3,m)?e.xalcq(l,14)|128:e[s(1708)](e[s(1805)](l,14),127);case 2:g[e[s(464)](b,1)]=e.MaQMe(2,m)?e.dIsSx(e[s(568)](l,7),128):e[s(1653)](e[s(1405)](l,7),127);case 1:g[b]=e[s(572)](1,m)?e[s(1704)](128,l):127&l}}function Yt(a){let n=t;if(e[n(1281)]!==n(1283)){if(this[n(1039)][n(1561)+n(936)+"nect"]||this._readyClosed)return;this._handleReconnect()}else return e.AoKyt(v,a)}function Bt(a){return e[t(1575)](A,a)}let Zt=65536,Gr=e[t(610)],ge=e.oDBaH(Zt,Zt),Se=ge*ge,Jn=Se/2,ke=String[t(1494)+"e"][t(1409)+"At"];class ce{constructor(n,s,l){let f=t;this[f(897)]=!0,this[f(1861)]=e[f(1675)](0,n),this[f(728)]=e[f(1342)](0,s),this[f(1239)]=!!l}static isLong(n){return n&&n.isLong===!0}static fromBits(n,s,l){return new ce(n,s,l)}static[t(1788)+"s"](n,s,l){let f=t,p={qaPle:function(m,b,g){return e[j(1660)](m,b,g)},XKiVo:e[f(650)],EgFoE:function(m,b){return e[f(602)](m,b)}};if(e[f(619)](e[f(1477)],e.DSCrH)){let m={CmcZG:function(g,T,C){return p.qaPle(g,T,C)},izdNu:p[f(964)]},b=_0x5f47f2[f(1251)][f(1262)](_0x2fdae6[f(880)+"et"],p[f(625)](_0x31beb3[f(1181)+"th"],_0x2de02b.byteOffset));this._socket&&this[f(1271)][f(649)]({data:b,fail:g=>{let T=f;this[T(729)]("error",m[T(1545)](_0xc1d58b,m[T(680)],{message:this[T(1037)+T(1276)+"age"](g)}))}})}else return l?ce["fromByte"+f(1090)](n,s):ce.fromBytesBE(n,s)}static["fromByte"+t(1090)](n,s){let l=t;return new ce(e[l(720)](e.BxZtc(n[0],e.GAtWt(n[1],8)),e[l(535)](n[2],16))|e[l(445)](n[3],24),e[l(994)](e[l(726)](n[4],n[5]<<8)|n[6]<<16,e[l(671)](n[7],24)),s)}static[t(1788)+t(858)](n,s){let l=t;return new ce(e[l(1704)](e[l(504)](e.eHYlW(n[4],24),e.NJvIh(n[5],16))|e[l(1173)](n[6],8),n[7]),e[l(1914)](e.blHxs(e[l(632)](n[0]<<24,e[l(444)](n[1],16)),n[2]<<8),n[3]),s)}static[t(1440)](n){let s=t;return e[s(710)](n,Gr)?jd:new ce(e[s(523)](e[s(699)](e[s(892)](e[s(965)](ke[s(978)](n,0),e[s(1710)](ke[s(978)](n,1),8)),ke[s(978)](n,2)<<16),e[s(987)](ke.call(n,3),24)),0),e[s(963)](e[s(716)](e[s(652)](e[s(780)](ke[s(978)](n,4),e.PjnSD(ke.call(n,5),8)),ke[s(978)](n,6)<<16),e[s(995)](ke[s(978)](n,7),24)),0),!0)}toHash(){let n=t,s={zNxwV:e[n(779)]};if(e[n(1840)]===e[n(1840)])return String[n(1243)+n(1855)](e.VZrdj(255,this.low),e[n(1127)](this.low>>>8,255),e[n(1002)](e[n(1478)](this[n(1861)],16),255),e[n(567)](this[n(1861)],24),e.PDTNh(255,this[n(728)]),e[n(1405)](this[n(728)],8)&255,e[n(1127)](e[n(678)](this[n(728)],16),255),e.AlULM(this.high,24));this[n(729)](s[n(633)],_0x178c0d),this[n(1226)+"e"]&&this[n(1226)+"e"](_0x428155)}static[t(843)+"er"](n,s=!0){let l=t;if(e[l(1109)](isNaN,n))return s?rp:jd;if(s){if(e.KKmNw(n,Se))return sp}else{if(e.GaPSY(n,-Jn))return op;if(e[l(477)](e[l(434)](n,1),Jn))return ip}return ce[l(1597)](e[l(886)](n%ge,0),e[l(1901)](e.rowDy(n,ge),0),s)}toNumber(){let n=t;return this[n(1239)]?e.GNYxZ(e[n(972)](this[n(728)],0)*ge,e[n(1896)](this[n(1861)],0)):this.high*ge+e[n(1805)](this[n(1861)],0)}[t(1705)](){let n=t;return this[n(728)]===0&&e[n(515)](0,this[n(1861)])}add(n){let s=t;ce[s(897)](n)||(n=ce[s(843)+"er"](n));let l=e[s(1381)](this[s(728)],16),f=e.jFOcK(65535,this[s(728)]),p=this[s(1861)]>>>16,m=e.vmJdj(65535,this.low),b=n.high>>>16,g=e[s(1127)](65535,n.high),T=e.UJrpV(n[s(1861)],16),C=e[s(962)](65535,n[s(1861)]),M=0,K=0,U=0,Q=0;return Q+=e[s(1439)](m,C),U+=Q>>>16,Q&=65535,U+=e.KnIeE(p,T),K+=e[s(829)](U,16),U&=65535,K+=f+g,M+=K>>>16,K&=65535,M+=l+b,M&=65535,ce.fromBits(e[s(1887)](e[s(740)](U,16),Q),e[s(1931)](M,16)|K,this[s(1239)])}equals(n){let s=t;return ce[s(897)](n)||(n=ce.fromNumber(n)),e.adxRs(this[s(1239)],n[s(1239)])&&e[s(855)](this[s(728)]>>>31,1)&&e.vmujH(e[s(1896)](n[s(728)],31),1)?!1:e[s(423)](this[s(728)],n[s(728)])&&this.low===n[s(1861)]}[t(1959)](){let n=t;return this.low===-1&&this.high===-1?ce[n(1597)](0,0,this.unsigned):e[n(855)](-1,this.low)?ce[n(1597)](0,e.ToSGl(this.high,1),this[n(1239)]):ce[n(1597)](this[n(1861)]+1,this.high,this[n(1239)])}[t(1503)](n){let s=t;return n?this[s(512)+"E"]():this[s(1687)+"E"]()}[t(512)+"E"](){let n=t,s=this[n(728)],l=this[n(1861)];return[e[n(1369)](255,l),e[n(624)](l,8)&255,e.oTjKU(l,16)&255,e[n(1025)](l,24),e.LHatB(255,s),e[n(509)](e[n(1274)](s,8),255),e[n(1812)](e[n(769)](s,16),255),e.bPYjl(s,24)]}[t(1687)+"E"](){let n=t,s=this[n(728)],l=this[n(1861)];return[e[n(1272)](s,24),e[n(1107)](s>>>16,255),e[n(1759)](s,8)&255,e.OKYfb(255,s),e[n(624)](l,24),e[n(1812)](e.NtlVV(l,16),255),e[n(668)](l,8)&255,e[n(1904)](255,l)]}}let jd=new ce(0,0,!1),rp=new ce(0,0,!0),ip=ce[t(1597)](-1,2147483647,!1),sp=ce[t(1597)](-1,-1,!0),op=ce[t(1597)](0,-2147483648,!1);var Xt=(function(a){let n=t,s=(n(1539)+"0|5").split("|"),l=0;for(;;){switch(s[l++]){case"0":a[a[e.NscgL]=5005]=e[n(521)];continue;case"1":a[a[e[n(1331)]]=5001]=n(1352)+"RROR";continue;case"2":a[a[e[n(612)]]=5004]=e.zmqyK;continue;case"3":a[a[e[n(686)]]=5003]=e[n(686)];continue;case"4":a[a[e.JyCQw]=5002]=e.JyCQw;continue;case"5":return a}break}})({});class Yn{constructor(n){let s=t,l={WTkvJ:function(f,p,m){return f(p,m)}};if(e[s(841)](e[s(469)],e[s(469)])){let f=SuEQms[s(1866)](_0x5c853b,_0x3b9b81,1);_0x122e70[s(1522)][f]=_0x4d95c5}else this[s(1841)]=n,this[s(1365)]=null}}class Wd extends Yn{constructor(n,s){let l=t;e.quHer===l(1044)?this._isMiniTT?_0x21d476[l(1200)+"kStatusC"+l(1451)](({isConnected:f})=>{let p=l;this["_miniNav"+p(919)+"line"]=f,f?this[p(1514)+p(666)]():this["_handleO"+p(1176)]()}):this[l(1084)+"X"]&&_0x3f1a74[l(1200)+l(753)+"hange"](({isConnected:f})=>{let p=l;this[p(1304)+"igatorOn"+p(1259)]=f,f?this[p(1514)+p(666)]():this[p(1514)+p(1176)]()}):(super(n),this[l(616)]=s&&s[l(616)]||null)}}class Kd extends Yn{constructor(n,s){let l=t,f=(l(1739)+"0|5|1")[l(605)]("|"),p=0;for(;;){switch(f[p++]){case"0":this[l(1641)]=s&&s.lineno||0;continue;case"1":this[l(518)]=s&&s[l(518)]||5001;continue;case"2":this[l(1928)]=s&&s[l(1928)]||"";continue;case"3":this[l(1285)]=s&&s[l(1285)]||0;continue;case"4":this.error=s&&s[l(1569)]||null;continue;case"5":this.message=s&&s.message||"";continue;case"6":super(n);continue}break}}}class $d extends Yn{constructor(n,s){let l=t;super(n),this[l(518)]=s&&s[l(518)]||0,this[l(1815)]=s&&s[l(1815)]||"",this[l(1546)]=s&&s.wasClean||!1,this[l(1397)+l(590)]=s&&s[l(1397)+l(590)]||!1}}class Vd extends Yn{constructor(n,s){let l=t;super(n),this[l(1463)]=s&&s[l(1463)]||null}}class Jd extends Vd{constructor(n,s){let l=t;super(n),this[l(1463)]=s&&s[l(1463)]||null,this[l(616)]=s&&s.message||null}}class Yd extends Yn{constructor(n,s){let l=t;super(n),this[l(1463)]=s&&s.data||null}}function st(a,{message:n,code:s,error:l}){return new Kd(a,{message:n,code:s,error:l})}function ft(a,{code:n,reason:s,wasClean:l,willReconnect:f}){return new $d(a,{code:n,reason:s,wasClean:l,willReconnect:f})}function Zd(a,{data:n,message:s}){return new Jd(a,{data:n,message:s})}function Xd(a,{data:n}){return new Yd(a,{data:n})}function ca(a,{message:n}){return new Wd(a,{message:n})}class Qd{constructor(n,s){let l=t;this[l(1421)+"s"]=n,this[l(1378)+"es"]=s,this[l(1391)+"ndex"]=0,this.currentEndpointTriesCount=0}[t(1952)+t(1884)+t(1217)](){let n=t;this["currentI"+n(1036)]=0,this[n(483)+n(1034)+n(430)+"t"]=0}resetTries(){let n=t;this[n(483)+n(1034)+n(430)+"t"]=0}getCurrentEndpoint(){let n=t;return this[n(1421)+"s"][this["currentI"+n(1036)]]}["getCurre"+t(868)+"ntTriesCount"](){return this[t(483)+"ndpointTriesCount"]}[t(1912)+t(1961)+"es"](){let n=t;return!!(e.dwpBY(this[n(1391)+n(1036)],this[n(1421)+"s"][n(437)])||this.currentIndex===e.ZHEAk(this[n(1421)+"s"][n(437)],1)&&e[n(1155)](this[n(483)+"ndpointT"+n(430)+"t"],this[n(1378)+"es"]))}["checkCurrentEndp"+t(1734)+t(1410)+t(446)](){let n=t;return e[n(1459)](this[n(1391)+"ndex"],this[n(1421)+"s"][n(437)])?!0:e[n(1691)](this[n(483)+"ndpointT"+n(430)+"t"],this[n(1378)+"es"])}[t(1485)+t(1103)+t(1942)+t(1724)+t(1183)](){let n=t;return this["currentE"+n(1034)+n(430)+"t"]=1,this[n(1391)+n(1036)]++,this.endpoints[this[n(1391)+n(1036)]]}["getCurre"+t(868)+"ntAndUpdateCount"](){let n=t;if(e[n(619)](e[n(853)],e[n(875)]))this[n(729)](n(922),_0x1ef295),this["onReceiv"+n(1149)]&&this[n(1306)+n(1149)](_0x1729e6);else return this[n(483)+n(1034)+n(430)+"t"]++,this[n(1639)+n(868)+"nt"]()}}let Zn=(e[t(1403)]!=typeof globalThis&&e[t(1828)](t(1350),globalThis[t(1663)+t(1533)][t(603)])||e.XFhHj(e[t(1403)],typeof window)&&e.iCsTv===window[t(1663)+t(1533)][t(603)])&&e.CfcNk(e[t(1403)],typeof document),An=e[t(975)](e[t(1403)],typeof globalThis)&&(e[t(1544)](t(654),globalThis[t(1663)+"tor"][t(603)])||e.inLHi(e.miByd,globalThis[t(1663)+t(1533)][t(603)]))&&e[t(1403)]!=typeof tt,qr=(e[t(928)](e[t(1403)],typeof globalThis)&&e[t(1610)](t(654),globalThis[t(1663)+t(1533)][t(603)])||e[t(1517)](e[t(1403)],typeof globalThis)||e[t(1004)](e[t(1403)],typeof globalThis)&&!!globalThis[t(1558)+"Bridge"])&&e.CMKBg!=typeof wx,jr=e.kTvRO(e[t(1403)],typeof globalThis)&&("Dedicate"+t(1690)+t(1580)+"pe"===globalThis.constructor[t(603)]||e[t(1535)](e[t(1743)],globalThis["construc"+t(1533)].name)||e[t(1594)](e[t(1307)],globalThis[t(1663)+t(1533)][t(603)]))&&t(558)+"d"!=typeof self,ap=e[t(1857)](e.CMKBg,typeof globalThis)&&e[t(618)]===globalThis[t(1663)+"tor"].name&&e[t(1556)](e[t(1403)],typeof global)&&e[t(618)]===global["construc"+t(1533)].name&&e[t(928)](e[t(1403)],typeof process)&&!!process.version;class da{constructor(){this._listeners={}}[t(729)](n,...s){let l=t,f=this[l(1829)+"rs"][n];if(f)f.slice().forEach(p=>p.fn.apply(p[l(669)],s));else if(e[l(515)](l(1569),n)&&!this[l(1582)]){let p=s[l(437)]&&s[0];if(e.cGECQ(p,Error))throw p;let m=new Error(e[l(1787)](e[l(520)],p?e[l(1679)](" (",p[l(616)])+")":""));throw m[l(1318)]=p,p}return this}[t(1963)](n,s){let l=t,f={WLjsg:l(419)};if(e[l(842)](void 0,n))this[l(1829)+"rs"]={};else if(e.FuudH(void 0,s))this[l(1829)+"rs"][n]=null;else if(e[l(1328)]===e[l(861)])this[l(786)]&&this[l(786)][l(649)](_0x405a0d),this[l(620)](f[l(1196)],_0x59cfec);else{let p=this[l(1829)+"rs"][n];if(p)for(let m=0;e[l(486)](m,p[l(437)]);)e[l(493)](p[m].fn,s)?p[l(778)](m,1):++m}return this}on(n,s,l){let f=t;return(this._listeners[n]||(this[f(1829)+"rs"][n]=[])).push({fn:s,ctx:l||this}),this}}class cp extends da{[t(1037)+t(1276)+t(1072)](n){let s=t;return n[s(1432)]||n[s(943)]?(s(1277)+" "+(n[s(1432)]||"")+" code: "+(n.errNo||"")).trim():JSON[s(1838)+"y"](n)}constructor(n,s,l){let f=t;e[f(688)](e.rXKXP,e[f(613)])?(super(),this._socket=null,qr&&wx[f(1394)+"ocket"]&&(this[f(1271)]=wx.connectSocket({url:n,protocols:s,header:l,fail:this[f(496)+f(1889)+f(1087)].bind(this),success:this["_createS"+f(1500)+f(1718)+"ler"].bind(this)})),An&&tt[f(1394)+f(626)]&&(this._socket=tt[f(1394)+f(626)]({url:n,protocols:s,header:l,fail:this[f(496)+f(1889)+f(1087)][f(923)](this),success:this[f(496)+f(1500)+f(1718)+f(1113)].bind(this)}))):(this[f(786)]&&this._ws[f(649)](_0x3d1351),this[f(620)](e[f(1706)],_0x1f97e1))}[t(496)+"ocketSuc"+t(1718)+t(1113)](){let n=t;Promise[n(622)]()[n(1428)](()=>{let s=n;this[s(1830)+s(1644)]()})}[t(496)+t(1889)+"lHandler"](n){let s=t,l={gIfaq:function(f,p,m){return e.PlJmn(f,p,m)},LAbBB:e[s(650)],POkxQ:s(940)};Promise[s(622)]().then(()=>{let f=s,p=l[f(1338)](st,l[f(706)],{message:this["_formatE"+f(1276)+"age"](n)});this[f(729)](f(1569),p);let m=ft(l.POkxQ,{reason:this[f(1037)+f(1276)+f(1072)](n)});this[f(729)](l[f(653)],m)})}[t(1830)+t(1644)](){let n=t,s={buBje:function(l,f,p){return e.DmUtT(l,f,p)},rVNmF:e[n(1135)],iAeJM:n(940),enHlW:function(l,f){return e[n(1609)](l,f)},sDvMW:e.QxFKD,jpPVd:function(l,f,p){return e.kZEtR(l,f,p)},EvUwa:e[n(779)],cTnqi:e[n(793)],vZvwA:e[n(1707)],iPHoM:e[n(1863)],NvjIn:e.QgdKE,amzeo:function(l,f){return e[n(968)](l,f)},cWqgH:e[n(703)],sGvMF:e.Jdnpo,jIZyW:function(l,f,p){return e.nZDbQ(l,f,p)}};e[n(1643)]!==e[n(608)]?(this[n(1271)][n(808)](l=>{let f=n;this[f(729)](f(1618),s[f(549)](Xd,s[f(1530)],{...l,data:l.errMsg||""}))}),this._socket[n(1711)](l=>{let f=n;this[f(729)](s[f(879)],ft(s[f(879)],{...l}))}),this[n(1271)][n(519)+"e"](l=>{let f=n;if(s.enHlW(f(1035),s[f(1333)]))this[f(729)](f(616),s[f(1968)](Zd,s.EvUwa,{...l}));else{let p="connect "+_0x50c1a4+(f(771)+f(1148)+"tries re"+f(1891));this[f(620)](p),this[f(534)+f(1027)+f(1527)](s[f(549)](_0x2be1ac,f(1569),{message:p,code:_0x57d892[f(1638)+f(474)+"R"]}));return}}),this._socket[n(902)](l=>{let f=n,p={OZLUa:s.vZvwA,WkulN:s[f(409)],LXYIa:function(m,b,g){return s.buBje(m,b,g)},NfmQj:s[f(431)]};if(s[f(1247)](s[f(648)],s[f(648)])){let m={kDPOU:function(b,g){return b(g)},qkEsR:s[f(1377)],HrlKT:"ping_onc"+f(990)+"s",Bdjsz:f(1934)+f(1015)+"t"};return new _0x2f3aec((b,g)=>{let T=f,C={DoMCw:function(U,Q){return U(Q)},KWvCa:p.OZLUa,IeITb:p[T(539)]};this[T(913)+T(1074)](),this[T(525)+"gTimeoutId"]=p[T(924)](_0x561dfb,this[T(636)][T(923)](this),this[T(1039)][T(725)+T(533)]);let M=()=>{let U=T;C[U(1163)](b,C[U(947)]),this.off(C[U(1854)],M),this[U(1963)](U(1934)+U(1015)+"t",K)},K=()=>{let U=T;m[U(904)](g,m.qkEsR),this[U(1963)](m[U(1388)],M),this.off(m[U(1970)],K)};this.on(p[T(539)],M),this.on(p.NfmQj,K),this[T(636)]()})}else this.emit(s.sGvMF,s[f(1578)](st,f(1569),{...l,message:l[f(1432)]||""}))})):(e[n(1418)](_0x2ac869,this[n(1019)+n(1498)+"Id"]),this[n(1019)+n(1498)+"Id"]=_0x47ef1f(()=>{this[n(585)+"ired"]()},this._interval))}send(n){let s=t,l={MJrvO:function(f,p){return f+p},qiEfj:function(f,p){return f*p},Rxifm:function(f,p){return e[j(600)](f,p)},pPxHF:function(f,p){return e[j(568)](f,p)},GYDZg:s(1569)};if(e[s(1559)](n,Uint8Array)){if(e[s(516)]===e.QueSS)return this[s(1239)]?meCORh[s(542)](meCORh[s(833)](meCORh.Rxifm(this[s(728)],0),_0x1d7cdc),meCORh[s(846)](this[s(1861)],0)):meCORh[s(542)](meCORh[s(833)](this[s(728)],_0x30b7c8),meCORh[s(1567)](this[s(1861)],0));{let f=n.buffer[s(1262)](n[s(880)+"et"],e.qkirN(n[s(1181)+"th"],n[s(880)+"et"]));this._socket&&this[s(1271)][s(649)]({data:f,fail:p=>{let m=s;this[m(729)](e[m(650)],e[m(1356)](st,m(1569),{message:this[m(1037)+"rrorMess"+m(1072)](p)}))}})}}else this[s(1271)]&&this[s(1271)][s(649)]({data:n,fail:f=>{let p=s;this.emit(l[p(1327)],st(l.GYDZg,{message:this["_formatE"+p(1276)+p(1072)](f)}))}})}[t(940)](n,s){let l=t;e[l(651)](e.RlYiZ,e[l(1442)])?(_0x36180c=e[l(466)](_0x38a25a,_0x56b7eb),_0x30e07e=0):this[l(1271)]&&this[l(1271)][l(940)]({code:n,reason:s})}[t(1351)+t(1313)](n,s){this.on(n,s)}[t(1013)+t(1941)+t(1796)](n,s){this.off(n,s)}get[t(1585)+"te"](){let n=t;return this[n(1271)][n(1585)+"te"]}get[t(557)+"pe"](){let n=t;return this[n(1271)][n(557)+"pe"]}set binaryType(n){}get[t(1064)](){return this[t(1271)].url}get protocol(){let n=t;return this[n(1271)][n(1720)]}get[t(1249)+"ns"](){let n=t,s={mEgOp:function(l,f){return l||f}};if(e[n(416)]!==e[n(416)]){let l=this[n(1437)].getItem(this[n(1799)]),f=_0xa555a8[n(949)](s[n(1051)](l,"{}"));return _0x2671c4[n(1652)](f)}else return this[n(1271)][n(1249)+"ns"]}get[t(805)+t(1816)](){return 0}}function dp(a,n){let s=t;if(n)return new n(a[s(1064)],a.protocol);if(e[s(641)](qr,An))return new cp(a[s(1064)],a.protocol,a[s(1938)]);if(e[s(813)](Zn,jr)&&e[s(781)](e[s(1403)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(1064)],a.protocols)}function lp(a){let n=t,s=(n(1189)+"0").split("|"),l=0;for(;;){switch(s[l++]){case"0":return!1;case"1":if(a)return!0;continue;case"2":if(qr&&wx.connectSocket)return!0;continue;case"3":if(An&&tt[n(1394)+n(626)])return!0;continue;case"4":if(e[n(813)](Zn,jr)&&e[n(433)](e[n(1403)],typeof WebSocket)&&WebSocket)return!0;continue}break}}function el(a,n,s){let l={oTNPv:function(m,b){return e.YmOyD(m,b)}},f=-1;async function p(m){let b=j;return e.tttsA(e[b(420)],e[b(712)])?e.GaPSY(m,f)?Promise[b(1626)](new Error(e.mrmVM)):(f=m,m===s[b(437)]?Promise[b(622)]():s[m][b(923)](a)(n,p.bind(null,m+1))):(_0x1cbdbf.apply(zkMUAa[b(1584)](_0x3d4652,this),_0xee3d6c),_0x517e71(_0x4ed620[b(1068)](this)))}p(0)}function tl(a){let n=t,s=0,l=0;for(let f=0;e[n(1915)](f,a[n(437)]);++f)if(e[n(1702)]===e.GdFWD){if(_0x19d0d5<1||e[n(1423)](_0xe1b0d3,_0x558502))return e[n(933)](_0x128376,_0x34d58b);e[n(1022)](e[n(1170)](_0x273231,_0x4d715e),_0x44f90e)&&(_0x58cde0=e.Fhzad(_0x5ec18,_0x4c35aa),_0x4cfa04=0);let p=_0x59e856[n(978)](_0x363227,_0x1d86eb,_0x3e7505+=_0x383271);return e[n(817)](7,_0x2b940b)&&(_0x317666=e.BLLZU(7,_0x1ff238)+1),p}else l=a.charCodeAt(f),e[n(1264)](l,128)?s+=1:e.Olcxd(l,2048)?s+=2:e[n(657)](e[n(1347)](64512,l),55296)&&e[n(405)](64512&a[n(1409)+"At"](e[n(1469)](f,1)),56320)?(++f,s+=4):s+=3;return s}function nl(a,n,s){let l=t,f={GNHGP:function(m,b){return m>=b},pRvVm:function(m,b){return e.PJVup(m,b)},mxgnu:function(m,b){return e[j(1620)](m,b)},IMyqm:function(m,b){return e[j(741)](m,b)},TWeAV:function(m,b){return e.cnsBX(m,b)},DeCPC:function(m,b){return m/b}};if(e[l(1835)](s,n)<1)return"";let p="";for(let m=n;e[l(574)](m,s);){let b=a[m++];if(e[l(1897)](b,127))p+=String[l(1243)+l(1855)](b);else if(e[l(1716)](b,192)&&e[l(752)](b,224))p+=String[l(1243)+"Code"](e.EpFwx(e[l(1904)](31,b),6)|e[l(524)](63,a[m++]));else if(e[l(1244)](b,224)&&e[l(1264)](b,240))p+=String[l(1243)+l(1855)](e[l(1392)](e[l(1948)](e[l(1848)](15,b),12),e[l(770)](63,a[m++])<<6)|e.ogPXU(63,a[m++]));else if(e[l(1716)](b,240))if(e.TFpDu(e[l(1455)],e[l(1455)])){if(_0x1d26ab(_0x1ecbac))return _0x33e1f7?_0x36c788:_0x263a46;if(_0x211f45){if(CcKfnH[l(1606)](_0x4783d1,_0x3718a6))return _0x518824}else{if(CcKfnH[l(935)](_0x44a6b1,-_0x218a93))return _0x59b138;if(_0x348055+1>=_0x2b25d5)return _0x516c7d}return _0x29bb33[l(1597)](CcKfnH[l(1358)](CcKfnH[l(1910)](_0x1ae0d1,_0x1409c2),0),CcKfnH[l(1233)](CcKfnH[l(1811)](_0x147d8a,_0x27b6a9),0),_0x2f6c70)}else{let g=e[l(790)](e.blHxs(e[l(427)](e[l(544)](e.zqSFf(7,b)<<18,e.xSXJT(e.IAzqr(63,a[m++]),12)),e[l(1882)](e.LoaWh(63,a[m++]),6)),63&a[m++]),65536);p+=String.fromCharCode(e.ToSGl(55296,g>>10)),p+=String["fromChar"+l(1855)](e[l(1003)](56320,1023&g))}}return p}function la(a,n,s){let l=t,f={yHKWJ:function(g){return g()}},p=s,m,b;for(let g=0;e[l(752)](g,a[l(437)]);++g)if(e[l(688)](e.wkjvM,e[l(1520)]))if(m=a[l(1409)+"At"](g),e[l(1819)](m,128))n[s++]=m;else if(e[l(495)](m,2048))n[s++]=e[l(1336)](m>>6,192),n[s++]=e.qoqNj(63,m)|128;else if(e[l(498)](e[l(1865)](64512,m),55296)&&(64512&(b=a[l(1409)+"At"](e[l(1047)](g,1))))===56320){let T=e[l(869)][l(605)]("|"),C=0;for(;;){switch(T[C++]){case"0":n[s++]=e[l(1370)](e[l(546)](m,6)&63,128);continue;case"1":m=e[l(745)](e[l(1768)](65536,e.AuDfp(e[l(1773)](1023,m),10)),e[l(1107)](1023,b));continue;case"2":++g;continue;case"3":n[s++]=e.DRtmC(e.BugHe(e[l(900)](m,12),63),128);continue;case"4":n[s++]=e.Qgviv(63&m,128);continue;case"5":n[s++]=e[l(1506)](m,18)|240;continue}break}}else n[s++]=e[l(1956)](e[l(1923)](m,12),224),n[s++]=e.nbLPC(e.fMbet(m,6)&63,128),n[s++]=e.LHatB(63,m)|128;else return this[l(534)+l(1493)+l(1900)](_0x1a18d7),f[l(490)](_0x9f06ff);return e.HbyBw(s,p)}async function rl(a){let n=t;if(e[n(1459)](n(531),typeof a)){let s=new Uint8Array(tl(a));return e[n(426)](la,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a[n(880)+"et"],a.byteLength)}function up(a){let n=t;try{return e.kTvRO(e[n(1310)],typeof a)&&(a instanceof ArrayBuffer||a.buffer&&e.IRZRf(a.buffer,ArrayBuffer))||e.Qjifw(n(531),typeof a)?"":(JSON.parse(a),n(1820)+n(421))}catch{return e[n(1459)](e[n(1310)],typeof a)?e[n(1202)]:""}}let fp=(a,n)=>{let s=t;switch(a){case e[s(1241)]:case e[s(776)]:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class xp{constructor(n){let s=t;this[s(894)+"ount"]=n,this[s(1471)]=0}[t(440)](){let n=t;this[n(1471)]++}[t(1912)+"chMaxCount"](){let n=t;return e.srRIg(this.count,this["maxLossC"+n(756)])}["resetCou"+t(552)](n=0){let s=t;this[s(894)+s(756)]=n,this[s(1471)]=0}}async function hp(a){let n=t,s={rKebQ:function(l,f){return e.jQOCX(l,f)},PdVWP:e[n(1849)]};return new Promise(l=>{let f=n;if(!Zn)return l(e.IHwRk);try{let p=document[f(1041)+"ement"](e[f(489)]);window["frontier"+f(955)]=m=>{let b=f;document[b(432)][b(1920)+"ild"](p),window[b(598)+"JSONP"]=void 0,s.rKebQ(l,m&&m[b(1940)]||s[b(1209)])},p[f(1841)]=f(658)+f(723),p[f(1839)]=e[f(453)](a[f(852)](/^ws/,e[f(818)]),e[f(1238)]);try{document[f(432)][f(1628)+f(554)](p)}catch{document.body["removeCh"+f(554)](p)}}catch{window[f(598)+f(955)]=void 0,e[f(1109)](l,e[f(1849)])}})}function Qt(a,n,s){let l=t,f={gDccH:function(p,m){return p+m},LKrrF:function(p,m){return p<m},CCmQH:function(p,m,b){return e.KPBDf(p,m,b)},MpEtk:function(p,m){return e[j(444)](p,m)}};if(e.HdJBD(e[l(1806)],e[l(1806)])){let p=0,m=_0x5670f8,b=f.gDccH(_0x3c75f6,4);for(;f[l(1157)](m,b);){let{value:g,offset:T}=f[l(1499)](_0x394a6b,_0x12caa7,m);m=T,p=f[l(1612)](p,8)>>>0,p+=g}return{value:p,offset:b}}else return!!a?.find(p=>p[l(1057)]===n&&p[l(1425)]===s)}function Xn(a,n){let s=t;return a?.find(l=>l[s(1057)]===n)?.[s(1425)]}let ua=null;async function pp(){let a=t;return ua||(ua=Promise[a(622)]()[a(1428)](Nt[a(923)](Nt,e[a(517)]))),ua}class gp extends da{constructor(n,s){let l=t;if(e[l(572)](e[l(1587)],e.yRpDV))return this[l(728)]===0&&this[l(1861)]===0;super(),this[l(1727)]=n,this._keyPath=s,this[l(1437)]=void 0,this["_initPro"+l(588)]=null}async openDB(){await this[t(528)]()}async[t(528)](){let n=t;if(!this[n(1437)]){if(this[n(918)+n(588)])return this[n(918)+"mise"];try{let s=this[n(1727)],l=this[n(1894)];this["_initPro"+n(588)]=(async()=>{let f=n,{openDB:p}=await e[f(1461)](pp);this[f(1437)]=await e.eTwhe(p,f(598)+"_"+s,1,{upgrade(m){m["createOb"+f(1411)+"e"](s,{keyPath:l})}})})(),await this[n(918)+n(588)]}catch(s){console.log(s)}finally{if(e[n(572)](e[n(1096)],e.OLVvr))this[n(918)+"mise"]=null;else return _0xac8baa||(_0x319050=[_0x4045fc[n(1494)+"e"][n(1214)],_0x2bceb8[n(1494)+"e"][n(1548)],_0x396923.prototype[n(1548)+n(792)+"ey"]])}}}async[t(1068)](n){let s=t;try{return await this[s(528)](),this[s(1437)]?.[s(1068)](this[s(1727)],n)}catch(l){console[s(872)](l)}}async[t(540)](n,s){let l=t;if(e.TkdMC(e[l(564)],e.oHCiw))return await this[l(528)](),this[l(1437)]?.[l(667)](this[l(1727)],n);this._cursorNameSpace=_0x1e4145,this._cursorFileName=_0xdc6994,this[l(1722)+l(1126)]=_0x429feb,this[l(1437)]=_0x1113fd(this[l(1275)+l(1813)],e[l(1065)])}async del(n){let s=t,l={KrhcY:function(f,p){return f!==p},RDQWN:function(f,p){return e[j(1118)](f,p)}};if(e.SPqoT(e.wSgQa,e[s(768)]))try{if(e[s(1390)](s(948),e[s(1184)])){if(itLCzJ[s(763)](4,_0x113be5.length)){let f=_0x5b6e42[s(1648)+"g"](0,itLCzJ[s(1402)](4,_0x4c9ec3.length)),p=f[s(698)](_0x5d07e9);_0x33bb24[s(1715)](p)}else _0x4c0c78.push(_0xf9f608);_0x3da975&&(_0x2f434b+=1),_0x409b74+=1,_0x18c588=!1}else return await this._init(),this[s(1437)]?.[s(1384)](this[s(1727)],n)}catch(f){console[s(872)](f)}else this[s(1963)](_0xd46655,_0xaa2392)}async[t(932)](){let n=t;try{return await this._init(),this[n(1437)]?.[n(932)](this._dbName)}catch(s){console.log(s)}}async[t(1426)](){let n=t;return await this[n(528)](),this[n(1437)]?.[n(1862)+"ys"](this[n(1727)])}async getAll(){let n=t;return await this[n(528)](),this[n(1437)]?.[n(597)](this._dbName)}async[t(1110)](){let n=t;try{if(e[n(631)](e.OxmCY,e[n(681)])){let s=e[n(1770)](_0x3198b5,"error",{message:_0x11f727[n(616)],code:_0x3423a4[n(1383)+n(401)],error:_0x17ccf7});this["_dispatc"+n(1027)+n(1527)](s)}else this._qosDB?.[n(940)](),this[n(1437)]=void 0}catch(s){console[n(872)](s)}}get[t(1513)](){let n=t;if(e[n(766)](e.tZngy,"bnJhu"))return _0x4ab4ab?this[n(512)+"E"]():this[n(1687)+"E"]();try{return!!this[n(1437)]}catch(s){return console[n(872)](s),!1}}}class mp{constructor(n,s){let l=t;this._DBName=n,this[l(1624)]=s,this[l(1437)]=localStorage}async[t(1080)](){}get[t(1799)](){let n=t,s={Jdtfn:function(l,f,p){return l(f,p)},YvQYv:function(l,f,p){return e.xwBZA(l,f,p)},sctWh:function(l,f){return e[j(797)](l,f)},UMRPO:function(l,f,p){return e[j(1507)](l,f,p)}};if(e[n(643)]("QAHSh",e[n(814)])){let l=0,f=[];for(;l<_0x2b83f7[n(1181)+"th"];){let{offset:p}=s[n(537)](_0x1f93a2,_0x4d3b06,l);l=p;let m={cursor_name:"",cursor:0,service:0},{value:b,offset:g}=_0x188c5d(_0x220ef8,l);m[n(1918)]=b,l=g;let{value:T,offset:C}=s.YvQYv(_0x519aac,_0xde5b9c,l);l=C,m[n(1326)+n(393)]=_0x4178a7(_0x458ea2,l,s.sctWh(l,T)),l+=T;let{value:M,offset:K}=s[n(1736)](_0x44161a,_0x25507c,l);m[n(406)]=M[n(1470)](),l=K,f[n(1715)](m)}return f}else return"frontier_"+this._DBName}async[t(1068)](n){let s=t,l=this._qosDB.getItem(this[s(1799)]);return JSON[s(949)](e.RAPGi(l,"{}"))[n]}async[t(540)](n,s){let l=t,f=this[l(1437)][l(447)](this[l(1799)]),p=JSON[l(949)](e[l(641)](f,"{}"));return p[s||n[this[l(1624)]]]=n,this[l(1437)].setItem(this._prefix,JSON[l(1838)+"y"](p)),s||n[this._pathKey]}async[t(614)](n){let s=t,l=this[s(1437)].getItem(this[s(1799)]),f=JSON[s(949)](e[s(1607)](l,"{}"));return f[n]=void 0,this[s(1437)][s(1345)](this[s(1799)],JSON[s(1838)+"y"](f))}async[t(932)](){let n=t;return this._qosDB[n(932)]()}async[t(1426)](){let n=t,s=this._qosDB[n(447)](this._prefix),l=JSON.parse(e[n(813)](s,"{}"));return Object[n(1426)](l)}async[t(597)](){let n=t,s=this[n(1437)][n(447)](this[n(1799)]),l=JSON[n(949)](e[n(813)](s,"{}"));return Object[n(1652)](l)}[t(1110)](){return Promise[t(622)]()}get[t(1513)](){return!!this[t(1437)]}}class wp{constructor(n,s){let l=t;this._DBName=n,this[l(1624)]=s,this[l(1437)]=An?tt:qr?wx:null}async openDB(){}get _prefix(){let n=t;if(e[n(800)](e[n(1223)],e[n(1717)]))this.off(_0x4967a3,_0x1fa7e5);else return"frontier_"+this[n(758)]}async get(n){let s=t,l=this._qosDB["getStora"+s(1635)](this[s(1799)]);return JSON[s(949)](l||"{}")[n]}async set(n,s){let l=t,f=this[l(1437)][l(1858)+l(1635)](this._prefix),p=JSON[l(949)](e[l(813)](f,"{}"));return p[s||n[this[l(1624)]]]=n,this[l(1437)][l(1935)+l(1635)](this[l(1799)],JSON.stringify(p)),s||n[this[l(1624)]]}async[t(614)](n){let s=t,l=this[s(1437)].getStorageSync(this._prefix),f=JSON[s(949)](e.MJuEA(l,"{}"));return f[n]=void 0,this[s(1437)][s(1935)+s(1635)](this[s(1799)],JSON[s(1838)+"y"](f))}async[t(932)](){let n=t;return this._qosDB[n(762)+n(1407)]()}async[t(1426)](){let n=t;if(e[n(1832)](e[n(611)],e[n(1406)])){let s=_0x417c4b.length&&_0x34c835[0];if(e[n(443)](s,_0x3f4e84))throw s;let l=new _0x56b032(e[n(520)]+(s?e[n(453)](e[n(1454)](" (",s.message),")"):""));throw l[n(1318)]=s,s}else{let s=this._qosDB[n(1858)+n(775)+"nc"](this[n(1799)]),l=JSON[n(949)](e[n(1700)](s,"{}"));return Object[n(1426)](l)}}async getAll(){let n=t,s=this[n(1437)][n(1858)+"geInfoSync"](this._prefix),l=JSON[n(949)](e[n(1414)](s,"{}"));return Object[n(1652)](l)}closeDB(){return Promise.resolve()}get isReady(){return!!this._qosDB}}function il(a,n){let s=t,l={IzYMu:function(f,p){return e.hQDFB(f,p)}};if(e[s(710)](s(545),e[s(1083)])){if(An||An)return new wp(a,n);if((Zn||jr)&&e[s(433)](e[s(1403)],typeof indexedDB))return new gp(a,n);if(e[s(1360)](Zn,jr)&&s(558)+"d"!=typeof localStorage)return new mp(a,n);throw new Error(e[s(1030)])}else _0xc7a066+=DNgIGq[s(1737)](_0x6bc9ac,_0x385164),_0x37ad0d++}class _p{constructor(){let n=t;this[n(1019)+n(1498)+"Id"]=null,this[n(1019)+"l"]=36e5,this._qosDB=e[n(885)](il,e[n(1042)],e.qCsQE)}async["_interva"+t(422)](){let n=t,s={xGiUn:function(l,f){return e[j(1459)](l,f)},IFJVM:e.XJemB,cNiMW:function(l,f){return e.IATEe(l,f)},ulVgG:function(l,f){return e[j(443)](l,f)}};if(e.aLEGx(e.ENfvP,n(1332)))e[n(967)](clearInterval,this[n(1019)+n(1498)+"Id"]),this[n(1019)+n(1498)+"Id"]=e[n(1049)](setInterval,()=>{let l=n;this[l(585)+l(1032)]()},this[n(1019)+"l"]);else{if(sOsaiV[n(951)](sOsaiV[n(1859)],typeof _0x4f0e45)){let l=new _0x714742(sOsaiV[n(1809)](_0x5f1912,_0xd6951));return _0x1bba21(_0x35295f,l,0),l}return sOsaiV[n(1408)](_0x5c324d,_0x2c0ef3)?new _0x364873(_0x178211):new _0x556e26(_0xd8cf73[n(1251)],_0x216ad2[n(880)+"et"],_0x2ca2da[n(1181)+"th"])}}async[t(1080)](){let n=t,s={WLBaD:n(1059),MyjDp:n(1754)};await this[n(1437)][n(1080)]()[n(1428)](()=>{let l=n;s[l(1299)]!==s[l(916)]?this["_interva"+l(422)]():this.on(_0x1b93de,_0x371d06)})}async[t(585)+t(1032)](){let n=t,s={eMVCy:function(p,m){return p>=m},sQBvu:function(p,m){return e[j(423)](p,m)}};(await this[n(1437)]?.getAll()||[])[n(1146)](({timestamp:p})=>p<Date[n(1853)]()).forEach(p=>{let m=n;if(s[m(637)]("bAmAo",m(1054)))this[m(1437)]?.del(p[m(1650)+"id"]);else return sitbPz[m(1814)](_0x525706[m(399)],_0x1d3cb3[m(1906)])})}async del(n){return this[t(1437)]?.del(n)}async[t(540)](n,s){let l=t;return this[l(1437)]?.[l(540)]({message_id:n,timestamp:s})}async[t(1068)](n){let s=t;return this[s(1437)]?.[s(1068)](n)}async closeDB(){let n=t;if(e[n(1681)](e[n(1100)],e[n(1642)])){let s=this[n(1437)][n(447)](this[n(1799)]),l=_0x56b20e[n(949)](s||"{}");return l[_0x56cb8e||_0x5f1e01[this._pathKey]]=_0xfb8029,this[n(1437)][n(1345)](this[n(1799)],_0x13acc5[n(1838)+"y"](l)),_0x1e9b01||_0x5385eb[this[n(1624)]]}else e[n(1361)](clearInterval,this[n(1019)+n(1498)+"Id"]),await this._qosDB?.[n(1110)]()}get[t(1513)](){let n=t,s={cBVEh:function(l,f){return e[j(1616)](l,f)},kBidC:e[n(1185)]};if(e[n(840)]===n(487)){let l={bpRad:function(f,p){let m=n;return fUtbUK[m(1151)](f,p)},NVxgk:n(558)+"d",FGdao:fUtbUK[n(1957)]};_0x4ffde5.r=f=>{let p=n;l[p(689)](l.NVxgk,typeof _0x49b40a)&&_0x189cee[p(715)+p(1608)]&&_0x505a80[p(1621)+"operty"](f,_0x3bff2a[p(715)+"Tag"],{value:"Module"}),_0x568f36[p(1621)+p(1458)](f,l[p(1479)],{value:!0})}}else return this[n(1437)]?.[n(1513)]}}function fa(a){let n=t,s=!!this[n(1039)][n(1651)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e[n(804)](Qt,a[n(616)].headers,n(1382)+"er_qos","2"),f=l&&e[n(426)](Qt,a.message[n(1938)],e[n(696)],"1"),p=l&&e[n(1797)](Qt,a[n(616)][n(1938)],e[n(865)],"1"),m=p?e[n(1913)](Xn,a[n(616)].headers,n(1382)+n(580)+n(1486))?.[n(605)](",")[n(1146)](Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:f,isAckCleanupMessage:p,ackMsgIds:m}}async function sl(){let a=t;return this[a(1121)+"ger"]||(this["_QoSMana"+a(807)]=new _p),this[a(1121)+a(807)][a(1513)]||await this[a(1121)+"ger"][a(1080)](),this[a(1121)+a(807)]}async function yp(a,n){let s=t,{enableAutoAck:l}=this[s(1039)],f=Qt(a[s(616)].headers,e[s(801)],"1"),p=Qt(a[s(616)][s(1938)],e.AsUKj,"1"),m=fa[s(978)](this,a);if(e[s(984)](l,f))if(e[s(579)](e.tgcBB,"rIxnW")){let{SeqID:b,LogID:g,service:T,LogIDNew:C,method:M}=a[s(616)];this[s(1078)]({SeqID:b,LogID:g,LogIDNew:C,service:T,method:M,headers:[{key:e[s(1292)],value:"1"},{key:e[s(828)],value:e[s(1268)](C,"")},{key:e[s(1256)],value:"0"}]})}else return this[s(1437)]?.[s(1513)];p&&!m.isQoSAck&&this[s(534)+"hAckMess"+s(607)](a),e.VyplL(n)}async function Ep(a,n){let s=t;if(s(1852)!==e[s(1308)])this[s(620)](e[s(559)],a[s(616)]),n();else return _0x5d1d64[s(1279)+"8"]?{value:_0x10beb7[s(1279)+"8"](_0xdd572a),offset:e[s(1674)](_0x1047db,1)}:{value:e[s(1904)](255,_0x143843[_0x20660e]),offset:_0x4f6944+1}}async function bp(a,n){let s=t,l=e[s(441)](Yt,await e[s(857)](rl,a[s(1463)]));try{if(e[s(1559)](l[s(1198)],Uint8Array)){let f=e[s(1613)](this[s(1039)]["payloadE"+s(1052)],Object)?{force:!!this[s(1039)]["payloadE"+s(1052)][s(408)],encoding:this[s(1039)][s(1376)+"ncoding"][s(1543)]?this._options[s(1376)+s(1052)][s(1543)][s(852)](/\s/g,"")[s(429)+s(1230)]():""}:{force:!1,encoding:this[s(1039)][s(1376)+s(1052)]?this[s(1039)][s(1376)+s(1052)][s(852)](/\s/g,"")["toLowerC"+s(1230)]():""},p=l[s(1376)+s(1052)]?l[s(1376)+"ncoding"][s(852)](/\s/g,"")[s(429)+s(1230)]():"",m=this[s(1039)][s(850)+s(812)]instanceof Object?{force:!!this[s(1039)][s(850)+s(812)].force,type:this._options.payloadType[s(1841)]?this[s(1039)][s(850)+s(812)][s(1841)][s(852)](/\s/g,"")[s(429)+"ase"]():""}:{force:!1,type:this[s(1039)].payloadType?this[s(1039)][s(850)+s(812)][s(852)](/\s/g,"")[s(429)+s(1230)]():""},b=l.payloadType?l[s(850)+s(812)][s(852)](/\s/g,"")[s(429)+s(1230)]():"",g=m[s(408)]?m[s(1841)]:b||m.type,T=f[s(408)]?f.encoding:p||f[s(1543)],C=[e[s(1202)],e.RuRPP,e[s(1484)],e[s(1310)]],M=[e[s(1794)],e[s(1050)]];this._options[s(692)+s(594)+s(656)+"ad"]&&C.includes(g)&&(!T||M[s(1924)](T))?l[s(1237)+"oad"]=nl(l[s(1198)],0,l.payload[s(1181)+"th"]):l["textPayl"+s(1303)]=""}else l[s(1237)+"oad"]=""}catch(f){l["textPayl"+s(1303)]="",console[s(872)](f)}a.message=l,e[s(1698)](n)}function vp(a,n,s){let l=t,f={oukat:e[l(1261)],oophu:function(T,C){return e[l(1294)](T,C)},QqvNH:function(T,C){return e[l(551)](T,C)},pWCuq:function(T,C){return T(C)},kpgdT:function(T,C){return e[l(986)](T,C)},KXMDH:function(T,C){return e[l(1588)](T,C)},TtneS:function(T,C){return e[l(630)](T,C)}},p=e[l(1595)](s,8192),m=e[l(1092)](p,1),b=null,g=p;return function(T){let C=l;if(f[C(1008)]===C(1340))this[C(758)]=_0x1dc0e6,this[C(1624)]=_0x3818cb,this[C(1437)]=_0x49ae79;else{if(f[C(435)](T,1)||f[C(1334)](T,m))return f[C(755)](a,T);f[C(1334)](f[C(1798)](g,T),p)&&(b=a(p),g=0);let M=n.call(b,g,g+=T);return f[C(1552)](7,g)&&(g=f[C(502)](7,g)+1),M}}}let Sp=4294967295;function Ap(a,n,s){let l=t;if(e.TQZuz(e.YzGkz,e.YzGkz))return RangeError(e[l(1170)](e[l(1827)](e[l(1003)](e[l(453)](e[l(1490)](e[l(1492)],a),e[l(914)]),n||1),e[l(587)]),s));_0x5e85b9=e[l(1723)](_0x36aa88,_0x16fc46),e[l(721)](_0x422e33,32)&&(_0x21b856|=e[l(1152)](127,_0x1f5b6e)<<_0x24fafb),_0x34e0b2+=7}function Ip(a,n,s){let l=t;if(e[l(417)](s,Sp))throw new Error(l(1526)+l(501)+"e");let f=3;for(;f>=0;){let p=e[l(1521)](255,s);e.jdZYO(ha,p,a,n+f),s>>>=8,f--}return e.VEEOc(n,4)}function Tp(a,n){let s=t,l=0,f=n,p=e[s(1401)](n,4);for(;e.KUJmb(f,p);){let{value:m,offset:b}=e[s(1355)](xa,a,f);f=b,l=e[s(1659)](e[s(1882)](l,8),0),l+=m}return{value:l,offset:p}}function Cp(a,n,s){let l=t,f=e[l(930)][l(605)]("|"),p=0;for(;;){switch(f[p++]){case"0":return e.xaDff(e[l(1797)](la,a,n,s),s);case"1":if(!a)return s;continue;case"2":if(n[l(1191)+"e"])return n[l(1191)+"e"](a,s)+s;continue;case"3":if(a[l(437)]<40)return e[l(895)](e[l(1323)](la,a,n,s),s);continue;case"4":if(n.write)return e[l(464)](n[l(1210)](a,s),s);continue}break}}function Dp(a,n){let s=t,l=new ce(e[s(1266)](e.ydeOj(e[s(912)](e.qPeWb(a[e[s(1712)](n,4)],24),e[s(1792)](a[n+5],16)),e[s(971)](a[e[s(566)](n,6)],8)),a[n+7]),e.SshrH(e[s(740)](a[e.wZFwp(n,0)],24)|a[n+1]<<16|e[s(1931)](a[n+2],8),a[e[s(1868)](n,3)]),!0);return n+=8,{value:l,offset:e.LxJBD(n,8)}}function Rp(a,n,s){let l=t,f=a.low,p=a[l(728)];return n[s]=e[l(1160)](p,24),n[e[l(1818)](s,1)]=e[l(553)](e[l(1204)](p,16),255),n[s+2]=e[l(679)](p,8)&255,n[e[l(566)](s,3)]=e[l(1445)](255,p),n[e[l(1115)](s,4)]=e[l(957)](f,24),n[e[l(460)](s,5)]=f>>>16&255,n[s+6]=e[l(1236)](e[l(1092)](f,8),255),n[e[l(566)](s,7)]=e.coLZQ(255,f),s+=8,s}function xa(a,n){let s=t;return a[s(1279)+"8"]?{value:a[s(1279)+"8"](n),offset:e.xBGFF(n,1)}:{value:e[s(1457)](255,a[n]),offset:e.TKPba(n,1)}}function ha(a,n,s){let l=t;return n[l(1284)+"t8"]?n[l(1284)+"t8"](a,s):n[s]=e[l(1448)](255,a),e[l(541)](s,1)}let kp=function(a){return new Uint8Array(a)},Pp=e[t(787)](e[t(1403)],typeof Buffer)?Buffer[t(1178)+"afe"]:e.aoJnD(vp,kp,Uint8Array[t(1494)+"e"][t(1206)]);(()=>{let a=t,n={dPbQi:function(l,f,p){return l(f,p)},fMwqA:a(940),gbuXi:function(l,f){return l===f},bNPhH:a(717),WujYk:e[a(1128)],iWohj:function(l,f){return l>f},jtSfN:function(l,f){return e[a(1058)](l,f)},TVrdv:function(l,f){return e[a(1236)](l,f)},PWcQJ:function(l,f){return l|f},rqOKW:function(l,f){return e[a(1070)](l,f)},CAUjd:function(l,f){return e[a(826)](l,f)},emNTa:function(l,f){return e[a(1882)](l,f)},jlFCR:function(l,f){return e[a(609)](l,f)},PRphr:function(l,f){return e[a(1025)](l,f)},oGKcW:function(l,f){return l|f},pNvOW:function(l,f){return l<<f},hbdjv:function(l,f){return e.QqPuT(l,f)},mSkQK:function(l,f){return e[a(1675)](l,f)},vQlsf:function(l,f){return l<<f},QMZKJ:function(l,f){return e[a(770)](l,f)},jCsbP:function(l,f){return e.ySxes(l,f)},NgfDP:function(l,f){return l<f}},s=4294967295;return function(l,f,p=!0){let m=a;if(n[m(1510)](n[m(1570)],m(717))){let b=n.WujYk.split("|"),g=0;for(;;){switch(b[g++]){case"0":if(n[m(1124)](f+=5,l[m(437)]))throw f=l[m(437)],Ap(f,10,l[m(437)]);continue;case"1":s=n[m(821)](n[m(1082)](127,l[f]),0);continue;case"2":return{value:p?s:n[m(1288)](0,s),offset:f};case"3":s=n.rqOKW(n[m(470)](s,n[m(582)](n[m(1165)](127,l[f]),14)),0);continue;case"4":s=n[m(1646)](n[m(1833)](s,n.pNvOW(n[m(1317)](127,l[f]),7)),0);continue;case"5":s=n[m(1892)](n[m(1572)](s,n[m(1159)](n.QMZKJ(15,l[f]),28)),0);continue;case"6":if(n[m(1311)](l[f++],128))return{value:p?s:n[m(470)](0,s),offset:f};continue;case"7":s=n[m(1833)](s,n.QMZKJ(127,l[f])<<21)>>>0;continue;case"8":if(l[f++]<128)return{value:p?s:0|s,offset:f};continue;case"9":if(n.NgfDP(l[f++],128))return{value:p?s:0|s,offset:f};continue;case"10":if(n[m(1311)](l[f++],128))return{value:p?s:n[m(1833)](0,s),offset:f};continue;case"11":if(n[m(480)](l[f++],128))return{value:p?s:n[m(1833)](0,s),offset:f};continue}break}}else{let b=this[m(1039)][m(1826)+m(1636)+m(839)](_0x2aa8f6,_0x3f1582);this["_dispatc"+m(1975)+m(1527)](n[m(950)](_0x57bade,n[m(722)],{code:_0x24c3d9,reason:_0x4f351e,wasClean:!0,willReconnect:b})),b&&this._connect()}}})();let Op=16,pa=32;function Np(a){let n=t,s=0,l={};for(let f=0;e[n(1097)](f,a[n(437)]);f++)l[a[f][n(1326)+"ame"]]=e[n(967)](tl,a[f][n(1326)+n(393)]),s+=e[n(1599)](14,l[a[f][n(1326)+n(393)]]);return[s,l]}function ol(a,n,s){let l=t,f={lFtod:e[l(1875)],TiTas:e[l(970)],ebMNY:function(T,C,M,K){return e[l(804)](T,C,M,K)},vrVxQ:e[l(1075)],jXNNM:function(T,C,M,K){return e[l(426)](T,C,M,K)},DESYu:e.xxJFh,UZDvz:e[l(497)],IaXGe:e[l(1267)]},[p,m]=Np(a),b=e[l(1534)](Pp,p),g=0;return a.forEach(T=>{let C=l,M=f[C(1180)][C(605)]("|"),K=0;for(;;){switch(M[K++]){case"0":console[C(872)](f[C(1379)],g);continue;case"1":g=f[C(1314)](ha,0,b,g);continue;case"2":console[C(872)](f[C(730)],g);continue;case"3":g=f.ebMNY(ha,m[T[C(1326)+C(393)]],b,g);continue;case"4":g=f[C(1339)](Ip,b,g,T[C(1918)]||0);continue;case"5":console[C(872)](C(1248),g);continue;case"6":console[C(872)](f[C(1255)],T,T[C(1918)]);continue;case"7":g=f[C(1314)](Rp,ce[C(843)+"er"](T[C(406)]||n),b,g);continue;case"8":g=f.ebMNY(Cp,T[C(1326)+C(393)],b,g);continue;case"9":console.log(f[C(899)],g);continue;case"10":console[C(872)](f[C(1664)],g);continue}break}}),{frameType:pa,headers:[{key:e[l(945)],value:s}],payload:b}}function Lp(a){let n=t,s=0,l=[];for(;e[n(906)](s,a[n(1181)+"th"]);){let{offset:f}=e.UNzNE(xa,a,s);s=f;let p={cursor_name:"",cursor:0,service:0},{value:m,offset:b}=e[n(1049)](Tp,a,s);p[n(1918)]=m,s=b;let{value:g,offset:T}=xa(a,s);s=T,p[n(1326)+n(393)]=e[n(426)](nl,a,s,e[n(434)](s,g)),s+=g;let{value:C,offset:M}=e[n(499)](Dp,a,s);p[n(406)]=C[n(1470)](),s=M,l[n(1715)](p)}return l}function Mp(){let a=t;return{frameType:pa,headers:[{key:a(1873)+a(1389),value:e[a(1029)]}],payload:void 0}}class Bp{constructor(n,s,l){let f=t,p={spJlJ:function(m,b,g,T,C){return e.oViIf(m,b,g,T,C)},aRpLB:function(m,b){return m(b)},UTyIx:function(m,b){return e[j(934)](m,b)}};e.IxtfT(e[f(1728)],e.IfSJT)?(this[f(1275)+f(1813)]=n,this[f(1926)+f(536)]=s,this["_message"+f(1126)]=l,this._qosDB=e[f(982)](il,this[f(1275)+f(1813)],e[f(1065)])):IFfBNI[f(1012)](_0x34b5db,IFfBNI[f(473)](_0x291812,_0x15b8ab.result),_0x1c37fc.oldVersion,_0x329d52[f(1762)+"on"],IFfBNI[f(743)](_0x4e173a,_0x3aa71a[f(1291)+f(1468)]))}async openDB(){let n=t,s={APnQT:function(l,f,p){return e[j(1095)](l,f,p)}};if(e[n(1778)]!==n(1063))await this._qosDB[n(1080)]();else return _0x2dc62a[n(1522)][BVzXmM[n(1971)](_0x10363c,_0x554ff1,1)]}async getCursors(){let n=t;if(!this[n(1437)][n(1513)])return;let s=this[n(1722)+n(1126)],l=await this._qosDB[n(597)]();switch(console.log(e.BiIBC,l),s){case n(794):return l&&l.length?e.WXXXR(ol,l,0,this[n(1926)+n(536)]):void 0;case e[n(1260)]:return;case n(903):return l&&l[n(437)]?e.GjGlW(ol,l,0,this[n(1926)+n(536)]):Mp()}}async[t(540)](n,s,l){let f=t;return console[f(872)](e.aHKSe,n,s,l),this[f(1437)].set({cursor_name:n,cursor:s,service:l})}async[t(1899)+"rs"](n){let s=t,l=e[s(1834)](Lp,n);for(let f of l)console[s(872)](e[s(1688)],l),await this[s(1437)].set(f)}async get(n){let s=t;return(await this._qosDB[s(1068)](n))?.[s(406)]}async[t(1110)](){let n=t;if(e[n(925)](e[n(697)],"calwD"))await this._qosDB[n(1110)]();else{if(_0x4ce7d1===UqIFIN[n(1258)])return _0x3f9864[n(1068)](_0x3da2ae);if(UqIFIN[n(1140)](_0x41beee,UqIFIN[n(1374)]))return _0x3dc222["objectSt"+n(960)]||_0x311eb7[n(1068)](_0x20dc7a);if(UqIFIN[n(682)](_0x2894df,n(1763)))return _0x1dbda5["objectSt"+n(960)][1]?void 0:_0x55ce44[n(576)+n(739)](_0x28de99.objectStoreNames[0])}}[t(1939)+t(890)+t(1614)](n){let s=t;this[s(1926)+"ileName"]=n}get isReady(){let n=t;return this._qosDB[n(1513)]}}let Fp=t(708)+t(764);async function al(a){let n=t,s={JBsIe:function(l,f){return e.kKsrG(l,f)}};if(e[n(1211)](e[n(1800)],n(1199))){if(!this[n(1039)][n(1651)+"S"])return null;let{aID:l,fpID:f,messageStrategy:p}=this._options,m=e[n(1969)](a,Fp);try{return this["_cursorM"+n(1761)]?a&&this[n(1079)+n(1761)][n(1939)+"rsorFile"+n(1614)](a):this[n(1079)+n(1761)]=new Bp(f+"_"+l+"_"+m,m,p),this[n(1079)+n(1761)][n(1513)]||await this[n(1079)+n(1761)][n(1080)](),this[n(1079)+n(1761)]}catch{return null}}else{let l=this._listeners[_0x529d05];if(l)for(let f=0;JRBRqU[n(478)](f,l[n(437)]);)l[f].fn===_0x5b0039?l[n(778)](f,1):++f}}async function zp(a,n){let s=t,l={ogQVu:e[s(650)],wHsgT:function(U,Q,Ve){return e[s(402)](U,Q,Ve)},OEpJQ:e[s(1175)]},f=e.GjGlW(Qt,a[s(616)].headers,s(518),"-1"),p=e.jdZYO(Qt,a[s(616)][s(1938)],e[s(1292)],"1"),m=e[s(1507)](Xn,a.message.headers,e[s(1312)]),b=e[s(1169)](Number,Xn(a[s(616)][s(1938)],s(1382)+"er_ttl"))||0,g=fa.call(this,a),T=e.eTwhe(Qt,a[s(616)][s(1938)],e[s(1622)],"2"),C=e[s(885)](Xn,a[s(616)].headers,e[s(1745)]),M=Number(e[s(1850)](Xn,a[s(616)].headers,e.KYxSh));if(g[s(500)])return n();let K=g["isQoSMes"+s(1583)]?await sl[s(978)](this):null;if(e[s(475)](a[s(616)].service,0)&&p&&!f||e[s(529)](a[s(616)].service,0)){if(m&&g["isQoSMes"+s(1583)]&&K){if(!!!await K[s(1068)](m))if(s(1031)===e[s(1871)])this["_dispatc"+s(1493)+s(1900)](a),await K[s(540)](m,e[s(1679)](Date.now(),b));else{let Q=_0x1f4afe(SwFhWD[s(1359)],{message:this[s(1037)+"rrorMess"+s(1072)](_0x2f60ea)});this.emit(SwFhWD[s(1359)],Q);let Ve=SwFhWD[s(1203)](_0x1e3bd8,SwFhWD[s(973)],{reason:this[s(1037)+s(1276)+s(1072)](_0x398d27)});this[s(729)](SwFhWD[s(973)],Ve)}return n()}if(T){let U=await al.call(this);if(!U)return this[s(534)+s(1493)+"Event"](a),e.XoNdU(n);let Q=await U[s(1068)](C)??-1;if(e[s(1453)](Q,M))this[s(534)+s(1493)+"Event"](a),U[s(540)](C,M,a[s(616)][s(1918)]);else throw new Error(s(463)+" message"+s(1758)+M+(s(1166)+s(526)+s(1560)+"r ")+Q);return e.sZrAC(n)}return this["_dispatc"+s(1493)+s(1900)](a),e[s(1017)](n)}}async function Up(a,n){let s=t,l=fa[s(978)](this,a);if(!l[s(1192)+s(1583)])return e.htunq(n);let f=await sl[s(978)](this);if(l[s(1672)+s(1117)+"age"]&&l[s(690)+"s"][s(437)])for(let p of l[s(690)+"s"])await f[s(614)](p);e[s(1733)](n)}async function Hp(a,n){let s=t,l=e[s(896)](a[s(616)][s(1741)+"e"],Op),f=e[s(954)](a.message[s(1741)+"e"],pa);if(e.WHIbH(!l,!f))return e.htunq(n);let p=e[s(1660)](Xn,a.message[s(1938)],e[s(945)]);if(!p)return e.FMQre(n);let m=await al.call(this,p);if(!m)return n();if(l)if(e[s(1735)](e[s(789)],e.mnhqh))this[s(729)](e[s(1135)],_0x17e15c),this[s(1950)]&&this[s(1950)](_0x1bfef2);else{let b=await m[s(413)+"rs"](),g={frameType:b?.[s(1741)+"e"],SeqID:ce.fromNumber(this._seqId++),LogID:ce[s(843)+"er"](this[s(1039)]["logIDGen"+s(837)]()),service:9e3,method:5,headers:b?.[s(1938)],payload:b?.[s(1198)]},T=e[s(1834)](A,g);this[s(786)]&&this._ws[s(1585)+"te"]&&this[s(786)][s(649)](T)}if(f){let b=a[s(616)][s(1198)];b&&m[s(1899)+"rs"](b)}}let Gp=async function(a,n){let s=t;this[s(1132)]=!1,e.pjuXe(clearTimeout,this[s(1860)+s(1967)+s(1670)]),e.wIpZd(n)},qp=async function(a,n){let s=t,l={yZWnF:function(m,b){return e[j(443)](m,b)},Qjtoy:function(m,b){return e[j(443)](m,b)},zTwcj:e[s(870)],WFHyW:e[s(1484)],DTsfB:e[s(1310)],PWtBG:e[s(1050)],mdlmw:function(m,b,g,T){return m(b,g,T)}};if(!this[s(786)]||e[s(673)](this._ws.readyState,this[s(1740)]))return e[s(1565)](n);let{pingInterval:f}=this._options;this[s(1604)+"tManager"]?.[s(1952)+s(1884)+s(1217)]();for(let m=0;e[s(1294)](m,this[s(1722)+s(979)][s(437)]);m++)if(e[s(506)](e[s(1033)],"lIuEn")){let b=this["_message"+s(979)][m];if(this._ws[s(1585)+"te"]===this[s(1740)]&&e[s(1252)](null,b))this._ws&&this[s(786)].send(b),this[s(1722)+s(979)][m]=null;else break}else if(_0x41dea9.payload instanceof _0x521010){let b=gCDjKn[s(1253)](this[s(1039)]["payloadE"+s(1052)],_0x4b4079)?{force:!!this[s(1039)][s(1376)+s(1052)][s(408)],encoding:this[s(1039)]["payloadE"+s(1052)][s(1543)]?this[s(1039)]["payloadE"+s(1052)][s(1543)][s(852)](/\s/g,"")["toLowerC"+s(1230)]():""}:{force:!1,encoding:this[s(1039)][s(1376)+s(1052)]?this[s(1039)]["payloadE"+s(1052)][s(852)](/\s/g,"")[s(429)+s(1230)]():""},g=_0x8e0b87[s(1376)+s(1052)]?_0x38a51d[s(1376)+s(1052)][s(852)](/\s/g,"").toLowerCase():"",T=gCDjKn[s(1571)](this._options.payloadType,_0x11033b)?{force:!!this[s(1039)][s(850)+s(812)][s(408)],type:this[s(1039)]["payloadT"+s(812)][s(1841)]?this[s(1039)][s(850)+s(812)][s(1841)][s(852)](/\s/g,"")["toLowerC"+s(1230)]():""}:{force:!1,type:this[s(1039)]["payloadT"+s(812)]?this[s(1039)][s(850)+s(812)][s(852)](/\s/g,"").toLowerCase():""},C=_0x1a497d[s(850)+"ype"]?_0x3c540c[s(850)+s(812)].replace(/\s/g,"")[s(429)+s(1230)]():"",M=T[s(408)]?T[s(1841)]:C||T[s(1841)],K=b.force?b.encoding:g||b.encoding,U=["text/pla"+s(1547)+"et=utf-8",gCDjKn[s(1220)],gCDjKn[s(1130)],gCDjKn.DTsfB],Q=[s(711)+"e",gCDjKn[s(958)]];this[s(1039)][s(692)+s(594)+s(656)+"ad"]&&U.includes(M)&&(!K||Q[s(1924)](K))?_0x58b7fd["textPayl"+s(1303)]=gCDjKn[s(655)](_0x4d17b9,_0x5a1925[s(1198)],0,_0x20386c[s(1198)][s(1181)+"th"]):_0x108fc6["textPayl"+s(1303)]=""}else _0x9e9e44.textPayload="";this[s(1722)+s(979)]=this["_message"+s(979)].filter(m=>!!m),this[s(525)+s(1801)+"Id"]=e.zeeWV(setTimeout,()=>this[s(636)](),f),this[s(534)+"hOpenEvent"](a),this[s(455)+"er"]&&this[s(786)]&&(this._ws[s(557)+"pe"]=this["_binaryT"+s(812)]);let p=this[s(1604)+s(503)]?.[s(1639)+s(868)+"nt"]();this._debug(s(1396)+p+s(1657)),e[s(578)](n)},jp=async function(a,n){let s=t,l=this[s(1604)+s(503)]?.["getCurre"+s(868)+"nt"]();this[s(620)](s(1396)+l),e[s(784)](n)};class Wp extends da{constructor(n){let s=t,l={HWlCy:function(f,p,m){return f(p,m)},FLjTb:function(f,p){return e[j(1683)](f,p)},wJVsq:function(f,p){return e[j(1893)](f,p)},pcXXk:e[s(733)],NzamI:s(1934)+s(990)+"s",GmKDW:function(f,p,m){return e[s(1171)](f,p,m)},IRnxE:function(f,p){return e[s(1876)](f,p)},nSSNd:function(f,p,m,b){return e[s(1102)](f,p,m,b)},RsumQ:e.Jdnpo,xkcSZ:function(f,p){return e[s(1620)](f,p)},kvtDj:function(f,p){return f&p}};if(e.qVOPo(s(820),s(820))){super(),this[s(1304)+s(919)+s(1259)]=!0,this[s(455)+"er"]=Zn,this[s(593)]=ap,this[s(1137)+"T"]=An,this[s(1084)+"X"]=qr,this[s(1273)+"r"]=jr,this["_message"+s(979)]=[],this[s(1604)+s(503)]=null,this[s(1869)+s(996)]=!1,this[s(1554)+s(812)]=e[s(1685)],this[s(1860)+s(1974)]=!1,this[s(1860)+s(1967)+s(1670)]=null,this[s(530)+"ctTimeoutId"]=null,this[s(525)+"gTimeoutId"]=null,this[s(659)]=0,this[s(1132)]=!1,this[s(1916)]="",this[s(1121)+s(807)]=null,this[s(1079)+s(1761)]=null,this[s(1138)+s(1921)]=null,this[s(1400)+"ls"]=e[s(642)],this[s(663)]=3,this[s(783)+"NG"]=0,this[s(1740)]=1,this[s(1246)]=2,this[s(456)]=b=>{let g=s;try{if(e[g(647)]!==e[g(647)]){let T=_0x3bc2eb();return VCaVql[g(1300)](_0x159098,_0x2da6cb,T),_0x15b780(T)}else e[g(665)](el,this,b,[Gp,qp,jp])}catch(T){let C=e.jDYFU(st,e[g(650)],{message:T.message,code:Xt.OPEN_ERROR,error:T});this[g(534)+g(1027)+g(1527)](C)}},this[s(849)+"ge"]=async b=>{let g=s,{pingInterval:T,pingFrequency:C}=this[g(1039)];if((l[g(1482)]("hi",b[g(1463)])&&l[g(1964)](l[g(1697)],C)||l[g(1964)](g(1105),C))&&(this[g(913)+g(1074)](),this[g(729)](l[g(1695)],g(953)),this[g(525)+g(1801)+"Id"]=l.GmKDW(setTimeout,this._ping[g(923)](this),T)),!l[g(920)]("hi",b.data))try{l[g(1467)](el,this,b,[bp,yp,Up,Hp,zp,Ep])}catch(M){let K=st(l[g(1321)],{message:M[g(616)],code:Xt[g(1383)+"ERROR"],error:M});this[g(534)+g(1027)+g(1527)](K)}},this[s(1104)]=b=>{let g=s,T=this[g(1604)+g(503)]?.[g(1912)+g(1961)+"es"](),C=this[g(1604)+g(503)]?.[g(1639)+g(868)+"nt"]();if(T&&!b[g(616)]){let M=g(425)+C+(g(1020)+g(459)+g(1619)+"ed");this[g(534)+g(1027)+"ent"](st(g(1569),{message:M,code:Xt["MAX_RETR"+g(474)+"R"],error:b}));return}this[g(786)]&&e[g(579)](this._ws[g(1585)+"te"],this[g(1740)])&&this["_disconn"+g(1433)](),this[g(534)+g(1027)+"ent"](st(e[g(650)],{message:b[g(616)],code:Xt[g(1352)+g(1062)],error:b}))},this[s(1335)]=async b=>{let g=s;this[g(685)+g(827)](),this[g(913)+g(1074)](),this[g(563)+g(737)+"rs"](),this[g(786)]=null,this[g(1860)+g(1974)]=!1;let T=this[g(1604)+g(503)]?.[g(1912)+g(1961)+"es"]();if(!T&&this[g(905)+"orOnline"]()&&!this["_readyCl"+g(996)])if(e.alAiD(e[g(1764)],e[g(1596)]))VCaVql[g(1300)](_0x4adab9,_0x3134dc,VCaVql[g(584)](VCaVql[g(569)](127,_0x48be1e),128)),_0x198beb>>>=7;else{let C=this[g(1604)+g(503)]?.[g(1639)+g(868)+"nt"](),M=this._options[g(1826)+g(1636)+g(839)](b.code,b[g(1815)]);this[g(534)+g(1975)+g(1527)](ft(e[g(1175)],{code:1006,reason:b[g(1815)]||g(1305)+g(1460)+g(1937)+g(760)+g(1946)+"ame: "+C,willReconnect:M})),M&&this[g(1860)]();return}if(e[g(645)](1e3,b[g(518)])&&this[g(1869)+g(996)]){this[g(534)+g(1975)+g(1527)](e[g(1874)](ft,g(940),{code:1e3,reason:e[g(856)]})),this[g(1604)+g(503)]?.["resetEnd"+g(1884)+g(1217)](),this["_pingLos"+g(1921)]?.["resetCou"+g(552)]();return}if(e[g(1131)](1e3,b.code)&&T){let C=this[g(1604)+"tManager"]?.[g(1639)+g(868)+"nt"](),M=b[g(1815)];M||(M=await e[g(562)](hp,this[g(1916)])),M=g(1305)+g(1460)+g(1067)+M+(g(629)+"me: ")+C+(g(1148)+g(1804)+g(1891)),this[g(534)+g(1975)+g(1527)](e.aoJnD(ft,e.sjWdy,{code:b[g(518)],reason:M}));let K=g(425)+C+(g(1020)+g(459)+g(1619)+"ed");this[g(534)+"hErrorEv"+g(1527)](e[g(1976)](st,e[g(650)],{message:K,code:Xt["MAX_RETR"+g(474)+"R"]})),this["_endpoin"+g(503)]?.["resetEndpointCon"+g(1217)](),this[g(1138)+g(1921)]?.[g(1625)+"nter"]();return}if(e.MSFRS(1e3,b[g(518)])&&!b[g(1815)]){let C=this[g(1604)+g(503)]?.[g(1639)+g(868)+"nt"]();this[g(534)+g(1975)+g(1527)](e[g(1549)](ft,g(940),{code:b[g(518)],reason:g(1305)+g(1460)+g(1937)+"wn reaso"+g(1946)+g(424)+C})),this["_endpoin"+g(503)]?.[g(1952)+g(1884)+g(1217)](),this._pingLossCounter?.[g(1625)+g(552)]();return}this[g(534)+g(1975)+g(1527)](b),this[g(1604)+"tManager"]?.["resetEnd"+g(1884)+"fig"](),this["_pingLos"+g(1921)]?.[g(1625)+g(552)]()},this.onclose=null,this[s(1582)]=null,this[s(1226)+"e"]=null,this[s(1950)]=null,this[s(1807)+"econnect"]=null,this[s(1306)+"eAck"]=null,this[s(917)+s(1844)+s(1888)+"ct"]=null,this[s(1514)+s(666)]=this["_handleO"+s(666)][s(923)](this),this[s(1514)+"ffLine"]=this["_handleO"+s(1176)][s(923)](this),this[s(734)+s(1398)]=this[s(734)+s(1398)].bind(this),this["_handleP"+s(751)]=this[s(734)+s(751)].bind(this),this[s(1039)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1566)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:s(1105),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1943)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=n,m=Array.isArray(f)?f:e[s(1459)](e[s(1310)],typeof f)?[f]:[];if(!m||m.length===0)throw new Error(e.LNWCn);if(!lp(p))throw new Error(e[s(560)]);Object[s(966)](this[s(1039)],n),this["_endpoin"+s(503)]=new Qd(m,this._options.maxRetries),this[s(1138)+s(1921)]=new xp(this[s(1039)]["pingLoss"+s(1542)]),this[s(1039)].automaticOpen&&(this[s(1132)]=!0,this[s(1860)]()),this._options["listenNe"+s(863)+s(1590)]&&(this[s(1137)+"T"]||this._isMiniWX?this[s(956)+"etWorkCh"+s(1564)]():this[s(455)+"er"]&&this[s(774)+s(1225)+s(1313)]())}else return new _0x4d45aa(_0x10d8b2,{message:_0x20f9a6})}[t(1514)+"nLine"](){let n=t;if(e[n(484)]===e[n(1023)]){let s=e[n(1549)](_0x57488a,_0x3a0a26,_0x3a77fb[n(437)]);_0x375a9f[n(1522)][n(540)](_0x4a7aa3,s)}else{if(this[n(1039)][n(1561)+"utoRecon"+n(992)]||this["_readyCl"+n(996)])return;this[n(1174)+n(1785)]()}}[t(1514)+t(1176)](){let n=t;this[n(1529)+n(555)+"t"]();let s=e.aARoK(ca,e[n(777)],{message:e[n(1760)]});this[n(917)+"mediatelyReconnect"]&&this[n(917)+n(1844)+n(1888)+"ct"](s)}["_initGlo"+t(1225)+t(1313)](){let n=t;this[n(455)+"er"]&&window[n(1351)+n(1313)](e.vTPEY,this[n(1514)+"nLine"]),this._isBrowser&&window[n(1351)+n(1313)]("offline",this[n(1514)+"ffLine"]),this._isBrowser&&window[n(1351)+n(1313)](n(946),this[n(734)+n(1398)]),this[n(455)+"er"]&&window["addEvent"+n(1313)](n(1821),this[n(734)+n(751)])}["_dropGlo"+t(1225)+t(1313)](){let n=t;this._isBrowser&&window["removeEv"+n(1941)+n(1796)]("online",this[n(1514)+n(666)]),this[n(455)+"er"]&&window["removeEv"+n(1941)+n(1796)](e.QDVvk,this._handleOffLine),this[n(455)+"er"]&&window[n(1013)+n(1941)+n(1796)](e.zIchm,this[n(734)+"ageHide"]),this[n(455)+"er"]&&window["removeEv"+n(1941)+n(1796)](e[n(1444)],this[n(734)+n(751)])}[t(734)+t(1398)](n){let s=t;!n[s(550)+"d"]&&(this[s(455)+"er"]&&window[s(1013)+s(1941)+s(1796)](e[s(1280)],this[s(734)+"ageHide"]),this[s(455)+"er"]&&window[s(1013)+"entListe"+s(1796)](e.NZOlO,this[s(734)+s(751)]),this[s(940)]()),this[s(455)+"er"]&&window[s(1013)+s(1941)+"ner"](e.vTPEY,this[s(1514)+s(666)]),this._isBrowser&&window["removeEv"+s(1941)+"ner"](e[s(1438)],this["_handleO"+s(1176)])}[t(734)+t(751)](n){let s=t;n[s(550)+"d"]&&(this[s(905)+"orOnline"]()&&(!this[s(786)]||this[s(786)][s(1585)+"te"]!==this[s(1740)]||this[s(786)][s(1585)+"te"]!==this.CONNECTING)&&this[s(1514)+s(666)](),this[s(455)+"er"]&&window[s(1351)+"Listener"](s(1769),this[s(1514)+"nLine"]),this[s(455)+"er"]&&window[s(1351)+s(1313)](e.QDVvk,this[s(1514)+s(1176)]))}async["_generat"+t(1245)](n){let s=t,{fpID:l,deviceID:f,bddID:p,ttwID:m,accessKey:b,aID:g,customParams:T={},enableAutoAck:C,enableQoS:M,QoSLevel:K,env:U}=this._options,Q,Ve,xt;this._isBrowser||this[s(1084)+"X"]||this[s(1137)+"T"]?(Q=location&&e[s(1459)](e[s(1474)],location.protocol)?e[s(835)]:e[s(1366)],Ve=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),xt=/^wss(.*:\/\/)/[s(1497)](n)?n:""+Q+Ve):(Q=e.aBKxn,Ve=n.replace(/(^http)((?:[s]*:\/\/))/,""),xt=/(^ws)((?:[s]*:\/\/))/[s(1497)](Ve)?Ve:""+Q+Ve);let cl=p?e[s(1395)]:m?e[s(458)]:s(1483)+"d",dl=p||m||f;if(!dl||!cl)throw new Error(e[s(1145)]);let Kp=e[s(1960)]==typeof T?await e.XoNdU(T):T,$p=U?e[s(1197)](fp,U[s(1088)],U[s(931)]):{},ga=Object.assign({device_platform:e.eaxzJ,version_code:e[s(1106)],access_key:b,fpid:l,aid:g,[cl]:dl,xsack:C?1:0,xaack:C?1:0,xsqos:M?1:0,qos_level:M?K:void 0,qos_sdk_version:2,...$p},Kp),Vp=Object[s(1426)](ga)[s(854)]((ma,wa)=>ga[wa]!==void 0?""+ma+(ma?"&":"?")+wa+"="+ga[wa]:ma,"");return xt+"/ws/v2"+Vp}async[t(1860)](){let n=t;if(!(this[n(1860)+n(1974)]||this[n(1869)+n(996)])){this[n(1860)+n(1974)]=!0;try{let s=this["_endpoin"+n(503)]?.["checkCur"+n(765)+n(1734)+n(1410)+n(446)](),{timeoutInterval:l}=this[n(1039)];if(s)if(e.fdioO(e[n(1786)],e[n(412)]))e.YIXvl(_0x187135,_0x524354,24),e[n(1846)](_0x380445,_0x53ed6e,_0x305aa4(_0x3b70fe));else{let p=this[n(1604)+"tManager"]?.[n(1639)+n(868)+"nt"](),m=this[n(1604)+n(503)]?.[n(1485)+n(1103)+n(1942)+"UpdateCo"+n(1183)](),b=this[n(1604)+n(503)]?.["getCurre"+n(868)+n(1945)+n(756)]();if(m)if(e.ogugX===e[n(1367)])_0x34e5f8=e[n(1810)](_0x2261f6,_0x217ba9),_0x3805aa|=e[n(757)](127&_0x52fd3f,21),128&_0x43499e&&(_0x11970c=e[n(1771)](_0x144859,_0x445891),_0x157e36=e.RcgGX(127,_0x5ad72d),e[n(1236)](128,_0x71866d)&&(_0x4c74c0=e[n(644)](_0x3562a7,_0x36856a),_0x886079|=e[n(1782)](e.kydGw(127,_0x560217),7)));else{let g=n(425)+p+(n(771)+n(1148)+n(1804)+n(1776)+n(1048)+n(415)+n(709))+m+(n(744)+"y"),T=e[n(403)](st,"error",{message:g,code:Xt["MAX_RETR"+n(474)+"R"]});this[n(620)](g),this["_dispatc"+n(1027)+n(1527)](T),this[n(1916)]=await this[n(1703)+n(1245)](m),this[n(620)](n(425)+m+" "+b+" times"),this[n(563)+n(737)+"rs"]()}else{let g="connect "+p+(n(771)+n(1148)+n(1804)+n(1891));this[n(620)](g),this[n(534)+n(1027)+n(1527)](e.GpBhi(st,e[n(650)],{message:g,code:Xt[n(1638)+n(474)+"R"]}));return}}else{let p=this[n(1604)+n(503)]?.[n(1639)+n(868)+"ntAndUpd"+n(1404)](),m=this[n(1604)+n(503)]?.[n(1639)+n(868)+"ntTriesC"+n(756)]();this[n(1916)]=await this[n(1703)+n(1245)](e.SzmzW(p,"")),this[n(620)](n(425)+p+" "+m+n(938)),this[n(563)+n(737)+"rs"]()}if(this[n(1132)])this[n(1132)]=!1;else{let p=e[n(1895)](ca,n(1826)+"t",{message:e[n(589)]});this[n(1807)+n(1785)]&&this[n(1807)+"econnect"](p)}let f=this[n(1604)+n(503)]?.[n(1639)+n(868)+n(1945)+"ount"]()||0;f>1&&await this._wait(f-1),this[n(620)](n(1305)+n(1525)+this[n(1916)]+(n(1909)+n(1656))+this._protocols),this[n(786)]=e[n(635)](dp,{url:this[n(1916)],protocols:[this._protocols],headers:this[n(1039)][n(570)+n(479)+"s"][n(1213)+n(1667)]},this._options.ws),(this[n(455)+"er"]||this[n(1273)+"r"])&&this[n(786)]&&(this[n(786)][n(557)+"pe"]=this[n(1554)+"ype"]),this[n(1830)+n(1644)](),this[n(1860)+"ionTimeo"+n(1670)]=e.jjdit(setTimeout,this[n(1431)+"ut"][n(923)](this),l)}catch(s){throw this[n(1860)+n(1974)]=!1,s}}}[t(685)+t(827)](){let n=t;e[n(844)](clearTimeout,this["_connect"+n(1967)+n(1670)]),this[n(1860)+"ionTimeo"+n(1670)]=null}[t(913)+t(1074)](){let n=t;clearTimeout(this[n(525)+n(1801)+"Id"]),e[n(466)](clearTimeout,this[n(530)+"ctTimeou"+n(929)]),this[n(525)+n(1801)+"Id"]=null,this["_reconnectTimeou"+n(929)]=null}[t(620)](...n){let s=t;this[s(1039)][s(627)]&&console[s(872)][s(1289)](console,[e[s(893)],...n])}[t(1227)+t(1449)+"e"](n){let s=t,{initReconnectInterval:l,maxReconnectInterval:f,reconnectIntervalGrowFactor:p}=this._options,m=e[s(1666)](l,Math[s(1877)](p,e[s(1747)](n,1)));return e[s(454)](m,f)?f:m}[t(636)](){let n=t;if(this[n(786)]&&this[n(786)][n(1585)+"te"]===this[n(783)+"NG"])if(e[n(1505)](n(862),n(969))){this[n(913)+n(1074)](),this[n(525)+n(1801)+"Id"]=e[n(983)](setTimeout,this[n(636)].bind(this),this[n(1039)][n(725)+n(533)]);return}else{let s=_0x272460[n(605)](":");_0x125c17&&(_0x4d4fb9=s[n(437)]),_0x28c1db+=s[n(437)];for(let l=0;e.ZpWGs(l,s.length);l++)if(s[l][n(437)]!==4){let f=_0x4a5cd2[n(1648)+"g"](0,e.RWBGu(4,s[l][n(437)])),p=f[n(698)](s[l]);_0x191bfa[n(1715)](p)}else _0x2ae345.push(s[l]);_0x3a3275=!1}if(!this._ws||this[n(786)][n(1585)+"te"]!==this[n(1740)])return void this[n(1174)+n(1785)]();this[n(786)]&&this[n(786)][n(649)]("hi"),this[n(530)+"ctTimeou"+n(929)]=e[n(1476)](setTimeout,this[n(1174)+n(1785)+n(606)][n(923)](this),this[n(1039)][n(1880)+n(1750)+n(799)])}[t(1174)+t(1785)+t(606)](){let n=t;this[n(1138)+n(1921)]?.[n(440)](),this[n(729)](n(1934)+n(1015)+"t",e.JMltw),this["_pingLos"+n(1921)]?.[n(1912)+"chMaxCount"]()?this[n(1174)+"econnect"]():this[n(636)]()}[t(905)+t(1591)](){let n=t;if(e[n(1385)](e[n(1917)],"odYDh"))return this[n(1137)+"T"]||this[n(1084)+"X"]?this[n(1304)+n(919)+"line"]:(this[n(455)+"er"]||this._isWorker)&&this[n(1039)][n(1077)+"tworkCha"+n(1590)]?navigator[n(1242)]:!0;this[n(786)]&&this[n(786)][n(940)](_0x12b8fa,_0x2b3485)}["_handleR"+t(1785)](){let n=t;!this[n(905)+n(1591)]()||this[n(1869)+n(996)]||(this[n(1604)+n(503)]?.[n(1952)+n(1884)+n(1217)](),this[n(1138)+"sCounter"]?.[n(1625)+n(552)](),this._ws?this._disconnect(1001,"going aw"+n(1774)+n(1826)+"ting ser"+n(1293),!0):this[n(1860)]())}["_onPageNetWorkCh"+t(1564)](){let n=t,s={iWzKX:function(l,f){return e[j(1302)](l,f)},gtPim:e.IHwRk,yiEdJ:function(l,f){return e.xaeEv(l,f)},MhKTp:function(l,f){return e.fFYNH(l,f)},VYceL:e[n(1495)],wdFfh:e[n(397)],ywOjs:n(1823)};e[n(1119)](e[n(1221)],e[n(1413)])?(_0x61f200[n(432)][n(1920)+n(554)](_0x5930e0),_0x5b0048["frontier"+n(955)]=void 0,YpegYp.iWzKX(_0x5a9b98,_0x2a551f&&_0x559597.msg||YpegYp[n(1749)])):this._isMiniTT?tt["onNetworkStatusC"+n(1451)](({isConnected:l})=>{let f=n;this[f(1304)+f(919)+f(1259)]=l,l?this[f(1514)+f(666)]():this[f(1514)+"ffLine"]()}):this[n(1084)+"X"]&&wx[n(1200)+n(753)+n(1451)](({isConnected:l})=>{let f=n;if(s.wdFfh===s[f(891)]){if(YpegYp[f(1372)](YpegYp[f(1380)](_0x54afb3.offset,_0x90278b),_0x129af1[f(1906)]))throw new _0x2ea3cc(YpegYp[f(1349)]);_0x1cc88d[f(399)]+=_0x419ba2}else this[f(1304)+"igatorOnline"]=l,l?this[f(1514)+"nLine"]():this[f(1514)+f(1176)]()})}[t(1732)](n){return new Promise(s=>{let l=j;e.nZBkg(setTimeout,s,this["_getInte"+l(1449)+"e"](n))})}[t(1524)+t(1433)](n=1e3,s="",l=!1){let f=t;if(e.xsaHI(e.SooES,e[f(1611)]))return this[f(483)+f(1034)+f(430)+"t"]++,this["getCurre"+f(868)+"nt"]();if(!this[f(786)])return;this[f(1529)+f(555)+"t"](n,s,l)}[t(1431)+"ut"](){let n=t,s=this[n(1604)+"tManager"]?.[n(1639)+n(868)+"nt"]();this[n(620)]("connect "+s+n(771)),this["_disconn"+n(1433)](1001,e[n(705)],!0)}[t(1078)](n){let s=t,l=Bt(n);this[s(786)]&&e[s(1544)](this._ws[s(1585)+"te"],this[s(1740)])&&(this[s(786)]&&this._ws[s(649)](l),this[s(620)](e[s(1069)],n))}[t(563)+t(737)+"rs"](){let n=t,s=e[n(1511)][n(605)]("|"),l=0;for(;;){switch(s[l++]){case"0":if(!this[n(786)])return;continue;case"1":this._ws[n(1013)+n(1941)+"ner"](e[n(779)],this[n(849)+"ge"]);continue;case"2":this[n(786)][n(1013)+n(1941)+n(1796)](e[n(650)],this[n(1104)]);continue;case"3":this._ws[n(1013)+n(1941)+n(1796)](e.rjASg,this[n(456)]);continue;case"4":this[n(786)][n(1013)+n(1941)+n(1796)](e.sjWdy,this[n(1335)]);continue}break}}[t(1830)+"steners"](){let n=t;this[n(786)]&&(this[n(786)][n(1351)+n(1313)](e[n(1135)],this[n(456)]),this._ws["addEvent"+n(1313)](e[n(1175)],this._onClose),this[n(786)]["addEvent"+n(1313)](e[n(779)],this._onMessage),this[n(786)][n(1351)+n(1313)](e[n(650)],this[n(1104)]))}["_wsInsta"+t(1073)](n=1e3,s=""){let l=t;if(e.mnxQM!==e.poumR)try{this[l(786)]&&this[l(786)][l(940)](n,s)}catch{}else return _0xf144f7?.[l(1973)](f=>f[l(1057)]===_0x2079bf)?.value}["_destroy"+t(555)+"t"](n=1e3,s="",l=!1){let f=t;if(this[f(913)+f(1074)](),this[f(685)+f(827)](),this[f(563)+f(737)+"rs"](),this["_wsInsta"+f(1073)](1e3,s),this[f(1860)+f(1974)]=!1,l&&this[f(905)+f(1591)]()&&!this["_readyCl"+f(996)]){if(this[f(1604)+f(503)]?.[f(1912)+"chMaxTries"]()){let m=this[f(1604)+f(503)]?.getCurrentEndpoint();this[f(534)+f(1975)+f(1527)](e[f(1680)](ft,e.sjWdy,{code:1006,reason:f(425)+m+(f(771)+f(1148)+"tries reached"),wasClean:!0}))}else{let m=this[f(1039)][f(1826)+f(1636)+f(839)](n,s);this[f(534)+f(1975)+f(1527)](e[f(411)](ft,e[f(1175)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[f(1860)]()}return}this[f(905)+f(1591)]()||this[f(1869)+f(996)]?this[f(534)+f(1975)+"ent"](e[f(713)](ft,e[f(1175)],{code:n,reason:f(1682)})):this["_dispatchCloseEv"+f(1527)](e[f(1551)](ft,e[f(1175)],{code:1006,reason:e[f(1919)]})),this[f(786)]=null,this._endpointManager?.[f(1952)+f(1884)+f(1217)](),this["_pingLos"+f(1921)]?.[f(1625)+f(552)]()}["_dispatc"+t(1364)+"nt"](n){let s=t;this[s(729)](e[s(1135)],n),this[s(1950)]&&this[s(1950)](n)}[t(534)+t(1493)+t(1900)](n){let s=t;this[s(729)](e[s(779)],n),this.onmessage&&this[s(1226)+"e"](n)}[t(534)+"hAckMess"+t(607)](n){let s=t;this.emit(e.VOtcw,n),this["onReceiv"+s(1149)]&&this[s(1306)+s(1149)](n)}[t(534)+t(1027)+t(1527)](n){let s=t;this.emit("error",n),this[s(1582)]&&this.onerror(n)}[t(534)+t(1975)+t(1527)](n){let s=t;this.emit(e[s(1175)],n),this[s(1319)]&&this[s(1319)](n)}get binaryType(){let n=t;return this[n(786)]?this._ws[n(557)+"pe"]:this["_binaryT"+n(812)]}set[t(557)+"pe"](n){let s=t;this["_binaryT"+s(812)]=n,this._ws&&(this[s(786)].binaryType=n)}get[t(1164)+"nt"](){let n=t;return this[n(1604)+n(503)]?.[n(1639)+n(868)+n(1945)+n(756)]()||0}get[t(805)+t(1816)](){let n=t;if(e[n(538)](e[n(1167)],e.Bjrjq))return e[n(433)](e[n(1310)],typeof _0x18b8b3)&&(e[n(1559)](_0x5c459c,_0xb87ee8)||_0x20a4fa.buffer&&e[n(443)](_0x506c71[n(1251)],_0x196d20))||e.qZxpF(e[n(1310)],typeof _0x3ee661)?"":(_0x4b5b1c[n(949)](_0x161e64),n(1820)+n(421));{let s=this._messageQueue[n(854)]((l,f)=>(l+=f&&f[n(1181)+"th"]||0,l),0);return e[n(1115)](s,this[n(786)]?this[n(786)][n(805)+n(1816)]:0)}}get[t(1249)+"ns"](){let n=t;if(e[n(510)](e[n(803)],e.EVFnm))this[n(729)](n(1569),_0xded9ef),this[n(1582)]&&this[n(1582)](_0x431f32);else return this[n(786)]?this[n(786)][n(1249)+"ns"]:""}get protocol(){let n=t;return this[n(786)]?this._ws[n(1720)]:""}get[t(1585)+"te"](){let n=t;return this._ws?this[n(786)][n(1585)+"te"]:this[n(1039)][n(926)+n(1094)]?this[n(783)+"NG"]:this[n(663)]}get[t(1064)](){let n=t;return this[n(786)]?this[n(786)][n(1064)]:this[n(1916)]}[t(940)](n=1e3,s){let l=t,f=e.UhPOl.split("|"),p=0;for(;;){switch(f[p++]){case"0":this[l(1869)+l(996)]=!0;continue;case"1":if(!this[l(786)])return void this[l(620)](e[l(1286)]);continue;case"2":this["_clearTi"+l(827)]();continue;case"3":this["_QoSMana"+l(807)]?.[l(1110)]();continue;case"4":this["_destroy"+l(555)+"t"](n,s);continue;case"5":if(e[l(1753)](this[l(786)][l(1585)+"te"],this[l(663)])||e[l(619)](this[l(786)][l(1585)+"te"],this[l(1246)]))return void this[l(620)](e[l(1576)]);continue;case"6":this[l(913)+l(1074)]();continue;case"7":this[l(1240)+l(1225)+l(1313)]();continue}break}}async[t(649)](n,s){let l=t;if(e[l(1517)](null,n))throw new Error(l(1541)+l(876)+l(811)+l(1726)+"a must b"+l(1016)+l(1867)+" arraybu"+l(847));e[l(888)]==typeof n&&(n=JSON.stringify(n)),e[l(928)](e.XJemB,typeof n)&&!(n instanceof ArrayBuffer)&&!(n[l(1251)]&&e[l(662)](n.buffer,ArrayBuffer))&&(n=JSON[l(1838)+"y"](n));let f=await e[l(1655)](rl,n),p=e[l(1563)](up,n),{method:m=0,service:b=this[l(1039)][l(1918)],logID:g=this[l(1039)][l(889)+"erator"](),headers:T=this[l(1039)][l(1938)],payloadEncoding:C=this[l(1039)][l(1376)+l(1052)],payloadType:M=this._options[l(850)+"ype"],logIDNew:K=this._options[l(785)+l(1930)][l(747)+l(436)+"teLogIDNew"]?e.ihEXt(i,this[l(1039)][l(785)+l(1930)][l(823)]):""}=e[l(575)](s,{});if(!b)throw new Error(l(1541)+l(876)+l(601)+l(693));let U={SeqID:ce[l(843)+"er"](this[l(659)]++),LogID:ce[l(843)+"er"](g),service:b,method:m,headers:T,payloadEncoding:C instanceof Object?C[l(1543)]?C[l(1543)]:"":C,payloadType:M instanceof Object?M.type?M[l(1841)]:p:M||p,payload:f,LogIDNew:K},Q=e[l(1631)](Bt,U);return this[l(786)]&&e[l(1429)](this[l(786)][l(1585)+"te"],this.OPEN)?(this._ws&&this[l(786)][l(649)](Q),this[l(620)](e[l(1706)],U)):e[l(1843)](this["_message"+l(979)][l(437)],this._options["maxMessageQueueL"+l(1851)])?(this[l(1722)+"Queue"][l(1715)](Q),this[l(620)](e.dkNwg,U)):(this[l(1722)+l(979)][l(471)](),this[l(1722)+l(979)].push(Q)),{seqID:this[l(659)],logID:g,logIDNew:K}}async[t(1826)+"t"](n){let s=t,{url:l}=e.RAPGi(n,{}),f=Array.isArray(l)?l:e[s(1459)](s(531),typeof l)?[l]:[];if(n&&Object[s(966)](this[s(1039)],n),f&&f[s(437)]?this["_endpoin"+s(503)]=new Qd(f,this._options[s(1378)+"es"]):this[s(1604)+s(503)]?.["resetEnd"+s(1884)+"fig"](),this[s(1138)+"sCounter"]?.["resetCou"+s(552)](this._options["pingLoss"+s(1542)]),this[s(1869)+s(996)]=!1,this[s(786)]&&e[s(651)](this[s(786)].readyState,this[s(663)]))this._disconnect(1e3,e[s(414)],!0);else if(e[s(492)](e[s(1419)],e[s(1357)]))this[s(1132)]=!0,this[s(1860)]();else return UqIFIN[s(1472)](typeof _0x1b9938,s(1387))?_0x126f36(_0x40d872):(UqIFIN[s(1089)](_0xed4f3,_0x1aa4c8)&&_0x1a34d0(_0x123282),_0x3bee06(_0x1ea97f,_0x2d8421())?new _0x1be4ab(_0x54e33e,_0x20b0c8):_0x251f1b)}async[t(1550)](){let n=t;if(!this[n(1860)+n(1974)]){let s=e.kAcfk[n(605)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(1132)]=!0;continue;case"1":this[n(1869)+n(996)]=!1;continue;case"2":this[n(1604)+n(503)]?.[n(1952)+n(1884)+n(1217)]();continue;case"3":this[n(1138)+"sCounter"]?.[n(1625)+n(552)]();continue;case"4":this[n(1860)]();continue}break}}}[t(1351)+"Listener"](n,s){this.on(n,s)}[t(999)+t(1900)](n){let s=t;if(e[s(864)](e[s(871)],e[s(548)])){let{type:l}=_0x470ce0;this[s(729)](l,_0x2043b6)}else{let{type:l}=n;this[s(729)](l,n)}}["removeEventListe"+t(1796)](n,s){this[t(1963)](n,s)}[t(1684)](){let n=t,s={kbsSn:function(l,f,p){return l(f,p)},yTPAS:e[n(1863)],TsdzO:function(l,f){return e[n(547)](l,f)},cEfnm:e[n(793)],YteCQ:function(l,f){return l===f},zaGiZ:e.doBiP,bCmBt:n(1627),NQELo:"ping_onc"+n(1015)+"t"};return new Promise((l,f)=>{let p=n,m={UYFOQ:s[p(1229)],jmrOO:function(b,g){return s.TsdzO(b,g)},JDPNZ:s[p(1790)]};if(s[p(1496)](s[p(1598)],s[p(1890)])){this[p(913)+"ngTimer"](),this[p(525)+"gTimeoutId"]=hzgqgi.kbsSn(_0x1dc6ac,this._ping[p(923)](this),this[p(1039)][p(725)+"rval"]);return}else{this["_clearPi"+p(1074)](),this[p(525)+p(1801)+"Id"]=s.kbsSn(setTimeout,this[p(636)].bind(this),this[p(1039)][p(725)+p(533)]);let b=()=>{let T=p;if(T(1116)===T(1116))l(T(953)),this[T(1963)](m[T(1649)],b),this.off(T(1934)+T(1015)+"t",g);else{let C=_0x2638c4.message[T(1198)];C&&_0x1a79af.setCursors(C)}},g=()=>{let T=p;m[T(941)](f,m[T(1099)]),this[T(1963)](m.UYFOQ,b),this[T(1963)](T(1934)+T(1015)+"t",g)};this.on(p(1934)+p(990)+"s",b),this.on(s[p(1053)],g),this[p(636)]()}})}}})(),De[L(838)+L(881)]=Ce[L(838)+"oseEvent"],De["CustomEr"+L(1001)]=Ce[L(1363)+"rorEvent"],De.ErrorCode=Ce.ErrorCode,De[L(1900)]=Ce.Event,De[L(1581)]=Ce[L(1581)],De[L(1228)+L(1257)+L(1516)]=Ce[L(1228)+L(1257)+L(1516)],De[L(1257)+L(1516)]=Ce[L(1257)+L(1516)],De[L(573)+"t"]=Ce.OpenEvent,De[L(1368)+L(508)]=Ce[L(1368)+L(508)],De[L(1038)+L(881)]=Ce[L(1038)+L(881)],De[L(639)+L(1001)]=Ce[L(639)+"rorEvent"],De[L(1601)+L(1748)+"nt"]=Ce[L(1601)+"ssageEvent"],De[L(1779)+L(1870)]=Ce.createOpenEvent,De[L(1161)+L(993)+"vent"]=Ce["createRe"+L(993)+L(1516)],De[L(1676)+L(1605)]=Ce[L(1676)+L(1605)],De[L(1795)+"ame"]=Ce[L(1795)+"ame"];for(So in Ce)[L(838)+L(881),L(1363)+L(1001),"ErrorCode",L(1900),L(1581),L(1228)+L(1257)+"vent",L(1257)+L(1516),L(573)+"t",L(1368)+"tEvent",L(1038)+L(881),L(639)+L(1001),"createMe"+L(1748)+"nt",L(1779)+L(1870),L(1161)+L(993)+L(1516),L(1676)+"rame",L(1795)+L(393)].indexOf(So)===-1&&(De[So]=Ce[So]);var So;Object[L(1621)+"operty"](De,L(1694)+"le",{value:!0})});var Wt=se((D3,ux)=>{"use strict";var dx=["nodebuffer","arraybuffer","fragments"],lx=typeof Blob<"u";lx&&dx.push("blob");ux.exports={BINARY_TYPES:dx,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:lx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Hi=se((R3,ko)=>{"use strict";var{EMPTY_BUFFER:gb}=Wt(),dd=Buffer[Symbol.species];function mb(t,e){if(t.length===0)return gb;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 dd(r.buffer,r.byteOffset,i):r}function fx(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function xx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function wb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ld(t){if(ld.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new dd(t):ArrayBuffer.isView(t)?e=new dd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ld.readOnly=!1),e}ko.exports={concat:mb,mask:fx,toArrayBuffer:wb,toBuffer:ld,unmask:xx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=de("bufferutil");ko.exports.mask=function(e,r,i,o,c){c<48?fx(e,r,i,o,c):t.mask(e,r,i,o,c)},ko.exports.unmask=function(e,r){e.length<32?xx(e,r):t.unmask(e,r)}}catch{}});var gx=se((k3,px)=>{"use strict";var hx=Symbol("kDone"),ud=Symbol("kRun"),fd=class{constructor(e){this[hx]=()=>{this.pending--,this[ud]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ud]()}[ud](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[hx])}}};px.exports=fd});var kr=se((P3,Ex)=>{"use strict";var Gi=de("zlib"),mx=Hi(),_b=gx(),{kStatusCode:_x}=Wt(),yb=Buffer[Symbol.species],Eb=Buffer.from([0,0,255,255]),Oo=Symbol("permessage-deflate"),Kt=Symbol("total-length"),Dr=Symbol("callback"),bn=Symbol("buffers"),Rr=Symbol("error"),Po,xd=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 _b(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[Dr];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,d)=>{o(),i(c,d)})})}compress(e,r,i){Po.add(o=>{this._compress(e,r,(c,d)=>{o(),i(c,d)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Gi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Gi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[Oo]=this,this._inflate[Kt]=0,this._inflate[bn]=[],this._inflate.on("error",vb),this._inflate.on("data",yx)}this._inflate[Dr]=i,this._inflate.write(e),r&&this._inflate.write(Eb),this._inflate.flush(()=>{let c=this._inflate[Rr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=mx.concat(this._inflate[bn],this._inflate[Kt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Kt]=0,this._inflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,d)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Gi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Gi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[Kt]=0,this._deflate[bn]=[],this._deflate.on("data",bb)}this._deflate[Dr]=i,this._deflate.write(e),this._deflate.flush(Gi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=mx.concat(this._deflate[bn],this._deflate[Kt]);r&&(c=new yb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Dr]=null,this._deflate[Kt]=0,this._deflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Ex.exports=xd;function bb(t){this[bn].push(t),this[Kt]+=t.length}function yx(t){if(this[Kt]+=t.length,this[Oo]._maxPayload<1||this[Kt]<=this[Oo]._maxPayload){this[bn].push(t);return}this[Rr]=new RangeError("Max payload size exceeded"),this[Rr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Rr][_x]=1009,this.removeListener("data",yx),this.reset()}function vb(t){if(this[Oo]._inflate=null,this[Rr]){this[Dr](this[Rr]);return}t[_x]=1007,this[Dr](t)}});var Pr=se((O3,No)=>{"use strict";var{isUtf8:bx}=de("buffer"),{hasBlob:Sb}=Wt(),Ab=[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 Ib(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function hd(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 Tb(t){return Sb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}No.exports={isBlob:Tb,isValidStatusCode:Ib,isValidUTF8:hd,tokenChars:Ab};if(bx)No.exports.isValidUTF8=function(t){return t.length<24?hd(t):bx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=de("utf-8-validate");No.exports.isValidUTF8=function(e){return e.length<32?hd(e):t(e)}}catch{}});var _d=se((N3,Dx)=>{"use strict";var{Writable:Cb}=de("stream"),vx=kr(),{BINARY_TYPES:Db,EMPTY_BUFFER:Sx,kStatusCode:Rb,kWebSocket:kb}=Wt(),{concat:pd,toArrayBuffer:Pb,unmask:Ob}=Hi(),{isValidStatusCode:Nb,isValidUTF8:Ax}=Pr(),Lo=Buffer[Symbol.species],dt=0,Ix=1,Tx=2,Cx=3,gd=4,md=5,Mo=6,wd=class extends Cb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Db[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[kb]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=dt}_write(e,r,i){if(this._opcode===8&&this._state==dt)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Lo(i.buffer,i.byteOffset+e,i.length-e),new Lo(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 Lo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case dt:this.getInfo(e);break;case Ix:this.getPayloadLength16(e);break;case Tx:this.getPayloadLength64(e);break;case Cx:this.getMask();break;case gd:this.getData(e);break;case md:case Mo: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[vx.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=Ix:this._payloadLength===127?this._state=Tx: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=Cx:this._state=gd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=gd}getData(e){let r=Sx;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&&Ob(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=md,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[vx.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 d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===dt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=dt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=pd(i,r):this._binaryType==="arraybuffer"?o=Pb(pd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=dt):(this._state=Mo,setImmediate(()=>{this.emit("message",o,!0),this._state=dt,this.startLoop(e)}))}else{let o=pd(i,r);if(!this._skipUTF8Validation&&!Ax(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===md||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=dt):(this._state=Mo,setImmediate(()=>{this.emit("message",o,!1),this._state=dt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Sx),this.end();else{let i=e.readUInt16BE(0);if(!Nb(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Lo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ax(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=dt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=dt):(this._state=Mo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=dt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let d=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[Rb]=o,d}};Dx.exports=wd});var bd=se((M3,Px)=>{"use strict";var{Duplex:L3}=de("stream"),{randomFillSync:Lb}=de("crypto"),Rx=kr(),{EMPTY_BUFFER:Mb,kWebSocket:Bb,NOOP:Fb}=Wt(),{isBlob:Or,isValidStatusCode:zb}=Pr(),{mask:kx,toBuffer:qn}=Hi(),lt=Symbol("kByteLength"),Ub=Buffer.alloc(4),Bo=8*1024,jn,Nr=Bo,bt=0,Hb=1,Gb=2,yd=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=bt,this.onerror=Fb,this[Bb]=void 0}static frame(e,r){let i,o=!1,c=2,d=!1;r.mask&&(i=r.maskBuffer||Ub,r.generateMask?r.generateMask(i):(Nr===Bo&&(jn===void 0&&(jn=Buffer.alloc(Bo)),Lb(jn,0,Bo),Nr=0),i[0]=jn[Nr++],i[1]=jn[Nr++],i[2]=jn[Nr++],i[3]=jn[Nr++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[lt]!==void 0?u=r[lt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!d);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(o?u+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(u,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(u,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],d?[h,e]:o?(kx(e,i,h,c,u),[h]):(kx(e,i,e,0,u),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=Mb;else{if(typeof e!="number"||!zb(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let d={[lt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==bt?this.enqueue([this.dispatch,c,!1,d,o]):this.sendFrame(t.frame(c,d),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(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 d={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Or(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==bt?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(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 d={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Or(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==bt?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}send(e,r,i){let o=this._extensions[Rx.extensionName],c=r.binary?2:1,d=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Or(e)?(u=e.size,x=!1):(e=qn(e),u=e.length,x=qn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=o._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[lt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:d};Or(e)?this._state!==bt?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==bt?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[lt],this._state=Gb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Ed,this,u,o);return}this._bufferedBytes-=i[lt];let d=qn(c);r?this.dispatch(d,r,i,o):(this._state=bt,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(qb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Rx.extensionName];this._bufferedBytes+=i[lt],this._state=Hb,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Ed(this,x,o);return}this._bufferedBytes-=i[lt],this._state=bt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===bt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][lt],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Px.exports=yd;function Ed(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 qb(t,e,r){Ed(t,e,r),t.onerror(e)}});var Hx=se((B3,Ux)=>{"use strict";var{kForOnEventAttribute:qi,kListener:vd}=Wt(),Ox=Symbol("kCode"),Nx=Symbol("kData"),Lx=Symbol("kError"),Mx=Symbol("kMessage"),Bx=Symbol("kReason"),Lr=Symbol("kTarget"),Fx=Symbol("kType"),zx=Symbol("kWasClean"),$t=class{constructor(e){this[Lr]=null,this[Fx]=e}get target(){return this[Lr]}get type(){return this[Fx]}};Object.defineProperty($t.prototype,"target",{enumerable:!0});Object.defineProperty($t.prototype,"type",{enumerable:!0});var Wn=class extends $t{constructor(e,r={}){super(e),this[Ox]=r.code===void 0?0:r.code,this[Bx]=r.reason===void 0?"":r.reason,this[zx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Ox]}get reason(){return this[Bx]}get wasClean(){return this[zx]}};Object.defineProperty(Wn.prototype,"code",{enumerable:!0});Object.defineProperty(Wn.prototype,"reason",{enumerable:!0});Object.defineProperty(Wn.prototype,"wasClean",{enumerable:!0});var Mr=class extends $t{constructor(e,r={}){super(e),this[Lx]=r.error===void 0?null:r.error,this[Mx]=r.message===void 0?"":r.message}get error(){return this[Lx]}get message(){return this[Mx]}};Object.defineProperty(Mr.prototype,"error",{enumerable:!0});Object.defineProperty(Mr.prototype,"message",{enumerable:!0});var ji=class extends $t{constructor(e,r={}){super(e),this[Nx]=r.data===void 0?null:r.data}get data(){return this[Nx]}};Object.defineProperty(ji.prototype,"data",{enumerable:!0});var jb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[qi]&&o[vd]===e&&!o[qi])return;let i;if(t==="message")i=function(c,d){let u=new ji("message",{data:d?c:c.toString()});u[Lr]=this,Fo(e,this,u)};else if(t==="close")i=function(c,d){let u=new Wn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Lr]=this,Fo(e,this,u)};else if(t==="error")i=function(c){let d=new Mr("error",{error:c,message:c.message});d[Lr]=this,Fo(e,this,d)};else if(t==="open")i=function(){let c=new $t("open");c[Lr]=this,Fo(e,this,c)};else return;i[qi]=!!r[qi],i[vd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[vd]===e&&!r[qi]){this.removeListener(t,r);break}}};Ux.exports={CloseEvent:Wn,ErrorEvent:Mr,Event:$t,EventTarget:jb,MessageEvent:ji};function Fo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var zo=se((F3,Gx)=>{"use strict";var{tokenChars:Wi}=Pr();function Mt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Wb(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,d,u,x=-1,h=-1,w=-1,y=0;for(;y<t.length;y++)if(h=t.charCodeAt(y),d===void 0)if(w===-1&&Wi[h]===1)x===-1&&(x=y);else if(y!==0&&(h===32||h===9))w===-1&&x!==-1&&(w=y);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);w===-1&&(w=y);let E=t.slice(x,w);h===44?(Mt(e,E,r),r=Object.create(null)):d=E,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(u===void 0)if(w===-1&&Wi[h]===1)x===-1&&(x=y);else if(h===32||h===9)w===-1&&x!==-1&&(w=y);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);w===-1&&(w=y),Mt(r,t.slice(x,w),!0),h===44&&(Mt(e,d,r),r=Object.create(null),d=void 0),x=w=-1}else if(h===61&&x!==-1&&w===-1)u=t.slice(x,y),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(o){if(Wi[h]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);x===-1?x=y:i||(i=!0),o=!1}else if(c)if(Wi[h]===1)x===-1&&(x=y);else if(h===34&&x!==-1)c=!1,w=y;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(h===34&&t.charCodeAt(y-1)===61)c=!0;else if(w===-1&&Wi[h]===1)x===-1&&(x=y);else if(x!==-1&&(h===32||h===9))w===-1&&(w=y);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);w===-1&&(w=y);let E=t.slice(x,w);i&&(E=E.replace(/\\/g,""),i=!1),Mt(r,u,E),h===44&&(Mt(e,d,r),r=Object.create(null),d=void 0),u=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=y);let A=t.slice(x,w);return d===void 0?Mt(e,A,r):(u===void 0?Mt(r,A,!0):i?Mt(r,u,A.replace(/\\/g,"")):Mt(r,u,A),Mt(e,d,r)),e}function Kb(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(d=>d===!0?o:`${o}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Gx.exports={format:Kb,parse:Wb}});var qo=se((H3,eh)=>{"use strict";var $b=de("events"),Vb=de("https"),Jb=de("http"),Wx=de("net"),Yb=de("tls"),{randomBytes:Zb,createHash:Xb}=de("crypto"),{Duplex:z3,Readable:U3}=de("stream"),{URL:Sd}=de("url"),vn=kr(),Qb=_d(),ev=bd(),{isBlob:tv}=Pr(),{BINARY_TYPES:qx,CLOSE_TIMEOUT:nv,EMPTY_BUFFER:Uo,GUID:rv,kForOnEventAttribute:Ad,kListener:iv,kStatusCode:sv,kWebSocket:ze,NOOP:Kx}=Wt(),{EventTarget:{addEventListener:ov,removeEventListener:av}}=Hx(),{format:cv,parse:dv}=zo(),{toBuffer:lv}=Hi(),$x=Symbol("kAborted"),Id=[8,13],Vt=["CONNECTING","OPEN","CLOSING","CLOSED"],uv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pe=class t extends $b{constructor(e,r,i){super(),this._binaryType=qx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Uo,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]),Vx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){qx.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 Qb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new ev(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[ze]=this,c[ze]=this,e[ze]=this,o.on("conclude",hv),o.on("drain",pv),o.on("error",gv),o.on("message",mv),o.on("ping",wv),o.on("pong",_v),c.onerror=yv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Zx),e.on("data",Go),e.on("end",Xx),e.on("error",Qx),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){it(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Yx(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){Td(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Uo,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){Td(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Uo,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){Td(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||Uo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){it(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(pe,"CONNECTING",{enumerable:!0,value:Vt.indexOf("CONNECTING")});Object.defineProperty(pe.prototype,"CONNECTING",{enumerable:!0,value:Vt.indexOf("CONNECTING")});Object.defineProperty(pe,"OPEN",{enumerable:!0,value:Vt.indexOf("OPEN")});Object.defineProperty(pe.prototype,"OPEN",{enumerable:!0,value:Vt.indexOf("OPEN")});Object.defineProperty(pe,"CLOSING",{enumerable:!0,value:Vt.indexOf("CLOSING")});Object.defineProperty(pe.prototype,"CLOSING",{enumerable:!0,value:Vt.indexOf("CLOSING")});Object.defineProperty(pe,"CLOSED",{enumerable:!0,value:Vt.indexOf("CLOSED")});Object.defineProperty(pe.prototype,"CLOSED",{enumerable:!0,value:Vt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(pe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(pe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ad])return e[iv];return null},set(e){for(let r of this.listeners(t))if(r[Ad]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ad]:!0})}})});pe.prototype.addEventListener=ov;pe.prototype.removeEventListener=av;eh.exports=pe;function Vx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:nv,protocolVersion:Id[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,!Id.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Id.join(", ")})`);let c;if(e instanceof Sd)c=e;else try{c=new Sd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!d&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;Ho(t,I);return}let h=d?443:80,w=Zb(16).toString("base64"),y=d?Vb.request:Jb.request,A=new Set,E;if(o.createConnection=o.createConnection||(d?xv:fv),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":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(E=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=cv({[vn.extensionName]:E.offer()})),r.length){for(let I of r){if(typeof I!="string"||!uv.test(I)||A.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.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}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,R]of Object.entries(I))i.headers[S.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!d)&&(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=y(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=y(o);o.timeout&&v.on("timeout",()=>{it(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[$x]||(v=t._req=null,Ho(t,I))}),v.on("response",I=>{let S=I.headers.location,R=I.statusCode;if(S&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){it(t,v,"Maximum redirects exceeded");return}v.abort();let N;try{N=new Sd(S,e)}catch{let k=new SyntaxError(`Invalid URL: ${S}`);Ho(t,k);return}Vx(t,N,r,i)}else t.emit("unexpected-response",v,I)||it(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,R)=>{if(t.emit("upgrade",I),t.readyState!==pe.CONNECTING)return;v=t._req=null;let N=I.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){it(t,S,"Invalid Upgrade header");return}let _=Xb("sha1").update(w+rv).digest("base64");if(I.headers["sec-websocket-accept"]!==_){it(t,S,"Invalid Sec-WebSocket-Accept header");return}let k=I.headers["sec-websocket-protocol"],P;if(k!==void 0?A.size?A.has(k)||(P="Server sent an invalid subprotocol"):P="Server sent a subprotocol but none was requested":A.size&&(P="Server sent no subprotocol"),P){it(t,S,P);return}k&&(t._protocol=k);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!E){it(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=dv(B)}catch{it(t,S,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(F);if(V.length!==1||V[0]!==vn.extensionName){it(t,S,"Server indicated an extension that was not requested");return}try{E.accept(F[vn.extensionName])}catch{it(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=E}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 Ho(t,e){t._readyState=pe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function fv(t){return t.path=t.socketPath,Wx.connect(t)}function xv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Wx.isIP(t.host)?"":t.host),Yb.connect(t)}function it(t,e,r){t._readyState=pe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,it),e.setHeader?(e[$x]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Ho,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Td(t,e,r){if(e){let i=tv(e)?e.size:lv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Vt[t.readyState]})`);process.nextTick(r,i)}}function hv(t,e){let r=this[ze];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[ze]!==void 0&&(r._socket.removeListener("data",Go),process.nextTick(Jx,r._socket),t===1005?r.close():r.close(t,e))}function pv(){let t=this[ze];t.isPaused||t._socket.resume()}function gv(t){let e=this[ze];e._socket[ze]!==void 0&&(e._socket.removeListener("data",Go),process.nextTick(Jx,e._socket),e.close(t[sv])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function jx(){this[ze].emitClose()}function mv(t,e){this[ze].emit("message",t,e)}function wv(t){let e=this[ze];e._autoPong&&e.pong(t,!this._isServer,Kx),e.emit("ping",t)}function _v(t){this[ze].emit("pong",t)}function Jx(t){t.resume()}function yv(t){let e=this[ze];e.readyState!==pe.CLOSED&&(e.readyState===pe.OPEN&&(e._readyState=pe.CLOSING,Yx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Yx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Zx(){let t=this[ze];if(this.removeListener("close",Zx),this.removeListener("data",Go),this.removeListener("end",Xx),t._readyState=pe.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[ze]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",jx),t._receiver.on("finish",jx))}function Go(t){this[ze]._receiver.write(t)||this.pause()}function Xx(){let t=this[ze];t._readyState=pe.CLOSING,t._receiver.end(),this.end()}function Qx(){let t=this[ze];this.removeListener("error",Qx),this.on("error",Kx),t&&(t._readyState=pe.CLOSING,this.destroy())}});var ih=se((q3,rh)=>{"use strict";var G3=qo(),{Duplex:Ev}=de("stream");function th(t){t.emit("close")}function bv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function nh(t){this.removeListener("error",nh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function vv(t,e){let r=!0,i=new Ev({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&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(th,i);return}let d=!1;t.once("error",function(x){d=!0,c(x)}),t.once("close",function(){d||c(o),process.nextTick(th,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,d){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,d)});return}t.send(o,d)},i.on("end",bv),i.on("error",nh),i}rh.exports=vv});var Cd=se((j3,sh)=>{"use strict";var{tokenChars:Sv}=Pr();function Av(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let d=t.charCodeAt(o);if(i===-1&&Sv[d]===1)r===-1&&(r=o);else if(o!==0&&(d===32||d===9))i===-1&&r!==-1&&(i=o);else if(d===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}sh.exports={parse:Av}});var fh=se((K3,uh)=>{"use strict";var Iv=de("events"),jo=de("http"),{Duplex:W3}=de("stream"),{createHash:Tv}=de("crypto"),oh=zo(),Kn=kr(),Cv=Cd(),Dv=qo(),{CLOSE_TIMEOUT:Rv,GUID:kv,kWebSocket:Pv}=Wt(),Ov=/^[+/0-9A-Za-z]{22}==$/,ah=0,ch=1,lh=2,Dd=class extends Iv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Rv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Dv,...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=jo.createServer((i,o)=>{let c=jo.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=Nv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,d)=>{this.handleUpgrade(o,c,d,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ah}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===lh){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!==ch)if(this._state=ch,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",dh);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){$n(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){$n(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Ov.test(c)){$n(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){$n(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 x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=Cv.parse(x)}catch{$n(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&w!==void 0){let A=new Kn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=oh.parse(w);E[Kn.extensionName]&&(A.accept(E[Kn.extensionName]),y[Kn.extensionName]=A)}catch{$n(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(E,v,I,S)=>{if(!E)return $i(r,v||401,I,S);this.completeUpgrade(y,c,h,e,r,i,o)});return}if(!this.options.verifyClient(A))return $i(r,401)}this.completeUpgrade(y,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[Pv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ah)return $i(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Tv("sha1").update(r+kv).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let y=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;y&&(h.push(`Sec-WebSocket-Protocol: ${y}`),w._protocol=y)}if(e[Kn.extensionName]){let y=e[Kn.extensionName].params,A=oh.format({[Kn.extensionName]:[y]});h.push(`Sec-WebSocket-Extensions: ${A}`),w._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",dh),w.setSocket(c,d,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ki,this)})),u(w,o)}};uh.exports=Dd;function Nv(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=lh,t.emit("close")}function dh(){this.destroy()}function $i(t,e,r,i){r=r||jo.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} ${jo.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
|
|
20
|
+
`+r)}function $n(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,$n),t.emit("wsClientError",d,r,e)}else $i(r,i,o,c)}});import{existsSync as iS,openSync as sS}from"node:fs";import{mkdir as oS}from"node:fs/promises";import{dirname as aS}from"node:path";import{fileURLToPath as cS}from"node:url";function lS(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Od(t=Y()){return iS(t.libEntry)?t.libEntry:cS(new URL("../index.ts",import.meta.url))}async function Ih(t={}){let e=t.paths??Y(),r=t.entryOverride??Od(e),i=lS(e,process.env.COZE_BRIDGE_LOG_MODE);await oS(aS(i),{recursive:!0});let o=sS(i,"a"),d=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=ct(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Yi]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return dS.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var dS,Yi,Jo=Je(()=>{"use strict";yn();ne();Ie();dS=H("spawn-daemon"),Yi="COZE_BRIDGE_DAEMON"});import{spawn as XS}from"node:child_process";import{mkdir as QS,unlink as e1,writeFile as t1}from"node:fs/promises";import{dirname as n1,join as r1}from"node:path";function Ur(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function i1(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 s1(t,e){return new Promise((r,i)=>{let o=XS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var zr,Xi,na,Ud,qh=Je(()=>{"use strict";ne();zr=H("supervisor.launchd"),Xi="ai.coze.bridge",na=s1,Ud={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>${i1(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return r1(t.homeDir,"Library","LaunchAgents",`${Xi}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await QS(n1(i),{recursive:!0}),await t1(i,this.renderConfig(t),"utf8"),zr.info("plist written",{plistPath:i,activate:r}),!r)return;await na("launchctl",["unload","-w",i]).catch(c=>zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await na("launchctl",["load","-w",i]),zr.info("launchd job loaded",{label:Xi});let o=process.getuid?.()??0;await na("launchctl",["kickstart","-k",`gui/${o}/${Xi}`]),zr.info("launchd job kickstarted",{label:Xi,uid:o})},async uninstall(t){let e=this.configPath(t);await na("launchctl",["unload","-w",e]).catch(r=>zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await e1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),zr.info("launchd job removed",{plistPath:e})}}});import{spawn as o1}from"node:child_process";import{mkdir as a1,unlink as c1,writeFile as d1}from"node:fs/promises";import{dirname as l1,join as jh}from"node:path";function ia(t,e){return t.isRoot?e:["--user",...e]}function f1(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function sa(t,e){return new Promise((r,i)=>{let o=o1(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var ra,Hr,u1,Hd,Wh=Je(()=>{"use strict";ne();ra=H("supervisor.systemd"),Hr="coze-bridge.service",u1="/etc/systemd/system";Hd={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
|
+
${f1(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?jh(u1,Hr):jh(t.homeDir,".config","systemd","user",Hr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await a1(l1(i),{recursive:!0}),await d1(i,this.renderConfig(t),"utf8"),ra.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await sa("systemctl",ia(t,["daemon-reload"])),await sa("systemctl",ia(t,r?["enable","--now",Hr]:["enable",Hr])),ra.info("systemd unit enabled",{unitName:Hr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await sa("systemctl",ia(t,["disable","--now",Hr])).catch(r=>ra.warn("systemctl disable failed (ignored)",{err:String(r)})),await c1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await sa("systemctl",ia(t,["daemon-reload"])).catch(()=>{}),ra.info("systemd unit removed",{unitPath:e})}}});import{spawn as x1}from"node:child_process";import{join as h1}from"node:path";function Kh(t,e){return new Promise((r,i)=>{let o=x1(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Gd,oa,qd,$h=Je(()=>{"use strict";ne();Gd=H("supervisor.taskscheduler"),oa="CozeBridge",qd={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,44 @@ 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),
|
|
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 h1(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 Kh("schtasks",["/Create","/SC","ONLOGON","/TN",oa,"/TR",r,"/RU",t.userName,"/F"]),Gd.info("task scheduler entry created",{task:oa,logFile:t.logFile})},async uninstall(t){await Kh("schtasks",["/Delete","/TN",oa,"/F"]).catch(e=>Gd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Gd.info("task scheduler entry removed",{task:oa})}}});var Vh={};ya(Vh,{buildContext:()=>y1,getSupervisor:()=>m1,launchdSupervisor:()=>Ud,systemdSupervisor:()=>Hd,taskSchedulerSupervisor:()=>qd});import{homedir as p1,userInfo as g1}from"node:os";function m1(t=process.platform){switch(t){case"darwin":return Ud;case"linux":return Hd;case"win32":return qd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function _1(){let t={};for(let e of w1){let r=process.env[e];r&&(t[e]=r)}return t}function y1(){let t=Y();return{nodeBin:process.execPath,entry:Od(t),logFile:t.logFile,homeDir:p1(),userName:g1().username,isRoot:process.getuid?.()===0,env:_1()}}var w1,Jh=Je(()=>{"use strict";Ie();Jo();qh();Wh();$h();w1=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();en();var El=H("acp-installer-warmup"),Eg=["claude-code","codex"];async function bl(t={}){let e=t.ensure??nr,i=(await Promise.allSettled(Eg.map(async o=>{let c=await e(o);El.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&El.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 Og}from"node:fs/promises";import{mkdir as Cl,writeFile as Dl}from"node:fs/promises";import{join as Ta}from"node:path";var Pg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await Cl(t,{recursive:!0});let i=Pg[e],o=Ta(t,i);return await Dl(o,r??"","utf8"),o}async function Rl(t,e){let r=Ta(t,".claude");await Cl(r,{recursive:!0});let i=Ta(r,"settings.local.json"),o={permissions:{defaultMode:"bypassPermissions"}};e==="cloud"&&(o.autoCompactWindow=15e4);let c=JSON.stringify(o,null,2);return await Dl(i,c,"utf8"),i}var Qe=H("agent-detail-sync"),Ng=6e4,Lg=5*6e4,ls=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Og(r)}catch(o){Qe.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Qe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Qe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){Qe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),Qe.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){Qe.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Qe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){Qe.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){Qe.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Lg):Ng;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(o.agentId&&o.agentId!==e){Qe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!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,d=!0),o.deployType&&Qe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Qe.debug("detail sync: no diff",{agentId:e});return}await Ze(i,this.opts.paths),Qe.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:i.agentName}),d&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var $f=St(du(),1);import{lstat as Gc,mkdir as qc,readFile as qf,readdir as c_,rm as d_,stat as l_,writeFile as jc}from"node:fs/promises";import{dirname as u_,join as kt,normalize as f_,relative as $c,resolve as Wc,sep as jf}from"node:path";import{Readable as Wf}from"node:stream";import{pipeline as Kf}from"node:stream/promises";import rm from"events";import Xe from"fs";import{EventEmitter as Ic}from"node:events";import ju from"node:stream";import{StringDecoder as im}from"node:string_decoder";import $u from"node:path";import pr from"node:fs";import{dirname as mm,parse as wm}from"path";import{EventEmitter as Im}from"events";import ac from"assert";import{Buffer as Bn}from"buffer";import*as hu from"zlib";import Tm from"zlib";import{posix as cr}from"node:path";import{basename as ew}from"node:path";import Gs from"fs";import Ct from"fs";import Eu from"path";import{win32 as uw}from"node:path";import Cu from"path";import df from"node:fs";import Cw from"node:assert";import{randomBytes as lf}from"node:crypto";import re from"node:fs";import Oe from"node:path";import uf from"fs";import Zs from"node:fs";import mi from"node:path";import rt from"node:fs";import Lw from"node:fs/promises";import Ws from"node:path";import{join as bf}from"node:path";import nt from"node:fs";import Af from"node:path";var tm=Object.defineProperty,nm=(t,e)=>{for(var r in e)tm(t,r,{get:e[r],enumerable:!0})},lu=typeof process=="object"&&process?process:{stdout:null,stderr:null},sm=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof ju||om(t)||am(t)),om=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.pipe=="function"&&t.pipe!==ju.Writable.prototype.pipe,am=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.write=="function"&&typeof t.end=="function",Ft=Symbol("EOF"),zt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),ps=Symbol("emittingEnd"),ei=Symbol("emittedError"),gs=Symbol("closed"),uu=Symbol("read"),ms=Symbol("flush"),fu=Symbol("flushChunk"),ht=Symbol("encoding"),ar=Symbol("decoder"),Le=Symbol("flowing"),ti=Symbol("paused"),fr=Symbol("resume"),Me=Symbol("buffer"),Ke=Symbol("pipes"),Be=Symbol("bufferLength"),Oa=Symbol("bufferPush"),ws=Symbol("bufferShift"),qe=Symbol("objectMode"),ve=Symbol("destroyed"),Na=Symbol("error"),La=Symbol("emitData"),xu=Symbol("emitEnd"),Ma=Symbol("emitEnd2"),At=Symbol("async"),Ba=Symbol("abort"),_s=Symbol("aborted"),ni=Symbol("signal"),Cn=Symbol("dataListeners"),et=Symbol("discarded"),ri=t=>Promise.resolve().then(t),cm=t=>t(),dm=t=>t==="end"||t==="finish"||t==="prefinish",lm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,um=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Wu=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()}},fm=class extends Wu{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)}},xm=t=>!!t.objectMode,hm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends Ic{[Le]=!1;[ti]=!1;[Ke]=[];[Me]=[];[qe];[ht];[At];[ar];[Ft]=!1;[on]=!1;[ps]=!1;[gs]=!1;[ei]=null;[Be]=0;[ve]=!1;[ni];[_s]=!1;[Cn]=0;[et]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");xm(e)?(this[qe]=!0,this[ht]=null):hm(e)?(this[ht]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ht]=null),this[At]=!!e.async,this[ar]=this[ht]?new im(this[ht]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Me]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ke]});let{signal:r}=e;r&&(this[ni]=r,r.aborted?this[Ba]():r.addEventListener("abort",()=>this[Ba]()))}get bufferLength(){return this[Be]}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[qe]}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}[Ba](){this[_s]=!0,this.emit("abort",this[ni]?.reason),this.destroy(this[ni]?.reason)}get aborted(){return this[_s]}set aborted(t){}write(t,e,r){if(this[_s])return!1;if(this[Ft])throw new Error("write after end");if(this[ve])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[At]?ri:cm;if(!this[qe]&&!Buffer.isBuffer(t)){if(um(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(lm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Le]&&this[Be]!==0&&this[ms](!0),this[Le]?this.emit("data",t):this[Oa](t),this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le]):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[Le]&&this[Be]!==0&&this[ms](!0),this[Le]?this.emit("data",t):this[Oa](t),this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le]):(this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le])}read(t){if(this[ve])return null;if(this[et]=!1,this[Be]===0||t===0||t&&t>this[Be])return this[zt](),null;this[qe]&&(t=null),this[Me].length>1&&!this[qe]&&(this[Me]=[this[ht]?this[Me].join(""):Buffer.concat(this[Me],this[Be])]);let e=this[uu](t||null,this[Me][0]);return this[zt](),e}[uu](t,e){if(this[qe])this[ws]();else{let r=e;t===r.length||t===null?this[ws]():typeof r=="string"?(this[Me][0]=r.slice(t),e=r.slice(0,t),this[Be]-=t):(this[Me][0]=r.subarray(t),e=r.subarray(0,t),this[Be]-=t)}return this.emit("data",e),!this[Me].length&&!this[Ft]&&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[Ft]=!0,this.writable=!1,(this[Le]||!this[ti])&&this[zt](),this}[fr](){this[ve]||(!this[Cn]&&!this[Ke].length&&(this[et]=!0),this[ti]=!1,this[Le]=!0,this.emit("resume"),this[Me].length?this[ms]():this[Ft]?this[zt]():this.emit("drain"))}resume(){return this[fr]()}pause(){this[Le]=!1,this[ti]=!0,this[et]=!1}get destroyed(){return this[ve]}get flowing(){return this[Le]}get paused(){return this[ti]}[Oa](t){this[qe]?this[Be]+=1:this[Be]+=t.length,this[Me].push(t)}[ws](){return this[qe]?this[Be]-=1:this[Be]-=this[Me][0].length,this[Me].shift()}[ms](t=!1){do;while(this[fu](this[ws]())&&this[Me].length);!t&&!this[Me].length&&!this[Ft]&&this.emit("drain")}[fu](t){return this.emit("data",t),this[Le]}pipe(t,e){if(this[ve])return t;this[et]=!1;let r=this[on];return e=e||{},t===lu.stdout||t===lu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ke].push(e.proxyErrors?new fm(this,t,e):new Wu(this,t,e)),this[At]?ri(()=>this[fr]()):this[fr]()),t}unpipe(t){let e=this[Ke].find(r=>r.dest===t);e&&(this[Ke].length===1?(this[Le]&&this[Cn]===0&&(this[Le]=!1),this[Ke]=[]):this[Ke].splice(this[Ke].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[et]=!1,this[Cn]++,!this[Ke].length&&!this[Le]&&this[fr]();else if(t==="readable"&&this[Be]!==0)super.emit("readable");else if(dm(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ei]){let i=e;this[At]?ri(()=>i.call(this,this[ei])):i.call(this,this[ei])}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[et]&&!this[Ke].length&&(this[Le]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[et]&&!this[Ke].length&&(this[Le]=!1)),e}get emittedEnd(){return this[on]}[zt](){!this[ps]&&!this[on]&&!this[ve]&&this[Me].length===0&&this[Ft]&&(this[ps]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[gs]&&this.emit("close"),this[ps]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ve&&this[ve])return!1;if(t==="data")return!this[qe]&&!r?!1:this[At]?(ri(()=>this[La](r)),!0):this[La](r);if(t==="end")return this[xu]();if(t==="close"){if(this[gs]=!0,!this[on]&&!this[ve])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ei]=r,super.emit(Na,r);let o=!this[ni]||this.listeners("error").length?super.emit("error",r):!1;return this[zt](),o}else if(t==="resume"){let o=super.emit("resume");return this[zt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[zt](),i}[La](t){for(let r of this[Ke])r.dest.write(t)===!1&&this.pause();let e=this[et]?!1:super.emit("data",t);return this[zt](),e}[xu](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(ri(()=>this[Ma]()),!0):this[Ma]())}[Ma](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[Ke])r.dest.write(e);this[et]||super.emit("data",e)}}for(let e of this[Ke])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ht]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ve,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[et]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ft])return e();let i,o,c=h=>{this.off("data",d),this.off("end",u),this.off(ve,x),e(),o(h)},d=h=>{this.off("error",c),this.off("end",u),this.off(ve,x),this.pause(),i({value:h,done:!!this[Ft]})},u=()=>{this.off("error",c),this.off("data",d),this.off(ve,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,w)=>{o=w,i=h,this.once(ve,x),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[et]=!1;let t=!1,e=()=>(this.pause(),this.off(Na,e),this.off(ve,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(Na,e),this.once(ve,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ve])return t?this.emit("error",t):this.emit(ve),this;this[ve]=!0,this[et]=!0,this[Me].length=0,this[Be]=0;let e=this;return typeof e.close=="function"&&!this[gs]&&e.close(),t?this.emit("error",t):this.emit(ve),this}static get isStream(){return sm}},pm=Xe.writev,gn=Symbol("_autoClose"),wt=Symbol("_close"),ii=Symbol("_ended"),ae=Symbol("_fd"),Fa=Symbol("_finished"),qt=Symbol("_flags"),za=Symbol("_flush"),sc=Symbol("_handleChunk"),oc=Symbol("_makeBuf"),pi=Symbol("_mode"),ys=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Ua=Symbol("_onread"),xr=Symbol("_onwrite"),mn=Symbol("_open"),mt=Symbol("_path"),un=Symbol("_pos"),It=Symbol("_queue"),hr=Symbol("_read"),Ha=Symbol("_readSize"),Gt=Symbol("_reading"),si=Symbol("_remain"),Ga=Symbol("_size"),Rs=Symbol("_write"),Dn=Symbol("_writing"),ks=Symbol("_defaultFlag"),Mn=Symbol("_errored"),Tc=class extends Un{[Mn]=!1;[ae];[mt];[Ha];[Gt]=!1;[Ga];[si];[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[ae]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[Ha]=e.readSize||16*1024*1024,this[Gt]=!1,this[Ga]=typeof e.size=="number"?e.size:1/0,this[si]=this[Ga],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ae]=="number"?this[hr]():this[mn]()}get fd(){return this[ae]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){Xe.open(this[mt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[ae]=e,this.emit("open",e),this[hr]())}[oc](){return Buffer.allocUnsafe(Math.min(this[Ha],this[si]))}[hr](){if(!this[Gt]){this[Gt]=!0;let t=this[oc]();if(t.length===0)return process.nextTick(()=>this[Ua](null,0,t));Xe.read(this[ae],t,0,t.length,null,(e,r,i)=>this[Ua](e,r,i))}}[Ua](t,e,r){this[Gt]=!1,t?this[mr](t):this[sc](e,r)&&this[hr]()}[wt](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[Gt]=!0,this[wt](),this.emit("error",t)}[sc](t,e){let r=!1;return this[si]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[si]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ae]=="number"&&this[hr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},gm=class extends Tc{[mn](){let t=!0;try{this[wr](null,Xe.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[hr](){let t=!0;try{if(!this[Gt]){this[Gt]=!0;do{let e=this[oc](),r=e.length===0?0:Xe.readSync(this[ae],e,0,e.length,null);if(!this[sc](r,e))break}while(!0);this[Gt]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}},Ks=class extends rm{readable=!1;writable=!0;[Mn]=!1;[Dn]=!1;[ii]=!1;[It]=[];[ys]=!1;[mt];[pi];[gn];[ae];[ks];[qt];[Fa]=!1;[un];constructor(t,e){e=e||{},super(e),this[mt]=t,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[pi]=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[ks]=e.flags===void 0,this[qt]=e.flags===void 0?r:e.flags,this[ae]===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[ae]}get path(){return this[mt]}[mr](t){this[wt](),this[Dn]=!0,this.emit("error",t)}[mn](){Xe.open(this[mt],this[qt],this[pi],(t,e)=>this[wr](t,e))}[wr](t,e){this[ks]&&this[qt]==="r+"&&t&&t.code==="ENOENT"?(this[qt]="w",this[mn]()):t?this[mr](t):(this[ae]=e,this.emit("open",e),this[Dn]||this[za]())}end(t,e){return t&&this.write(t,e),this[ii]=!0,!this[Dn]&&!this[It].length&&typeof this[ae]=="number"&&this[xr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ii]?(this.emit("error",new Error("write() after end()")),!1):this[ae]===void 0||this[Dn]||this[It].length?(this[It].push(t),this[ys]=!0,!1):(this[Dn]=!0,this[Rs](t),!0)}[Rs](t){Xe.write(this[ae],t,0,t.length,this[un],(e,r)=>this[xr](e,r))}[xr](t,e){t?this[mr](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[It].length?this[za]():(this[Dn]=!1,this[ii]&&!this[Fa]?(this[Fa]=!0,this[wt](),this.emit("finish")):this[ys]&&(this[ys]=!1,this.emit("drain"))))}[za](){if(this[It].length===0)this[ii]&&this[xr](null,0);else if(this[It].length===1)this[Rs](this[It].pop());else{let t=this[It];this[It]=[],pm(this[ae],t,this[un],(e,r)=>this[xr](e,r))}}[wt](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ku=class extends Ks{[mn](){let t;if(this[ks]&&this[qt]==="r+")try{t=Xe.openSync(this[mt],this[qt],this[pi])}catch(e){if(e?.code==="ENOENT")return this[qt]="w",this[mn]();throw e}else t=Xe.openSync(this[mt],this[qt],this[pi]);this[wr](null,t)}[wt](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}[Rs](t){let e=!0;try{this[xr](null,Xe.writeSync(this[ae],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[wt]()}catch{}}}},_m=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"]]),ym=t=>!!t.sync&&!!t.file,Em=t=>!t.sync&&!!t.file,bm=t=>!!t.sync&&!t.file,vm=t=>!t.sync&&!t.file,Sm=t=>!!t.file,Am=t=>_m.get(t)||t,Cc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Am(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Si=(t,e,r,i,o)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let x=Cc(c);if(o?.(x,d),ym(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,d)}else if(Em(x)){let h=e(x,d);return u?h.then(()=>u(),u):h}else if(bm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,d)}else if(vm(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Cm=Tm.constants||{ZLIB_VERNUM:4736},Rt=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},Cm)),Dm=Bn.concat,pu=Object.getOwnPropertyDescriptor(Bn,"concat"),Rm=t=>t,qa=pu?.writable===!0||pu?.set!==void 0?t=>{Bn.concat=t?Rm:Dm}:t=>{},Fn=Symbol("_superWrite"),Es=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"}},ja=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 hu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new hu[e](t)}catch(r){throw new Es(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 Es(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ac(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),{[ja]: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;ac(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},qa(!0);let d;try{let x=typeof t[ja]=="number"?t[ja]:this.#r;d=this.#t._processChunk(t,x),qa(!1)}catch(x){qa(!1),this.#o(new Es(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 Es(x,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let x=d[0];u=this[Fn](Bn.from(x));for(let h=1;h<d.length;h++)u=this[Fn](d[h])}else u=this[Fn](Bn.from(d));return r&&r(),u}},Vu=class extends Dc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Rt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Rt.Z_FINISH,t.fullFlushFlag=Rt.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(Rt.Z_SYNC_FLUSH),ac(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)}}}},km=class extends Vu{#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)}},Pm=class extends Vu{constructor(t){super(t,"Unzip")}},Ju=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Rt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Rt.BROTLI_OPERATION_FLUSH,super(t,e)}},Om=class extends Ju{constructor(t){super(t,"BrotliCompress")}},Nm=class extends Ju{constructor(t){super(t,"BrotliDecompress")}},Yu=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Rt.ZSTD_e_end,t.fullFlushFlag=Rt.ZSTD_e_flush,super(t,e)}},Lm=class extends Yu{constructor(t){super(t,"ZstdCompress")}},Mm=class extends Yu{constructor(t){super(t,"ZstdDecompress")}},Bm=(t,e)=>{if(Number.isSafeInteger(t))t<0?zm(t,e):Fm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Fm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},zm=(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]=Zu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Xu(o))}},Um=t=>{let e=t[0],r=e===128?Gm(t.subarray(1,t.length)):e===255?Hm(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},Hm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=Zu(c):c===0?d=c:(i=!0,d=Xu(c)),d!==0&&(r-=d*Math.pow(256,e-o-1))}return r},Gm=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},Zu=t=>(255^t)&255,Xu=t=>(255^t)+1&255,qm={};nm(qm,{code:()=>Rc,isCode:()=>Ps,isName:()=>jm,name:()=>$s});var Ps=t=>$s.has(t),jm=t=>Rc.has(t),$s=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Rc=new Map(Array.from($s).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??Rn(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??Wa(t,e+136,12),this.cksum=fn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Rn(t,e+156,1);if(Ps(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Rn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Rn(t,e+265,32),this.gname=r?.gname??i?.gname??Rn(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 d=Rn(t,e+345,155);this.path=d+"/"+this.path}else{let d=Rn(t,e+345,130);d&&(this.path=d+"/"+this.path),this.atime=r?.atime??i?.atime??Wa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Wa(t,e+488,12)}let c=256;for(let d=e;d<e+148;d++)c+=t[d];for(let d=e+156;d<e+512;d++)c+=t[d];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,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=Wm(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=Ka(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=Ka(t,e+476,12,this.atime)||this.needPax,this.needPax=Ka(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,xn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:$s.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Rc.get(t));if(Ps(e)||e==="Unsupported")this.#e=e;else if(Ps(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Wm=(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},Rn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Wa=(t,e,r)=>Km(fn(t,e,r)),Km=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?Um(t.subarray(e,e+r)):Vm(t,e,r),$m=t=>isNaN(t)?void 0:t,Vm=(t,e,r)=>$m(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Jm={12:8589934591,8:2097151},xn=(t,e,r,i)=>i===void 0?!1:i>Jm[r]||i<0?(Bm(i,t.subarray(e,e+r)),!0):(Ym(t,e,r,i),!1),Ym=(t,e,r,i)=>t.write(Zm(i,r),e,r,"ascii"),Zm=(t,e)=>Xm(Math.floor(t).toString(8),e),Xm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ka=(t,e,r,i)=>i===void 0?!1:xn(t,e,r,i.getTime()/1e3),Qm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Qm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Hs=class Qu{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/"+ew(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),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+o}static parse(e,r,i=!1){return new Qu(tw(nw(e),r),i)}},tw=(t,e)=>e?Object.assign({},e,t):t,nw=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(rw,Object.create(null)),rw=(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"),d=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},iw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=iw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),ef=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))))}},Vs=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},sw=1024*1024,cc=Buffer.from([31,139]),dc=Buffer.from([40,181,47,253]),ow=Math.max(cc.length,dc.length),ot=Symbol("state"),Pn=Symbol("writeEntry"),Ut=Symbol("readEntry"),$a=Symbol("nextEntry"),gu=Symbol("processEntry"),Tt=Symbol("extendedHeader"),oi=Symbol("globalExtendedHeader"),an=Symbol("meta"),mu=Symbol("emitMeta"),fe=Symbol("buffer"),Ht=Symbol("queue"),cn=Symbol("ended"),Va=Symbol("emittedEnd"),On=Symbol("emit"),Te=Symbol("unzip"),bs=Symbol("consumeChunk"),vs=Symbol("consumeChunkSub"),Ja=Symbol("consumeBody"),wu=Symbol("consumeMeta"),_u=Symbol("consumeHeader"),ai=Symbol("consuming"),Ya=Symbol("bufferConcat"),Ss=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),As=Symbol("onDone"),Nn=Symbol("sawValidEntry"),Is=Symbol("sawNullBlock"),Ts=Symbol("sawEOF"),yu=Symbol("closeStream"),aw=()=>!0,vi=class extends Im{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ht]=[];[fe];[Ut];[Pn];[ot]="begin";[an]="";[Tt];[oi];[cn]=!1;[Te];[dn]=!1;[Nn];[Is]=!1;[Ts]=!1;[dr]=!1;[ai]=!1;[Va]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(As,()=>{(this[ot]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(As,t.ondone):this.on(As,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||sw,this.filter=typeof t.filter=="function"?t.filter:aw;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[yu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Vs(this,t,e,r)}[_u](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new zn(t,e,this[Tt],this[oi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Is]?(this[Ts]=!0,this[ot]==="begin"&&(this[ot]="header"),this[On]("eof")):(this[Is]=!0,this[On]("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 ef(r,this[Tt],this[oi]);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[On]("ignoredEntry",o),this[ot]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[ot]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[On]("ignoredEntry",o),this[ot]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ot]="body":(this[ot]="header",o.end()),this[Ut]?this[Ht].push(o):(this[Ht].push(o),this[$a]())))}}}[yu](){queueMicrotask(()=>this.emit("close"))}[gu](t){let e=!0;if(!t)this[Ut]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ut]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[$a]()),e=!1);return e}[$a](){do;while(this[gu](this[Ht].shift()));if(this[Ht].length===0){let t=this[Ut];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ja](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[ot]="header",this[Pn]=void 0,r.end()),o.length}[wu](t,e){let r=this[Pn],i=this[Ja](t,e);return!this[Pn]&&r&&this[mu](r),i}[On](t,e,r){this[Ht].length===0&&!this[Ut]?this.emit(t,e,r):this[Ht].push([t,e,r])}[mu](t){switch(this[On]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=Hs.parse(this[an],this[Tt],!1);break;case"GlobalExtendedHeader":this[oi]=Hs.parse(this[an],this[oi],!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[fe]&&(t=Buffer.concat([this[fe],t]),this[fe]=void 0),t.length<ow)return this[fe]=t,r?.(),!0;for(let d=0;this[Te]===void 0&&d<cc.length;d++)t[d]!==cc[d]&&(this[Te]=!1);let o=!1;if(this[Te]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<dc.length;d++)if(t[d]!==dc[d]){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[fe]=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 d=this[cn];this[cn]=!1,this[Te]=this[Te]===void 0?new Pm({}):o?new Mm({}):new Nm({}),this[Te].on("data",x=>this[bs](x)),this[Te].on("error",x=>this.abort(x)),this[Te].on("end",()=>{this[cn]=!0,this[bs]()}),this[dr]=!0;let u=!!this[Te][d?"end":"write"](t);return this[dr]=!1,r?.(),u}}this[dr]=!0,this[Te]?this[Te].write(t):this[bs](t),this[dr]=!1;let i=this[Ht].length>0?!1:this[Ut]?this[Ut].flowing:!0;return!i&&this[Ht].length===0&&this[Ut]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ya](t){t&&!this[dn]&&(this[fe]=this[fe]?Buffer.concat([this[fe],t]):t)}[Ss](){if(this[cn]&&!this[Va]&&!this[dn]&&!this[ai]){this[Va]=!0;let t=this[Pn];if(t&&t.blockRemain){let e=this[fe]?this[fe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[fe]&&t.write(this[fe]),t.end()}this[On](As)}}[bs](t){if(this[ai]&&t)this[Ya](t);else if(!t&&!this[fe])this[Ss]();else if(t){if(this[ai]=!0,this[fe]){this[Ya](t);let e=this[fe];this[fe]=void 0,this[vs](e)}else this[vs](t);for(;this[fe]&&this[fe]?.length>=512&&!this[dn]&&!this[Ts];){let e=this[fe];this[fe]=void 0,this[vs](e)}this[ai]=!1}(!this[fe]||this[cn])&&this[Ss]()}[vs](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ts];)switch(this[ot]){case"begin":case"header":this[_u](t,e),e+=512;break;case"ignore":case"body":e+=this[Ja](t,e);break;case"meta":e+=this[wu](t,e);break;default:throw new Error("invalid state: "+this[ot])}e<r&&(this[fe]=this[fe]?Buffer.concat([t.subarray(e),this[fe]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[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[Ss]())),this}},gi=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)},cw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},tf=(t,e)=>{let r=new Map(e.map(c=>[gi(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||wm(c).root||".",x;if(c===u)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(mm(c),u)}return r.set(c,x),x};t.filter=i?(c,d)=>i(c,d)&&o(gi(c)):c=>o(gi(c))},dw=t=>{let e=new vi(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 d=Buffer.allocUnsafe(o.size),u=pr.readSync(i,d,0,o.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<o.size;){let x=pr.readSync(i,u,0,c,d);if(x===0)break;d+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},lw=(t,e)=>{let r=new vi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),pr.stat(o,(u,x)=>{if(u)d(u);else{let h=new Tc(o,{readSize:i,size:x.size});h.on("error",d),h.pipe(r)}})})},_r=Si(dw,lw,t=>new vi(t),t=>new vi(t),(t,e)=>{e?.length&&tf(t,e),t.noResume||cw(t)}),nf=(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:fw,parse:bu}=uw,kc=t=>{let e="",r=bu(t);for(;fw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=bu(t)}return[e,t]},Js=["|","<",">","?",":"],Pc=Js.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),xw=new Map(Js.map((t,e)=>[t,Pc[e]])),hw=new Map(Pc.map((t,e)=>[t,Js[e]])),vu=t=>Js.reduce((e,r)=>e.split(r).join(xw.get(r)),t),pw=t=>Pc.reduce((e,r)=>e.split(r).join(hw.get(r)),t),rf=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),gi(e)+"/"+t):Z(t),gw=16*1024*1024,Su=Symbol("process"),Au=Symbol("file"),Iu=Symbol("directory"),lc=Symbol("symlink"),Tu=Symbol("hardlink"),ci=Symbol("header"),Os=Symbol("read"),uc=Symbol("lstat"),Ns=Symbol("onlstat"),fc=Symbol("onread"),xc=Symbol("onreadlink"),hc=Symbol("openfile"),pc=Symbol("onopenfile"),hn=Symbol("close"),qs=Symbol("mode"),gc=Symbol("awaitDrain"),Za=Symbol("ondrain"),Dt=Symbol("prefix"),sf=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=Cc(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||gw,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,d]=kc(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=pw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||Eu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ns](o):this[uc]()}warn(t,e,r={}){return Vs(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[Ns](e)})}[Ns](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=_w(t),this.emit("stat",t),this[Su]()}[Su](){switch(this.type){case"File":return this[Au]();case"Directory":return this[Iu]();case"SymbolicLink":return this[lc]();default:return this.end()}}[qs](t){return nf(t,this.type==="Directory",this.portable)}[Dt](t){return rf(t,this.prefix)}[ci](){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[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](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 Hs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](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)}[Iu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ci](),this.end()}[lc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[xc](e)})}[xc](t){this.linkpath=Z(t),this[ci](),this.end()}[Tu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(Eu.relative(this.cwd,t)),this.stat.size=0,this[ci](),this.end()}[Au](){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[Tu](e);this.linkCache.set(t,this.absolute)}if(this[ci](),this.stat.size===0)return this.end();this[hc]()}[hc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[pc](e)})}[pc](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[Os]()}[Os](){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,d)=>{if(c)return this[hn](()=>this.emit("error",c));this[fc](d)})}[hn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[fc](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[Za]():this[gc](()=>this[Za]())}[gc](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)}[Za](){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[Os]()}},mw=class extends sf{sync=!0;[uc](){this[Ns](Ct.lstatSync(this.absolute))}[lc](){this[xc](Ct.readlinkSync(this.absolute))}[hc](){this[pc](Ct.openSync(this.absolute,"r"))}[Os](){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 d=Ct.readSync(e,r,i,o,c);this[fc](d),t=!1}finally{if(t)try{this[hn](()=>{})}catch{}}}[gc](t){t()}[hn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},ww=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 Vs(this,t,e,r)}constructor(t,e={}){let r=Cc(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[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?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[d,u]=kc(this.path);d&&typeof u=="string"&&(this.path=u,o=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new zn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new Hs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](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)}[Dt](t){return rf(t,this.prefix)}[qs](t){return nf(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}},_w=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",yw=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++)bw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)vw(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 d=0;o&&d<e;d++)o=o.next;let c=[];for(let d=0;o&&d<r;d++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let d of i)o=Ew(this,o,d);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 Ew(t,e,r){let i=e,o=e?e.next:t.head,c=new Oc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function bw(t,e){t.tail=new Oc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function vw(t,e){t.head=new Oc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Oc=class{list;next;prev;value;constructor(t,e,r,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}},Du=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Ru=Buffer.alloc(1024),Ls=Symbol("onStat"),di=Symbol("ended"),pt=Symbol("queue"),li=Symbol("queue"),ln=Symbol("current"),Ln=Symbol("process"),ui=Symbol("processing"),Cs=Symbol("processJob"),gt=Symbol("jobs"),Xa=Symbol("jobDone"),Ms=Symbol("addFSEntry"),ku=Symbol("addTarEntry"),mc=Symbol("stat"),wc=Symbol("readdir"),Bs=Symbol("onreaddir"),Fs=Symbol("pipe"),Pu=Symbol("entry"),Qa=Symbol("entryOpt"),zs=Symbol("writeEntryClass"),of=Symbol("write"),ec=Symbol("ondrain"),Ys=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;[pt];[li]=new Map;[gt]=0;[ui]=!1;[di]=!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[zs]=sf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new km(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Om(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Lm(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[ec]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ec]);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 yw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[ui]=!1,this[di]=!1}[of](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[di]=!0,this[Ln](),r&&r(),this}write(t){if(this[di])throw new Error("write after end");return t instanceof ef?this[ku](t):this[Ms](t),this.flowing}[ku](t){let e=Z(Cu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Du(t.path,e);r.entry=new ww(t,this[Qa](r)),r.entry.on("end",()=>this[Xa](r)),this[gt]+=1,this[pt].push(r)}this[Ln]()}[Ms](t){let e=Z(Cu.resolve(this.cwd,t));this[pt].push(new Du(t,e)),this[Ln]()}[mc](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";Gs[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Ls](t,i)})}[Ls](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Cs](t);else{let r=`${e.dev}:${e.ino}`,i=this[li].get(r);i?i.push(t):this[li].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[wc](t){t.pending=!0,this[gt]+=1,Gs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Bs](t,r)})}[Bs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[ui]){this[ui]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[Cs](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[ui]=!1,this[di]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(Ru):(super.write(Ru),super.end()))}}get[ln](){return this[pt]&&this[pt].head&&this[pt].head.value}[Xa](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[li].get(r);if(i){this[li].delete(r);for(let o of i)o.pending=!1,this[Cs](o)}}this[Ln]()}[Cs](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[Fs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ls](t,e):this[mc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Bs](t,e):this[wc](t),!t.readdir)return}if(t.entry=this[Pu](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Fs](t)}}}[Qa](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}}[Pu](t){this[gt]+=1;try{return new this[zs](t.path,this[Qa](t)).on("end",()=>this[Xa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ec](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Fs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ms](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Vs(this,t,e,r)}},Nc=class extends Ys{sync=!0;constructor(t){super(t),this[zs]=mw}pause(){}resume(){}[mc](t){let e=this.follow?"statSync":"lstatSync";this[Ls](t,Gs[e](t.absolute))}[wc](t){this[Bs](t,Gs.readdirSync(t.absolute))}[Fs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ms](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[of](i)})}},Sw=(t,e)=>{let r=new Nc(t),i=new Ku(t.file,{mode:t.mode||438});r.pipe(i),af(r,e)},Aw=(t,e)=>{let r=new Ys(t),i=new Ks(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,d)=>{i.on("error",d),i.on("close",c),r.on("error",d)});return cf(r,e).catch(c=>r.emit("error",c)),o},af=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:$u.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},cf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:$u.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Iw=(t,e)=>{let r=new Nc(t);return af(r,e),r},Tw=(t,e)=>{let r=new Ys(t);return cf(r,e).catch(i=>r.emit("error",i)),r},nA=Si(Sw,Aw,Iw,Tw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Dw=process.env.__FAKE_PLATFORM__||process.platform,ff=Dw==="win32",{O_CREAT:xf,O_NOFOLLOW:Ou,O_TRUNC:hf,O_WRONLY:pf}=uf.constants,gf=Number(process.env.__FAKE_FS_O_FILENAME__)||uf.constants.UV_FS_O_FILEMAP||0,Rw=ff&&!!gf,kw=512*1024,Pw=gf|hf|xf|pf,Nu=!ff&&typeof Ou=="number"?Ou|hf|xf|pf:null,mf=Nu!==null?()=>Nu:Rw?t=>t<kw?Pw:"w":()=>"w",_c=(t,e,r)=>{try{return Zs.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},js=(t,e,r,i)=>{Zs.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Ow=(t,e,r,i,o)=>{if(e.isDirectory())wf(mi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let d=mi.resolve(t,e.name);js(d,r,i,o)});else{let c=mi.resolve(t,e.name);js(c,r,i,o)}},wf=(t,e,r,i)=>{Zs.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 js(t,e,r,i);let d=c.length,u=null,x=h=>{if(!u){if(h)return i(u=h);if(--d===0)return js(t,e,r,i)}};for(let h of c)Ow(t,h,e,r,x)})},Nw=(t,e,r,i)=>{e.isDirectory()&&_f(mi.resolve(t,e.name),r,i),_c(mi.resolve(t,e.name),r,i)},_f=(t,e,r)=>{let i;try{i=Zs.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return _c(t,e,r);throw c}for(let o of i)Nw(t,o,e,r);return _c(t,e,r)},yf=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"}},Xs=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"}},Mw=(t,e)=>{rt.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new yf(t,r?.code||"ENOTDIR")),e(r)})},Bw=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,d=e.uid,u=e.gid,x=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),h=e.preserve,w=e.unlink,y=Z(e.cwd),A=(v,I)=>{v?r(v):I&&x?wf(I,d,u,S=>A(S)):c?rt.chmod(t,o,r):r()};if(t===y)return Mw(t,A);if(h)return Lw.mkdir(t,{mode:o,recursive:!0}).then(v=>A(null,v??void 0),A);let E=Z(Ws.relative(y,t)).split("/");yc(y,E,o,w,y,void 0,A)},yc=(t,e,r,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),x=Z(Ws.resolve(t+"/"+u));rt.mkdir(x,r,Ef(x,e,r,i,o,c,d))},Ef=(t,e,r,i,o,c,d)=>u=>{u?rt.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),d(x);else if(h.isDirectory())yc(t,e,r,i,o,c,d);else if(i)rt.unlink(t,w=>{if(w)return d(w);rt.mkdir(t,r,Ef(t,e,r,i,o,c,d))});else{if(h.isSymbolicLink())return d(new Xs(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,yc(t,e,r,i,o,c,d))},Fw=t=>{let e=!1,r;try{e=rt.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new yf(t,r??"ENOTDIR")}},zw=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),x=e.preserve,h=e.unlink,w=Z(e.cwd),y=v=>{v&&u&&_f(v,c,d),o&&rt.chmodSync(t,i)};if(t===w)return Fw(w),y();if(x)return y(rt.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=Z(Ws.relative(w,t)).split("/"),E;for(let v=A.shift(),I=w;v&&(I+="/"+v);v=A.shift()){I=Z(Ws.resolve(I));try{rt.mkdirSync(I,i),E=E||I}catch{let S=rt.lstatSync(I);if(S.isDirectory())continue;if(h){rt.unlinkSync(I),rt.mkdirSync(I,i),E=E||I;continue}else if(S.isSymbolicLink())return new Xs(I,I+"/"+A.join("/"))}}return y(E)},tc=Object.create(null),Lu=1e4,lr=new Set,Uw=t=>{lr.has(t)?lr.delete(t):tc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=tc[t],r=lr.size-Lu;if(r>Lu/10){for(let i of lr)if(lr.delete(i),delete tc[i],--r<=0)break}return e},Hw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Gw=Hw==="win32",qw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=bf(i,r)),e.push(r||"/"),e},[]),jw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Gw?["win32 parallelization disabled"]:t.map(i=>gi(bf(Uw(i))));let r=new Set(t.map(i=>qw(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 d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")o.add(u);else for(let x of u)o.add(x)}for(let c of i){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let x=d[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Ww=()=>process.umask(),Mu=Symbol("onEntry"),Ec=Symbol("checkFs"),Bu=Symbol("checkFs2"),bc=Symbol("isReusable"),at=Symbol("makeFs"),vc=Symbol("file"),Sc=Symbol("directory"),Us=Symbol("link"),Fu=Symbol("symlink"),zu=Symbol("hardlink"),hi=Symbol("ensureNoSymlink"),Uu=Symbol("unsupported"),Hu=Symbol("checkPath"),nc=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),Fe=Symbol("onError"),Ds=Symbol("pending"),Gu=Symbol("pend"),ur=Symbol("unpend"),rc=Symbol("ended"),ic=Symbol("maybeClose"),Ac=Symbol("skip"),wi=Symbol("doChown"),_i=Symbol("uid"),yi=Symbol("gid"),Ei=Symbol("checkedCwd"),Kw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,bi=Kw==="win32",$w=1024,Vw=(t,e)=>{if(!bi)return re.unlink(t,e);let r=t+".DELETE."+lf(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Jw=t=>{if(!bi)return re.unlinkSync(t);let e=t+".DELETE."+lf(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},qu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Lc=class extends vi{[rc]=!1;[Ei]=!1;[Ds]=0;reservations=new jw;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[rc]=!0,this[ic]()},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:$w,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||bi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Oe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Ww():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[Mu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ic](){this[rc]&&this[Ds]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[nc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=kc(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||bi&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Oe.posix.dirname(t.path),x=Oe.posix.normalize(Oe.posix.join(u,d.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Hu](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[nc](t,"path")||!this[nc](t,"linkpath"))return!1;if(t.absolute=Oe.isAbsolute(t.path)?Z(Oe.resolve(t.path)):Z(Oe.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}=Oe.win32.parse(String(t.absolute));t.absolute=i+vu(String(t.absolute).slice(i.length));let{root:o}=Oe.win32.parse(t.path);t.path=o+vu(t.path.slice(o.length))}return!0}[Mu](t){if(!this[Hu](t))return t.resume();switch(Cw.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[Uu](t)}}[Fe](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){Bw(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)}[wi](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}[_i](t){return qu(this.uid,t.uid,this.processUid)}[yi](t){return qu(this.gid,t.gid,this.processGid)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ks(String(t.absolute),{flags:mf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[Fe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&re.close(i.fd,()=>{}),this[Fe](u,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[Fe](x,t):this[ur](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let h=t.atime||new Date,w=t.mtime;re.futimes(x,h,w,y=>y?re.utimes(u,h,w,A=>c(A&&y)):c())}if(typeof x=="number"&&this[wi](t)){o++;let h=this[_i](t),w=this[yi](t);typeof h=="number"&&typeof w=="number"&&re.fchown(x,h,w,y=>y?re.chown(u,h,w,A=>c(A&&y)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[Fe](u,t),e()}),t.pipe(d)),d.pipe(i)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[Fe](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[wi](t)&&(o++,re.chown(String(t.absolute),Number(this[_i](t)),Number(this[yi](t)),c)),c()})}[Uu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Fu](t,e){let r=Z(Oe.relative(this.cwd,Oe.resolve(Oe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[hi](t,this.cwd,r,()=>this[Us](t,String(t.linkpath),"symlink",e),i=>{this[Fe](i,t),e()})}[zu](t,e){let r=Z(Oe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[hi](t,this.cwd,i,()=>this[Us](t,r,"link",e),o=>{this[Fe](o,t),e()})}[hi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let d=Oe.resolve(e,c);re.lstat(d,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new Xs(d,Oe.resolve(d,r.join("/"))));this[hi](t,d,r,i,o)})}[Gu](){this[Ds]++}[ur](){this[Ds]--,this[ic]()}[Ac](t){this[ur](),t.resume()}[bc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!bi}[Ec](t){this[Gu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Bu](t,r))}[Bu](t,e){let r=d=>{e(d)},i=()=>{this[pn](this.cwd,this.dmode,d=>{if(d){this[Fe](d,t),r();return}this[Ei]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=Z(Oe.dirname(String(t.absolute)));if(d!==this.cwd)return this[pn](d,this.dmode,u=>{if(u){this[Fe](u,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ac](t),r();return}if(d||this[bc](t,u))return this[at](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,h=w=>this[at](w??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[at](x??null,t,r))}if(t.absolute===this.cwd)return this[at](null,t,r);Vw(String(t.absolute),x=>this[at](x??null,t,r))})};this[Ei]?o():i()}[at](t,e,r){if(t){this[Fe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[vc](e,r);case"Link":return this[zu](e,r);case"SymbolicLink":return this[Fu](e,r);case"Directory":case"GNUDumpDir":return this[Sc](e,r)}}[Us](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[Fe](o,t):(this[ur](),t.resume()),i()})}},fi=t=>{try{return[null,t()]}catch(e){return[e,null]}},vf=class extends Lc{sync=!0;[at](t,e){return super[at](t,e,()=>{})}[Ec](t){if(!this[Ei]){let o=this[pn](this.cwd,this.dmode);if(o)return this[Fe](o,t);this[Ei]=!0}if(t.absolute!==this.cwd){let o=Z(Oe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[Fe](c,t)}}let[e,r]=fi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ac](t);if(e||this[bc](t,r))return this[at](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?fi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[at](d,t)}let[o]=fi(()=>re.rmdirSync(String(t.absolute)));this[at](o,t)}let[i]=t.absolute===this.cwd?[]:fi(()=>Jw(String(t.absolute)));this[at](i,t)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{re.closeSync(o)}catch(x){u=x}(d||u)&&this[Fe](d||u,t),e()},o;try{o=re.openSync(String(t.absolute),mf(t.size),r)}catch(d){return i(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[Fe](d,t)),t.pipe(c)),c.on("data",d=>{try{re.writeSync(o,d,0,d.length)}catch(u){i(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,u,x)}catch(h){try{re.utimesSync(String(t.absolute),u,x)}catch{d=h}}}if(this[wi](t)){let u=this[_i](t),x=this[yi](t);try{re.fchownSync(o,Number(u),Number(x))}catch(h){try{re.chownSync(String(t.absolute),Number(u),Number(x))}catch{d=d||h}}}i(d)})}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[Fe](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[wi](t))try{re.chownSync(String(t.absolute),Number(this[_i](t)),Number(this[yi](t)))}catch{}e(),t.resume()}[pn](t,e){try{return zw(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}}[hi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let d of r){c=Oe.resolve(c,d);let[u,x]=fi(()=>re.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new Xs(c,Oe.resolve(e,r.join("/"))))}i()}[Us](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Fe](c,t)}}},Yw=t=>{let e=new vf(t),r=t.file,i=df.statSync(r),o=t.maxReadSize||16*1024*1024;new gm(r,{readSize:o,size:i.size}).pipe(e)},Zw=(t,e)=>{let r=new Lc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),df.stat(o,(u,x)=>{if(u)d(u);else{let h=new Tc(o,{readSize:i,size:x.size});h.on("error",d),h.pipe(r)}})})},Sf=Si(Yw,Zw,t=>new vf(t),t=>new Lc(t),(t,e)=>{e?.length&&tf(t,e)}),Xw=(t,e)=>{let r=new Nc(t),i=!0,o,c;try{try{o=nt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=nt.openSync(t.file,"w+");else throw x}let d=nt.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let w=0,y=0;w<512;w+=y){if(y=nt.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(!y)break e}let x=new zn(u);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>d.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Qw(t,r,c,o,e)}finally{if(i)try{nt.closeSync(o)}catch{}}},Qw=(t,e,r,i,o)=>{let c=new Ku(t.file,{fd:i,start:r});e.pipe(c),t_(e,o)},e_=(t,e)=>{e=Array.from(e);let r=new Ys(t),i=(o,c,d)=>{let u=(A,E)=>{A?nt.close(o,v=>d(A)):d(null,E)},x=0;if(c===0)return u(null,0);let h=0,w=Buffer.alloc(512),y=(A,E)=>{if(A||E===void 0)return u(A);if(h+=E,h<512&&E)return nt.read(o,w,h,w.length-h,x+h,y);if(x===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(h<512)return u(null,x);let v=new zn(w);if(!v.cksumValid)return u(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),h=0,nt.read(o,w,0,512,x,y)};nt.read(o,w,0,512,x,y)};return new Promise((o,c)=>{r.on("error",c);let d="r+",u=(x,h)=>{if(x&&x.code==="ENOENT"&&d==="r+")return d="w+",nt.open(t.file,d,u);if(x||!h)return c(x);nt.fstat(h,(w,y)=>{if(w)return nt.close(h,()=>c(w));i(h,y.size,(A,E)=>{if(A)return c(A);let v=new Ks(t.file,{fd:h,start:E});r.pipe(v),v.on("error",c),v.on("close",o),n_(r,e)})})};nt.open(t.file,d,u)})},t_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:Af.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},n_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:Af.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},xi=Si(Xw,e_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Sm(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")}),mA=Si(xi.syncFile,xi.asyncFile,xi.syncNoFile,xi.asyncNoFile,(t,e=[])=>{xi.validate?.(t,e),r_(t)}),r_=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 Ai(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function If(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Mc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Tf(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}je();ne();Ie();je();function jt(t,e){if(Ai(t)!=="cloud")throw new D("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Qs(t){return t.startsWith("http://")||t.startsWith("https://")}function eo(t){return t.endsWith("/")?t.slice(0,-1):t}je();ne();var to="1008033",Cf="1289";var Df="pbbp2",Rf="https://www.coze.cn",kf="/api/coze_claw/resource/get_frontier_key",s_="https://www.coze.cn",o_="wss://frontier.coze.cn";function no(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??s_}function Pf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??o_}function Er(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 Ti(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ii=H("handshake");async function Bc(t){let e=no(t.endpoint),r=t.timeoutMs??1e4,i=`${eo(e)}${kf}?aid=${encodeURIComponent(to)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Er(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),r);Ii.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",h=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let y=w.data??{},A=typeof y.access_key=="string"&&y.access_key||typeof y.accessKey=="string"&&y.accessKey||void 0,E=typeof y.device_id=="string"&&y.device_id||typeof y.deviceId=="string"&&y.deviceId||void 0;if(!A||!E){let v=JSON.stringify(w).slice(0,500);throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ii.info("handshake ok",{remoteDeviceId:E,logid:x,traceId:h}),{accessKey:A,deviceId:E}}catch(u){if(u instanceof D)throw Ii.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ii.warn("handshake timeout",{base:e,timeoutMs:r}),new D("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw Ii.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new D("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var Fc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",Of=15e4;function Nf(t){return{model:zc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Lf(t){return!t||t===yt}var a_=new Set(["auto","\u81EA\u52A8"]);function zc(t){let e=t?.trim();if(e)return a_.has(e.toLowerCase())?yt:e}function Mf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Fc,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 Lf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Bf(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):Lf(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="${Fc}/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??Of;e.push("-c",`model_context_window=${r}`)}return e}function Ff(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Uc(t,e){let{ttEnv:r,usePpe:i}=Ti(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function zf(t,e,r){if(!t.modelToken)return{};let i=Uc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,d])=>`${c}:${d}`).join(`
|
|
92
|
+
`)}}function Hc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Uf(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=Uc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${Fc}/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??Of,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Hf(t,e,r){if(!t.modelToken)return[];let i=Uc(e,r),o=[];for(let[c,d]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var Ne=H("agent-handlers"),Gf=5*1024*1024,x_=1,h_=6,p_=new Set(["node_modules",".git",".coze","dist","build",".next"]),ro=class{constructor(e){this.opts=e}opts;async listSkills(e){jt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??We(r).workspace,c=i?.skills??[],d=[];for(let u of c){let x=kt(o,u.relPath,"SKILL.md");await l_(x).then(w=>w.isFile()).catch(()=>!1)&&d.push(y_(u))}return{skills:d}}async addSkills(e){jt(e._meta,"_agent/addSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],d=new Map(c.map((x,h)=>[x.skillId,h])),u=[];for(let x of o){let h=await Vc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Jc(c,d,h),u.push(x)}return await cs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){jt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],d=[];for(let u of c){if(!o.has(u.skillId)){d.push(u);continue}let x=kt(i.workspace,u.relPath);await d_(x,{recursive:!0,force:!0}),Ne.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await cs(r,d),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 d=c.acpSessionId;if(d&&i.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ne.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d});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:d}),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 D("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 D("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ze(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 D("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ze(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(jt(e._meta,"_agent/switchModel"),!e.agentId)throw new D("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=zc(e.model)??yt,i=await He(e.agentId);if(!i)throw new D("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ze(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(d=>Ne.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(d);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(jt(e._meta,_t.RESET),!e.agentId)throw new D("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,d]of i.sessions)o.set(c,{modelToken:d.modelToken,tokenGeneratedAt:d.tokenGeneratedAt});await Xr(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 Ze(r)}async repairAgent(e){if(jt(e._meta,_t.REPAIR),!e.agentId)throw new D("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new D("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){jt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",d=this.safeJoin(o,c),u=await Gc(d).catch(()=>null);if(!u)throw new D("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Zr(d,o))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=k_(e.depth);return u.isDirectory()?{tree:await R_(o,d,c,x)}:{tree:[{name:P_(c),path:Jf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){jt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new D("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Gc(o).catch(()=>null);if(!c||!c.isFile())throw new D("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Zr(o,i))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Gf)throw new D("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Gf})`);let d=await qf(o);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??We(e).workspace}safeJoin(e,r){let i=Wc(e,r||"."),o=$c(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${jf}`))throw new D("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 D("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function g_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new D("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new D("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function m_(t){return t==="claude-code"?kt(".claude","skills"):kt(".agents","skills")}var w_=3e4,__=50*1024*1024,br=3e4;async function Vc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new D("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,d=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!d)throw new D("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=g_(o.skillName),x=m_(i),h=kt(x,u),w=kt(r,h);if(await qc(w,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");Ci(A.length),await jc(kt(w,"SKILL.md"),A,"utf8")}else{let A=await E_(o.downloadUrl);v_(A)?await T_(A,w):S_(A)?await A_(A,w):await jc(kt(w,"SKILL.md"),A.toString("utf8"),"utf8")}let y={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"}),y}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 y_(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 E_(t){if(!t)throw new D("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ci(e);let r=b_(t);return Ci(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await qf(e);return Ci(r.length),r}if(Qs(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),w_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new D("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ci(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new D("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ci(t){if(t>__)throw new D("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function b_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new D("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function v_(t){return t.length>=2&&t[0]===31&&t[1]===139}function S_(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 Kc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function A_(t,e){let r,i;try{r=new $f.default(t),i=r.getEntries()}catch(d){throw new D("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of i){let u=d.entryName;if(!u||Kc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new D("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(h=>h===".."))throw new D("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=d.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new D("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=I_(i),c=Wc(e);for(let d of i){if(Kc(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Wc(e,u),h=$c(c,x);if(h.startsWith("..")||h==="..")throw new D("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await qc(x,{recursive:!0});continue}await qc(u_(x),{recursive:!0});let w;try{w=d.getData()}catch(y){throw new D("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${y.message}`,{cause:y})}await jc(x,w)}}function I_(t){let e;for(let r of t){let i=r.entryName;if(!i||Kc(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_(t,e){await C_(t);let r=Sf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`))},br);try{await Kf(Wf.from(t),r)}catch(c){throw c instanceof D?c:i?new D("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`):new D("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function C_(t){let e=[],r=_r({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`))},br);try{await Kf(Wf.from(t),r)}catch(c){throw i?new D("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`):new D("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new D("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var D_=5e3;async function R_(t,e,r,i){return Vf(t,e,r,i,{count:0})}async function Vf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await c_(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(p_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=D_){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=kt(e,u.name),h=f_(kt(r,u.name)),w=null;try{w=await Gc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let y={name:u.name,path:Jf($c(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(y.children=await Vf(t,x,h,i-1,o)),d.push(y)}return d.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),d}function k_(t){return!t||t<=0?x_:Math.min(t,h_)}function P_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Jf(t){return t.split(jf).join("/")}ne();import{readFileSync as TI}from"node:fs";import{dirname as DI,join as RI}from"node:path";import{fileURLToPath as PI}from"node:url";var vr="0.1.100-alpha.0";var wn=H("agent-health-reporter"),O_=1e4,Di=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??O_}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 d of this.opts.core.agents.values()){let u=N_(d);if(!u)continue;let x={agentId:d.agentId,status:u};d.patToken&&(x.patToken=d.patToken),d.accountId&&(x.accountId=d.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(d){wn.warn("heartbeat batch send failed",{count:r.length,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(wn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){wn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){wn.warn("onTickEnd hook failed",{err:String(r)})}}};function N_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as $y,mkdir as mo,rm as Vy,stat as Jy,writeFile as Yy}from"node:fs/promises";import{homedir as Zy}from"node:os";import{join as nd}from"node:path";en();import{existsSync as X_}from"node:fs";import{release as Q_}from"node:os";import{basename as ey,isAbsolute as ty}from"node:path";function Ri(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}}je();var io=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 Yf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Zf(t){return"method"in t&&!("id"in t)}function so(t){return!("method"in t)&&"id"in t}var L_={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 M_(t){if(t!=null)return t instanceof Error?{name:t.name,message:ki(t.message)}:typeof t=="string"?ki(t):typeof t=="object"?F_(t):t}var B_=[[/\/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 ki(t){let e=t;for(let[r,i]of B_)e=e.replace(r,i);return e}function F_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=ki(i):e[r]=i;return e}function Pi(t){if(t instanceof D){let e=M_(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:L_[t.code]??ee.INTERNAL_ERROR,message:ki(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:ki(t instanceof Error?t.message:String(t))}}function Xf(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:d,...u}=e;c=u}return new D(r,o,{retriable:e?.retriable??!1,cause:c})}function e0(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var Qf=10*1024*1024,oo=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>Qf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${Qf} 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(d){this.onError?.({line:c,error:d})}}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 n0={"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"},qI=Object.fromEntries(Object.entries(n0).map(([t,e])=>[e,t])),z_={"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=n0[e]??U_(e),o=z_[i]??[],c=[i,String(this.seq)];if(o.length>0){let d=o.map(x=>t0(r?.[x]??"")),u=H_(d).join(":");u&&c.push(u)}else r&&Object.values(r).some(d=>d)&&c.push(Object.values(r).filter(Boolean).map(d=>t0(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function U_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function t0(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 G_}from"node:fs";var q_=384;async function Yc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nn(t.agentEnvFile,r,{mode:q_})}function Oi(t){try{let e=JSON.parse(G_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function ao(t,e,r={},i=o=>o){return{...i({...t,...Oi(e)}),...r}}yn();Wr();je();ne();Ie();import{spawnSync as Y_}from"node:child_process";function co(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function lo(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Y_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Zc=new Set;function o0(t){typeof t=="number"&&t>0&&Zc.add(t)}function a0(t){typeof t=="number"&&Zc.delete(t)}function c0(){for(let t of Zc)lo(t,"SIGKILL")}var Z_=[{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 d0(t,e){if(!e)return null;for(let r of Z_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function l0(t,e){return d0(t,e)}function u0(t,e){return d0(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 f0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let h=t.suspendedMs+o,w=r-t.startedAt-h;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Tr(w,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,d=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=d?{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 x0=Ye("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),ny=200,ry=40,iy=Ye("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),sy=Ye("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),oy=Ye("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),ay=Ye("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),cy=Ye("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),dy=Ye("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),h0=500;function ly(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=h0?t:`${e.slice(0,h0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function uy(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 p0(t){try{return X_(t)}catch{return}}function fy(t,e){return{platform:process.platform,osRelease:Q_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:ty(e.command)?p0(e.command):void 0,cwd:e.cwd,cwdExists:p0(e.cwd),envKeys:e.envKeys}}function xy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${ey(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new oo({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 D("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=ao(process.env,this.opts.agentEnvFile??Y().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=ct(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,o0(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>ny&&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,a0(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,d=fy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:d}),this.failAllPending(new D("AGENT_SPAWN_FAILED",xy(c,d),{cause:d}))}),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()));lo(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||lo(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:cy,phase2GateMs:iy,livenessWindowMs:sy,absoluteMaxMs:oy,approvalMaxMs:dy,suspendThresholdMs:ay,...r};return this.call("session/prompt",e,x0,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=x0,o){if(!this.child||this.stopped)return Promise.reject(new D("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Ri(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,h)=>{let w={resolve:x,reject:h,timer:null,method:e,promptTimeout:null};if(o){let y=this.now(),A={cfg:o,startedAt:y,lastActivityAt:y,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:y,expectedIntervalMs:Tr(0,!1,o),sessionId:u};w.promptTimeout=A;let E=()=>{let v={startedAt:A.startedAt,lastActivityAt:A.lastActivityAt,firstFrameSeen:A.firstFrameSeen,hasActiveTool:A.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:A.suspendedMs,armedAt:A.armedAt,expectedIntervalMs:A.expectedIntervalMs},I=this.now(),S=f0(v,A.cfg,I),R=N=>{A.armedAt=I,A.expectedIntervalMs=N,w.timer=setTimeout(E,N)};if(S.action==="suspend"){A.suspendedMs+=S.suspendedDeltaMs,A.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:S.suspendedDeltaMs,suspendedMs:A.suspendedMs,...A.sessionId?{sessionId:A.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,...A.sessionId?{sessionId:A.sessionId}:{}}),h(S.awaitingApproval?new D("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${A.cfg.approvalMaxMs}ms`):new D("AGENT_TIMEOUT",`${e} timed out after ${A.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...A.sessionId?{sessionId:A.sessionId}:{}}),h(new D("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${A.cfg.livenessWindowMs}ms`)))};w.timer=setTimeout(E,A.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}),h(new D("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,w);try{this.writeFrame(d)}catch(y){w.timer&&clearTimeout(w.timer),this.pending.delete(c),h(y)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new D("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(e0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(so(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 D("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:ly(e.result)}),r.resolve(e.result));return}if(Zf(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(Yf(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 d=typeof i.status=="string"?i.status:void 0,u=d==="completed"||d==="failed"||d==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&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,Pi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=Xf(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=u0(this.framework,uy(e));return i?new D(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 D("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(ry).join(`
|
|
95
|
+
`),o=l0(this.framework,i);return o?new D(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new D("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 hy(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 uo=class extends Pt{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 hy(e)}};en();import{spawn as py}from"node:child_process";import{closeSync as gy,existsSync as w0,mkdirSync as my,mkdtempSync as wy,openSync as _y,readFileSync as yy,readSync as Ey,readdirSync as by,rmSync as vy,statSync as Sy}from"node:fs";import{homedir as Ay,tmpdir as Iy}from"node:os";import{join as Ni}from"node:path";Ie();var Qc=9e4,Ty=64*1024,Cy=100;function Dy(t){let e=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t):Number.NaN;return!Number.isFinite(e)||e<=0?Qc:Math.max(1,Math.floor(e*1e3))}function Ry(t){let e=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t):Number.NaN;return!Number.isFinite(e)||e<=0?Qc:Math.max(1,Math.floor(e))}function ky(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e={};for(let[r,i]of Object.entries(t))typeof i=="string"&&(e[r]=i);return Object.keys(e).length>0?e:void 0}function g0(t){if(typeof t=="string"&&t.trim())return{command:t,timeoutMs:Qc};if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(e.type&&e.type!=="command")return;let r=typeof e.command=="string"?e.command.trim():"";if(!r)return;let i=typeof e.working_directory=="string"&&e.working_directory.trim()?e.working_directory.trim():typeof e.cwd=="string"&&e.cwd.trim()?e.cwd.trim():void 0,o=ky(e.env);return{command:r,timeoutMs:e.timeout_ms===void 0?Dy(e.timeout):Ry(e.timeout_ms),...i?{cwd:i}:{},...o?{env:o}:{}}}function Xc(t){if(Array.isArray(t))return t.flatMap(i=>Xc(i));if(!t||typeof t!="object"){let i=g0(t);return i?[i]:[]}let e=t;if(e.hooks)return Xc(e.hooks);let r=g0(e);return r?[r]:[]}function Py(t){let e=Ni(t,"hooks.json");if(!w0(e))return[];let r=JSON.parse(yy(e,"utf8")),o=r.hooks&&typeof r.hooks=="object"?r.hooks:r;return Xc(o.Stop??o.stop)}function Oy(t,e){let r=Ni(t,"sessions");if(!w0(r))return;let i=[],o=c=>{let d;try{d=by(c,{withFileTypes:!0})}catch{return}for(let u of d){let x=Ni(c,u.name);if(u.isDirectory())o(x);else if(u.isFile()&&u.name.endsWith(".jsonl"))try{i.push({path:x,mtimeMs:Sy(x).mtimeMs})}catch{}}};o(r),i.sort((c,d)=>d.mtimeMs-c.mtimeMs);for(let c of i.slice(0,Cy))if(Ny(c.path,e))return c.path;return i[0]?.path}function Ny(t,e){let r;try{r=_y(t,"r");let i=Buffer.alloc(Ty),o=Ey(r,i,0,i.length,0),c=i.subarray(0,o).toString("utf8");return c.includes(JSON.stringify(e))||c.includes(e)}catch{return!1}finally{if(r!==void 0)try{gy(r)}catch{}}}function Ly(t){return Oi(t??Y().agentEnvFile)}function m0(t){let e=t?.trim();return e||void 0}function My(t){let e=Ly(t.agentEnvFile),r=m0(t.env?.CODEX_HOME??e.CODEX_HOME??process.env.CODEX_HOME);if(r)return r;let i=m0(t.env?.HOME??e.HOME??process.env.HOME)??Ay();return Ni(i,".codex")}var fo=class extends Pt{framework="codex";authMethodId;codexHomeDir;cleanupCodexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Jr("codex",e.command,i),d=e.isolateCodexHome?e.codexHomeDir??e.env?.CODEX_HOME??wy(Ni(Iy(),"coze-bridge-codex-home-")):My(e),u=!!e.isolateCodexHome&&!!d&&!e.codexHomeDir&&e.env?.CODEX_HOME!==d;e.isolateCodexHome&&d&&!u&&my(d,{recursive:!0});let x=e.isolateCodexHome&&d?{...e.env??{},CODEX_HOME:d}:e.env,h={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...e.agentEnvFile?{agentEnvFile:e.agentEnvFile}:{},...x?{env:x}:{}};super(h),this.authMethodId=e.authMethodId,this.codexHomeDir=d,this.cleanupCodexHomeDir=u}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async sessionPrompt(e){let r=await super.sessionPrompt(e);return this.runStopHooksBestEffort(e.sessionId).catch(i=>{this.log.warn("codex stop hook unexpected failure",{err:String(i)})}),r}async runStopHooksBestEffort(e){let r=this.codexHomeDir??this.opts.env?.CODEX_HOME;if(!r)return;let i;try{i=Py(r)}catch(d){this.log.warn("codex stop hook load failed",{codexHomeDir:r,err:String(d)});return}if(i.length===0)return;let o=Oy(r,e),c=JSON.stringify({hook_event_name:"Stop",session_id:e,...o?{transcript_path:o}:{},trigger:"coze-bridge"});await Promise.all(i.map(async d=>{try{await this.runHookCommand(d,c)}catch(u){this.log.warn("codex stop hook failed",{codexHomeDir:r,command:d.command.slice(0,200),err:String(u)})}}))}runHookCommand(e,r){return new Promise((i,o)=>{let c=py(e.command,{cwd:e.cwd??this.opts.cwd,env:ao(process.env,this.opts.agentEnvFile??Y().agentEnvFile,{...this.opts.env??{},...e.env??{}}),shell:!0,stdio:["pipe","ignore","pipe"]}),d="",u=setTimeout(()=>{c.kill("SIGTERM"),o(new Error(`hook timed out after ${e.timeoutMs}ms`))},e.timeoutMs);c.stderr?.setEncoding("utf8"),c.stderr?.on("data",x=>{d+=x,d.length>4e3&&(d=d.slice(-4e3))}),c.on("error",x=>{clearTimeout(u),o(x)}),c.on("close",(x,h)=>{if(clearTimeout(u),x===0){i();return}o(new Error(`hook exited code=${x} signal=${h} stderr=${d.slice(-1e3)}`))}),c.stdin.end(`${r}
|
|
96
|
+
`)})}async stop(e){if(await super.stop(e),this.codexHomeDir&&this.cleanupCodexHomeDir)try{vy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var By=3e4,Cr=class extends Pt{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}`}]},By))}get acpSessionName(){return this.sessionName}};je();ne();Ie();function ed(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}en();var En=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 xo=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 En,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)Li(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 Li(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();ne();import{constants as _0}from"node:fs";import{access as Fy}from"node:fs/promises";import{delimiter as zy,join as Uy}from"node:path";var Et=H("framework-detector"),y0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Hy=[".exe",".cmd",".bat",".ps1"],Hn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??ct,access:e.access??Fy}}async detect(e){let r=y0[e],i=await this.which(r);if(!i)return Et.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(y0).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(zy).filter(Boolean),i=this.env.platform==="win32"?["",...Hy]:[""];for(let o of r)for(let c of i){let d=Uy(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?_0.F_OK:_0.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 Et.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return Et.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 Et.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 Et.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(Et.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}:(Et.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return Et.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 Et.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||Et.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 d=JSON.parse(c[0]);typeof d.gateway?.port=="number"&&(o.port=d.gateway.port),typeof d.service?.runtime?.status=="string"&&(o.runtime=d.service.runtime.status),!i&&typeof d.rpc?.error=="string"&&(o.detail=d.rpc.error)}catch(d){Et.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(d)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(qy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,d,u=x=>{c||(c=!0,d&&clearTimeout(d),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",h=>{o+=h.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",h=>u({code:h,stdout:o}))}catch{u(null)}})}},Gy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function qy(t){return t.replace(Gy,"")}import{homedir as b0}from"node:os";import{join as po}from"node:path";yn();Wr();je();Yr();ne();async function v0(){let t=po(b0(),".openclaw/openclaw.json");return(await tn(t))?.gateway?.auth?.token??""}var Gn=H("openclaw.config"),jy=[0,5e3,5e3],Wy=Ye("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),E0="models.providers.",ho="agents.defaults.models",Ky=["operator.admin","operator.read","operator.write","operator.approvals","operator.pairing"];function td(t,e){if(!Array.isArray(t))return!1;let r=new Set(t);return e.every(i=>r.has(i))}var go=class{command;env;retryDelaysMs;cliTimeoutMs;openclawDir;queue=new En;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??jy,this.cliTimeoutMs=e.cliTimeoutMs??Wy,this.openclawDir=e.openclawDir??po(b0(),".openclaw")}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(d=>setTimeout(d,c));try{return await r()}catch(d){i=d,Gn.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(d)})}}throw new D("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=ct(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",d=!1,u=h=>{d||(d=!0,clearTimeout(x),h())};o.stderr?.on("data",h=>{c+=h.toString("utf8")});let x=setTimeout(()=>{u(()=>{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=>u(()=>i(h))),o.on("close",h=>u(()=>{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){Gn.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",`${E0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${E0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ho}[${e}]`,()=>this.runCli(["config","set",ho,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ho}[${e}]`,`${ho}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}async ensureAcpDeviceScopes(){try{let e=po(this.openclawDir,"identity","device.json"),i=(await tn(e))?.deviceId?.trim();if(!i)return Gn.debug("openclaw device identity absent, skip acp scope ensure",{identityPath:e}),!1;let o=po(this.openclawDir,"devices","paired.json"),c=await tn(o),d=c?.[i];if(!c||!d)return Gn.debug("acp device not yet paired, skip scope ensure",{deviceId:i}),!1;let u=[...Ky],x=d.tokens?.operator;return td(d.scopes,u)&&td(d.approvedScopes,u)&&td(x?.scopes,u)?(Gn.debug("acp device already has full operator scopes",{deviceId:i}),!1):(d.scopes=[...u],d.approvedScopes=[...u],x&&(x.scopes=[...u]),await nn(o,c,{mode:384}),Gn.info("acp device scopes upgraded to full operator set (bypass manual approval)",{deviceId:i,scopes:u}),!0)}catch(e){return Gn.warn("ensureAcpDeviceScopes failed (ignored, best-effort)",{err:String(e)}),!1}}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}};var xe=H("agent-manager"),Xy=(t,e,r,i,o,c,d,u,x,h)=>{switch(t){case"claude-code":{let w={...o?{...Mf(o),...zf(o,d,u)}:{},...x??{},IS_SANDBOX:"1"};return new uo({cwd:r,env:w,agentId:i})}case"codex":{let y=[...o?[...Bf(o),...Hf(o,d,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],A=!!o,E={...o?Ff(o):{},...x??{},...A?{COZE_CODEX_BYPASS_HOOK_TRUST:"1"}:{}};return new fo({cwd:r,agentId:i,...y.length>0?{extraArgs:y}:{},...Object.keys(E).length>0?{env:E}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0,codexHomeDir:h}:{}})}case"openclaw":return new Cr({command:e,cwd:r,agentId:i,...c?{sessionName:ed(c)}:{}})}};function rd(t){return t==="claude-code"||t==="codex"}function Qy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(eE(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
96
97
|
`)}
|
|
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
|
-
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=
|
|
100
|
-
`)}else c=
|
|
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
|
|
98
|
+
`}function eE(t){if(t.includes(`
|
|
99
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var tE={path:"",version:"cloud-deployed"},S0="openclaw_gateway_unavailable",nE="openclaw_default_agent_missing";function A0(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 rE={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},iE=6e4,wo=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??Xy,this.createTimeoutMs=e.createTimeoutMs??iE,this.detectorFactory=e.detectorFactory??(()=>new Hn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new go({command:r,openclawDir:this.openclawConfigDir})),this.openclawConfigDir=e.openclawConfigDir??nd(Zy(),".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 D("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=>{xe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=nd(e,".env");if(await Jy(r).then(c=>c.isFile()).catch(()=>!1)){xe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await mo(e,{recursive:!0});let o=Qy({...process.env,...Oi(this.paths.agentEnvFile)});if(await Yy(r,o,"utf8"),process.platform!=="win32")try{await $y(r,384)}catch(c){xe.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}xe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),xe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new D("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new D("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 D("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")xe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>xe.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){xe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await He(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Ze(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){xe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await He(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Ze(S,this.paths))}return xe.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 D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=We(e.agentId,this.paths),u=Ai(e._meta),x=e.framework==="openclaw"&&u==="local",h;x&&!r?.revive&&(h=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let w=h??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),y=e.workspace??w??d.workspace,A=new AbortController,E=setTimeout(()=>A.abort(new D("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&rd(e.framework)&&await nr(e.framework,A.signal);let S=()=>{if(A.signal.aborted)throw A.signal.reason instanceof Error?A.signal.reason:new D("AGENT_TIMEOUT","_agent/create aborted")};await mo(d.root,{recursive:!0}),await mo(y,{recursive:!0}),await mo(d.logs,{recursive:!0}),S(),x||await rr(y,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Rl(y,u),S();let R=await He(e.agentId,this.paths).catch(()=>null),N=Nf({model:e.model??R?.model}),_=If(e._meta)??R?.accountId,k=e.patToken??R?.patToken,P=u==="cloud"?e.modelInfo??R?.modelInfo:void 0;if(v=new xo({agentId:e.agentId,framework:e.framework,workspace:y,model:N.model??yt,deployType:u,..._?{accountId:_}:{},...k?{patToken:k}:{},...P?{modelInfo:P}:{}}),v.status="ok",R?.sessions){for(let[J,te]of Object.entries(R.sessions))v.sessions.set(J,{acpSessionId:te.acpSessionId,modelToken:te.modelToken,tokenGeneratedAt:te.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let V=Object.keys(R.sessions).length;V>0&&xe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:V})}this.registry.register(v),I=!0;let B={agentId:e.agentId,framework:e.framework,workspace:y,cozeIdentity:e.cozeIdentity,createdAt:R?.createdAt??Date.now(),sessions:R?.sessions??{},model:N.model};u==="cloud"&&(B.deployType="cloud"),_&&(B.accountId=_),k&&(B.patToken=k),P&&(B.modelInfo=P),R?.skills&&(B.skills=R.skills),R?.agentName&&(B.agentName=R.agentName),R?.description&&(B.description=R.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,y)):xe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let F=e.initialSkills??[];if(F.length>0){let V=[...B.skills??[]],J=new Map(V.map((ye,he)=>[ye.skillId,he])),te=await Promise.allSettled(F.map(ye=>Vc({agentId:e.agentId,workspace:y,framework:e.framework,skill:ye}))),X=0;for(let[ye,he]of te.entries()){let O=F[ye];O&&(he.status==="fulfilled"?(Jc(V,J,he.value),X++):xe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(he.reason)}))}X>0&&(B.skills=V,xe.info("initialSkills installed",{agentId:e.agentId,installed:X,requested:F.length}))}return await Ze(B,this.paths),xe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:y,framework:e.framework}}catch(S){throw xe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Vy(d.root,{recursive:!0,force:!0}).catch(R=>xe.warn("rm agent dir failed (ignored)",{err:String(R)})),S instanceof D?S:new D("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&rd(e.framework))u=tE;else throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);rd(e.framework)&&!ss(e.framework)&&(xe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await nr(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:u.path}):h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),e.framework==="codex"&&e.deployType==="cloud"?nd(We(e.agentId,this.paths).root,"codex-home"):void 0);try{return await h.start(),await h.initialize(rE),h}catch(w){let y=h instanceof Pt?h.getStderrTail():[];throw y.length>0&&xe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof D?w.code:"unknown",recentStderr:y}),await h.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 D("AGENT_ENV_NOT_READY",A0(o),{cause:{reason:S0}})}catch(o){xe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof D?new D(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new D("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};xe.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 xe.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 D("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:nE}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new D("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new D("AGENT_ENV_NOT_READY",A0(r),{cause:{reason:S0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,x=ed(o);if(r.deployType==="local"){let A=await this.ensureOpenclawDefaultAgent();return new Cr({command:u,cwd:A.workspace,agentId:A.id,sessionName:x})}let h=await v0();try{await this.getOpenclawConfig().ensureAcpDeviceScopes()}catch(A){xe.warn("acp device scope ensure failed (ignored)",{err:String(A)})}let w=i?Uf(i,c,d):null,y;if(w){let A=Hc(o),v=w.models[0]?.id??yt,I=`${A}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(A,w),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}y=I}return new Cr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...y?{slashModelOnStart:y}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Hc(i),c=`${o}/${e.model}`,d=!0;try{await r.removeProvider(o)}catch(u){d=!1,xe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){d=!1,xe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as R0}from"node:crypto";import{promises as fE}from"node:fs";import{basename as k0}from"node:path";je();ne();import{promises as oE}from"node:fs";import{basename as aE}from"node:path";var I0=H("file-upload"),cE="/api/coze_claw/file/agent_upload",dE=6e4;async function T0(t,e={}){let i=`${eo(no(e.handshakeBase))}${cE}`,o=e.timeoutMs??dE,c=await oE.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Er(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);I0.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:d,signal:x.signal}),y=w.headers.get("x-tt-logid")??"";if(!w.ok){let v=await w.text().catch(()=>"");throw new D("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${y}: ${v.slice(0,200)}`)}let A=await w.json();if(A.code!==void 0&&A.code!==0)throw new D("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${y}`);let E=A.data?.file?.file_url;if(!E)throw new D("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(A).slice(0,200)}`);return I0.info("file upload ok",{uri:E,logid:y}),{uri:E}}catch(w){throw w instanceof D?w:w.name==="AbortError"?new D("UPLOAD_FAILED",`upload timeout (${o}ms) for ${aE(t.path)}`):new D("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(h)}}je();ne();import{extname as lE}from"node:path";var uE={".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 C0(t){let e=lE(t).toLowerCase();return uE[e]??"application/octet-stream"}Ie();var _o=H("agent-send"),D0=50*1024*1024;function P0(t,e,r){let i=t.get(e);if(!i)throw new D("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new D("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new D("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function O0(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(h){u=h,x<2&&(_o.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(w=>setTimeout(w,5e3)))}throw new D("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function N0(t,e){let{session:r,runtime:i}=P0(e.core,t.agentId,t.sessionId);if(!await Zr(t.path,r.workspace))throw new D("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await fE.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new D("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>D0)throw new D("FILE_TOO_LARGE",`${o.size} bytes > limit ${D0}`);let c=await C0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new D("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??k0(t.path),u;try{u=await T0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw _o.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:h instanceof D?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:R0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await O0(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),_o.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,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 L0(t,e){let{session:r,runtime:i}=P0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new D("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??k0(t.path),c={sessionUpdate:"group_file",messageId:R0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await O0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),_o.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 M0(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 d=r[c]??0,u=i[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}en();yn();ne();var Ot=H("coze-cli-installer"),B0="@coze/cli@latest",xE="coze",F0="0.1.8",hE=5e3,pE=5e3,gE=9e4,z0=1e4,Mi=null,yo=!1;async function id(t,e={}){if(yo)return;if(Mi)return Mi;let r=e.exec??s0;return Mi=(async()=>{try{let i=await mE(xE,r),o=!1;if(i){let d=await wE(r);if(d===void 0)Ot.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(M0(d,F0))Ot.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:F0}),o=!0;else{Ot.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),yo=!0;return}}let c=o?"upgrade-only":"full";Ot.info("coze-cli install start",{package:B0,mode:c});try{await r("npm",["i","-g","--prefer-online",B0],{timeout:gE,maxBuffer:10*1024*1024}),Ot.info("coze-cli install ok")}catch(d){Ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(o){yo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:z0}),Ot.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Ot.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:z0}),Ot.info("coze auth login ok")}catch(d){Ot.warn("coze auth login failed",{err:String(d)});return}yo=!0}finally{Mi=null}})(),Mi}async function mE(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:hE});return Ia(i)}catch{return}}async function wE(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:pE});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Yr();Ie();var _E=10*6e4;function U0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?_E:e}function Eo(t){return tn(t??Y().configFile)}function Bi(t,e){return nn(e??Y().configFile,t)}import{randomBytes as zE}from"node:crypto";Wr();je();ne();import{createReadStream as yE}from"node:fs";import{mkdir as EE,readFile as bE,realpath as vE,stat as SE,writeFile as AE}from"node:fs/promises";import{basename as IE,dirname as sd,isAbsolute as TE,join as CE,relative as DE,resolve as H0,sep as RE}from"node:path";import{createInterface as kE}from"node:readline";var q0=H("fs-rpc"),Fi=Ye("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function j0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Fi)throw new D("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Fi} bytes`);let i=await K0(t.path,e);return await EE(sd(i),{recursive:!0}),await AE(i,t.content,"utf8"),q0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function W0(t,e){let r=await K0(t.path,e),i=await SE(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Fi&&!o)throw new D("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Fi} bytes`);let c;if(o&&i.size>Fi)c=await PE(r,t.line??1,t.limit);else{let d=await bE(r,"utf8");if(o){let u=d.split(`
|
|
100
|
+
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,h).join(`
|
|
101
|
+
`)}else c=d}return q0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function PE(t,e,r){let i=kE({input:yE(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,d=[],u=0;try{for await(let x of i)if(u>=o&&u<c&&d.push(x),u++,u>=c)break}finally{i.close()}return d.join(`
|
|
102
|
+
`)}async function K0(t,e){if(typeof t!="string"||t.length===0)throw new D("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([G0(H0(e)),G0(H0(t))]),o=DE(r,i);if(OE(o,RE,TE(o)))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function OE(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function G0(t){let e=[],r=t;for(;r!==sd(r);)try{let i=await vE(r);return e.length?CE(i,...e.reverse()):i}catch{e.push(IE(r)),r=sd(r)}return t}ne();var $0=H("prompt-multimodal"),V0=10*1024*1024,NE=15e3,LE=6;async function J0(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await ME(d))}}let o=Array.from({length:Math.min(LE,t.length)},()=>i());return await Promise.all(o),e}function Y0(t){return t.some(e=>e.type==="image")}async function ME(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Qs(e.uri))return t;try{let{buf:r,contentType:i}=await FE(e.uri),o=e.mimeType||BE(i)||"application/octet-stream";return $0.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 $0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function BE(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function FE(t){let e=new AbortController,r=setTimeout(()=>e.abort(),NE);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>V0)throw new Error(`image too large: ${o.byteLength} bytes (max ${V0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();je();ne();var $=H("core"),UE=3e4,HE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,GE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",qE="\u5BA1\u6279\u5DF2\u8D85\u65F6",jE=3e4,bo=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=U0(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,d)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),Li(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(_n(o,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>$.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.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 D("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(so(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&&HE.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,ee.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(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}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,Pi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new D("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new D("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new D("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new D("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let h=r._meta?.cozeTriggerMsgId,w=Mc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,GE,h,w)}}let d=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Tf(i);switch(r){case"session/new":{let c=WE();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,d=c.sessionId;if(!d)throw new D("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,d);if(u.replySeq=0,await this.ensureDownstream(e,d,u),!u.downstream||!u.acpSessionId)throw new D("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let h=Mc(i._meta);if(h?e.activeGroupIds.set(u.acpSessionId,h):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Y0(c.prompt))throw new D("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await J0(c.prompt);try{let y=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),y}catch(y){if(y instanceof D&&y.code==="AGENT_APPROVAL_TIMEOUT"){let A=u.pendingPermission;A&&(A.downstream.respondAgentRequest(A.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(A.upstreamId),u.pendingPermission=void 0);let E=u.acpSessionId,v=E?e.activeTriggers.get(E):void 0,I=E?e.activeGroupIds.get(E):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:d}),await this.synthesizePromptReply(e,u,d,qE,v,I)}throw y}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let y=u.downstream;y&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:u.acpSessionId}),y.stop("reload-after-turn").catch(A=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(A)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,d,u)}}case"session/cancel":{let d=o.sessionId;if(!d)throw new D("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let x=e.getSessionQueue(d);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:x.size}),x.dispose(new D("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new D("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(_t.GEN_MODEL_TOKEN,i,jE);if(!o?.modelToken)throw new D("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof D&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new D("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Li(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new D("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,d=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(d>=o&&Date.now()-u<c)throw new D("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw i.spawnFailCount=d+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),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}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}}catch(h){throw $.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(Li(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 d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,d){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),d&&(u.cozeGroupId=d),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(VE(r)){$.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let d={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(d.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(i);x&&(d.cozeGroupId=x),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:d})).catch(h=>$.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}$.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??{},d=await j0(c,o);r.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await W0(c,o);r.respondAgentRequest(i.id,d)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Pi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let w=u?e.activeGroupIds.get(u):void 0;w&&(h.cozeGroupId=w);let y=u?this.reverseSessionId(e,u):void 0,A=y?e.sessions.get(y):void 0;A&&(A.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let E={...c,...y?{sessionId:y}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:y}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:y,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ri(o,"session/request_permission",E)).catch(v=>{this.pendingUpstream.delete(o),$.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?($.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"&&KE(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 io(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),d=e.get(c);if(d)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,i=UE){let o=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),d(new D("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(Ri(o,e,r)).catch(x=>{let h=this.pendingBridge.get(o);h&&(clearTimeout(h.timer),this.pendingBridge.delete(o)),d(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 Xr(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(_n(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function WE(){return zE(16).toString("hex")}function KE(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 $E=["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 VE(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 $E.some(c=>o.startsWith(c))}ne();Ie();import{randomBytes as JE}from"node:crypto";import{chmod as YE,mkdir as ZE,writeFile as Z0}from"node:fs/promises";import{createServer as XE}from"node:http";import{dirname as QE}from"node:path";var eb=1e6,od=H("ipc"),vo=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=JE(32).toString("hex");let e=XE((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(),od.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 ZE(QE(this.paths.portFile),{recursive:!0}),await Z0(this.paths.portFile,String(this.port),"utf8"),await Z0(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await YE(this.paths.tokenFile,384)}catch(e){od.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){zi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){zi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await tb(e)}catch(u){zi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);zi(r,200,u??{ok:!0})}catch(u){od.error("IPC handler failed",{key:o,err:String(u)}),zi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function zi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function tb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>eb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var yh=St(cx(),1);var Lv=St(ih(),1),Mv=St(zo(),1),Bv=St(kr(),1),Fv=St(_d(),1),zv=St(bd(),1),Uv=St(Cd(),1),xh=St(qo(),1),Hv=St(fh(),1);var hh=xh.default;je();ne();var Re=H("upstream.frontier"),gh="application/json",mh="none",qv=15e3;function jv(t){class e extends hh{constructor(i){super(i,Df,{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(hl("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 d=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(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){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Rf,...Er(this.opts.ppeOverride)},r=jv(e),i=Pf(this.opts.urlOverride),o={url:i,ws:r,fpID:Cf,aID:to,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:gh,force:!0},payloadEncoding:{encoding:mh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new yh.FWS(o),d=!1,u=null,x,h,w=new Promise((E,v)=>{x=E,h=v}),y=E=>{d||(d=!0,u&&(clearTimeout(u),u=null),E?h(E):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&y();for(let v of this.connectHandlers)Promise.resolve(v({initial:E})).catch(I=>Re.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=E=>{this.opened=!1,Re.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},c.onerror=E=>{Re.warn("frontier error",{code:E.code,msg:E.message}),y(new D("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},c.onmessage=E=>this.handleMessage(E),this.fws=c;let A=this.opts.openTimeoutMs??qv;u=setTimeout(()=>{y(new D("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await w}catch(E){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,E}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){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 D("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new D("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;wh(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:gh,payloadEncoding:mh})}catch(u){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new D("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){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=$v(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(d){Re.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;wh(c)||Re.info("frontier frame in",{logid:Kv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Wv(i)}),Promise.resolve(this.handler(o)).catch(d=>Re.warn("frontier frame handler threw",{err:String(d)}))}};function wh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var _h=2e3;function Wv(t){return t.length<=_h?t:`${t.slice(0,_h)}...<truncated, total ${t.length} chars>`}function Kv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function $v(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 Rd=H("upstream.switchable"),Wo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Rd.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 Rd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Rd.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 kd=H("upstream"),Br=class{handler=null;async start(){kd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){kd.info("NoopUpstream stopped",{reason:e})}async send(e){kd.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)}};je();ne();ne();Ie();import{promises as Pd}from"node:fs";import{dirname as Vv}from"node:path";var Jv=H("pat-token-store");async function Ko(t=Y()){try{let r=(await Pd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Jv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ji(t,e=Y()){if(!t)throw new Error("writePatToken: empty patToken");await Pd.mkdir(Vv(e.patTokenFile),{recursive:!0}),await Pd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Ie();Ie();import{promises as $o}from"node:fs";import{join as Yv}from"node:path";function Zv(t,e){return`#!/bin/sh
|
|
102
103
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
103
|
-
`}function
|
|
104
|
+
`}function Xv(t,e){return`@echo off\r
|
|
104
105
|
"${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(
|
|
109
|
-
`)}async function
|
|
106
|
+
`}async function Eh(t,e=Y()){let r=e.binDir;await $o.mkdir(r,{recursive:!0});let i=Yv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Xv(t,o):Zv(t,o);return await $o.readFile(i,"utf8").catch(()=>null)===c||(await $o.writeFile(i,c,"utf8"),process.platform!=="win32"&&await $o.chmod(i,493)),r}ne();Ie();import{execSync as bh}from"node:child_process";import{readFileSync as vh,unlinkSync as Qv}from"node:fs";import{mkdir as eS,readFile as Sh,unlink as Ah,writeFile as tS}from"node:fs/promises";import{dirname as nS}from"node:path";var rS=H("single-instance"),Vo=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&&(rS.warn("removing stale pid file",{stalePid:e}),await Ah(this.pidFile).catch(()=>{})),await eS(nS(this.pidFile),{recursive:!0}),await tS(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Sh(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ah(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Sh(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 co(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=vh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=bh(`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=bh(`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{vh(this.pidFile,"utf8").trim()===String(process.pid)&&Qv(this.pidFile)}catch{}})}};Jo();ne();var Vn=H("daemon.upstream-watchdog"),uS=12e4,fS=9e5,xS=3e4;function Nd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Yo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Nd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",uS),this.hardMs=e.hardMs??Nd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",fS),this.intervalMs=e.intervalMs??Nd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",xS),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?.(),Vn.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&&Vn.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&&Vn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Vn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Vn.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,Vn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Vn.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 q=H("daemon"),hS="coze-bridge-daemon";async function Ch(){let t=Y();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&fl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>We(O,t).logs,listAgentIds:()=>os(t)});let e=new Vo({processTitle:hS}),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??{};rs({pid:process.pid}),q.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Hn;o.frameworksCache=await O.detectAll(),q.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){q.warn("framework detection failed",{err:String(O)})}await Bi(o);let c=new Wo(new Br),d=null,u=new bo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,G,W,ie)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(O,G,W,ie)}});await gS(t,u);let x=new wo({paths:t,config:o,registry:u});d=x;let h,w,y=null,A={},E,v=null,I=null,S=null,R=new En;function N(O,G){return R.enqueue(()=>k(O,G))}function _(){I||(I=new Yo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?N(S,{force:!0}):void 0,onFatal:O=>{if(process.env[Yi]==="1"){q.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}q.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),I.start()}async function k(O,G){let W=O,ie=W?.privatecode;if(!ie)throw new D("IPC_BAD_REQUEST","/connect requires privatecode");let $e=Ti(W.env),le=W.handshake_url,ue=W.frontier_url,vt=Th(W.env,le,ue);if(S=W,!G?.force&&h===ie&&w===vt){let ge=await pS(t);return u.agents.size===0&&ge?(q.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Xo(t,x).catch(Se=>q.warn("connect-noop auto-revive error (ignored)",{err:String(Se)}))):q.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ut=!!h&&h!==ie,Yt=w!==void 0&&w!==vt,Bt=ut||Yt,Zt=await Bc({privatecode:ie,...le?{endpoint:le}:{},ppeOverride:$e});if(Bt){q.warn("connect config switched, resetting agents",{pcChanged:ut,envChanged:Yt,previousPc:h?Zo(h):"",nextPc:Zo(ie)});for(let ge of[...u.agents.values()])await ge.dispose("connect config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Br,"connect switch").catch(()=>{})}y=Zt.deviceId,rs({deviceId:y,pid:process.pid}),id({patToken:ie,env:W.env}).catch(ge=>q.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Gr=new Vi({handshake:Zt,privatecode:ie,...ue?{urlOverride:ue}:{},ppeOverride:$e,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});return await c.swap(Gr,"connect"),h=ie,w=vt,A=$e,E=le,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),q.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new Di({core:u,getDeviceId:()=>y??"",onTickEnd:()=>F.retryPending().catch(ge=>q.warn("detailSync.retryPending failed (ignored)",{err:String(ge)})),onAuthFailures:V})),v.start(),_(),Bt&&Xo(t,x).catch(ge=>q.warn("post-connect-switch auto-revive error (ignored)",{err:String(ge)})),Ji(ie,t).catch(ge=>q.warn("writePatToken after /connect failed (ignored)",{err:String(ge)})),q.info("/connect: WS established",{deviceId:y}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async O=>x.createAgent(O.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let P={},B=new ro({agents:u.agents,disposeAndMarkDisconnected:async(O,G)=>{let W=u.agents.get(O);if(W){await x.cleanupOpenclawSessionProviders(W).catch($e=>q.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String($e)}));let ie=!0;try{await W.dispose(`disconnect: ${G}`)}catch($e){ie=!1,q.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String($e)}),W.status="error"}ie&&(W.status="disconnected",u.unregister(O),u.disconnectedAgents.add(O))}else u.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!P.ref)throw new Error("agent-detail-sync not initialized yet");await P.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,G)=>{await x.openclawRepair(O,G)},isRuntimePendingPermission:O=>u.hasPendingPermissionFor(O)});u.registerExtension("_agent/listSkills",O=>B.listSkills(O.params)),u.registerExtension("_agent/addSkills",O=>B.addSkills(O.params)),u.registerExtension("_agent/removeSkills",O=>B.removeSkills(O.params)),u.registerExtension("_agent/getFileTree",O=>B.getFileTree(O.params)),u.registerExtension("_agent/getFileContent",O=>B.getFileContent(O.params)),u.registerExtension("_agent/update",O=>B.updateAgent(O.params)),u.registerExtension("_agent/disconnect",O=>B.disconnectAgent(O.params)),u.registerExtension("_agent/switchModel",O=>B.switchModel(O.params)),u.registerExtension("_agent/reset",O=>B.resetAgent(O.params)),u.registerExtension("_agent/repair",O=>B.repairAgent(O.params));let F=new ls({paths:t,handlers:B,sendDetail:O=>u.sendRequest("_agent/detail",O)});P.ref=F;let V=async O=>{await Promise.allSettled(O.map(async G=>{try{await B.disconnectAgent({agentId:G.agentId,reason:`auth_failure: code=${G.code} ${G.message}`}),q.info("agent disconnected due to auth failure from heartbeat response",{agentId:G.agentId,code:G.code,message:G.message})}catch(W){q.warn("disconnect during authFailure handling failed (ignored)",{agentId:G.agentId,err:String(W)})}}))};c.onConnect(({initial:O})=>{q.info("frontier upstream connected, triggering detail sync",{initial:O}),F.syncAll(O?"initial-connect":"reconnect").catch(G=>q.warn("detail sync top-level error (ignored)",{err:String(G)}))});let J=new vo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Yi]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:y??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let G=O,W=G?.privatecode,ie=G?.pairing_code;if(!W||!ie)throw new D("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let $e=Ti(G.env),le=G.handshake_url,ue=G.frontier_url,vt=Th(G.env,le,ue),ut=!!h&&h!==W,Yt=w!==void 0&&w!==vt,Bt=ut||Yt,Zt=await Bc({privatecode:W,...le?{endpoint:le}:{},ppeOverride:$e});if(Bt){q.warn("pair config switched, resetting agents",{pcChanged:ut,envChanged:Yt,previousPc:h?Zo(h):"",nextPc:Zo(W),previousEnvKey:w??"",nextEnvKey:vt});for(let Se of[...u.agents.values()])await Se.dispose("pair config switch").catch(()=>{}),u.agents.delete(Se.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Br,"pair switch").catch(()=>{})}y=Zt.deviceId,rs({deviceId:y,pid:process.pid}),id({patToken:W,env:G.env}).catch(Se=>q.warn("coze-cli setup error (ignored)",{err:String(Se)}));let Gr=new Vi({handshake:Zt,privatecode:W,...ue?{urlOverride:ue}:{},ppeOverride:$e,getPatTokenForAgent:Se=>u.agents.get(Se)?.patToken});await c.swap(Gr,"pair");try{let Se=new Hn;o.frameworksCache=await Se.detectAll(),await Bi(o),q.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Se){q.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Se)})}let ge=Object.keys(o.frameworksCache??{});try{let Se=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:W,frameworks:ge,_meta:{cozeDeviceId:y}});q.info("_agent/pair ok",{pairResult:Se}),h=W,w=vt,A=$e,E=le,G.mock_scenario!==void 0&&(u.setMockScenario(G.mock_scenario),q.info("mock scenario set",{scenario:G.mock_scenario})),Ji(W,t).catch(ke=>q.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),v||(v=new Di({core:u,getDeviceId:()=>y??"",onTickEnd:()=>F.retryPending().catch(ke=>q.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:V})),v.start(),_(),Bt&&Xo(t,x).catch(ke=>q.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let Jn;return G.agent_id&&(Jn=await mS(G.agent_id,t,x,ke=>u.sendRequest("_agent/detail",ke),W).catch(ke=>(q.error("--agent-id ensureAgent failed",{agentId:G.agent_id,err:String(ke)}),{ok:!1,agentId:G.agent_id??"",note:String(ke)}))),{ok:!0,note:"paired with cloud",...Jn?{agent:Jn}:{}}}catch(Se){return q.error("_agent/pair failed",{err:String(Se)}),{ok:!1,note:`pair failed: ${String(Se)}`}}}},{method:"POST",path:"/connect",handler:O=>N(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let G=O;return{ok:!0,result:await x.createAgent(G)}}},{method:"POST",path:"/agent/send",handler:async O=>{let G=O;if(!G?.agentId||!G?.sessionId||!G?.kind||!G?.path)throw new D("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new D("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=G;return await(W.groupFile?L0:N0)(W,{core:u,patToken:h,handshakeBase:E,ppeOverride:A})}catch(W){if(W instanceof D)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async O=>{let G=O?.agent_id,W=await u.reloadAgents(G);return q.info("IPC /reload: recycled agent subprocesses",{agentId:G??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(q.info("IPC /shutdown received"),setImmediate(()=>{he.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:te,token:X}=await J.start();try{await Eh(t.libEntry,t)}catch(O){q.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await u.start(),Xo(t,x).catch(O=>q.warn("auto-revive top-level error (ignored)",{err:String(O)})),bl().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(en(),yl));for(let G of["claude-code","codex"]){let W=await O(G);W&&q.info("acp wrapper version",{framework:G,version:W})}}).catch(O=>q.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let ye=null,he={port:te,token:X,core:u,ipc:J,shutdown(O){return ye||(q.info("daemon shutdown",{reason:O}),ye=(async()=>{v?.stop(),I?.stop(),await u.stop(O),await J.stop(),await e.release()})(),ye)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{he.shutdown(O).then(()=>process.exit(0))});return process.on("exit",()=>c0()),process.on("unhandledRejection",O=>{q.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{q.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}
|
|
107
|
+
`)}catch{}process.exit(1)}),q.info("daemon ready",{port:te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),wS({cliSpawned:process.env[Yi]==="1",readPatToken:()=>Ko(t),connect:N}).catch(O=>q.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(O)})),he}async function pS(t){return os(t).length>0}function Zo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Th(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function gS(t,e){let r=os(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),ds));for(let c of r){await o(c,t).catch(d=>q.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(d)}));try{let d=await i(c,t);d?.disconnectedAt&&(e.disconnectedAgents.add(c),q.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:d.disconnectedAt,reason:d.disconnectReason??""}))}catch(d){q.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(d)})}}}async function mS(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),ds)),d=await c(t,e);if(d){q.info("--agent-id: local config found, reconnecting",{agentId:t,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let w={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...o?{patToken:o}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:d.disconnectedAt?"revived from local config":"connected from local config"}}q.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 D("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let h=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function Xo(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(),ds));q.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,d=0;for(let u of i){let x;try{x=await o(u,t)}catch(h){q.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(h)}),d+=1;continue}if(!x){d+=1;continue}if(x.disconnectedAt){q.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),d+=1;continue}try{q.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let h=_S(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}},{revive:!0}),c+=1}catch(h){q.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(h)}),d+=1}}return q.info("auto-revive: done",{revived:c,skipped:d,total:i.length}),{revived:c,skipped:d,total:i.length}}async function wS(t){let e=t.logger??q;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 _S(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Jo();Ie();import{readFile as Dh}from"node:fs/promises";var Jt=class{paths;constructor(e){this.paths=e??Y()}async probe(e=1e3){let r=await Qo(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:ES(i)}}}async request(e){let r=await Qo(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,d=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),x=await u.text();return{status:u.status,body:yS(x)}}finally{clearTimeout(d)}}};async function Qo(t){try{let[e,r]=await Promise.all([Dh(t.portFile,"utf8"),Dh(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 yS(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function ES(t){return t instanceof Error?t.message:String(t)}yn();ne();Ie();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],d=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,d=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),d=!0;break}}d||r.push(c)}return{value:i,rest:r}}en();import{chmod as bS,copyFile as Rh,mkdir as Ph,readFile as ea,rename as kh,rm as Ld,stat as Oh,writeFile as vS}from"node:fs/promises";import{homedir as cR}from"node:os";import{dirname as SS,join as Fr,resolve as Md,sep as Zi}from"node:path";import{fileURLToPath as AS}from"node:url";yn();ne();Ie();var Bd=H("dist-install");function IS(t){let e=AS(t),r=SS(e),i=`${Zi}src${Zi}`;if(r.includes(i)||r.endsWith(`${Zi}src${Zi}cli`))return null;let o=Md(r,"index.js"),c=Md(r,"..","package.json");return{dist:o,pkgJson:c}}async function zd(t={}){let e=t.paths??Y(),r=IS(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,d;try{let A=JSON.parse(await ea(o,"utf8"));c=A.version??"unknown",d=A.dependencies??{}}catch(A){return Bd.warn("cannot read source package.json,skip dist install",{err:String(A)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(A)}`}}let u=Vr.map(A=>`${A}@${d[A]??"latest"}`),x=await Eo(e.configFile)??{},h=x.libVersion,w=await ea(e.libEntry).then(()=>!0).catch(()=>!1),y=h===c;if(y&&w&&await Fd(e))return{kind:"already-current",libVersion:c};if(!y||!w){await Ph(e.libDir,{recursive:!0}),await Rh(i,e.libEntry),await Rh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let A=Md(e.libDir,"package.json"),E=`${JSON.stringify({type:"module"},null,2)}
|
|
108
|
+
`;await ea(A,"utf8").catch(()=>null)!==E&&await vS(A,E)}return(!y||!await Fd(e))&&await(t.installWrappers??TS)(e,u),x.libVersion=c,await Bi(x,e.configFile),Bd.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:c}),y&&w?{kind:"already-current",libVersion:c}:h?{kind:"version-changed",fromVersion:h,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Fd(t){for(let e of Vr){let r=Fr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Oh(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function TS(t,e){await RS(t.installLock,async()=>{if(await Fd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Zi}.staging-${process.pid}-${r}`,o=Fr(i,"node_modules"),c=Fr(t.libDir,"node_modules");try{await Ph(i,{recursive:!0}),await CS(e,i),await DS(o);let d=`${c}.trash-${r}`;await kh(c,d).catch(()=>{}),await kh(o,c),await Ld(d,{recursive:!0,force:!0}).catch(()=>{}),Bd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Ld(i,{recursive:!0,force:!0}).catch(()=>{})}})}function CS(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=ct("npm",r,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",x=>{d.length<8192&&(d+=x.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(u),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${d.trim().slice(0,2e3)}`))})})}async function DS(t){for(let e of Vr){let r=Fr(t,...e.split("/")),i=JSON.parse(await ea(Fr(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=Fr(t,".bin",o),d=await Oh(c);process.platform!=="win32"&&!(d.mode&73)&&await bS(c,d.mode|73).catch(()=>{})}}async function RS(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 Ld(t,{force:!0}).catch(()=>{})}}ba();ne();Ie();import{closeSync as Lh,fstatSync as Mh,openSync as Bh,readFileSync as kS,readSync as PS,readdirSync as OS,statSync as NS}from"node:fs";import{join as ta}from"node:path";var LS=new Set(["debug","info","warn","error"]);function Fh(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 d=Sn(e,"--grep");e=d.rest;let u=o.value===void 0?200:Number(o.value),x=Number.isInteger(u)&&u>=0?u:200,h=c.value&&LS.has(c.value)?c.value:void 0,w={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(w.agentId=r.value),i.value&&(w.date=i.value),h&&(w.level=h),d.value&&(w.grep=d.value),w}function MS(t,e){return t.agentId?ta(We(t.agentId,e).logs,Qn("agent",t.date)):ta(e.bridgeLogsDir,Qn("bridge",t.date))}function BS(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function FS(t,e){let r;try{r=OS(t)}catch{return[]}let i=[];for(let o of r){let c=Ea(o,e);if(!c)continue;let d=0;try{d=NS(ta(t,o)).size}catch{}i.push({file:ta(t,o),date:c,size:d})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function zh(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"&&!pl(r,e.level))return!1}return!0}var Nh={debug:"90",info:"36",warn:"33",error:"31"},zS=new Set(["ts","level","module","msg"]);function US(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Uh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=US(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&Nh[o]&&(c=`\x1B[${Nh[o]}m${c}\x1B[0m`);let d=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([h])=>!zS.has(h)).map(([h,w])=>` ${h}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${d} ${u}${x}`}function HS(t,e,r){let c=kS(t,"utf8").split(`
|
|
109
|
+
`).filter(d=>d.length>0).filter(d=>zh(d,{level:e.level,grep:e.grep}));for(let d of BS(c,e.lines))process.stdout.write(`${Uh(d,{raw:e.raw,color:r})}
|
|
110
|
+
`)}async function Hh(t,e){let r=e.paths??Y(),i=process.stdout.isTTY===!0;if(t.list){let d=t.agentId?We(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",x=FS(d,u);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${d}
|
|
110
111
|
`),1;for(let h of x)process.stdout.write(`${h.date} ${(h.size/1024).toFixed(1)}KB ${h.file}
|
|
111
|
-
`);return 0}let o=t.date??In(new Date),c=
|
|
112
|
+
`);return 0}let o=t.date??In(new Date),c=MS({agentId:t.agentId,date:o},r);try{HS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
112
113
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
113
114
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
114
|
-
`),1}return t.follow&&await
|
|
115
|
-
`);o=x.pop()??"";for(let h of x)h.length>0&&
|
|
116
|
-
`)}await new Promise(x=>setTimeout(x,
|
|
115
|
+
`),1}return t.follow&&await jS(c,t,i),0}var GS=500;function qS(t){try{let e=Bh(t,"r");try{return Mh(e).size}finally{Lh(e)}}catch{return 0}}async function jS(t,e,r){let i=qS(t),o="",c=!1,d=()=>{c=!0};process.on("SIGINT",d);try{for(;!c;){let u="";try{let x=Bh(t,"r");try{let h=Mh(x).size;if(h>i){let w=Buffer.allocUnsafe(h-i),y=PS(x,w,0,w.length,i);u=w.subarray(0,y).toString("utf8"),i+=y}}finally{Lh(x)}}catch{}if(u){let x=(o+u).split(`
|
|
116
|
+
`);o=x.pop()??"";for(let h of x)h.length>0&&zh(h,{level:e.level,grep:e.grep})&&process.stdout.write(`${Uh(h,{raw:e.raw,color:r})}
|
|
117
|
+
`)}await new Promise(x=>setTimeout(x,GS))}}finally{process.off("SIGINT",d)}}import{basename as WS,resolve as KS}from"node:path";Ie();var $S=9e4,VS={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 JS(t){return VS[t]??1}async function Gh(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
118
|
`),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:
|
|
119
|
+
`),3;let i=await Qo(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.
|
|
120
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:KS(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 YS(i,"/agent/send",o,$S)}catch(d){return process.stderr.write(`Error: daemon IPC failed: ${d instanceof Error?d.message:String(d)}
|
|
120
121
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
121
|
-
`),
|
|
122
|
-
`);else{let
|
|
123
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
124
|
-
`)}return 0}async function
|
|
125
|
-
`)}function
|
|
122
|
+
`),JS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
123
|
+
`);else{let d=t.name??WS(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${d} (uri=${u})
|
|
124
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${d} (${ZS(c.bytes)})
|
|
125
|
+
`)}return 0}async function YS(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let d=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),u=await d.text(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${d.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function ZS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Zh=H("cli");function Ue(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function aa(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
126
|
+
`)}function E1(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}=Ue(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 b1(e.slice(1));if(e[0]==="log")return{mode:"log",...Fh(e.slice(1))};if(e[0]==="connect")return v1(e.slice(1));if(e.includes("--status"))return aa("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return aa("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return aa("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return aa("--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}=Ue(r,"--pat-token");r=o;let{value:c,rest:d}=Ue(r,"--pair-code");r=d;let{value:u,rest:x}=Ue(r,"--env");r=x;let{value:h,rest:w}=Ue(r,"--handshake-url");r=w;let{value:y,rest:A}=Ue(r,"--frontier-url");r=A;let{value:E,rest:v}=Ue(r,"--mock-scenario");r=v;let{value:I}=Ue(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return u&&(S.env=u),h&&(S.handshakeUrl=h),y&&(S.frontierUrl=y),E&&(S.mockScenario=E),I&&(S.agentId=I),S}function b1(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}=Ue(i,"--caption");i=c;let{value:d,rest:u}=Ue(i,"--name");i=u;let{value:x,rest:h}=Ue(i,"--agent-id");i=h;let{value:w,rest:y}=Ue(i,"--session-id");i=y;let{value:A,rest:E}=Ue(i,"--mime");i=E;let v=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let I=i.includes("--json"),S={mode:"send",kind:e,path:r,json:I};return o&&(S.caption=o),d&&(S.name=d),x&&(S.agentId=x),w&&(S.sessionId=w),v&&(S.groupFile=!0),A&&(S.mimeType=A),S}function v1(t){let e=t,{value:r,rest:i}=Ue(e,"--pat-token");e=i;let{value:o,rest:c}=Ue(e,"--env");e=c;let{value:d,rest:u}=Ue(e,"--handshake-url");e=u;let{value:x,rest:h}=Ue(e,"--frontier-url");e=h;let{value:w,rest:y}=Ue(e,"--mock-scenario");e=y;let A={mode:"connect"};return r&&(A.privatecode=r),o&&(A.env=o),d&&(A.handshakeUrl=d),x&&(A.frontierUrl=x),w&&(A.mockScenario=w),A}var S1=`
|
|
126
127
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
127
128
|
|
|
128
129
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -201,56 +202,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
201
202
|
|
|
202
203
|
Internal:
|
|
203
204
|
<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
|
|
205
|
+
`.trimStart();async function Xh(t=process.argv,e={}){let r=E1(t);switch(r.mode){case"help":return process.stdout.write(S1),0;case"version":return process.stdout.write(`${vr}
|
|
206
|
+
`),0;case"daemon":{try{await Ch()}catch(i){return Zh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return A1(e);case"stop":return ep(e);case"reload":return C1(r.agentId,e);case"log":return Hh(r,e);case"update":return I1(e);case"purge":return D1(e);case"service-install":return R1(e);case"service-uninstall":return k1(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),P1(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),O1(r.privatecode,e,i)}case"send":return Gh({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 Qh(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 A1(t){let e=t.paths??Y(),r=new Jt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
207
|
+
`),1;if(i.kind==="stale")return await Qh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
207
208
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
208
209
|
${JSON.stringify(o.body,null,2)}
|
|
209
|
-
`),0}async function
|
|
210
|
+
`),0}async function ep(t){let e=t.paths??Y(),r=new Jt(e),i=await Qi(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
210
211
|
`)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
211
212
|
`:`coze-bridge: not running
|
|
212
|
-
`),0;if(c.kind==="stale")return await
|
|
213
|
+
`),0;if(c.kind==="stale")return await Qh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
214
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
214
|
-
`),0}catch(
|
|
215
|
-
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(
|
|
216
|
-
`),1)}}async function
|
|
217
|
-
`),e(1)})})}async function
|
|
215
|
+
`),0}catch(d){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
216
|
+
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(d)}
|
|
217
|
+
`),1)}}async function I1(t){return await ep(t),(t.spawnNpx??T1)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function T1(t){return new Promise(e=>{let r=ct("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)}
|
|
218
|
+
`),e(1)})})}async function C1(t,e){let r=new Jt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
218
219
|
`),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
220
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
220
221
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
221
222
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
222
|
-
`),1}}async function
|
|
223
|
+
`),1}}async function Qi(t){if(t.supervisor){let c=t.supervisor,d={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(d,u),uninstall:()=>c.uninstall(d)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Jh(),Vh)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function tp(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??Ih,o=t.waitTimeoutMs??15e3,c=t.sleep??L1,d=t.paths??Y(),u=await Qi(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let x=await Yh(e,o,c);if(x.kind==="connected")return x;$r(d.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){$r(d.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}await u.uninstall().catch(()=>{}),await N1(d.pidFile,c)}else u&&await u.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
|
|
223
224
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
224
|
-
`),await i({paths:t.paths}),
|
|
225
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
226
|
-
`)}await new Promise(
|
|
227
|
-
`)}catch(
|
|
228
|
-
`)}let o=t.paths??
|
|
229
|
-
`)}catch(
|
|
225
|
+
`),await i({paths:t.paths}),Yh(e,o,c)}async function D1(t){let e=new Jt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
226
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
|
|
227
|
+
`)}await new Promise(d=>setTimeout(d,500))}let i=await Qi(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
228
|
+
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
229
|
+
`)}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}
|
|
230
|
+
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
230
231
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
231
|
-
`),0}async function
|
|
232
|
+
`),0}async function R1(t){let e=await Qi(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
232
233
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
233
234
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
234
|
-
`),1}}async function
|
|
235
|
+
`),1}}async function k1(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
236
|
`),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 x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let
|
|
237
|
+
`),1}}async function P1(t,e,r,i={},o){let c=new Jt(r.paths),d=r.paths??Y();if(await Yc(d).catch(h=>$r(d.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!r.skipDistInstall){let h=await zd({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
238
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
239
|
+
`)}let u=await tp(r,c);if(u.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
240
|
+
`),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let w=h.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
|
|
240
241
|
`),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
242
|
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
|
|
242
243
|
`),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
245
|
-
`)}let
|
|
246
|
-
`),1;let
|
|
247
|
-
`),await Ji(o,i).catch(h=>
|
|
244
|
+
`),1}}async function O1(t,e,r={}){let i=e.paths??Y(),o=t??await Ko(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 Jt(e.paths);if(await Yc(i).catch(x=>$r(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!e.skipDistInstall){let x=await zd({paths:e.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
245
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
246
|
+
`)}let d=await tp(e,c);if(d.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${d.kind}
|
|
247
|
+
`),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 x=await c.request({method:"POST",path:"/connect",body:u,timeoutMs:35e3});return x.status===200&&x.body?.ok?(process.stdout.write(`coze-bridge: connected (${x.body.note??"ok"})
|
|
248
|
+
`),await Ji(o,i).catch(h=>Zh.warn("writePatToken after connect failed (ignored)",{err:String(h)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
|
|
248
249
|
`),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
|
|
249
|
-
`),1}}async function
|
|
250
|
+
`),1}}async function Yh(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 N1(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let d;try{d=await o(t,"utf8")}catch{return}let u=Number.parseInt(d.trim(),10);if(!Number.isFinite(u)||u<=0||!co(u))return;await e(i)}}function L1(t){return new Promise(e=>setTimeout(e,t))}ne();function M1(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 np(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=M1(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
251
|
`),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
252
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
252
253
|
npx -y coze-bridge@latest stop
|
|
253
254
|
npx -y coze-bridge@latest connect
|
|
254
255
|
|
|
255
|
-
`)}
|
|
256
|
+
`)}np();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&xl("warn");Xh(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
256
257
|
`),process.exit(1)});
|