coze-bridge 0.1.96-beta.1 → 0.1.96-beta.2
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 +75 -71
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,25 +5,25 @@ 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 Dp=Object.create;var ha=Object.defineProperty;var kp=Object.getOwnPropertyDescriptor;var Op=Object.getOwnPropertyNames;var Pp=Object.getPrototypeOf,Np=Object.prototype.hasOwnProperty;var ce=(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 Ze=(t,e)=>()=>(t&&(e=t(t=0)),e);var ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xa=(t,e)=>{for(var r in e)ha(t,r,{get:e[r],enumerable:!0})},Lp=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Op(e))!Np.call(t,o)&&o!==r&&ha(t,o,{get:()=>e[o],enumerable:!(i=kp(e,o))||i.enumerable});return t};var It=(t,e,r)=>(r=t!=null?Dp(Pp(t)):{},Lp(e||!t||!t.__esModule?ha(r,"default",{value:t,enumerable:!0}):r,t));function Ft(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Zi=Ze(()=>{"use strict"});import{createWriteStream as Mp,mkdirSync as Bp,readdirSync as zp,unlinkSync as Fp}from"node:fs";import{join as Xd}from"node:path";function An(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Xn(t,e){return`${t}-${e}.log`}function pa(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Up(t,e,r){let i=c=>{let[l,u,h]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,h??1)};return Math.floor((i(e)-i(t))/864e5)>r}function Xi(t,e,r,i){let o;try{o=zp(t)}catch{return}for(let c of o){let l=pa(c,e);if(l&&Up(l,r,i))try{Fp(Xd(t,c))}catch{}}}var Gr,ga=Ze(()=>{"use strict";Gr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>An(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Bp(this.dir,{recursive:!0});let r=Mp(Xd(this.dir,Xn(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&Xi(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 qp,mkdirSync as
|
|
11
|
-
`;
|
|
12
|
-
`;if(es){let l=Jp(o,i),
|
|
13
|
-
`),{cause:o})}}async function Qp(t){let e=_a[t];if(e)try{let r=ol.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(sl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){wa.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ns(t){return Kr.get(t)}function al(t,e){if(e)return e;let r=ns(t);if(!r)throw new
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await ul(o,i,{encoding:"utf8",mode:r.mode}):await ul(o,i,"utf8"),await fl(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await fl(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Vr=Ze(()=>{"use strict"});import{promises as xl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as De,resolve as hl}from"node:path";function ee(t){let e=t??cg(),r=De(e,".coze"),i=De(r,"bridge"),o=De(i,"lib"),c=De(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:De(o,"index.js"),binDir:De(i,"bin"),pidFile:De(i,"bridge.pid"),portFile:De(i,"bridge.port"),tokenFile:De(i,"bridge.token"),patTokenFile:De(i,"pat-token"),agentEnvFile:De(i,"agent-env.json"),logFile:De(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:De(c,"daemon-stdio.log"),installLock:De(i,"install.lock"),configFile:De(i,"config.json"),agentsRoot:De(r,"agents")}}function Xe(t,e=ee()){let r=De(e.agentsRoot,t);return{root:r,config:De(r,"config.json"),workspace:De(r,"workspace"),logs:De(r,"logs")}}function rs(t=ee()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Yr(t,e){let r=await xl.realpath(hl(t)).catch(()=>null);if(!r)return!1;let i=await xl.realpath(hl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+dg)}var Le=Ze(()=>{"use strict"});var os={};ha(os,{AGENT_CONFIG_FILE_MODE:()=>is,enforceAgentConfigMode:()=>ug,loadAgentConfig:()=>je,persistAgentSessions:()=>Zr,persistAgentSkills:()=>ss,saveAgentConfig:()=>Qe});import{chmod as lg,stat as fg}from"node:fs/promises";function je(t,e){return tr(Xe(t,e).config)}function Qe(t,e){return nr(Xe(t.agentId,e).config,t,{mode:is})}async function ug(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await fg(r);if(!i.isFile())return;let o=i.mode&511;o!==is&&(await lg(r,is),pl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;pl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Zr(t,e,r){let i=await je(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function ss(t,e,r){let i=await je(t,r);i&&(i.skills=e,await Qe(i,r))}var pl,is,rn=Ze(()=>{"use strict";Vr();ie();Le();pl=j("agent-config"),is=384});var Ea=ae((LS,_l)=>{_l.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var cs=ae(bl=>{var yl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function 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(yl))bl[t]=mg(yl[t])});var Al=ae((MS,Il)=>{var wg=ue("fs"),Ne=ue("path"),El=Ea(),_g=cs(),yg=typeof process=="object"&&process.platform==="win32",vl=t=>typeof t=="object"&&t!==null,Sl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ie(t){this.sep=Ne.sep,this.fs=wg,vl(t)&&vl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Il.exports=Ie;Ie.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 _g.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ie.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=Ne.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};Ie.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 p=Ne.dirname(t);c.fs.exists(p,function(b){b||c.makeDir(p),c.fs.open(t,"w",438,function(_,A){_?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(w,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)})})})})})};Ie.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=Ne.join(i,f),p=e.fs.statSync(x);(!o||o.test(x))&&l.push(Ne.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};Ie.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=Ne.join(t,f),r.fs.stat(f,function(x,p){if(x)return e(x);p&&(i.push(Ne.normalize(f)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(f,function(b,_){if(b)return e(b);i=i.concat(_),--l||e(null,i)}):--l||e(null,i))})})})};Ie.prototype.getAttributes=function(){};Ie.prototype.setAttributes=function(){};Ie.crc32update=function(t,e){return Sl[(t^e)&255]^t>>>8};Ie.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ie.crc32update(r,t[i++]);return~r>>>0};Ie.methodToString=function(t){switch(t){case El.STORED:return"STORED ("+t+")";case El.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ie.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};Ie.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.posix.join(".",e)};Ie.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]};Ie.sanitize=function(t,e){t=Ne.resolve(Ne.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ne.normalize(Ne.join(t,r.slice(i,o).join(Ne.sep)));if(c.indexOf(t)===0)return c}return Ne.normalize(Ne.join(t,Ne.basename(e)))};Ie.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ie.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ie.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)};Ie.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};Ie.isWin=yg;Ie.crcTable=Sl});var Cl=ae((BS,Tl)=>{var bg=ue("path");Tl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=bg.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 Rl=ae((FS,Dl)=>{Dl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=ae((zS,ir)=>{ir.exports=Al();ir.exports.Constants=Ea();ir.exports.Errors=cs();ir.exports.FileAttr=Cl();ir.exports.decoder=Rl()});var Pl=ae((US,kl)=>{var sn=sr(),H=sn.Constants;kl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,f=0,x=0,p=0,b=0,_=0,A=0,w=0,v=0;t|=sn.isWin?2560:768,r|=H.FLG_EFS;let I={extraLen:0},S=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,L=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&H.FLG_EFS)>0},set flags_efs(y){y?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(y){y?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return i},set method(y){switch(y){case H.STORED:this.version=10;case H.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=S(y)},get timeHighByte(){return L(o>>>8)},get crc(){return c},set crc(y){c=S(y)},get compressedSize(){return l},set compressedSize(y){l=S(y)},get size(){return f},set size(y){f=S(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return b},set commentLength(y){b=y},get diskNumStart(){return _},set diskNumStart(y){_=S(y)},get inAttr(){return A},set inAttr(y){A=S(y)},get attr(){return w},set attr(y){w=S(y)},get fileAttr(){return(w||0)>>16&4095},get offset(){return v},set offset(y){v=S(y)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+x+p+b},get realDataOffset(){return v+H.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var D=y.slice(v,v+H.LOCHDR);if(D.readUInt32LE(0)!==H.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=D.readUInt16LE(H.LOCVER),I.flags=D.readUInt16LE(H.LOCFLG),I.flags_desc=(I.flags&H.FLG_DESC)>0,I.method=D.readUInt16LE(H.LOCHOW),I.time=D.readUInt32LE(H.LOCTIM),I.crc=D.readUInt32LE(H.LOCCRC),I.compressedSize=D.readUInt32LE(H.LOCSIZ),I.size=D.readUInt32LE(H.LOCLEN),I.fnameLen=D.readUInt16LE(H.LOCNAM),I.extraLen=D.readUInt16LE(H.LOCEXT);let R=v+H.LOCHDR+I.fnameLen,M=R+I.extraLen;return y.slice(R,M)},loadFromBinary:function(y){if(y.length!==H.CENHDR||y.readUInt32LE(0)!==H.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(H.CENVEM),e=y.readUInt16LE(H.CENVER),r=y.readUInt16LE(H.CENFLG),i=y.readUInt16LE(H.CENHOW),o=y.readUInt32LE(H.CENTIM),c=y.readUInt32LE(H.CENCRC),l=y.readUInt32LE(H.CENSIZ),f=y.readUInt32LE(H.CENLEN),x=y.readUInt16LE(H.CENNAM),p=y.readUInt16LE(H.CENEXT),b=y.readUInt16LE(H.CENCOM),_=y.readUInt16LE(H.CENDSK),A=y.readUInt16LE(H.CENATT),w=y.readUInt32LE(H.CENATX),v=y.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(H.LOCHDR);return y.writeUInt32LE(H.LOCSIG,0),y.writeUInt16LE(e,H.LOCVER),y.writeUInt16LE(r,H.LOCFLG),y.writeUInt16LE(i,H.LOCHOW),y.writeUInt32LE(o,H.LOCTIM),y.writeUInt32LE(c,H.LOCCRC),y.writeUInt32LE(l,H.LOCSIZ),y.writeUInt32LE(f,H.LOCLEN),y.writeUInt16LE(x,H.LOCNAM),y.writeUInt16LE(I.extraLen,H.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(H.CENHDR+x+p+b);return y.writeUInt32LE(H.CENSIG,0),y.writeUInt16LE(t,H.CENVEM),y.writeUInt16LE(e,H.CENVER),y.writeUInt16LE(r,H.CENFLG),y.writeUInt16LE(i,H.CENHOW),y.writeUInt32LE(o,H.CENTIM),y.writeUInt32LE(c,H.CENCRC),y.writeUInt32LE(l,H.CENSIZ),y.writeUInt32LE(f,H.CENLEN),y.writeUInt16LE(x,H.CENNAM),y.writeUInt16LE(p,H.CENEXT),y.writeUInt16LE(b,H.CENCOM),y.writeUInt16LE(_,H.CENDSK),y.writeUInt16LE(A,H.CENATT),y.writeUInt32LE(w,H.CENATX),y.writeUInt32LE(v,H.CENOFF),y},toJSON:function(){let y=function(D){return D+" 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(p),commentLength:y(b),diskNumStart:_,inAttr:A,attr:w,offset:v,centralHeaderSize:y(H.CENHDR+x+p+b)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ll=ae((qS,Ol)=>{var or=sr(),ye=or.Constants;Ol.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 ye.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ye.ENDHDR||c.readUInt32LE(0)!==ye.ENDSIG)&&(c.length<ye.ZIP64HDR||c.readUInt32LE(0)!==ye.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===ye.ENDSIG?(t=c.readUInt16LE(ye.ENDSUB),e=c.readUInt16LE(ye.ENDTOT),r=c.readUInt32LE(ye.ENDSIZ),i=c.readUInt32LE(ye.ENDOFF),o=c.readUInt16LE(ye.ENDCOM)):(t=or.readBigUInt64LE(c,ye.ZIP64SUB),e=or.readBigUInt64LE(c,ye.ZIP64TOT),r=or.readBigUInt64LE(c,ye.ZIP64SIZE),i=or.readBigUInt64LE(c,ye.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ye.ENDHDR+o);return c.writeUInt32LE(ye.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ye.ENDSUB),c.writeUInt16LE(e,ye.ENDTOT),c.writeUInt32LE(r,ye.ENDSIZ),c.writeUInt32LE(i,ye.ENDOFF),c.writeUInt16LE(o,ye.ENDCOM),c.fill(" ",ye.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 Sa=ae(va=>{va.EntryHeader=Pl();va.MainHeader=Ll()});var Ml=ae((HS,Nl)=>{Nl.exports=function(t){var e=ue("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),x=0;f.fill(0);for(var p=0;p<c.length;p++){var b=c[p];b.copy(f,x),x+=b.length}i&&i(f)}),o.end(t)}}}});var Fl=ae((jS,Bl)=>{var Eg=+(process.versions?process.versions.node:"").split(".")[0]||0;Bl.exports=function(t,e){var r=ue("zlib");let i=Eg>=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),p=0;x.fill(0);for(var b=0;b<l.length;b++){var _=l[b];_.copy(x,p),p+=_.length}o&&o(x)}),c.end(t)}}}});var Hl=ae((WS,Gl)=>{"use strict";var{randomFillSync:zl}=ue("crypto"),vg=cs(),Sg=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,Ul=(t,e)=>Sg[(t^e)&255]^t>>>8,Xr=()=>typeof zl=="function"?zl(Buffer.alloc(12)):Xr.node();Xr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ds={genSalt:Xr};function ls(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}ls.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ul(e[0],t),e[1]+=e[0]&255,e[1]=ql(e[1],134775813)+1,e[2]=Ul(e[2],e[1]>>>24),t};ls.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return ql(t,t^1)>>8&255};function Ig(t){let e=new ls(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Ag(t){let e=new ls(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ig(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Cg(t){Buffer.isBuffer(t)&&t.length>=12?ds.genSalt=function(){return t.slice(0,12)}:t==="node"?ds.genSalt=Xr.node:ds.genSalt=Xr}function Dg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ag(r),c=ds.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Gl.exports={decrypt:Tg,encrypt:Dg,_salter:Cg}});var jl=ae(fs=>{fs.Deflater=Ml();fs.Inflater=Fl();fs.ZipCrypto=Hl()});var Aa=ae(($S,Wl)=>{var ce=sr(),Rg=Sa(),Ae=ce.Constants,Ia=jl();Wl.exports=function(t,e){var r=new Rg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let b=t,_=typeof b.decoder=="object"?b.decoder:ce.decoder;p=_.hasOwnProperty("efs")?_.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 w(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ce.crc32(y)!==r.localHeader.crc)return!1}else{let D={},R=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(R)==Ae.LOCSIG||e.readUInt32LE(R)==Ae.CENSIG)throw ce.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(R)==Ae.EXTSIG)D.crc=e.readUInt32LE(R+Ae.EXTCRC),D.compressedSize=e.readUInt32LE(R+Ae.EXTSIZ),D.size=e.readUInt32LE(R+Ae.EXTLEN);else if(e.readUInt16LE(R+12)===19280)D.crc=e.readUInt32LE(R+Ae.EXTCRC-4),D.compressedSize=e.readUInt32LE(R+Ae.EXTSIZ-4),D.size=e.readUInt32LE(R+Ae.EXTLEN-4);else throw ce.Errors.DESCRIPTOR_UNKNOWN();if(D.compressedSize!==r.compressedSize||D.size!==r.size||D.crc!==r.crc)throw ce.Errors.DESCRIPTOR_FAULTY();if(ce.crc32(y)!==D.crc)return!1}return!0}function v(y,D,R){if(typeof D>"u"&&typeof y=="string"&&(R=y,y=void 0),c)return y&&D&&D(Buffer.alloc(0),ce.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=A();if(M.length===0)return y&&D&&D(M),M;if(r.encrypted){if(typeof R!="string"&&!Buffer.isBuffer(R))throw ce.Errors.INVALID_PASS_PARAM();M=Ia.ZipCrypto.decrypt(M,r,R)}var B=Buffer.alloc(r.size);switch(r.method){case ce.Constants.STORED:if(M.copy(B),w(B))return y&&D&&D(B),B;throw y&&D&&D(B,ce.Errors.BAD_CRC()),ce.Errors.BAD_CRC();case ce.Constants.DEFLATED:var Z=new Ia.Inflater(M,r.size);if(y)Z.inflateAsync(function(X){X.copy(X,0),D&&(w(X)?D(X):D(X,ce.Errors.BAD_CRC()))});else{if(Z.inflate(B).copy(B,0),!w(B))throw ce.Errors.BAD_CRC(`"${_.decode(i)}"`);return B}break;default:throw y&&D&&D(Buffer.alloc(0),ce.Errors.UNKNOWN_METHOD()),ce.Errors.UNKNOWN_METHOD()}}function I(y,D){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&D&&D(A()),A();if(l.length&&!c){var R;switch(r.method){case ce.Constants.STORED:return r.compressedSize=r.size,R=Buffer.alloc(l.length),l.copy(R),y&&D&&D(R),R;default:case ce.Constants.DEFLATED:var M=new Ia.Deflater(l);if(y)M.deflateAsync(function(Z){R=Buffer.alloc(Z.length),r.compressedSize=Z.length,Z.copy(R),D&&D(R)});else{var B=M.deflate();return r.compressedSize=B.length,B}M=null;break}}else if(y&&D)D(Buffer.alloc(0));else return Buffer.alloc(0)}function S(y,D){return ce.readBigUInt64LE(y,D)}function C(y){try{for(var D=0,R,M,B;D+4<y.length;)R=y.readUInt16LE(D),D+=2,M=y.readUInt16LE(D),D+=2,B=y.slice(D,D+M),D+=M,Ae.ID_ZIP64===R&&L(B)}catch{throw ce.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(y){var D,R,M,B;y.length>=Ae.EF_ZIP64_SCOMP&&(D=S(y,Ae.EF_ZIP64_SUNCOMP),r.size===Ae.EF_ZIP64_OR_32&&(r.size=D)),y.length>=Ae.EF_ZIP64_RHO&&(R=S(y,Ae.EF_ZIP64_SCOMP),r.compressedSize===Ae.EF_ZIP64_OR_32&&(r.compressedSize=R)),y.length>=Ae.EF_ZIP64_DSN&&(M=S(y,Ae.EF_ZIP64_RHO),r.offset===Ae.EF_ZIP64_OR_32&&(r.offset=M)),y.length>=Ae.EF_ZIP64_DSN+4&&(B=y.readUInt32LE(Ae.EF_ZIP64_DSN),r.diskNumStart===Ae.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(y){i=ce.toBuffer(y,_.encode);var D=i[i.length-1];c=D===47||D===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return f},set extra(y){f=y,r.extraLength=y.length,C(y)},get comment(){return _.decode(o)},set comment(y){if(o=ce.toBuffer(y,_.encode),r.commentLength=o.length,o.length>65535)throw ce.Errors.COMMENT_TOO_LONG()},get name(){var y=_.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=ce.toBuffer(y,ce.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ce.Constants.DEFLATED,r.crc=ce.crc32(y),r.changed=!0):r.method=ce.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,D){r.changed?y(l):v(!0,y,D)},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(),D=ce.Constants.CENHDR;return i.copy(y,D),D+=i.length,f.copy(y,D),D+=r.extraLength,o.copy(y,D),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let D=r.localHeaderToBinary(),R=Buffer.alloc(D.length+i.length+r.extraLocalLength);return D.copy(R,y),y+=D.length,i.copy(R,y),y+=i.length,x.copy(R,y),y+=x.length,R},toJSON:function(){let y=function(D){return"<"+(D&&D.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 Jl=ae((JS,$l)=>{var Kl=Aa(),kg=Sa(),We=sr();$l.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,f=null;let x=new Set,p=e,{noSort:b,decoder:_}=p;t?v(p.readEntries):l=!0;function A(){let S=new Set;for(let C of Object.keys(i)){let L=C.split("/");if(L.pop(),!!L.length)for(let y=0;y<L.length;y++){let D=L.slice(0,y+1).join("/")+"/";S.add(D)}}for(let C of S)if(!(C in i)){let L=new Kl(p);L.entryName=C,L.attr=16,L.temporary=!0,r.push(L),i[L.entryName]=L,x.add(L)}}function w(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/We.Constants.CENHDR)throw We.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,C=0;C<r.length;C++){var L=S,y=new Kl(p,t);y.header=t.slice(L,L+=We.Constants.CENHDR),y.entryName=t.slice(L,L+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(L,L+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(L,L+y.header.commentLength)),S+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}x.clear(),A()}function v(S){var C=t.length-We.Constants.ENDHDR,L=Math.max(0,C-65535),y=L,D=t.length,R=-1,M=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(L=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===We.Constants.ENDSIG){R=C,M=C,D=C+We.Constants.ENDHDR,y=C-We.Constants.END64HDR;continue}if(t.readUInt32LE(C)===We.Constants.END64SIG){y=L;continue}if(t.readUInt32LE(C)===We.Constants.ZIP64SIG){R=C,D=C+We.readBigUInt64LE(t,C+We.Constants.ZIP64SIZE)+We.Constants.ZIP64LEAD;break}}if(R==-1)throw We.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(R,D)),c.commentLength&&(o=t.slice(M+We.Constants.ENDHDR)),S&&w()}function I(){r.length>1&&!b&&r.sort((S,C)=>S.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||w(),r.filter(S=>!x.has(S))},get comment(){return _.decode(o)},set comment(S){o=We.toBuffer(S,_.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||w(),i[S]||null},setEntry:function(S){l||w(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,C=!0){l||w();let L=i[S];this.getEntryChildren(L,C).map(D=>D.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||w();let C=i[S],L=r.indexOf(C);L>=0&&(r.splice(L,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,C=!0){if(l||w(),typeof S=="object")if(S.isDirectory&&C){let L=[],y=S.entryName;for(let D of r)D.entryName.startsWith(y)&&L.push(D);return L}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let C=this.getEntryChildren(S);return C.includes(S)?C.length-1:C.length}return 0},compressToBuffer:function(){l||w(),I();let S=[],C=[],L=0,y=0;c.size=0,c.offset=0;let D=0;for(let B of this.entries){let Z=B.getCompressedData();B.header.offset=y;let X=B.packLocalHeader(),re=X.length+Z.length;y+=re,S.push(X),S.push(Z);let te=B.packCentralHeader();C.push(te),c.size+=te.length,L+=re+te.length,D++}L+=c.mainHeaderSize,c.offset=y,c.totalEntries=D,y=0;let R=Buffer.alloc(L);for(let B of S)B.copy(R,y),y+=B.length;for(let B of C)B.copy(R,y),y+=B.length;let M=c.toBinary();return o&&o.copy(M,We.Constants.ENDHDR),M.copy(R,y),t=R,l=!1,R},toAsyncBuffer:function(S,C,L,y){try{l||w(),I();let D=[],R=[],M=0,B=0,Z=0;c.size=0,c.offset=0;let X=function(re){if(re.length>0){let te=re.shift(),Se=te.entryName+te.extra.toString();L&&L(Se),te.getCompressedDataAsync(function(ge){y&&y(Se),te.header.offset=B;let O=te.packLocalHeader(),K=O.length+ge.length;B+=K,D.push(O),D.push(ge);let V=te.packCentralHeader();R.push(V),c.size+=V.length,M+=K+V.length,Z++,X(re)})}else{M+=c.mainHeaderSize,c.offset=B,c.totalEntries=Z,B=0;let te=Buffer.alloc(M);D.forEach(function(ge){ge.copy(te,B),B+=ge.length}),R.forEach(function(ge){ge.copy(te,B),B+=ge.length});let Se=c.toBinary();o&&o.copy(Se,We.Constants.ENDHDR),Se.copy(te,B),t=te,l=!1,S(te)}};X(Array.from(this.entries))}catch(D){C(D)}}}}});var Zl=ae((VS,Yl)=>{var Ee=sr(),be=ue("path"),Pg=Aa(),Og=Jl(),Tn=(...t)=>Ee.findLast(t,e=>typeof e=="boolean"),Vl=(...t)=>Ee.findLast(t,e=>typeof e=="string"),Lg=(...t)=>Ee.findLast(t,e=>typeof e=="function"),Ng={noSort:!1,readEntries:!1,method:Ee.Constants.NONE,fs:null};Yl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Ng);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=Ee.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new Ee(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=Ee.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=Ee.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw Ee.Errors.INVALID_FILENAME();let c=new Og(r,i),{canonical:l,sanitize:f,zipnamefix:x}=Ee;function p(w){if(w&&c){var v;if(typeof w=="string"&&(v=c.getEntry(be.posix.normalize(w))),typeof w=="object"&&typeof w.entryName<"u"&&typeof w.header<"u"&&(v=c.getEntry(w.entryName)),v)return v}return null}function b(w){let{join:v,normalize:I,sep:S}=be.posix;return v(be.isAbsolute(w)?"/":".",I(S+w.split("\\").join(S)+S))}function _(w){return w instanceof RegExp?(function(v){return function(I){return v.test(I)}})(w):typeof w!="function"?()=>!0:w}let A=(w,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",be.relative(w,v)+I};return{readFile:function(w,v){var I=p(w);return I&&I.getData(v)||null},childCount:function(w){let v=p(w);if(v)return c.getChildCount(v)},readFileAsync:function(w,v){var I=p(w);I?I.getDataAsync(v):v(null,"getEntry failed for:"+w)},readAsText:function(w,v){var I=p(w);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(w,v,I){var S=p(w);S?S.getDataAsync(function(C,L){if(L){v(C,L);return}C&&C.length?v(C.toString(I||"utf8")):v("")}):v("")},deleteFile:function(w,v=!0){var I=p(w);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(w){var v=p(w);v&&c.deleteEntry(v.entryName)},addZipComment:function(w){c.comment=w},getZipComment:function(){return c.comment||""},addZipEntryComment:function(w,v){var I=p(w);I&&(I.comment=v)},getZipEntryComment:function(w){var v=p(w);return v&&v.comment||""},updateFile:function(w,v){var I=p(w);I&&I.setData(v)},addLocalFile:function(w,v,I,S){if(o.fs.existsSync(w)){v=v?b(v):"";let C=be.win32.basename(be.win32.normalize(w));v+=I||C;let L=o.fs.statSync(w),y=L.isFile()?o.fs.readFileSync(w):Buffer.alloc(0);L.isDirectory()&&(v+=o.sep),this.addFile(v,y,S,L)}else throw Ee.Errors.FILE_NOT_FOUND(w)},addLocalFileAsync:function(w,v){w=typeof w=="object"?w:{localPath:w};let I=be.resolve(w.localPath),{comment:S}=w,{zipPath:C,zipName:L}=w,y=this;o.fs.stat(I,function(D,R){if(D)return v(D,!1);C=C?b(C):"";let M=be.win32.basename(be.win32.normalize(I));if(C+=L||M,R.isFile())o.fs.readFile(I,function(B,Z){return B?v(B,!1):(y.addFile(C,Z,S,R),setImmediate(v,void 0,!0))});else if(R.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),S,R),setImmediate(v,void 0,!0)})},addLocalFolder:function(w,v,I){if(I=_(I),v=v?b(v):"",w=be.normalize(w),o.fs.existsSync(w)){let S=o.findFiles(w),C=this;if(S.length)for(let L of S){let y=be.join(v,A(w,L));I(y)&&C.addLocalFile(L,be.dirname(y))}}else throw Ee.Errors.FILE_NOT_FOUND(w)},addLocalFolderAsync:function(w,v,I,S){S=_(S),I=I?b(I):"",w=be.normalize(w);var C=this;o.fs.open(w,"r",function(L){if(L&&L.code==="ENOENT")v(void 0,Ee.Errors.FILE_NOT_FOUND(w));else if(L)v(void 0,L);else{var y=o.findFiles(w),D=-1,R=function(){if(D+=1,D<y.length){var M=y[D],B=A(w,M).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(M,function(Z,X){Z&&v(void 0,Z),X.isFile()?o.fs.readFile(M,function(re,te){re?v(void 0,re):(C.addFile(I+B,te,"",X),R())}):(C.addFile(I+B+"/",Buffer.alloc(0),"",X),R())}):process.nextTick(()=>{R()})}else v(!0,void 0)};R()}})},addLocalFolderAsync2:function(w,v){let I=this;w=typeof w=="object"?w:{localPath:w},localPath=be.resolve(b(w.localPath));let{zipPath:S,filter:C,namefix:L}=w;C instanceof RegExp?C=(function(R){return function(M){return R.test(M)}})(C):typeof C!="function"&&(C=function(){return!0}),S=S?b(S):"",L=="latin1"&&(L=R=>R.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=R=>R);let y=R=>be.join(S,L(A(localPath,R))),D=R=>be.win32.basename(be.win32.normalize(L(R)));o.fs.open(localPath,"r",function(R){R&&R.code==="ENOENT"?v(void 0,Ee.Errors.FILE_NOT_FOUND(localPath)):R?v(void 0,R):o.findFilesAsync(localPath,function(M,B){if(M)return v(M);B=B.filter(Z=>C(y(Z))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(Z,X){return function(re,te){if(re||te===!1)return setImmediate(Z,re,!1);I.addLocalFileAsync({localPath:X,zipPath:be.dirname(y(X)),zipName:D(X)},Z)}},v))})})},addLocalFolderPromise:function(w,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:w},v),(C,L)=>{C&&S(C),L&&I(this)})})},addFile:function(w,v,I,S){w=x(w);let C=p(w),L=C!=null;L||(C=new Pg(i),C.entryName=w),C.comment=I||"";let y=typeof S=="object"&&S instanceof o.fs.Stats;y&&(C.header.time=S.mtime);var D=C.isDirectory?16:0;let R=C.isDirectory?16384:32768;return y?R|=4095&S.mode:typeof S=="number"?R|=4095&S:R|=C.isDirectory?493:420,D=(D|R<<16)>>>0,C.attr=D,C.setData(v),L||c.setEntry(C),C},getEntries:function(w){return c.password=w,c?c.entries:[]},getEntry:function(w){return p(w)},getEntryCount:function(){return c.getEntryCount()},forEach:function(w){return c.forEach(w)},extractEntryTo:function(w,v,I,S,C,L){S=Tn(!1,S),C=Tn(!1,C),I=Tn(!0,I),L=Vl(C,L);var y=p(w);if(!y)throw Ee.Errors.NO_ENTRY();var D=l(y.entryName),R=f(v,L&&!y.isDirectory?L:I?D:be.basename(D));if(y.isDirectory){var M=c.getEntryChildren(y);return M.forEach(function(X){if(X.isDirectory)return;var re=X.getData();if(!re)throw Ee.Errors.CANT_EXTRACT_FILE();var te=l(X.entryName),Se=f(v,I?te:be.basename(te));let ge=C?X.header.fileAttr:void 0;o.writeFileTo(Se,re,S,ge)}),!0}var B=y.getData(c.password);if(!B)throw Ee.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(R)&&!S)throw Ee.Errors.CANT_OVERRIDE();let Z=C?w.header.fileAttr:void 0;return o.writeFileTo(R,B,S,Z),!0},test:function(w){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(w);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(w,v,I,S){if(I=Tn(!1,I),S=Vl(I,S),v=Tn(!1,v),!c)throw Ee.Errors.NO_ZIP();c.entries.forEach(function(C){var L=f(w,l(C.entryName));if(C.isDirectory){o.makeDir(L);return}var y=C.getData(S);if(!y)throw Ee.Errors.CANT_EXTRACT_FILE();let D=I?C.header.fileAttr:void 0;o.writeFileTo(L,y,v,D);try{o.fs.utimesSync(L,C.header.time,C.header.time)}catch{throw Ee.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(w,v,I,S){if(S=Lg(v,I,S),I=Tn(!1,I),v=Tn(!1,v),!S)return new Promise((R,M)=>{this.extractAllToAsync(w,v,I,function(B){B?M(B):R(this)})});if(!c){S(Ee.Errors.NO_ZIP());return}w=be.resolve(w);let C=R=>f(w,be.normalize(l(R.entryName))),L=(R,M)=>new Error(R+': "'+M+'"'),y=[],D=[];c.entries.forEach(R=>{R.isDirectory?y.push(R):D.push(R)});for(let R of y){let M=C(R),B=I?R.header.fileAttr:void 0;try{o.makeDir(M),B&&o.fs.chmodSync(M,B),o.fs.utimesSync(M,R.header.time,R.header.time)}catch{S(L("Unable to create folder",M))}}D.reverse().reduce(function(R,M){return function(B){if(B)R(B);else{let Z=be.normalize(l(M.entryName)),X=f(w,Z);M.getDataAsync(function(re,te){if(te)R(te);else if(!re)R(Ee.Errors.CANT_EXTRACT_FILE());else{let Se=I?M.header.fileAttr:void 0;o.writeFileToAsync(X,re,v,Se,function(ge){ge||R(L("Unable to write file",X)),o.fs.utimes(X,M.header.time,M.header.time,function(O){O?R(L("Unable to set times",X)):R()})})}})}}},S)()},writeZip:function(w,v){if(arguments.length===1&&typeof w=="function"&&(v=w,w=""),!w&&i.filename&&(w=i.filename),!!w){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(w,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(w,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((C,L)=>{!w&&i.filename&&(w=i.filename),w||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let D=R=>R?C(R):L("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(w,y,I,S,D)},L)})},toBufferPromise:function(){return new Promise((w,v)=>{c.toAsyncBuffer(w,v)})},toBuffer:function(w,v,I,S){return typeof w=="function"?(c.toAsyncBuffer(w,v,I,S),null):c.compressToBuffer()}}}});import{execFile as I_,spawn as A_,spawnSync as cA}from"node:child_process";import{promisify as T_}from"node:util";function D_(t){if(process.platform!=="win32")return!1;if(K0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(K0,"").toLowerCase();return C_.has(r)}function $0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return D_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function lt(t,e=[],r={}){return A_(t,e,$0(t,r))}function J0(t,e=[],r={}){return R_(t,e,$0(t,r))}var C_,K0,R_,yn=Ze(()=>{"use strict";C_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),K0=/\.(cmd|bat|ps1)$/i;R_=T_(I_)});var Hu=ae(ve=>{"use strict";var N=U;(function(t,e){let r=U,i=t();for(;;)try{if(parseInt(r(1509))/1*(-parseInt(r(408))/2)+parseInt(r(387))/3*(parseInt(r(1446))/4)+parseInt(r(410))/5*(-parseInt(r(915))/6)+parseInt(r(1867))/7+parseInt(r(1545))/8+parseInt(r(1297))/9*(parseInt(r(1344))/10)+-parseInt(r(1399))/11===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(yo,378866);var pb=Object["definePr"+N(542)],gb=Object[N(1233)+N(606)+N(1206)],Fu=(t,e)=>function(){return t&&(e=(0,t[{lThoj:function(c,l){return c(l)}}[N(684)](gb,t)[0]])(t=0)),e},mb=(t,e)=>{let r=N,i={awPNh:function(c,l,f,x){return c(l,f,x)}};for(var o in e)i[r(1479)](pb,t,o,{get:e[o],enumerable:!0})};function U(t,e){t=t-278;let r=yo(),i=r[t];if(U.uBVDNS===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",b="",_="";for(let A=0,w,v,I=0;v=x.charAt(I++);~v&&(w=A%4?w*64+v:v,A++%4)?b+=String.fromCharCode(255&w>>(-2*A&6)):0)v=p.indexOf(v);for(let A=0,w=b.length;A<w;A++)_+="%"+("00"+b.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(_)};U.IgpYxJ=o,U.TJwzOn={},U.uBVDNS=!0}let c=r[0],l=t+c,f=U.TJwzOn[l];return f?i=f:(i=U.IgpYxJ(i),U.TJwzOn[l]=i),i}function yo(){let t=["rLfnDhC","s0jQAwu","nJi5mJy3zMPvtvHz","q0Liv3y","Cgf5Bg9Hzfq","z2vrDwv1zuW","uM5QEKS","AeDksuW","yxzywgO","s0XWs1K","AxHevfu","s1rnBu0","AxDTt2q","AvjMBg8","wwrLwem","Ewjewhy","vgLTzw91Da","tu9iDKy","yvbZvuy","A1n0yxr1C0m","CIb0DhDjra","x29UvgLTzw8","t1bftL9fuLi","D2fZq2XLyw4","BffuCfG","CLL4zhO","ywrKq291BNq","uMT0A1G","zNbjB0C","BMDLza","EuPlANe","zg9gq2y","DxrVuMvJB24","A2v5CW","wu1WDhq","qM5bDu8","x2nVBM5Ly3q","uw1qufe","ntu0mZmZnKnPAgDHqG","x2nSzwfYugK","BfzsqMe","q0f1vuK","BMvLzf9Hy2S","zuDLzLq","y29UDgLUDwu","CMvWBgfJzui","r0DcshC","yKHVBMS","t3v6ENC","A3bgAK0","yw1Lu3bHy2u","CeDqExy","DgLTzw91DcW","CuPqtgK","wuTJANe","D2LSBfjLy28","x2n1CNnVCKy","DhbizwfKzxi","A0Prt0q","y29UBMvJDca","CLDzsfy","BKfstMC","whveBMG","s1HmtMe","D2vI","uw5dwwS","DxbNCMfKzw4","CxP1D3O","D3jPDgu","B2XKvMvYC2K","CKXuyMi","A2PxDgS","t1z0vNq","yxv0B21HDgK","Ce9NC2q","AwrI","BhvxzfO","DePTD3O","Dg9iyxnO","C3f1AMG","v2rQA1y","D05cyKe","uNH4uKq","sgvfrLa","x19LC01Vzhu","B3H6AwW","zcWGDw5RBM8","DLHrs3O","A2Lpzfi","zxnLweC","CLzZq2m","sgrYzeK","zxjYtxnN","Cxjtsuq","Ec1TC2CTCw8","wfHwq3y","x2TLEvbHDgG","Bu5TCKW","wwvyuuG","CufmrNm","ig1LC3nHz2u","ywLYvvu","ChjVDg90Exa","DeLjrxi","qMjxsMO","B2XXA0G","zxjYB3i","zgrjrcWGzgu","B2zMC2v0","Cxrjvei","DgLLCKPtt04","Ew16Agq","yvrrCge","zMLUza","Cwrot1a","CeDer2y","tLztsfC","Dffkvhu","sLbMvvO","Ae9Wzw5fDMu","wez0C0q","v1vby0q","rgrvB1O","Chv0","D01tDhe","tuHwCLG","BwvZC2fNzv8","vLHvrvm","B0jdD1C","yMPNA0C","yLrnA1O","DvzZsvK","DNfxvNK","uejkwuG","CMLLC0nVDw4","rNjVBNrPzxi","CMvZzxrdB3u","lcbOB3n0BMe","x194x21Zz18","z2vY","DNPhv1u","BM5Ly3q","Dgv4DfbHEwW","shDdEfq","uLjpuG","ENvuAKO","ALPfvNa","C3vIyxjYyxK","BwLUzW","yvruvKi","q3LMEfy","BxnN","CgvYC2LZDgu","Dgv4Dc9Qyxy","zv9ZDwnJzxm","zw5HyMXLuw8","CM92AwrLihC","v01TBxi","shDKzMm","CMfTzq","qxLRzeO","v0rks1i","rNDrCKC","x21PBMLoyxy","EKLzthG","rLDt","ufvTBxy","Cw5OzMC","zMzmAw5L","z2v0","thHPsg8","DMfSDwvZ","t0vdsg4","y29UDgv4Da","x2HHBMrSzu8","B2HsyM0","uwjurNq","BLDcDxO","yMrFzgLK","q1Dis0q","CeHdExe","AxnmB25N","BKLPBgW","BwLZzq","CwfktNO","z0zxsvK","m3WYFdv8mxW","AevvD3a","q0fOCvy","C2TMrKu","qKz0zgO","Bwu6ia","vwrovey","wMLeuMm","CfzPBva","C2TOy3y","DxnLCKLW","ExDurMK","AMfLBha","y2HLy2Tszwe","t2vTt3u","wNjKq0O","AgfUz2u","zgPyqwG","wuz4qMe","s3LICem","Bg93","x2DLBMvYyxq","qvj0uhq","yuPIBuK","zM1ODMy","vvbpuvO","DhfHyMO","ExbL","z3LVquO","tMzLsxa","AwDHDg9Yt24","zxjHDg9Y","y29Kzq","D0fRB2K","ywXSzwqGBxu","id4G","y29fCfG","qvfOBe0","q0LdDeK","C2v0u3rVCMe","rKHlC3i","qNHzwe4","CNPQBe0","BKnqzgO","sg1hCKm","txzVse4","mNW0Fdn8mxW","sfblDgi","CvfSDgW","DxrMofDYAxq","aaaaaaaaaaa","Bhj5uuy","AM9jsgG","DK5qAuC","u0DYwwW","m3WXFdr8mNW","z1fyEfm","BeTjyxG","CMvXDwLYzwq","zw5JB2rPBMC","sxzKCLu","s3bpAgK","CMvJzxzPzwq","vgrgtgW","yxGGCMv0CMK","B3nLrxzLBNq","txnHuwO","s3LesK8","sufqs1e","uhjnCNC","uLjPue0","x2LZv29YA2u","tg5svKC","C3rYAw5NAwy","B1DcAvy","ywnRDxbfBMq","uKztsgG","qvLquNO","DwH4BuK","rMLSEKK","BhLNreO","rgXzruy","mNW0Fdn8mhW","BMfTzq","zNjVBu51Bwi","uNbxwxi","Agnkvfu","ENDmALO","Dxf2ugS","q25usfK","vNrVvxy","yMXTAve","vNjdse8","x2rPC2nVBM4","ChjVDg9JB2W","C2LRvfO","wgvHCgm","Bfvczu0","uuvdshO","CwTtsuS","Eef1uNq","uKnLuKS","DwTdC3e","B25pCgvU","sunYCKq","AwXLx25HBwu","v1zVB2y","BLvUq24","uuvfrfe","x2jPBMfYEvq","BwDdBLe","D2HAALO","zgvSzxrL","AxnrB1nnzxm","CgfNzxnOB3C","yKXfyMW","sgDZAg8","ywnRx2nVzgu","x2HHBMrSzvi","C0nVDw50zxi","yw5gCeu","y3jLyxrLtwu","DfHqr0u","rgvKAwnHDgu","Dw5ZAwDUzwq","wLb4DuS","DNPcuuO","rLjMrui","BM93","tePivgO","CMv0CNLdB3u","C0XPC3rLBMu","B25fCNjVCG","DMfS","qLjtq1a","nhW2Fdf8mNW","q3z5Bgy","u0fqtui","r2fnDg8","v3feBNC","BMfkzKW","Dxrjza","qLjgv0K","AuvADKS","Dvfzvwu","DwPwu3e","x3nLCuLK","yMLUza","mxW0Fdj8m3W","Efrurw52","qKPuqvi","igzHAwWSig0","Dg9tDhjPBMC","rK9bzvG","wxHZywq","qKvJqwG","EvzpuKu","BgPTAgm","qwrwtvC","rMHJsfO","yw5ZzM9YBvq","u2HHCMvKv28","zxffAeG","ywr2yw5Jzq","y3n1r0W","ExrxruO","D3jvswK","qLrHz1e","quXm","v1H5ww0","BwfW","B0jkte4","DhDVCMTdAge","r210vgq","ndCYmteXnu9yzNjqwa","y2HHCKnVzgu","q014tgi","DwvgBeq","rg12svO","shndwfO","Aw52yLa","BgLUzq","BM1OvKu","ChrVCG","B2jMqLq","Bxnhy1i","z1vQvu4","r1ncvfi","x2nYzwf0zvm","CMvTB3zLq2G","t3fmwgi","wwXIB3C","sLrkuwy","BMvY","C3rVCcbPBw0","DeLK","y29UBMvJDfm","zNjHBwvuExa","EhPMC1a","r0f0rKO","B3jRzxjhBg8","vxzMv00","uvLesLm","s1jLt1m","sNHbvhO","ExDzzKe","C3nHz2vfDMu","mNWWFdn8nhW","tuLIsK0","B3jRig9MzMW","AwXLtMfTzq","Bg9zuu4","v0XTu0i","wMzpBhq","B0DyyKu","vMHlEKe","q2nKrfi","zxrxB3jRq2G","EezyvLi","x2rItMfTzq","t1bftG","AxnAzxjV","r05Oze4","twnnshC","y2HLy2TdDxi","verAzxG","t1fOvhC","u2TPCcbWyxm","wKPdyNi","ChbL","t0PYtwO","uxf5wLm","y2HnyxHdB3u","ihjLy29UBMu","r1nyA0K","t2nzDu8","uwLZz1C","sLDsBeu","CMfUzg9T","x2LZtwLUAvC","yxbWzw5Kq2G","zvL0tu0","zNvUy3rPB24","t1zJDhq","r052z0m","CxnYr0q","D3zyz2i","whz4vNG","CunOu2G","tuHSEve","CgXLyxnLiha","DxjS","CMvZB2X2zq","ugTWzgS","v2vIu29JA2u","vw5Oyw5KBgu","ihzHBgLKigq","D0jezLe","r09ywwu","n3WXmhW2Fde","BMv3vMvYC2K","x3bYB3rVy28","wLvpChK","zNDcCu4","t2nhu24","BMCGzMfPBgu","DuLjr2G","whfVreC","CwLVvfy","BNjrAw0","x2nSzwfYvgK","yNL0zxm","ENHnsum","AMrXveS","AxmGDw5Kzwy","Bwv0Ag9K","BvDxBNa","rvvAwK0","ihbYB3rVy28","t25WBgC","x29UtwvZC2e","CMvZzxrfBMq","zNHvvNK","Eezjyuu","AuHkwg4","B3jL","mtCWmJC3ourAwvLeva","x3jLywr5q2W","ywP1tMy","Cwvorgu","zgLZCgf0y2G","x3bPBMDqB24","uNvdEg0","yxnJCMLWDa","weD3vhq","Dev2zw50","C2DPza","tMfTzq","u3jjsfa","BgLTAxq","BK9TvLa","sgzZvfm","BgLZDgvUtMu","qM50Aha","BwXQr3C","BMnLq2XVC2u","ww11uha","mM5wD2P0Da","BNrbBMrvCgq","mta2ndq4mhbZCe9vzG","D3fXq08","qKDnDgC","sM9QALu","sMzNB1e","wK9OtLi","wvnUy3i","q291BNq","yxjYyxLIDwy","y291BNq","x3bYzwzPEa","CLHsCvC","C3rLBMvYCW","wuzuDeS","Bg9NsurozxC","AgfAA1i","zfz0Afq","D24GCMvHC28","BLrhA1O","uuHcq2y","D3m6lY8","ywnOzwq","wvDuzeO","B2nRzxq","zgvSzxrLrge","DgvmB2Djre4","zxjYtM8","C2v0zgi","z29PBMCGyxC","B3vUDa","zwXzDw8","C3rHCNq","Ae1LC3nHz2u","zLPfvKW","Aw5PDcbrB1m","rvjst1i","EujKuMq","x2rLyNvN","BhHSs3C","uxzgzKu","zNjVBunOyxi","vvnfs0O","y2fSBa","x2rLC3rYB3K","u1fJDxu","yMrfr1e","x3nVy2TLDa","twjwvfG","wxnevwK","r0TVr3O","BxnNsuq","tvPlzLO","x3jLBw92zvC","BLDgCwe","ruPxBKG","B2nRzxrgywK","AxjLza","B0D3y3a","zxjFBxnNAwq","C1nlEfa","y3jLyxrLq2W","vvnRrw8","y3vYCMvUDeK","sfHrzuK","AwXK","sgjiBLi","C3rVCMu","u09mzg8","C3jJ","rvH0DNq","CLnRELK","AK9pB0C","AgvHzgvYCW","wKD1u0u","x2rPC3bHDgm","tMzxr28","u0L3B3m","A2f3Buu","A1zvy2u","x2HHBMrSzva","yvzNq2S","ELnRBwW","DNn6wxC","u2jNDxa","x3jLy29UBMu","BNruCMLLC0m","z2v0sxrLBq","Aw50zwDLCIa","EffusMy","wwrfCg4","zxf1ywXZ","ANPorva","u0r0sg0","yNDXDwm","CMvKDwnL","rhPwvgO","we5jEwO","zLnTAey","BMrWB2LUDfq","Cwz4r0K","C2vUzf9Hy2S","EhrquwW","Aw5JBhvKzxm","s0DruNm","yu1kwxi","BgLUzw5V","y2uGBM90igK","A3HiuxK","sgfVv3m","DfzOt1y","twHvz3a","v0TqugG","Een1AeC","AMvJDfn0B3i","Dfzit3C","D2vlz1m","zxH0zw5ZAw8","t1PArKy","BNrLCG","CgvUv0q","ruXZrxu","x29Ut3bLBG","zw5JB2rLrNi","ywvIBNK","A1ngrfa","wxLjve8","Dg9cExrLC0i","y29Uy2f0","uwX0wwK","D3DYDgS","y29UBMvJDgK","ueL0rxm","B3bLCNr5","y29SBM8","BNHuExK","vNznDKq","BwvKAwf0zwW","DhbkA1y","BvvbwwK","z21qy2u","tfbQu08","CMvJB25Uzwm","sKLkrw4","DLPACNO","DhPVB0y","ywrKt25L","s0Lor2G","x3bHDgHlzxK","whbrt0u","EKz5qNe","CgLUz0XVC3m","igzPzwXKoIa","AeXHAuO","B25Uzwn0Aw4","rhzTreC","EwrtD3C","EKjIAuK","y2XVC2u","CMjvwNy","Dw5KzwzPBMu","CvvbEem","ywDL","tKDFrvjst1i","B3bLBKrc","veXjte4","y3vYC29Y","wKvMCvu","De1HBMfNzxi","D0rhrNm","vKPbvfO","B3jpBMXPBMu","Eejrrey","q3jXwuu","DMP2rvi","DcbVzIbYyw4","uvDjtNa","z2vjBMzVu3K","Bgnszu8","EKf1AuC","C2v0","s1fyvLu","yMfSrxzLBNq","wKL1uMi","q0Xpu0ve","y2vZC0HHBMq","v1jSBMu","Ef9MCM9UDgK","zw5XDwv1zq","DhjPzxmGCMu","A0PuC1q","CKDHEe8","rNjNyw4","sef0svq","t21iDu0","C1HJshi","AxnFywnR","B3bLCNr5tMe","rhr4t3i","v2X6uwe","uMvJB25Uzwm","Dvb0txG","yNPJDxC","DMvUDa","tMLJAwu","x2LZtwLUAvq","vgz4yKu","vKfxrM0","vuvWwue","BevVvvO","seLXEM4","zg9Uzq","EvLpCNC","tLDOAxa","uxfpCwm","q3zZD2y","x25HDMLNyxq","m3W0Fdj8mxW","qvjQC2W","yM9bD08","shPwAeq","y3PfuvK","D3nZoI8V","EKn5zKm","v2v0v3u","zu5ewLa","vhfVv24","zuLYt20","swzwDLK","DLz1vMi","rKrVzMK","zfnYr0e","C09XtwC","rfDzv0i","tufSv1m","ELjLtw4","C2v0q3vYC28","uLjiCwe","Chr1suS","v3z4vLO","rfLMu0C","z2v0s2v5","zu1tBxu","DengyKW","C2PwsuG","yxrLq291BNq","yMLUyxj5vhK","B25LCNjVCG","tufyx1jfvfi","B3jLtMfTzxm","BuPZquC","wKfWshe","ue5ds24","Cg9PBNrdB24","Ahr0Chm6","r3nYz3K","BvLTuM8","B1H4Ahm","Ew9VC3y","wwnvCeq","Cg9W","AevYCM9Yrxy","mdaWma","C29Tzq","zuvWwLC","Ag5krNa","BfrPBwvVDxq","DKnjs1m","zM9YrwfJAa","twrorvK","tLLTuu0","q0Xpu0LorW","q1zIrLm","CNzHBfzHBhu","CNfMBgC","BfrOB2O","sML0teu","tuvtu0fhrv8","y2nrugO","tLfYqK0","ywDLsgLKzq","yvD5uMG","t3bLBKv2zw4","D0Lswfa","DuXOBfK","A2v5","CMvJzwL2zwq","vvP1y2S","CePks1C","sg9OCKe","uNPzv3i","vMnzEum","su5tvefova","v1jAC3y","zgLZywjSzue","suPzBLK","DMvYC2LVBMm","vhLPBwK","wMHSyKW","qNvxrMq","yurJCgm","ohWZFdj8mhW","qKnvBe4","uNLPwu4","BMvJDa","C0XguwC","BfD0B1m","ywX3yxLZ","tvvPr2e","Aw1LCYbPBIa","rvvkr1i","rLHvqvC","yKT4zLe","ChnJvvG","AenzzNe","rLPPA3e","ywDoBuu","C3bSAxq","vfPSEvm","CYbPBNn0yw4","C2vYDMLJzs0","Cxfzse4","zv90Aw1LB3u","x2n1CNnVCK0","A2v0ignVBNm","ywWGy3vYC28","Bxfnr00","qLPuELe","icSG","zvz6A1O","yw1LoIa","shvkvue","BezSDxnO","DxDHwuC","sM9uCKW","tfDrDLa","tg9JAW","BgHbtg8","yxv0BW","reHhwuG","z2rICuq","zNjVBuj5Dgu","Bvbbt0W","tg9NsurozxC","qxzUue8","yMXVy2TLza","BhjPC0u","DgHLBG","EeTbEeq","C2vUza","BKvkDxG","DxDgy0u","CMvHzhDYAxq","qw9jrxm","ENbAvg0","AefJA01LC3m","zhb5ELO","CMvHzfvjBNq","tKvsEKW","vMPTD2u","BufjDeu","tLbXuMq","DMvY","mxWZFdj8nhW","A1DmvuS","q1jbq1i","tgHUwK4","tuDsuMu","qxbAC2W","y3jLyxrLt3a","CMvTB3zLrxy","B29muuG","vNHszgW","AwPWt2G","x2LZtM9Kzq","ihrPBwvZ","CgfYC2u","r1fvq0S","EfzQwgm","pxv0zI04","qNfcrLC","D0L1y2e","y0jez24","zezuDw0","tvn4Axe","A2DPA1m","qujLDNO","zhHyvvm","uKDIr20","twX4zLO","qw1VDw50","AunwyMi","wNPYALm","A0XhrNe","vfLJALu","s3j6uxi","zMXVB3i","sNfZzK8","zMLSzw5HBwu","y3vYC29Yx24","y3jLyxrLrxi","Aw47y2HHCNm","CMfNzvn5BMm","zeLKC1u","B25szwnLAxy","y3ruAw1LB3u","C29YDa","zw5NDgG","v2PRC0S","rNPeuu8","zM5KsKu","wujrvLu","yxzfquK","AMLSDMq","D3LOsfi","yLzoDLK","yNvMzMvY","v0niCLy","y3jLyxrLuMu","ru1gC2W","zxj2AwnL","BhDAtgq","De13shq","zxjFCw9Zx2e","x2LUDgvYDMe","uNPsvui","BvP2tMW","r25vAKe","tvj6zuu","Aw9UvgLTzw8","BMnPqM0","Bwf4twvZC2e","uKjoqxC","B2zM","y0TnDfu","quzoDee","BMv4DcGPigm","AgfZ","t1Pky3C","rhbWBKe","D3jPDgvvAw4","s2zey0y","AxnbCNjHEq","Agruv3q","v1D0tfK","x2vUzhbVAw4","yKHKquq","q0Tez0y","CNnVCL92ywW","qLvVsfe","q1bxt08","yNvMzMvYzwq","s3z1B1a","ywnRtxnNswq","s1rfyKi","x2LUAxq","AenSB3nLrxy","zNjVBujPDhm","DNnLtw0","DLPRy2K","z3D5rNi","Dg9VigXHCMC","B25tDgfYDfi","ruHrBxa","y2rWqvi","C0Dkt0W","D0LgDLu","rxjYB3jdB2q","zMzMzG","DxvwBeG","uM16teK","qwjVCNrfCNi","y2TeEw0","zMDYDuW","ExnzDKq","C2nYAxb0","AxnszwfKEq","AgvHzgvY","tw9KDwXL","C0jnDwy","z2u6ia","v0rlCNa","CK9MsuS","u2v5v3m","tNDishO","DhjHBNnHy3q","x3vYBa","v1jJv2m","ALLryLm","BMnVzgLUzW","vLbiAMi","rKvIque","t3jWyuO","B25JBg9Zzq","DgfYz2v0","EgPMDLK","tg1OvKG","BMrWB2LUDca","wgTcq1m","tgnxq3m","jMPZy2fSBgi","rxz2uu0","zwnVBM5Ly3q","D3PhyMm","y3DwufG","x29UrxjYB3i","nKXkCvbZBW","BwvY","Ahr0Ca","DgLTzw91Da","C2HPzNq","Dw5RBM93BIa","tMHsEKy","ALPPBhO","zwvKzwq","qwThz2y","zg9zrKS","q3vZDg9Trxi","zfLUvLy","Be5Srha","Aw5N","rKzsCxi","CgzZBhy","C0Dfs2m","B25VCgvU","CgLUz0LUDgu","ExHwwwy","swLusNq","r0PiDxK","ywDLrxzLBNq","uMrAAfG","u2flA1m","mhW1Fdn8nW","Cw9Zx18","z2v0q3vYCMu","zxq9DxrMltG","t2vfzKe","twvZC2fNzuu","x0rctMfTzq","B0f5zhe","tNrSr2K","uuLxqMy","zLLvA2C","tvHiExm","EergEgC","zw5fDMvUDa","tK15DwC","BNj4uxe","DKnNq2q","x1fVu01HBMe","q2XdzgK","Aw5L","uMvMy3q","veHmu2O","uwHytxu","Eevfr2u","x3DZ","zxH0ugf5Bg8","BeHHBMrSzxi","sMHTEvG","werdqNe","z2jsA3u","zgvMAw5Luhi","y29UBMvJDeu","DMLfsLu","Ec11C2uT","yxnL","zxP2ug4","CMvZDwX0","qungruu","sNzmtei","ANjdsMy","sLjRDhO","x2fKzfDZtgK","q0D6z1y","z1bREwq","zM9Yy2u","DLLpywO","Dg9hzw5LCMe","Aw5KzxGGB3u","BMCGDxjSoIa","yMfJA3vWigu","v3PHshu","DxbKyxrLq3u","C3vJy2vZCW","CKXmyLy","yxnZAwDU","s090r1y","Ae5Tyve","A29pyLe","quXcr2y","Cgf5Bg9Hzeu","D2f1Beu","zMLSDgvY","tLfzuwC","zvvYBa","B25SAw5L","wMPTveq","Cg1wz3e","CNjVCK1LC3m","DvrIC1C","DKjRBue","s3b6zKq","uhH2AKS","x2LZqNjVD3m","ChvZAa","uNnQzKO","CMvHzhLtDge","wvfYs0q","sKXLvwy","CwHgq1u","rLrpA2u","sLbkvue","shnWz0W","sLnptLa","rejotwi","q29UzMLN","zgf0yq","y2HnyxHuCMK","EgPgqxq","zxmGCMvHy2G","lcbxzwjtB2m","AMDnCKG","C3bSAwnL","vKLsvKC","yMXMtva","DMriv0C","zNrTzgO","Dhr3Awq","wxnuBxy","yM9L","y2XLyxi","z2v0u3rVCMe","BKXPBMu","y25xy0K","CgfNzwHPzgu","q3brEgu","z3vwCfG","Cwvmqwu","Cg9PBNrbBMq","thvLzeS","zvDeywS","zwn0","uuXWANK","wLfmD2i","mxW1","AKrszKi","v0zdEgO","r0Xss0W","CLzHBhvLCW","DvzSBwu","Dg9oDw1Izxi","C3vIC3rYAw4","A3nSu24","CMTLCKDSB2i","Bwf4uMv0CMK","zgvIDwC","AgfZt3DUuhi","zNHjuhe","y0HqDKO","yw5Nzq","BNrfBMrWB2K","ywnOzwqSihC","DeDrv1G","Aujkq1y","vfL4sha","CMvWBgfJzq","y29TCgXLDgu","zwD0Bfy","yxbWBhK","r29jrMS","yLj3Eu8","t21JDvq","vw5PBxbSzw0","q056z2S","CgLUz19VBMm","zxjFCw9Z","BKfRsKm","zuLsCee","ENj6v1C","DgvZDa","zeDnEfe","z1rPBwvVDxq","Dgv4Dc9WBge","y2XVC2uSihC","z21nA1u","ywrK","zNjVBuHHC2G","wxPgsxO","BgvY","yKvuwxK","x2LUAxrqCM8","BMCGB3iGyw4","B2fK","yufxwu0","q3zgBLe","CMvHC29U","zwzqruS","z2D6zfO","m3WY","q3PZqwK","CLn2D2y","x3DHAxq","r1rbtxG","Dhn1uuK","wLP0uee","ExrUBuG","CLPbENy","z2v0qwXS","u2vYDMLJzvC","Dg9mB3DLCKm","sgPdt2m","wK1KC2y","BhrPCgXLihq","re1QCeC","BNz0DwW","yNbcuvy","u0rtqw4","EfnJCwq","t0TAwK0","uvLTAvy","uw9yv0i","zsbHihn0CMK","rurwEfC","B3nLza","yLjyrva","EKXRwwe","CMvHzg9UBhK","CurSD2m","uwjqveG","DKjWuwS","Bwz6qKC","CM9YrxzLBNq","zw5HyMXLvhi","zwrPyxrLBhK","zw50","vMXiy1C","s3n6u0S","yM9KEq","y29UBMvJDa","AxnrB1nby2S","tMjgCuK","weDwEg0","t25JEeK","v0f3thu","C3vjsfq","z2v0qwXSs2u","rxzLBNq","y2f0y2G","sKnrD3u","BufvCvi","DhjPBq","s0zNrgu","x2LZsw5PDa","Aw5KzxHpzG","zgvJB2rLzey","tgLZDgvUzxi","yMLUyxj5","ywr5ruG","EfvZzuvUDG","y3z4Cfm","Ce14ALm","BvzItxC","nhWWFdv8mxW","EMLTAeC","v21hDhu","zw1PDa","z2v0q3vYC28","y3vYDMfSDwu","CMvUDevUzha","qufMque","BIWGAg9ZDg4","CfbLy04","C2fNzq","x2LUAxrhBg8","x3DZsw5ZDge","sevWwwW","ywDLu2HVDW","qvnis1K","t3fLrva","uffsuNK","rvPJrK4","CfPywxe","EvjLy29UBMu","r3rbALu","tKfruK8","B25tDg9Wsw0","n3W4Fdf8mta","BwvZC2fNzq","u0rou1i","CNnls04","AKLtv1C","igfYCMf5yNu","y2XVC2veqG","B25TzxnZywC","zeTTsve","zxHWB3j0CW","BwvZ","s2TOwfG","vxbKyxrLq28","BwvZC2fNztO","AwXSihvZzsa","D3LPq2e","D2Psy2C","v3LOqMO","qvjhy2G","EsbJBg9Zzwq","y09Wzw4","CMvQzwn0","ywnR","wgzMqwW","y0Tmsgm","u05iuwe","Aw9Ul2PZB24","vxrQCLO","t2zvALC","C3besMm","r2DoqLG","u2rhAg8","C3rYAw5N","AwPtzK8","x0vysvnu","x3bPBMC","zcbLCNjVCI4","z2v0t3DUuhi","mhWZFdj8nhW","BMrLEa","B3bLBG","BMDuAw1LCG","yxrHlcbKyxq","tevJsuK","zMXrrw0","B015r2G","AKXRvxq","u1reCgC","s0XUwNy","BKvvAKu","B2nRzxrtDwm","y2XLyxjtDg8","twLZC2LUzYa","CMvZzxruCMK","sKPZBui","mxWWFdn8mNW","mhW0","zfv6B0y","sMPXDxa","BfnTBK4","ywrKrxzLBNq","zxbJtNu","BgvUz3rO","AKDryK4","u2H6swW","Cgf5Bg9Hza","ueHyAwO","tfrTsuC","uffjsNq","seXgD3y","Dw50","Dg9cExrLCW","shfquwG","rLjptLrjrvi","q3vZDg9Tq2W","DhLWzq","BhfhEem","x2DLDeLUDgu","mNWXFdr8mhW","BML0AwfSAxO","C0Try1i","Cu52yu8","B2jQzwn0u3q","vLrID08","rfbozxy","ywnRx2LK","AM9PBG","ANnvtxC","wu5gCe8","wKfpwwC","zwnSrvK","BM9Uzv9UB24","tNLowLy","yuLJsKK","ALrAD2S","D05ru3a","Dfnmrhy","DgrkCvm","uurgufi","z0XTCgu","zw1LBNq","mtyYv2D5tMjA","AMzfq3i","BgzMsfu","suvtx0vsuK8","sgzLvuq","C2vYDMvYvgK","r05jyK8","yw1L","B29zB0W","u3rYyxrLz3K","ywzL","CNzHBa","EMjOv2m","v2Dzq1G","Agnztfm","z3DkC2u","Aw9U","Bwf4tg9ZC0m","Aw5KzxG","y2zgD1O","D1D3ueO","zw50zwqGDhK","q1fJAu8","zefZuKi","tg9Nsuq","ruvPqLO","zNjVBNrPzxi","tKfusvzfx0u","x2rYB3bhBg8","Bw9ouwe","DgLUzYbZzxi","Bxz5zLi","B3bLBIa","yw55Bhi","q09otKvdveK","CM92AwrLige","CMPWDgO","ve5psNq","CNnVCKzPBgu","rMnAsNe","x3bPBMDmB3m","z2vtEw5J","x29UugfNzu4","z3rPAeS","ign1CNnVCIa","Dg9cExrLC0W","vungq1q","mtC1mZeWreXxrvfm","suD3CNC","yNL0zuXLBMC","B3Dsze8","DhjPzxm","igXHCMDLCIa","v3nVCNe","zMX1C2HfEha","zgXAseS","uxnytwG","x3nLBMrby2S","yw5Hz2vY","y29UC3rYDwm","CuLIzhG","rKLmrv9ot1q","BM5eDxO","AgvKtwf4uMu","tNveBfy","Bg9N","Dg9Y","AxPKsu0","C3z1q2u","y3bqCwG","rxzLDe8","ufPgD2m","CMPvrgm","CM92AwrLihy","ugryswG","yNL0zu9MzNm","CNnVCL9Uyw0","BxDqwMi","twH6t2W","ywXty29Wzq","tLjRCwy","zMzLCG","v3vMEuW","y3vYCMvUDeu","sfbbtuO","zxblB1G","tunTuxq","x2XPC3rLBMu","vu5rvMe","Egn0Dva","ihrPBwvVDxq","zfDVCMTLCKC","t2jQzwn0","rLDXveC","t0r3DLO","zu9LwLG","mdaWmdaWmda","x21LC3nHz2u","v3vguxe","yMfSu2nVCgu","x3fVC0rc","yND6B0q","mteZmJqZmJrovKPeD2u","C2jprfG","Dhj1y3rVCIa","u2vXsuq","AwndueW","B3Hzsxm","Du13ChC","wePACNK","s3vQrNu","x2n1CNnVCK4","AhbUAMK","swDVv20","uLzVAe8","BfHyCuC","D09UzMC","EKHyEhq","sunyvLK","C0Xf","BNvTyMvY","rwrqALK","zNHLuhi","uMvHzcbWyxm","AgLNAa","yw51Ce1LC3m","sLL1vKu","zgvS","zNrzrxG","wgTvvwm","D0HPqwK","zMLN","t2D2wuK","B2zMBgLUzq","C2v0y3vYC28","q3LbCeG","zgv2AwnLx2K","A1zYBw4","AerbB3a","t05utey","BgP1s2C","zhnlv3m","yNLL","vgfN","yxbKBey","EK9KwKG","rML2Axq","x29WDgLVBNm","y0Hbr3O","ngvtvKjAwG","EKvzAuq","tfnfyw4","z0TfzeG","rwLLAKe","DMfSDwu","Evvby3u","C0jf","DeLUDgvYy2u","Du9Vzu8","AxDwCLe","BNfhALe","B1zosfG","C2vYDMLJzq","zufJAW","uwfozvC","B3PcDe0","uxvLDwu","Ew9Yz0K","y3jLyxrLrwW","zw5KCg9PBNq","BKLpu2S","Bg9Nsurhzw4","twzytha","teXKzwW","A3Lvu0W","zuHmteS","B2LUDfjLywm","Bg9IywXty28","zw50tgLZDgu","BwnNCMO","lcbTyxGGCMu","AxLxq1C","yxDqtMG","Efv5Bwq","AurOAvO","ihzHBgLKihm","ywXS","swPXAe4","EhDivLa","sgvxwvm","tuX3tgS","x29Uq2XVC2u","DcbSAw1PDa","t3zzA04","C2XPy2u","qLPbs0e","x2zVCM1HDeu","wgrHzgC","v1jzr2O","DMzXCgW","q29Kzq","DMLJzuLeig8","ChHyDuu","qxHSB1q","t0jcBhm","wwTZDwK","s2XLrxi","EvnUwuO","C2v0sxrLBq","AxzdEhi"];return yo=function(){return t},yo()}function wb(){return Ou||(Ou=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _b(){let t=N;return Lu||(Lu=[IDBCursor[t(1609)+"e"][t(1856)],IDBCursor[t(1609)+"e"][t(1551)],IDBCursor[t(1609)+"e"].continuePrimaryKey])}function yb(t){let e=N,r={qqYHN:function(o,c){return o(c)},NRkqf:function(o){return o()},pPecN:e(597),qhFCU:function(o,c){return o===c},dpyzZ:"AlSSK",jISWW:e(993),egtlV:e(1613),kVUce:e(1005),sFInO:e(1430),MhUgp:e(1044),idcLs:"pageshow",FWqTG:function(o,c){return o!==c},vZZrz:e(1223)},i=new Promise((o,c)=>{let l=e,f={vBpQk:r[l(1181)],ZOhNR:function(_,A){return r[l(1019)](_,A)},YFxBa:r[l(765)],CPWOO:function(_,A){return _(A)},pscUX:function(_){return r[l(1377)](_)}},x=()=>{let _=l;t[_(779)+_(1475)+_(294)](_(993),p),t[_(779)+_(1475)+_(294)](_(1613),b)},p=()=>{let _=l;f[_(415)](f.YFxBa,f[_(1711)])?(f[_(859)](o,f.CPWOO(Mt,t[_(977)])),f[_(722)](x)):(this["_message"+_(1463)][_(1014)](_0x4270c0),this[_(447)](f[_(1139)],_0x3a5945))},b=()=>{r[l(730)](c,t.error),r.NRkqf(x)};t.addEventListener(r[l(1200)],p),t[l(1256)+l(1165)](r[l(1077)],b)});return i[e(756)](o=>{let c=e,l={xwHVP:r[c(488)],PNCKn:r.sFInO,yBdRd:r[c(520)],adyEH:r.idcLs};r[c(1390)](r[c(553)],r[c(553)])?(this._isBrowser&&_0x278bfb[c(1256)+c(1165)](l[c(1485)],this["_handleO"+c(1042)]),this[c(1013)+"er"]&&_0x42c8d5[c(1256)+"Listener"](l[c(661)],this[c(1681)+c(1675)]),this._isBrowser&&_0x160812[c(1256)+"Listener"](l[c(446)],this[c(489)+"ageHide"]),this[c(1013)+"er"]&&_0x34636c[c(1256)+"Listener"](l[c(1167)],this._handlePageShow)):o instanceof IDBCursor&&Xc[c(589)](o,t)}).catch(()=>{}),Eo.set(i,t),i}function bb(t){let e=N,r={SOLdo:"abort",jZilz:function(o,c){return o==c},BUoHQ:e(1228),bVNvY:function(o,c){return o(c)},zCyfC:function(o,c,l,f){return o(c,l,f)},uOoeO:function(o,c){return o instanceof c},mcgrj:function(o,c){return o!==c},ywTFi:e(1135),CAhqV:e(522),pGDGf:function(o){return o()},dNGvl:e(880)+"or",xEAos:e(1613)};if(bo[e(846)](t))return;let i=new Promise((o,c)=>{let l=e,f={YzFIz:r.dNGvl,PUmmv:function(_){return r[U(1622)](_)}},x=()=>{let _=U;t[_(779)+_(1475)+"ner"]("complete",p),t[_(779)+_(1475)+"ner"](_(1613),b),t[_(779)+"entListener"](r[_(477)],b)},p=()=>{let _=U,A={BvtNY:function(w,v){return r[U(922)](w,v)},XkUUc:r[_(858)],QYmiV:function(w,v){return r[_(824)](w,v)},CICtI:function(w,v,I,S){return r[_(632)](w,v,I,S)},WyhBj:function(w,v){return r[_(1455)](w,v)}};if(r[_(1476)](r[_(1704)],r[_(1695)]))r[_(1622)](o),x();else{if(A.BvtNY(A[_(1426)],typeof _0x2eef3b)){let w=new _0x34d28b(A[_(1129)](_0x4460bf,_0x41d12a));return A[_(1731)](_0x20cf4a,_0x372006,w,0),w}return A[_(1213)](_0x4a8f44,_0x52afed)?new _0x412f0c(_0x3c093e):new _0x8c27d0(_0x545391[_(825)],_0x514f90[_(1372)+"et"],_0x23bcd9[_(1346)+"th"])}},b=()=>{let _=U;c(t.error||new DOMException(_(880)+"or",f[_(1097)])),f[_(1673)](x)};t[l(1256)+l(1165)](l(1076),p),t[l(1256)+l(1165)](r.xEAos,b),t[l(1256)+l(1165)](r.SOLdo,b)});bo[e(589)](t,i)}function Eb(t){vo=t(vo)}function vb(t){let e=N,r={mvyfR:function(i,o){return i(o)},wwrtk:function(i,o){return i(o)},OgvYI:"cursor.s"+e(829),ukCsq:e(886),ARtPt:function(i,o,c,l){return i(o,c,l)},xctuP:function(i,o,c,l){return i(o,c,l)},UQvie:"service-"+e(1776),wHiAi:function(i,o,c,l){return i(o,c,l)},ZApHq:e(1776),dxXUS:"curvalue",TfxbE:function(i,o){return i===o},xAuRt:function(i,o){return i in o},wMCJk:e(1278)+e(658),RVohO:e(964),ymzhd:function(i){return i()},VEqqt:function(i,o){return i!==o},nUnCn:e(900)};if(r[e(615)](t,IDBDatabase[e(1609)+"e"]["transact"+e(1313)])&&!r[e(1793)](r.wMCJk,IDBTransaction[e(1609)+"e"]))return r.TfxbE(r[e(1411)],r[e(1411)])?function(i,...o){let c=e,l=t[c(452)](r.mvyfR(Bi,this),i,...o);return Zc[c(589)](l,i[c(815)]?i[c(815)]():[i]),r[c(1328)](Mt,l)}:!!this[e(1397)];if(r[e(1618)](_b)[e(512)](t)){if(r.VEqqt(e(1718),r[e(1800)]))return function(...i){let o=e;return t[o(1078)](r[o(539)](Bi,this),i),r[o(1328)](Mt,Xc[o(1676)](this))};_0x3077f1.log(r[e(1429)],_0x5192e2,_0xec85cf.service),_0x14e2ca=_0x3ccede(0,_0x2f4157,_0x48210c),_0x1afbb0[e(1362)](r[e(1795)],_0x330639),_0x495f0b=r[e(1715)](_0x572694,_0x913ffb,_0x2a7734,_0x533129.service||0),_0x2cb413[e(1362)](e(1459),_0xbcb244),_0x462c15=r[e(1386)](_0xe55402,_0x1a691d[_0x57ba99[e(808)+e(1304)]],_0x5d7e2c,_0x2b18c2),_0x303c79.log(r.UQvie,_0x551e77),_0x2e693d=r[e(1427)](_0x40aea0,_0x2ad023[e(808)+"ame"],_0x21695c,_0x3b72ea),_0x3332e8.log(r[e(660)],_0x5c762f),_0x53bbf9=r.xctuP(_0x58f677,_0x4f99f1[e(1777)+"er"](_0x5270db.cursor||_0x5344ce),_0x3c2704,_0x211db3),_0x5af687[e(1362)](r[e(796)],_0x4b945f)}return function(...i){let o=e;return r[o(539)](Mt,t[o(1078)](r[o(539)](Bi,this),i))}}function Sb(t){let e=N,r={BOtvQ:function(i,o){return i===o},SbBIG:e(343),ezvPn:function(i,o){return i instanceof o},ozBtM:function(i,o){return i(o)},tJmwz:function(i){return i()}};return r.BOtvQ(typeof t,r.SbBIG)?vb(t):(r[e(976)](t,IDBTransaction)&&r[e(1462)](bb,t),zu(t,r[e(1584)](wb))?new Proxy(t,vo):t)}function Mt(t){let e=N,r={vCIKS:function(o,c){return o instanceof c},ZcORj:function(o,c){return o(c)},dsKWs:function(o,c){return o(c)},dAsRB:function(o,c){return o!==c},QsXMh:function(o,c){return o===c},jaelp:e(1364)};if(r[e(676)](t,IDBRequest))return r.ZcORj(yb,t);if(wo[e(846)](t))return wo[e(1676)](t);let i=r[e(1438)](Sb,t);if(r[e(1320)](i,t))if(r[e(1353)](r.jaelp,r[e(1705)]))wo[e(589)](t,i),Eo.set(i,t);else{if(this[e(1444)][e(703)+e(1539)+e(713)]||this._readyClosed)return;this[e(1811)+"econnect"]()}return i}var zu,Ou,Lu,Xc,bo,Zc,wo,Eo,vo,Bi,Nu=Fu({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={CzsAi:"boe",WdjkV:t(330),hLaiJ:function(r,i){return r(i)},FKteL:"wss://",wOnfg:t(1034),nWBuz:function(r,i){return r instanceof i},AkGgf:function(r,i){return r===i},xUymd:t(620),SeyWs:t(1278)+"oreNames",HeWYS:t(476),apdlF:function(r,i){return r===i},kLGFq:"xfQmS",OqeEP:function(r,i){return r(i)},oGwcp:t(1748)+"0",WgMGg:function(r,i){return r!==i},BFYsY:t(1189),ZZtPA:"AJyzy",VIRVG:t(342),mgDwr:function(r,i){return r in i}};zu=(r,i)=>i[t(672)](o=>r instanceof o),Xc=new WeakMap,bo=new WeakMap,Zc=new WeakMap,wo=new WeakMap,Eo=new WeakMap,vo={get(r,i,o){let c=t,l={eYVcy:function(f,x){return e[U(562)](f,x)},xFKwt:e.FKteL};if(e[c(1413)]!==e.wOnfg){let f={MRzeE:function(x,p){return QFibAC.eYVcy(x,p)}};return function(...x){let p=c;return _0x124692[p(1078)](f[p(837)](_0xb2d273,this),x),f[p(837)](_0x2ae9c1,_0x9301d2[p(1676)](this))}}else{if(e[c(1684)](r,IDBTransaction))if(e[c(924)](c(883),"NmdBb"))switch(_0x156078){case e[c(1109)]:case e[c(1587)]:return{[c(974)+_0x5c00f5]:1,"x-tt-env":_0xa6ec05};default:return{}}else{if(e.AkGgf(i,e[c(1480)]))return bo.get(r);if(e[c(924)](i,e[c(892)]))return r[c(1278)+c(658)]||Zc[c(1676)](r);if(e[c(924)](i,e.HeWYS)){if(e.apdlF(e[c(802)],e.kLGFq))return o[c(1278)+c(658)][1]?void 0:o[c(1278)+c(386)](o.objectStoreNames[0]);_0x374d6f=l.xFKwt,_0x13f9c=_0x5b3b2e[c(1075)](/(^http)((?:[s]*:\/\/))/,""),_0x635e7c=/(^ws)((?:[s]*:\/\/))/[c(1089)](_0x2ec216)?_0x5cffa8:""+_0x1fb3cc+_0x265ecb}}return e[c(1188)](Mt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t,c={JlXeG:e[o(467)]};if(e.WgMGg(e.BFYsY,o(1189)))this[o(842)](_0x221293,_0x24ed5c);else{if(r instanceof IDBTransaction&&(e[o(1441)](i,e.xUymd)||e[o(924)](i,e[o(1486)]))){if(e[o(1114)]!==e[o(1033)])return!0;{let l=c.JlXeG[o(726)]("|"),f=0;for(;;){switch(l[f++]){case"0":this[o(1543)]();continue;case"1":this[o(1337)+o(1812)]?.[o(1643)+"nter"]();continue;case"2":this[o(1162)]=!0;continue;case"3":this[o(854)+o(577)]?.[o(382)+o(662)+o(1428)]();continue;case"4":this[o(388)+"osed"]=!1;continue}break}}}return e.mgDwr(i,r)}}},Bi=r=>Eo[t(1676)](r)}}),Uu={};mb(Uu,{deleteDB:()=>Ab,openDB:()=>Ib,unwrap:()=>Bi,wrap:()=>Mt});function Ib(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=N,f={OemOu:function(b,_){return b(_)},mfzBG:l(705)+"hange",loYQN:function(b,_){return b(_)},HeclP:l(1573)+l(923)},x=indexedDB[l(1236)](t,e),p=f[l(312)](Mt,x);return i&&x[l(1256)+l(1165)](f.HeclP,b=>{let _=l;i(f[_(1707)](Mt,x[_(977)]),b[_(1576)+"on"],b[_(361)+"on"],f[_(1707)](Mt,x[_(894)+"ion"]))}),r&&x[l(1256)+"Listener"](l(754),()=>r()),p[l(756)](b=>{let _=l;c&&b[_(1256)+_(1165)](_(567),()=>c()),o&&b["addEvent"+_(1165)](f[_(1140)],()=>o())})[l(1157)](()=>{}),p}function Ab(t,{blocked:e}={}){let r=N,i={yYOrw:"blocked",MMKBk:function(c,l){return c(l)}},o=indexedDB[r(434)+"tabase"](t);return e&&o[r(1256)+r(1165)](i[r(621)],()=>e()),i.MMKBk(Mt,o).then(()=>{})}function Mu(t,e){let r=N,i={PlMzC:r(761)+"e",CQciO:function(x,p){return x instanceof p},PDIEe:function(x,p){return x===p},XNIyj:r(1228),qFJrA:function(x,p){return x!==p},kWLUK:function(x,p){return x in p}};if(!(i[r(1319)](t,IDBDatabase)&&!(e in t)&&i.PDIEe(typeof e,i[r(506)])))return;if(_o[r(1676)](e))return _o[r(1676)](e);let o=e.replace(/FromIndex$/,""),c=i.qFJrA(e,o),l=Gu.includes(o);if(!i[r(773)](o,(c?IDBIndex:IDBObjectStore)[r(1609)+"e"])||!(l||qu[r(512)](o)))return;let f=async function(x,...p){let b=r,_=this[b(894)+b(1313)](x,l?i.PlMzC:b(1136)),A=_[b(476)];return c&&(A=A[b(1315)](p[b(919)]())),(await Promise[b(1483)]([A[o](...p),l&&_[b(620)]]))[0]};return _o[r(589)](e,f),f}var qu,Gu,_o,Tb=Fu({"node_modules/idb/build/index.js"(){let t=N,e={JLeUf:t(1274)+"5|3",nJYPe:"put",bRFKO:"add",BxYXN:t(1805),jTxLD:t(1040),HEpYl:function(o){return o()},HeEFP:function(o,c){return o(c)},mYzKY:t(1676),XJZry:"getAll",QYDJS:t(1155)+"ys"},r=e[t(1018)][t(726)]("|"),i=0;for(;;){switch(r[i++]){case"0":Gu=[e.nJYPe,e.bRFKO,e[t(1734)],e.jTxLD];continue;case"1":e[t(1185)](Nu);continue;case"2":Nu();continue;case"3":e[t(1590)](Eb,o=>({...o,get:(c,l,f)=>Mu(c,l)||o[t(1676)](c,l,f),has:(c,l)=>!!Mu(c,l)||o[t(846)](c,l)}));continue;case"4":qu=[e.mYzKY,t(650),e[t(1406)],e[t(303)],t(419)];continue;case"5":_o=new Map;continue}break}}}),Cb={idb:function(t){let e=N;t[e(1205)]=Promise.resolve()[e(756)](()=>(Tb(),Uu))[e(756)](function(r){return r})}},Bu={};function Nt(t){let e=N,r={hDAop:function(f,x){return f!==x}},i=(e(1251)+"4")[e(726)]("|"),o=0;for(;;){switch(i[o++]){case"0":if(r[e(1435)](void 0,c))return c[e(1205)];continue;case"1":var c=Bu[t];continue;case"2":Cb[t](l,l[e(1205)],Nt);continue;case"3":var l=Bu[t]={exports:{}};continue;case"4":return l.exports}break}}Nt.d=(t,e)=>{let r=U;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object[r(971)+r(542)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;Nt.o=(e,r)=>Object[t(1609)+"e"][t(1066)+t(542)][t(452)](e,r)})(),(()=>{let t=N,e={kslSn:t(569)+"d",RktkX:t(887),dYnVV:t(1591)+"le"};Nt.r=r=>{let i=t;e[i(1062)]!=typeof Symbol&&Symbol[i(1845)+i(1440)]&&Object[i(971)+i(542)](r,Symbol["toString"+i(1440)],{value:e[i(1534)]}),Object["definePr"+i(542)](r,e[i(927)],{value:!0})}})();var ke={};(()=>{let t=N,e={fxIPq:function(a,n){return a!==n},HuJUA:t(1103),FzrTr:"RlOVB",sGEKc:function(a,n){return a(n)},FFRqr:function(a,n){return a+n},aVgCk:function(a,n){return a+n},zEYiD:function(a,n){return a+n},gwJse:function(a,n){return a*n},EUJGR:function(a,n,s){return a(n,s)},NWhip:function(a,n){return a(n)},nEJux:function(a,n,s){return a(n,s)},LPjSO:function(a,n){return a(n)},KujFu:"0000",dKmIQ:t(877),NFzJc:t(1623),HzVhD:t(1393)+"00000000"+t(1393)+t(1393),vCgCd:function(a,n){return a>n},wvXgb:function(a,n){return a<n},OeEfA:function(a,n){return a>n},wBDfQ:function(a,n){return a-n},qJPLi:function(a,n){return a-n},flQEm:function(a,n){return a<n},RCeRK:function(a,n){return a===n},aIcJI:t(1017),OfUjW:function(a,n){return a!==n},msGcR:"CUNcE",jdqTK:function(a,n){return a-n},OqLXb:function(a,n,s){return a(n,s)},LJHTj:t(1613),qeLAe:function(a,n){return a instanceof n},SDNSR:t(1190),mJsAG:function(a,n,s){return a(n,s)},sbODX:function(a,n){return a!==n},ALBGf:function(a,n,s){return a(n,s)},jsUMw:function(a,n){return a&n},pVimP:t(1248)+"required field: "+t(694),KyDJO:function(a,n){return a===n},wNXMA:t(1248)+t(1751)+t(561)+t(1451),uTbsW:"close",Xdadg:t(1439),bKxfQ:t(438)+"ay, netw"+t(310)+t(960),Hwdfc:function(a){return a()},MUiGa:function(a,n){return a|n},WufyL:function(a,n){return a<<n},iwVrQ:function(a,n){return a&n},ARjsl:function(a,n){return a&n},wyhHR:function(a,n){return a<<n},lNlDp:function(a,n){return a>>n},QnCYk:t(1197),KReOS:function(a,n){return a!==n},OQhTw:t(1263),aMJYr:function(a,n,s){return a(n,s)},xDCpT:function(a,n,s){return a(n,s)},moNQa:function(a,n){return a!==n},oxYIs:function(a,n,s){return a(n,s)},AAfAA:function(a,n){return a(n)},bLEbl:function(a,n){return a!==n},FzDQO:function(a,n,s){return a(n,s)},JvLLB:function(a,n){return a(n)},BTagQ:function(a,n){return a!==n},OECHn:function(a,n,s){return a(n,s)},sSKxP:function(a,n,s){return a(n,s)},RzYWr:function(a,n){return a!==n},ClCdi:function(a,n,s){return a(n,s)},MXHys:function(a,n,s){return a(n,s)},lwZLd:function(a,n){return a!==n},ApZsl:function(a,n,s){return a(n,s)},SIwos:function(a,n){return a!==n},ixDTU:t(1115),XGVxm:t(1669),HfeUD:function(a,n,s){return a(n,s)},nIOSk:function(a,n){return a!==n},AYPRz:t(401),rqflg:function(a,n,s){return a(n,s)},uQYUe:function(a,n){return a!==n},hnJFp:function(a,n){return a!==n},ohqaB:t(503),kawmE:t(1631),zPKsL:function(a,n){return a(n)},anFpE:function(a,n){return a===n},ijpOh:t(395),kHBVy:t(1605),rSkzY:function(a,n){return a(n)},OrpaJ:function(a,n){return a(n)},ccQPj:function(a,n){return a>>>n},AQhlM:function(a,n){return a(n)},DMjpG:function(a,n){return a(n)},YcUpD:function(a,n){return a(n)},JYuVE:function(a,n){return a(n)},lqGxC:function(a,n,s){return a(n,s)},Xeapc:function(a,n){return a&n},LhnZN:"Missing "+t(1751)+" field: "+t(1402),ljuKg:t(1248)+"required field: LogID",fZEVL:t(1248)+t(1751)+t(561)+"service",SAPMB:function(a,n){return a===n},pJJKW:t(1248)+t(1751)+t(561)+t(376),DPNev:function(a,n){return a(n)},wWwPJ:function(a,n){return a<n},GmtTd:function(a,n){return a+n},ICrrD:function(a,n){return a===n},uhxmI:t(611),GGBHw:function(a,n){return a&n},LxiHo:function(a,n){return a(n)},rbUZv:function(a,n,s){return a(n,s)},gbRku:t(1082)+t(1318)+"pe: ",kyUSL:t(533),WDKrp:function(a,n){return a>>n},sGJOL:function(a,n){return a>=n},XhQnN:t(404),CVbFS:function(a,n){return a===n},EHQmp:function(a,n){return a+n},GLRKL:function(a,n){return a>n},hWWGh:t(1420)+t(1489),ybDXv:function(a,n,s){return a(n,s)},rkdGN:function(a,n,s){return a(n,s)},AFIoK:function(a,n){return a===n},QIWBf:function(a,n){return a+n},VlHcW:function(a,n){return a+n},vZkci:function(a,n){return a&n},xjfvY:function(a,n){return a(n)},PHXij:function(a,n){return a>=n},SrIHP:"oUdFK",HaoWs:t(1125),bHdAD:function(a,n){return a+n},vfqpl:function(a,n){return a+n},zwLjZ:function(a,n){return a|n},zxMIC:"Wutmc",EvvQM:function(a,n){return a&n},WlzQa:function(a,n){return a<n},zpZTm:function(a,n){return a>=n},qnhfg:function(a,n){return a<=n},MhzOl:function(a,n){return a==n},kjWtk:function(a,n){return a+n},LuedK:function(a,n){return a+n},hGJIL:function(a,n){return a|n},HspgL:function(a,n){return a|n},lygDJ:function(a,n){return a<<n},PQIJt:function(a,n){return a|n},cHPvJ:function(a,n){return a|n},HLFwv:function(a,n){return a<<n},tXPGE:function(a,n){return a&n},RFSHh:function(a,n){return a<<n},IJYnY:function(a,n){return a&n},QisgW:function(a,n){return a<n},ajuNf:function(a,n){return a+n},Ouzzw:function(a,n){return a>>n},nTGkZ:function(a,n){return a<=n},lKIax:function(a,n){return a-n},UCFCT:function(a,n){return a+n},wNQSp:function(a,n){return a<n},JfgoQ:function(a,n){return a<n},Sbgup:function(a,n,s){return a(n,s)},XRqDL:function(a,n){return a<n},GQUCK:function(a,n){return a>=n},wNBbA:function(a,n){return a<<n},alcMf:function(a,n){return a<n},BZTzQ:function(a,n){return a|n},FQMtw:function(a,n){return a>>n},qeNDe:function(a,n){return a<n},OWtTL:function(a,n){return a|n},mwPZb:function(a,n){return a&n},dFTum:function(a,n){return a|n},AWOmt:function(a,n){return a&n},aPsUF:function(a,n){return a>>n},TLILN:function(a,n){return a|n},MvoHN:function(a,n){return a&n},UNQVa:t(592),HjCOc:function(a,n,s){return a(n,s)},GSXkI:function(a,n,s){return a(n,s)},KTMmM:"qwdzZ",YdEpn:function(a,n){return a<n},Vjmwe:function(a,n){return a<<n},GqcJT:function(a,n){return a>=n},CfRDU:function(a,n){return a&n},Fivit:function(a,n,s){return a(n,s)},mWWnp:t(729)+t(1776),doYFK:"cursor.service",Cvswf:"service",aTQpa:function(a,n,s,d){return a(n,s,d)},ZAOYg:function(a,n){return a(n)},tsuQI:"cursor_f"+t(1798),MdNEY:function(a,n,s){return a(n,s)},djXAh:function(a,n){return a&n},qsrGD:function(a,n){return a&n},PrMrw:function(a,n){return a&n},PItEs:function(a,n){return a&n},iCVbb:t(1741),pfDPI:function(a,n){return a&n},ftYEx:function(a,n){return a&n},mljGw:function(a,n){return a(n)},QoXWB:function(a,n){return a===n},ACFEE:t(1634),uIIGh:function(a,n){return a&n},ljmhc:function(a,n){return a<<n},sXcHr:function(a,n){return a&n},IiTJt:function(a,n){return a&n},Nicie:function(a,n){return a&n},WRcWc:function(a,n){return a(n)},yGgoD:function(a,n){return a&n},nmhVE:function(a,n){return a|n},doFCf:function(a,n){return a>>>n},cvxpS:function(a,n){return a<<n},xDFxg:function(a,n){return a<n},ueFlD:function(a,n,s){return a(n,s)},uZIcp:function(a,n){return a+n},KQXVU:function(a,n){return a>>>n},KTEbB:function(a,n){return a+n},iHJXn:function(a,n){return a!==n},WzaHu:function(a,n){return a|n},zIYLx:function(a,n){return a&n},nIill:function(a,n){return a&n},mqMGM:function(a,n){return a+n},KOtGV:function(a,n){return a!==n},qIbdx:function(a,n){return a>>>n},USkEo:function(a,n){return a|n},vszYw:function(a,n){return a+n},kpFjM:function(a,n){return a|n},OVctt:function(a,n){return a&n},oLOGL:function(a,n){return a&n},guVpX:function(a,n){return a!==n},OZJcw:function(a,n){return a|n},tQJTu:function(a,n){return a!==n},uVsIY:function(a,n){return a&n},pMxjS:function(a,n){return a(n)},yeByN:function(a,n){return a===n},vVuVb:function(a,n){return a|n},IAPKQ:function(a,n){return a<<n},OmcuT:function(a,n){return a<<n},jGQbN:function(a,n){return a<<n},voblT:function(a,n){return a|n},gwyFr:function(a,n){return a<<n},EXtvt:function(a,n){return a<<n},cpPqh:function(a,n){return a|n},SGrYl:function(a,n){return a<<n},xVjXc:function(a,n){return a|n},gPkyd:function(a,n){return a<<n},kxHQy:function(a,n){return a<<n},qtITB:function(a,n){return a===n},jOOoG:function(a,n){return a>>>n},MOHvF:function(a,n){return a<<n},JWRlE:function(a,n){return a<<n},iEZvK:function(a,n){return a<<n},nrxQq:function(a,n){return a&n},YMptt:function(a,n){return a&n},kVrmn:function(a,n){return a&n},fgruL:function(a,n){return a>>>n},JoTrL:function(a,n){return a(n)},eqEhH:function(a,n){return a|n},AoIEs:function(a,n){return a%n},mPAOL:function(a,n){return a|n},qaJNz:function(a,n){return a/n},sUbaY:function(a,n){return a>>>n},GJHuy:function(a,n){return a===n},JqsfO:t(1150),coEpX:function(a,n){return a===n},gvrwI:t(664),CAuUI:function(a,n){return a&n},fNgpP:function(a,n){return a>>>n},IjqhN:function(a,n){return a&n},zFyBq:function(a,n){return a+n},CGzgV:function(a,n){return a>>>n},eVzkZ:function(a,n){return a>>>n},NhFDI:function(a,n){return a>>>n},HwCxT:function(a,n){return a===n},aDcpc:function(a,n){return a===n},vzGWU:function(a,n){return a+n},jilvd:function(a,n){return a>>>n},MfXLp:function(a,n){return a&n},NfWGo:function(a,n){return a&n},DvmDG:t(1005),dpUEx:t(848),LEcII:function(a,n){return a&n},NERzL:function(a,n){return a&n},TdFLl:function(a,n){return a&n},cHAGz:function(a,n){return a>>>n},kkGyO:t(1172)+t(1108),MGRRe:t(1331)+t(572),penWD:t(686)+t(445),LnRVG:t(1529)+"OR",NwHHz:"NATIVE_E"+t(1651),EUZZM:t(657)+t(1300)+"R",HqPQh:"application/json",uLWFZ:"applicat"+t(1222)+";charset"+t(788),mYmRo:t(1166),yUAcu:function(a,n,s,d){return a(n,s,d)},qzuwz:t(370),rXRqW:t(432),qqtUk:t(1841)+"0",Pkpdk:function(a,n){return a+n},YKcjq:function(a,n){return a<<n},dTdkq:function(a,n){return a+n},nEUjE:function(a,n){return a+n},QhXMu:function(a,n){return a|n},ONTLF:function(a,n){return a|n},SpNlY:function(a,n){return a<<n},vNPiG:function(a,n){return a+n},JitLE:t(1667),tFQpt:t(359),eclEY:t(826),wzGbc:t(899),jfECr:t(1745),WjksK:function(a,n){return a===n},spDJc:function(a,n){return a==n},ZrdCJ:function(a,n){return a>n},qkSIK:function(a,n){return a!==n},lffHU:t(652),sKQcR:function(a,n){return a instanceof n},COzpH:t(356)+t(1232),LOobI:function(a,n){return a+n},gdbqD:function(a,n){return a===n},YBQVU:function(a,n){return a===n},RZyVx:function(a,n){return a===n},dUzoF:t(510),rWYHV:t(1334),jrCJf:t(1694),sOqMg:t(1095),vHAtg:t(1040),RnjzK:function(a,n){return a(n)},fxUVy:t(650),IfVvY:t(1117),gQXxS:t(1155)+"ys",sikTZ:"count",epcNu:t(1458),BRFWI:"EifmJ",OcYuO:t(1391),FXUAW:function(a,n,s){return a(n,s)},WFCxj:function(a,n,s){return a(n,s)},lVRBa:"open",xFIaE:function(a,n){return a||n},Wsorq:"CvFnQ",kgikS:function(a,n){return a<n},ooYoL:function(a,n){return a<n},weKgS:function(a,n){return a===n},QFYgT:function(a,n){return a&n},CnTHY:t(1415),nxTyy:function(a,n,s){return a(n,s)},LryJB:function(a,n){return a instanceof n},UcZmN:t(1365),oXxhs:function(a,n){return a+n},HbHnR:function(a){return a()},nqGjQ:function(a,n){return a===n},GKoGz:t(723),XpQOE:t(1383),WAwLu:function(a){return a()},GNhdN:function(a,n){return a===n},hWukd:t(801),lhALo:t(1094),naJfL:function(a,n){return a!=n},QECHz:"undefined",vzALf:t(626)+"0",wrUIi:function(a,n){return a||n},RyiYN:function(a,n){return a!=n},BFtdj:function(a,n){return a<=n},QqyZS:function(a,n){return a===n},MIbJM:function(a,n){return a+n},tVhOV:t(1382),iBJCV:function(a,n){return a(n)},xKAxD:function(a,n){return a<n},VAWFm:function(a,n){return a&n},blmiQ:t(986),tuljJ:function(a,n){return a(n)},OaAkq:function(a,n){return a<n},fndJE:function(a,n){return a<=n},ftmdj:function(a,n){return a>=n},PTHUd:function(a,n){return a|n},loAjF:function(a,n){return a&n},KBjie:function(a,n){return a<n},BqBFW:function(a,n){return a|n},NhRzF:function(a,n){return a&n},HsCXZ:t(507),HXQeI:function(a,n){return a-n},WRZsv:function(a,n){return a|n},VrCHO:function(a,n){return a<<n},VTbwO:function(a,n){return a>>n},tdJqS:function(a,n){return a+n},STDpg:function(a,n){return a&n},PhLza:function(a,n){return a===n},CyApH:t(1726),jYQbS:function(a,n){return a<n},pxXuE:function(a,n){return a<n},paKtW:function(a,n){return a|n},WMmmr:function(a,n){return a===n},aJbmI:function(a,n){return a&n},CpQxe:function(a,n){return a|n},KXLNa:function(a,n){return a&n},lUBeM:function(a,n){return a+n},YFTtK:function(a,n){return a>>n},lWtoS:function(a,n){return a|n},hwHJa:function(a,n){return a&n},KpOhi:t(1228),bHonk:function(a,n,s,d){return a(n,s,d)},KINGh:function(a,n){return a instanceof n},hcJTU:function(a,n){return a instanceof n},NPqRd:t(1092)+t(810)+t(944),EidDk:t(330),lryQF:t(993),pZXYq:t(998),airUU:t(753),oWBiV:function(a,n){return a>=n},AxloT:t(920)+t(1105),JJsmB:function(a,n){return a(n)},EsWGM:t(1660)+t(394),xScqd:t(917),FilzI:t(909)+"ack=fron"+t(1617)+"P",llGXI:t(907),qrSID:function(a,n){return a&n},BEcAh:t(1132),NYmQM:t(790),JEHgZ:t(1582),YsDUi:function(a){return a()},qhzZX:function(a,n,s,d){return a(n,s,d)},IEkrv:function(a,n){return a+n},tzooF:t(988)+t(584)+t(889),kJQOD:t(737),ZfOlt:function(a,n){return a||n},RdZhX:function(a,n){return a!==n},GaMto:t(1074),nWFqa:function(a,n){return a<n},MHVrX:function(a,n){return a<=n},sulbO:function(a,n){return a>=n},aWyRh:function(a,n){return a<<n},brLTk:function(a,n){return a|n},DYfSG:function(a,n){return a+n},Onplg:t(1418),fpIoG:function(a,n,s){return a(n,s)},cdpAR:function(a,n,s){return a(n,s)},iwmOd:function(a,n){return a!==n},skfFE:t(891),uMwpw:"jFHul",CWHKD:function(a,n){return a!==n},zimhG:t(1637),WDJKR:"RInfA",yoosv:t(711),DlYEF:function(a,n){return a|n},JRktz:"YPfrL",WKPPh:function(a,n){return a||n},dVthT:"cbunX",KkhXX:function(a,n){return a!==n},PBJYH:t(1003),KleEr:function(a,n){return a||n},YyITO:function(a,n){return a!=n},mVbMw:function(a,n){return a instanceof n},KFgDe:function(a,n){return a!=n},jzNEP:function(a,n){return a==n},wIFvU:"jhHnH",iPRYd:function(a,n){return a||n},RGbGm:function(a,n){return a!=n},ggzdZ:function(a,n){return a!=n},LSEan:t(444)+"DB failed",LcWCs:t(1633)+"id",zOdZH:"x_fronti"+t(1085),BRSCP:t(596)+t(832)+"ck",WUAcD:function(a,n,s,d){return a(n,s,d)},rVsCc:t(596)+"er_is_ack",EvetO:t(596)+"er_ack_m"+t(397),zKHil:t(1549),uwFcE:t(605),oMyGh:function(a,n){return a&&n},EJWnH:t(1281),dSrGA:function(a,n){return a||n},BJTAR:t(1810),RuCxm:function(a){return a()},momai:t(695),MwJrW:function(a,n){return a&n},AdVMW:function(a,n){return a>>>n},dIdsU:function(a,n){return a(n)},rjptj:t(630),RxxRD:function(a,n){return a instanceof n},QqAHx:function(a,n){return a!==n},DZiys:t(1579),YsTmv:t(1290),UuvWQ:function(a){return a()},WRlne:function(a,n){return a<n},NuDlV:function(a,n){return a>n},vjvER:function(a,n){return a|n},kvSrc:function(a,n){return a||n},xzfsP:function(a,n,s){return a(n,s)},bdEGQ:t(1137),CzeSZ:t(948),rmxlf:function(a,n){return a(n)},mUDzy:function(a,n){return a+n},hNmaQ:function(a,n){return a+n},qUAxC:t(1728),Uzldi:function(a,n){return a*n},MxrMo:t(497)+t(870)+"e",VhKzA:function(a,n){return a>=n},wmsZM:t(1753),oXrpP:t(1006),rZAzv:function(a,n){return a&n},xBQDF:function(a,n,s){return a(n,s)},eWDak:t(693),Yxsad:t(1739)+"0",NAQRO:function(a,n){return a+n},cwVPX:function(a,n){return a+n},mZvNl:function(a,n){return a+n},yGbMw:function(a,n){return a|n},kDzVW:function(a,n){return a|n},aTTVB:function(a,n){return a<<n},MlxfZ:function(a,n){return a<<n},vXQKz:function(a,n){return a+n},ZUOpy:function(a,n){return a+n},obfBT:function(a,n){return a+n},QmPPQ:function(a,n){return a>>>n},DdUoZ:function(a,n){return a+n},kOgJN:function(a,n){return a>>>n},WqDnw:function(a,n){return a>>>n},qNvaO:function(a,n){return a+n},OwMXF:function(a,n){return a&n},vBkmA:function(a,n){return a>>>n},CMxLb:t(551)+"t",qdNOP:t(441),DBNMb:"aQsCJ",Vueuw:t(1214),nDxRR:function(a,n){return a===n},PdXIh:function(a,n){return a<n},ShzIl:function(a,n,s,d){return a(n,s,d)},SQcuu:"XnkwO",WmGtu:function(a,n){return a+n},HohrA:function(a,n){return a+n},sCErm:function(a,n){return a<<n},tIIEr:function(a,n){return a>>n},eMSmu:function(a,n){return a>>n},Refct:function(a,n){return a>>n},TqoWn:function(a,n){return a+n},QHBCf:t(1807),DHGYH:t(1763),USEKJ:t(710)+t(360)+"|4|5|9",gKEdH:"header",luWdZ:function(a,n){return a(n)},WgYCX:function(a,n){return a<n},ywYfA:function(a,n,s){return a(n,s)},ONvbA:function(a,n,s){return a(n,s)},lXXqG:function(a,n,s){return a(n,s)},uqvPk:function(a,n,s){return a(n,s)},sEtec:t(1358)+t(1230),upbQd:t(808)+"ame",iyWCW:function(a,n,s){return a(n,s)},pQfVM:t(576),ydSww:"allCurso"+t(1058),OKZZM:t(1861),BuWFd:"CONTINUE",HfsTS:function(a){return a()},elYuo:function(a,n){return a(n)},mMyOR:t(1431)+"r",nnDuz:"OlzID",ytWEJ:"UPLot",ZMdsf:function(a,n,s){return a(n,s)},zAuiG:"QufCp",FOAeX:t(1084)+"e_timeout",WWtLY:t(918),ijSfO:function(a,n,s,d){return a(n,s,d)},GEABF:t(1725),yxVYf:t(596)+t(468),tGQWX:function(a,n,s){return a(n,s)},fBosO:t(1601)+"s",zSkml:"x-msg-cu"+t(1373)+"e",EkNek:"x-msg-cu"+t(857)+"ue",hpnji:function(a){return a()},QWINp:function(a,n){return a>n},lCWGX:"wgKQJ",CIHWv:t(1490),mAUqR:t(1152),MLwLk:t(1316),pmVgq:function(a){return a()},IRALz:t(1221),WDRpi:t(1612),DWYWB:function(a){return a()},tSLDv:function(a){return a()},FcZJq:function(a){return a()},KrzQr:function(a,n){return a(n)},nvtul:function(a){return a()},lPyEz:function(a,n){return a<n},CRACR:function(a,n,s){return a(n,s)},eseXG:function(a){return a()},EEiBZ:function(a){return a()},rsKKN:"BDqtF",hdTWt:t(1084)+t(1661)+"s",GtAjU:function(a,n){return a!==n},kiOdR:function(a,n){return a!==n},sykNN:t(1864),NfeIp:t(1740),IERNI:function(a,n){return a===n},nciBm:"pbbp2",QvFfE:t(747),qioTV:t(351)+t(1370)+"alid url",SaKkS:t(351)+t(1663)+"s params"+t(1030)+t(733)+t(1401)+t(375)+"ined",ckDym:t(295)+t(1143)+t(334)+"ct",zBbiI:t(1430),Tyimi:t(1044),PxvjK:t(663),rLLbV:t(631),RpWYr:t(430),ZiDRc:t(1685),lWGmb:t(1433)+"d",boAwO:t(351)+"rovide b"+t(1614)+t(1498)+t(1527),izaZy:"function",HdrdI:function(a){return a()},NwqBz:"fws_1.0.0",AuLiS:function(a,n){return a(n)},zReMn:t(844),nBYyM:function(a,n,s){return a(n,s)},bETYy:function(a,n){return a||n},avXXj:function(a,n,s){return a(n,s)},yVORE:function(a,n){return a(n)},VJATZ:function(a,n){return a-n},RPnzF:function(a,n){return a>n},fRhyI:function(a,n){return a===n},rLTbb:function(a,n,s){return a(n,s)},fmhvf:t(438)+"ay, try "+t(551)+t(1327)+t(771),eEpZW:function(a,n){return a(n)},PRhSP:t(878),ApLCj:t(1502),haZkR:function(a,n){return a(n)},pGPyv:t(1043),XFtsD:t(772)+"0",itNcC:t(1775)+"1",WVoof:function(a,n){return a(n)},viEJU:function(a,n){return a+n},bRXEP:t(1368),CbxDf:t(1345),oGXbE:function(a,n,s){return a(n,s)},WKKJM:t(1218),efPEK:"LGAKR",ltrmw:function(a,n){return a!==n},tMwHt:"TBsnS",ZPxuK:function(a,n){return a+n},CNzgk:function(a,n){return a>>>n},tmCBi:function(a,n){return a>n},lQTpX:function(a,n){return a+n},sjVIH:function(a,n){return a&n},TZlyS:function(a,n){return a|n},YSncr:function(a,n){return a===n},KpzfD:"BvcOa",EMFsl:t(1828)+t(941),gMMTN:function(a,n){return a===n},pfslv:t(1093)+"s alread"+t(1215),Jlofm:t(1093)+t(728)+t(516)+t(1275)+"ed",JCQwu:function(a,n){return a<n},HIqzn:function(a,n){return a==n},Bqhfe:t(1417),SDtHm:function(a,n){return a!=n},nCPdj:function(a,n){return a(n)},WXyYm:function(a,n){return a||n},qDLup:"please p"+t(1332)+t(1482)+"ervice",kJTsT:t(968),YdeXC:"sent",OBBls:function(a,n){return a<n},mAItE:function(a,n){return a==n},WRYGj:"manual r"+t(911)+t(929),OZZFF:t(1743),XMiPG:function(a,n){return a===n},McMHw:"Window",QbTFt:t(1389),XXVCv:function(a,n){return a===n},GAtFJ:function(a,n){return a!=n},rzjlM:function(a,n){return a===n},icCPL:function(a,n){return a!=n},sLFQg:function(a,n){return a!=n},RBNAw:"Dedicate"+t(1388)+t(1474)+"pe",FTOke:function(a,n){return a===n},qwiYk:t(1854)+t(1063)+t(1376),HmGrC:function(a,n){return a!=n},JcsrB:function(a,n){return a!=n},FZikq:function(a,n){return a!=n},tpJkV:function(a,n){return a!=n},GNIbO:function(a,n,s){return a(n,s)},BGMtg:t(1645)+t(942)};Nt.r(ke),Nt.d(ke,{FWS:()=>Ap,CustomErrorEvent:()=>Md,createCloseEvent:()=>ht,ReconnectEvent:()=>Nd,createErrorEvent:()=>at,decodedFrame:()=>Xt,createOpenEvent:()=>Gd,CustomCloseEvent:()=>Bd,createReconnectEvent:()=>na,FrontierMessageEvent:()=>zd,encodeFrame:()=>Ft,createMessageEvent:()=>qd,OpenEvent:()=>Ud,ErrorCode:()=>en,Event:()=>Vn,MessageEvent:()=>Fd});let r="";function i(a=""){let n=t;if(e[n(1067)](e[n(740)],e.FzrTr)){let d=""+Date[n(1821)](),u=r||(r=e[n(932)](x,a)),h=Math[n(339)]()[n(1845)](16)[n(1491)](-6);return e[n(930)](e.aVgCk(e[n(1447)]("02",d),u),h)}else _0x13c74d[n(1147)][n(290)+n(474)](_0x1a3a07)}function o(){let a=t;return e[a(930)](e[a(1312)](1e4,Date[a(1821)]()),Math[a(805)](1e4*Math[a(339)]()))}function c(a){let n=t;return(Array(8)[n(1282)]("0")+e[n(719)](parseInt,a,10)[n(1845)](2))[n(1491)](-8)}function l(a){let n=t;return(e.NWhip(Array,4)[n(1282)]("0")+e.nEJux(parseInt,a,2).toString(16))[n(1491)](-4)}function f(a){let n=t,s=a[n(726)](/\./)[n(1863)](h=>c(h)),d=[];return d[0]=e[n(550)](l,s[0]+s[1]),d[1]=l(e[n(490)](s[2],s[3])),[e[n(1407)],n(671),e.KujFu,n(671),e.KujFu,e[n(1204)],d[0],d[1]][n(1282)]("")}function x(a){let n=t;if(n(1623)===e.NFzJc){let s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.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]))/[n(1089)](a);return s?e.LPjSO(f,a):d?e[n(932)](p,a):e[n(629)]}else return _0x5e934b(_0x704d23)}function p(a){let n=t,s="",d=[],u=0,h=0,m=!0,E=n(671);if(e[n(957)](a[n(1163)]("::"),-1)){let g=a.split("::");for(let P=0;e[n(347)](P,g[n(1258)]);P++){let F=g[P];if(e[n(945)](F[n(1163)](":"),0)){let z=F[n(726)](":");m&&(u=z.length),h+=z[n(1258)];for(let q=0;e[n(347)](q,z.length);q++)if(e[n(1067)](4,z[q][n(1258)])){let W=E[n(1061)+"g"](0,e[n(358)](4,z[q][n(1258)])),le=W[n(537)](z[q]);d.push(le)}else d[n(1014)](z[q]);m=!1}else{if(F[n(1258)]!==4){let z=E.substring(0,e[n(1560)](4,F[n(1258)])),q=z[n(537)](F);d[n(1014)](q)}else d[n(1014)](F);m&&(u+=1),h+=1,m=!1}}let k="";for(let P=0;e[n(347)](P,e[n(358)](8,h));P++)k=k.concat(E);for(let P=0;e[n(1240)](P,d[n(1258)]);P++)if(e[n(1794)](P,u))if(e[n(1067)](e[n(1289)],"wwIXb"))s=s.concat(k),s=s[n(537)](d[P]);else return n(1323)+"_"+this[n(947)];else s=s.concat(d[P]);return s}{let g=a[n(726)](":");for(let k=0;k<g[n(1258)];k++){let P=g[k];if(e[n(1067)](4,g[k].length))if(e.OfUjW(e[n(286)],"FavFg")){let F=E[n(1061)+"g"](0,e[n(374)](4,g[k].length)),z=F[n(537)](P);s=s[n(537)](z)}else this[n(1162)]=!0,this[n(1543)]();else s=s[n(537)](P)}return s}}function b(a,n){let s=t,d={uwaYG:function(m,E,g){return e[U(291)](m,E,g)},KybpC:e.LJHTj,uPtMx:function(m,E){return e.qeLAe(m,E)},vNeBQ:function(m,E){return m+E}},u=a[s(694)];if(u!==void 0)if(e.SDNSR===e[s(1198)])e.mJsAG(he,n,10),K(n,u);else if(d[s(610)](_0x479ae3,_0x13f637)){let m=_0x57812c[s(825)][s(1491)](_0x55937b.byteOffset,d.vNeBQ(_0x4fe7d4[s(1346)+"th"],_0x3fdcae[s(1372)+"et"]));this._socket&&this[s(456)].send({data:m,fail:E=>{let g=s;this.emit(g(1613),d.uwaYG(_0x13be4f,d[g(1712)],{message:this[g(1493)+"rrorMess"+g(571)](E)}))}})}else this[s(456)]&&this[s(456)][s(758)]({data:_0x1d07b7,fail:m=>{let E=s;this[E(1175)](d[E(1712)],d[E(742)](_0x2f1139,d[E(1712)],{message:this["_formatE"+E(1008)+E(571)](m)}))}});let h=a.value;e.sbODX(void 0,h)&&(e.ALBGf(he,n,18),K(n,h))}function _(a){let n=t,s={};e:for(;!e[n(622)](X,a);){let d=e[n(550)](xe,a);switch(d>>>3){case 0:break e;case 1:s[n(694)]=e.ALBGf(O,a,e.NWhip(xe,a));break;case 2:s[n(1451)]=e.EUJGR(O,a,xe(a));break;default:C(a,e.jsUMw(7,d))}}if(e[n(1794)](void 0,s[n(694)]))throw new Error(e[n(1701)]);if(e[n(1760)](void 0,s.value))throw new Error(e.wNXMA);return s}function A(a){let n=t;if(e[n(1794)](n(955),"NMyug")){let s=e[n(1665)](D);return e[n(759)](w,a,s),e[n(932)](B,s)}else{if(this[n(1546)+n(1237)](),this[n(371)+n(916)](),this["_removeW"+n(1824)+"rs"](),this[n(1184)+n(406)](1e3,_0x5b0c92),this[n(1543)+n(745)]=!1,_0x3a16b4&&this[n(625)+n(580)]()&&!this["_readyCl"+n(1133)]){if(this[n(854)+n(577)]?.[n(1706)+n(1027)+"es"]()){let d=this[n(854)+n(577)]?.[n(943)+n(1070)+"nt"]();this[n(484)+"hCloseEv"+n(1144)](_0x4dc8f8(e.uTbsW,{code:1006,reason:n(1566)+d+(n(1387)+", max re"+n(598)+"ached"),wasClean:!0}))}else{let d=this[n(1444)][n(551)+n(1454)+"ptor"](_0x350f49,_0x54b8e9);this[n(484)+n(865)+n(1144)](e[n(999)](_0x5c2da3,e.uTbsW,{code:_0x1c29aa,reason:_0x18a87e,wasClean:!0,willReconnect:d})),d&&this[n(1543)]()}return}this["_navigat"+n(580)]()||this[n(388)+n(1133)]?this[n(484)+n(865)+"ent"](e[n(759)](_0x2ca355,e.uTbsW,{code:_0x52bbb8,reason:e.Xdadg})):this[n(484)+n(865)+n(1144)](e[n(999)](_0x5d4cf7,e[n(1009)],{code:1006,reason:e[n(721)]})),this[n(965)]=null,this[n(854)+n(577)]?.[n(382)+n(662)+"fig"](),this[n(1337)+n(1812)]?.[n(1643)+n(528)]()}}function w(a,n){let s=t,d={lSmnN:function(G,$){return e.sGEKc(G,$)},cBDgn:function(G,$){return G>=$},mUAYi:function(G,$){return e[U(347)](G,$)},UvfWM:function(G,$){return e[U(717)](G,$)},ujVSq:function(G,$){return e[U(1379)](G,$)},HPAMJ:function(G,$){return e.iwVrQ(G,$)},anylr:function(G,$){return G&$},xjFAt:function(G,$){return G>=$},UZuck:function(G,$){return e[U(347)](G,$)},jDRfB:function(G,$){return e.MUiGa(G,$)},BnAuO:function(G,$){return e.iwVrQ(G,$)},zbhWc:function(G,$){return e[U(717)](G,$)},iRflo:function(G,$){return e[U(717)](G,$)},wIRXP:function(G,$){return e.WufyL(G,$)},Jjqup:function(G,$){return e[U(627)](G,$)},lEoUZ:function(G,$){return e[U(823)](G,$)},vstIu:function(G,$){return e.ARjsl(G,$)},qALFs:function(G,$){return e[U(928)](G,$)},mNmrL:function(G,$){return e[U(930)](G,$)},IgoWm:function(G,$){return G&$},jLkUt:e[s(1572)],jbvIK:function(G,$,Ke){return G($,Ke)}},u=a.SeqID;e[s(1067)](void 0,u)&&(e[s(719)](he,n,8),xt(n,u));let h=a.LogID;if(e.KReOS(void 0,h))if(s(317)!==e[s(327)])e[s(514)](he,n,16),e.mJsAG(xt,n,h);else return d[s(1255)](_0x3f9720,_0x3811af);let m=a.service;m!==void 0&&(e.xDCpT(he,n,24),e[s(514)](xt,n,L(m)));let E=a[s(376)];if(E!==void 0)if(e[s(1326)](s(1635),s(1635))){let G=_0x30de14[_0x40b52a++];if(G<=127)_0x35529e+=_0xd1023b[s(450)+s(1497)](G);else if(d[s(791)](G,192)&&d[s(548)](G,224))_0x2d6f51+=_0x34d734["fromChar"+s(1497)](d[s(302)](d[s(1838)](d.HPAMJ(31,G),6),d[s(1330)](63,_0x4f0cfd[_0x44a563++])));else if(d[s(1028)](G,224)&&d[s(696)](G,240))_0x15fa30+=_0x41326e[s(450)+s(1497)](d[s(1055)](d[s(1838)](d[s(1330)](15,G),12),d.ujVSq(d[s(1542)](63,_0x52c025[_0x3a7948++]),6))|d[s(1542)](63,_0x25e0a4[_0x5d35b2++]));else if(d.xjFAt(G,240)){let $=d[s(1309)](d[s(1520)](d[s(692)](d[s(1254)](7,G),18),d[s(618)](d[s(1381)](63,_0x4a2192[_0x35b7f5++]),12))|d[s(618)](d[s(1254)](63,_0x40cc85[_0x2786c9++]),6),d.vstIu(63,_0x533648[_0x37dbba++]))-65536;_0x218f31+=_0x145c66["fromChar"+s(1497)](55296+d[s(1606)]($,10)),_0x50bcae+=_0x3e2d6e["fromChar"+s(1497)](d[s(1604)](56320,d[s(1410)](1023,$)))}}else e[s(1404)](he,n,32),xt(n,e[s(1179)](L,E));let g=a.headers;if(e[s(1808)](void 0,g))for(let G of g){e.FzDQO(he,n,42);let $=e.Hwdfc(D);e[s(659)](b,G,$),e[s(759)](he,n,$[s(400)]),V(n,$),e[s(979)](R,$)}let k=a["payloadE"+s(898)];e[s(1860)](void 0,k)&&(e[s(1679)](he,n,50),e[s(469)](K,n,k));let P=a[s(1511)+s(1720)];e.fxIPq(void 0,P)&&(e[s(818)](he,n,58),K(n,P));let F=a.payload;e.RzYWr(void 0,F)&&(e[s(291)](he,n,66),he(n,F.length),e[s(959)](ge,n,F));let z=a[s(752)];z!==void 0&&(e[s(818)](he,n,74),e[s(952)](K,n,z));let q=a[s(1302)+s(1655)];e[s(830)](void 0,q)&&(he(n,82),e[s(777)](K,n,q));let W=a[s(460)];e.BTagQ(void 0,W)&&(e.SIwos(e[s(1517)],e[s(1151)])?(e[s(1301)](he,n,90),K(n,W)):this[s(1175)](d[s(1242)],d.jbvIK(_0xa66a34,d[s(1242)],{..._0x378397})));let le=a[s(298)+"e"];e[s(1467)](void 0,le)&&(e.bLEbl(e[s(1770)],s(401))?(this[s(472)+"ndex"]=0,this[s(1380)+s(508)+s(1641)+"t"]=0):(he(n,96),e[s(777)](xt,n,L(le))))}function v(a){let n=t;if(e[n(674)](e.ohqaB,e[n(487)]))return I(e.zPKsL(M,a));{let s=_0x2ee013[n(694)];s!==void 0&&(e.rqflg(_0x4062e3,_0x42c833,10),e[n(1301)](_0x45b952,_0x3c85f2,s));let d=_0x58747f[n(1451)];e[n(1837)](void 0,d)&&(e[n(999)](_0x1f4ed9,_0x2b762d,18),e.ALBGf(_0x428217,_0x4acf3f,d))}}function I(a){let n=t;if(e[n(1813)](e[n(782)],e.kHBVy))return this[n(965)]?this._ws[n(352)]:this[n(895)];{let s={};e:for(;!e[n(480)](X,a);){let d=e.OrpaJ(xe,a);switch(e[n(687)](d,3)){case 0:break e;case 1:s[n(1402)]=St(a,!0);break;case 2:s[n(1321)]=e[n(999)](St,a,!0);break;case 3:s.service=e[n(550)](xe,a);break;case 4:s[n(376)]=e[n(1730)](xe,a);break;case 5:{let u=S(a);(s[n(482)]||(s[n(482)]=[]))[n(1014)](e[n(480)](_,a)),a[n(400)]=u;break}case 6:s[n(1e3)+"ncoding"]=e.sSKxP(O,a,e.DMjpG(xe,a));break;case 7:s[n(1511)+n(1720)]=e[n(659)](O,a,e[n(668)](xe,a));break;case 8:s[n(1261)]=e[n(759)](Se,a,e[n(1423)](xe,a));break;case 9:s[n(752)]=O(a,e[n(932)](xe,a));break;case 10:s[n(1302)+n(1655)]=e[n(999)](O,a,xe(a));break;case 11:s[n(460)]=e[n(1272)](O,a,e[n(979)](xe,a));break;case 12:s.frameType=e[n(1123)](xe,a);break;default:e[n(952)](C,a,e[n(1789)](7,d))}}if(s[n(1402)]===void 0)throw new Error(e[n(775)]);if(e[n(1760)](void 0,s[n(1321)]))throw new Error(e[n(1437)]);if(e[n(1813)](void 0,s[n(1459)]))throw new Error(e[n(443)]);if(e[n(1830)](void 0,s[n(376)]))throw new Error(e[n(697)]);return s}}function S(a){let n=t,s=e.DPNev(xe,a),d=a[n(400)];return a[n(400)]=a.offset+s,d}function C(a,n){let s=t;if(e[s(1797)](e[s(1771)],e[s(1771)]))switch(n){case 0:for(;e[s(1553)](128,e[s(1677)](oe,a)););break;case 2:e[s(568)](Z,a,e.OrpaJ(xe,a));break;case 5:e[s(719)](Z,a,4);break;case 1:Z(a,8);break;default:throw new Error(e[s(1866)](e[s(970)],n))}else{let d=_0x115924(_0x54e412,_0x1548f9[s(400)]),u=_0x12a796.bytes,h=_0x39bdb9.bytes;for(let m=0,E=_0x5eb619[s(400)];e[s(1317)](m,E);m++)u[e[s(1866)](m,d)]=h[m]}}function L(a){let n=t;if(e[n(699)](e[n(1471)],e.kyUSL)){let s=_0x375e30[n(372)],d=_0x280ce1[n(1615)],u=_0x36e59c[n(400)],h=e[n(1866)](d,_0x248b0f);if(h>s[n(1258)]){let m=new _0x37f3b8(2*h);m[n(589)](s),_0x8e15d0[n(372)]=m}return _0xd811c0[n(1615)]=h,e.OeEfA(h,u)&&(_0x3e67a3[n(400)]=h),d}else return a|=0,{low:a,high:e[n(890)](a,31),unsigned:e[n(874)](a,0)}}let y=[];function D(){let a=t;if(e[a(1467)](e.XhQnN,a(744))){let n=y[a(669)]();return n?(n[a(1615)]=n[a(400)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}else this[a(1397)]?.[a(1424)](_0x37f39f[a(1633)+"id"])}function R(a){y[t(1014)](a)}function M(a){return{bytes:a,offset:0,limit:a[t(1258)]}}function B(a){let n=t,s=a[n(372)],d=a[n(400)];return e.CVbFS(s[n(1258)],d)?s:s[n(1654)](0,d)}function Z(a,n){let s=t;if(e[s(872)](a[s(1615)],n)>a[s(400)])throw new Error(s(328)+s(1489));a[s(1615)]+=n}function X(a){let n=t;return e[n(874)](a[n(1615)],a.limit)}function re(a,n){let s=t,d=a.bytes,u=a[s(1615)],h=a.limit,m=e.zEYiD(u,n);if(e[s(945)](m,d.length)){let E=new Uint8Array(e[s(1312)](2,m));E.set(d),a[s(372)]=E}return a[s(1615)]=m,e[s(957)](m,h)&&(a[s(400)]=m),u}function te(a,n){let s=t,d=a.offset;if(e[s(1057)](e[s(930)](d,n),a[s(400)]))throw new Error(e.hWWGh);return a[s(1615)]+=n,d}function Se(a,n){let s=t,d=e[s(659)](te,a,n);return a[s(372)].subarray(d,e[s(1447)](d,n))}function ge(a,n){let s=t,d=e[s(1522)](re,a,n[s(1258)]);a[s(372)][s(589)](n,d)}function O(a,n){let s=t,d=e[s(1679)](te,a,n),u=String[s(450)+s(1497)],h=a.bytes,m="\uFFFD",E="";for(let g=0;g<n;g++){let k=h[e[s(490)](g,d)],P,F,z,q;if(e[s(1283)](128,k)===0)E+=u(k);else if(e.AFIoK(e[s(1789)](224,k),192))g+1>=n?E+=m:(P=h[e[s(950)](e[s(1145)](g,d),1)],e.nIOSk(e[s(1283)](192,P),128)?E+=m:(q=e.MUiGa(e[s(823)](31&k,6),e.vZkci(63,P)),e.wvXgb(q,128)?E+=m:(E+=e[s(904)](u,q),g++)));else if((240&k)==224)if(e.PHXij(e[s(1447)](g,2),n))E+=m;else{if(e[s(681)](e[s(399)],e[s(518)]))return this._socket[s(352)];P=h[e[s(855)](g,d)+1],F=h[e[s(1496)](g+d,2)],e[s(1553)](e[s(1780)](P,e.WufyL(F,8)),49344)!==32896?E+=m:e.lwZLd(e.zxMIC,e[s(373)])?e.rkdGN(_0x58178d,_0x3d02f8,this["_getInte"+s(682)+"e"](_0x5574dc)):(q=e.MUiGa(e[s(1379)](e[s(1283)](15,k),12),(63&P)<<6)|e[s(910)](63,F),e[s(608)](q,2048)||e[s(763)](q,55296)&&e[s(1674)](q,57343)?E+=m:(E+=e[s(1423)](u,q),g+=2))}else e[s(1375)](248&k,240)?e.sGJOL(g+3,n)?E+=m:(P=h[e[s(1578)](g+d,1)],F=h[g+d+2],z=h[e[s(1049)](e[s(490)](g,d),3)],e[s(1400)](e[s(1283)](e[s(1514)](e[s(1022)](P,e.lygDJ(F,8)),z<<16),12632256),8421504)?E+=m:(q=e[s(717)](e[s(1264)](e.cHPvJ(e[s(1265)](e[s(1815)](7,k),18),e.RFSHh(e[s(704)](63,P),12)),e.ARjsl(63,F)<<6),e[s(1283)](63,z)),e[s(337)](q,65536)||e.OeEfA(q,1114111)?E+=m:(q-=65536,E+=e[s(291)](u,e[s(389)](e[s(1555)](q,10),55296),(1023&q)+56320),g+=3))):E+=m}return E}function K(a,n){let s=t,d=n[s(1258)],u=0;for(let E=0;e[s(347)](E,d);E++){let g=n.charCodeAt(E);e[s(763)](g,55296)&&e[s(428)](g,56319)&&e[s(1240)](E+1,d)&&(g=e[s(1750)](e[s(1343)](g<<10,n[s(1868)+"At"](++E)),56613888)),u+=e[s(1240)](g,128)?1:e[s(1291)](g,2048)?2:e[s(414)](g,65536)?3:4}he(a,u);let h=e[s(493)](re,a,u),m=a[s(372)];for(let E=0;e.XRqDL(E,d);E++){let g=n[s(1868)+"At"](E);e[s(786)](g,55296)&&e[s(1674)](g,56319)&&e[s(1317)](E+1,d)&&(g=e[s(389)](e[s(1588)](g,10),n[s(1868)+"At"](++E))-56613888),e.alcMf(g,128)?m[h++]=g:(g<2048?m[h++]=e[s(736)](e[s(1507)](g,6)&31,192):(e[s(390)](g,65536)?m[h++]=e.OWtTL(e[s(1374)](e.lNlDp(g,12),15),224):(m[h++]=e[s(1780)](e[s(1283)](e[s(928)](g,18),7),240),m[h++]=e[s(792)](e.WDKrp(g,12)&63,128)),m[h++]=e[s(717)](e.AWOmt(e[s(1525)](g,6),63),128)),m[h++]=e[s(574)](e[s(1738)](63,g),128))}}function V(a,n){let s=t,d={eGefT:function(u,h){return e[U(1830)](u,h)}};if(e[s(681)](e[s(1385)],s(1086)))return _0x1e684e&&d[s(1550)](!0,_0x80d715[s(1688)]);{let u=re(a,n[s(400)]),h=a[s(372)],m=n[s(372)];for(let E=0,g=n[s(400)];e[s(1291)](E,g);E++)h[E+u]=m[E]}}function oe(a){let n=t;return a[n(372)][e[n(1120)](te,a,1)]}function Ye(a,n){let s=t,d=e[s(335)](re,a,1);a[s(372)][d]=n}function xe(a){let n=t;if(e[n(1518)]!==e[n(1518)]){let s=e.OECHn(_0x13ea35,_0x37200f,_0x1758f7[n(1258)]);_0x32f691[n(372)][n(589)](_0x896987,s)}else{let s=0,d=0,u;do u=oe(a),e[n(499)](s,32)&&(d|=e[n(768)](e[n(704)](127,u),s)),s+=7;while(128&u);return d}}function he(a,n){let s=t;for(n>>>=0;e.GqcJT(n,128);)Ye(a,e.CfRDU(127,n)|128),n>>>=7;e[s(1443)](Ye,a,n)}function St(a,n){let s=t,d={wjRcg:function(g,k,P){return e[U(678)](g,k,P)}},u=0,h=0,m=0,E;if(E=oe(a),u=e[s(1710)](127,E),e[s(346)](128,E)&&(E=e[s(1280)](oe,a),u|=e[s(1769)](127&E,7),e[s(1283)](128,E)&&(E=oe(a),u|=e[s(1588)](e[s(1762)](127,E),14),e[s(541)](128,E)&&(E=e[s(901)](oe,a),u|=e[s(1773)](127&E,21),e.qsrGD(128,E)))))if(s(1461)===e[s(800)]){let g={VtoUv:s(886),CKDgF:e[s(377)],bjgkG:s(1177),UEpYA:e[s(925)],qChSh:function(q,W,le,G){return q(W,le,G)},YmuPp:e[s(624)],Ylbow:function(q,W,le,G){return e.aTQpa(q,W,le,G)}},[k,P]=_0x39cf7a(_0x1790aa),F=e[s(1285)](_0xe7e19d,k),z=0;return _0x1fa09a.forEach(q=>{let W=s,le=("3|6|0|9|"+W(1196)+"|4|5|2")[W(726)]("|"),G=0;for(;;){switch(le[G++]){case"0":_0x8f0b6d.log(g[W(1783)],z);continue;case"1":_0x34129e.log(g[W(856)],z);continue;case"2":_0x81bd1d[W(1362)](g[W(1636)],z);continue;case"3":_0x21f244[W(1362)](g[W(617)],q,q[W(1459)]);continue;case"4":_0x2e60d7.log(W(1776),z);continue;case"5":z=_0x31bf02(_0x1ad49a[W(1777)+"er"](q[W(575)]||_0x48a7fa),F,z);continue;case"6":z=g[W(349)](_0x3c39b2,0,F,z);continue;case"7":_0xb287f2[W(1362)](g[W(407)],z);continue;case"8":z=g[W(292)](_0x4bcb3b,P[q[W(808)+"ame"]],F,z);continue;case"9":z=g[W(349)](_0xef202,F,z,q.service||0);continue;case"10":z=g[W(349)](_0x309463,q[W(808)+W(1304)],F,z);continue}break}}),{frameType:_0x3f5ab6,headers:[{key:e.tsuQI,value:_0x9a3590}],payload:F}}else E=oe(a),h=e.pfDPI(127,E),e[s(1425)](128,E)&&(E=e[s(405)](oe,a),h|=e.HLFwv(127&E,7),e[s(1456)](128,E)&&(e[s(1130)](e[s(978)],e[s(978)])?(E=e[s(480)](oe,a),h|=e[s(367)](127,E)<<14,e[s(1456)](128,E)&&(E=oe(a),h|=e[s(1850)](e[s(604)](127,E),21),e[s(936)](128,E)&&(E=e[s(904)](oe,a),m=e[s(613)](127,E),128&E&&(E=e[s(896)](oe,a),m|=e[s(768)](e.yGgoD(127,E),7))))):(_0x3a4f69(_0x12e845,58),gzRyCo[s(1212)](_0x46ef5a,_0x44d458,_0x97ca0e))));return{low:u|e.HLFwv(h,28),high:e[s(283)](e[s(687)](h,4),e[s(1769)](m,24)),unsigned:n}}function xt(a,n){let s=t,d=e[s(1538)](n.low,0),u=e.ccQPj(e[s(1780)](n[s(1713)]>>>28,e.cvxpS(n[s(1421)],4)),0),h=e.doFCf(n[s(1421)],24),m=h===0?e[s(1794)](0,u)?e[s(390)](d,16384)?d<128?1:2:e[s(953)](d,2097152)?3:4:u<16384?u<128?5:6:e.alcMf(u,2097152)?7:8:e[s(1291)](h,128)?9:10,E=e.ueFlD(re,a,m),g=a[s(372)];switch(m){case 10:g[e.uZIcp(E,9)]=e[s(590)](h,7)&1;case 9:g[e[s(863)](E,8)]=e[s(385)](9,m)?e[s(991)](128,h):e[s(1671)](127,h);case 8:g[e[s(1049)](E,7)]=m!==8?u>>>21|128:e[s(1689)](u>>>21,127);case 7:g[e[s(735)](E,6)]=e[s(996)](7,m)?e[s(1538)](u,14)|128:e[s(1357)](u,14)&127;case 6:g[E+5]=e[s(1808)](6,m)?e[s(471)](u>>>7,128):u>>>7&127;case 5:g[e[s(492)](E,4)]=e[s(304)](5,m)?e[s(1556)](128,u):e.OVctt(127,u);case 4:g[e[s(1145)](E,3)]=e[s(674)](4,m)?e[s(736)](d>>>21,128):e.oLOGL(e[s(687)](d,21),127);case 3:g[e[s(930)](E,2)]=e[s(1046)](3,m)?e.hGJIL(e.ccQPj(d,14),128):e[s(627)](d>>>14,127);case 2:g[e.uZIcp(E,1)]=m!==2?e[s(847)](e[s(687)](d,7),128):e[s(1538)](d,7)&127;case 1:g[E]=e[s(1624)](1,m)?128|d:e[s(1638)](127,d)}}function Xt(a){return e[t(1170)](v,a)}function Ft(a){let n=t;if(!e.yeByN(n(843),n(279)))return A(a)}let Qt=65536,qr=e[t(527)],_e=e[t(1312)](Qt,Qt),Ce=_e*_e,Jn=e.qaJNz(Ce,2),Oe=String[t(1609)+"e"][t(1868)+"At"];class fe{constructor(n,s,d){let u=t;this[u(1688)]=!0,this[u(1713)]=e[u(638)](0,n),this[u(1421)]=e[u(1068)](0,s),this[u(1817)]=!!d}static[t(1688)](n){return n&&e.QoXWB(!0,n.isLong)}static[t(866)](n,s,d){return new fe(n,s,d)}static[t(750)+"s"](n,s,d){let u=t;return d?fe[u(750)+u(1416)](n,s):fe.fromBytesBE(n,s)}static[t(750)+t(1416)](n,s){let d=t;return new fe(e[d(847)](n[0]|e[d(1761)](n[1],8),e.OmcuT(n[2],16))|e[d(1259)](n[3],24),e.voblT(e[d(1264)](n[4]|n[5]<<8,e[d(869)](n[6],16)),e[d(479)](n[7],24)),s)}static[t(750)+t(1453)](n,s){let d=t;return new fe(e[d(1366)](e[d(1747)](n[4],24),e.EXtvt(n[5],16))|e[d(1259)](n[6],8)|n[7],e[d(787)](e.nmhVE(e[d(984)](n[0],24)|e[d(517)](n[1],16),e[d(1773)](n[2],8)),n[3]),s)}static[t(1096)](n){let s=t;return e[s(1616)](n,qr)?Ld:new fe(e[s(481)](e[s(736)](e[s(471)](Oe[s(452)](n,0)|e.MOHvF(Oe[s(452)](n,1),8),e[s(1588)](Oe[s(452)](n,2),16)),e[s(1850)](Oe.call(n,3),24)),0),e[s(574)](e[s(471)](e[s(1366)](Oe[s(452)](n,4),Oe[s(452)](n,5)<<8),e[s(338)](Oe[s(452)](n,6),16)),e[s(1836)](Oe[s(452)](n,7),24))>>>0,!0)}[t(1585)](){let n=t;return String[n(450)+n(1497)](255&this[n(1713)],e[n(956)](this[n(1713)]>>>8,255),e[n(1541)](this[n(1713)]>>>16,255),e.qIbdx(this[n(1713)],24),e[n(1434)](255,this[n(1421)]),e[n(882)](this[n(1421)],8)&255,e[n(1553)](e[n(1538)](this[n(1421)],16),255),e.qIbdx(this[n(1421)],24))}static fromNumber(n,s=!0){let d=t;if(e[d(743)](isNaN,n))return s?Fh:Ld;if(s){if(e[d(874)](n,Ce))return Uh}else{if(e[d(428)](n,-Jn))return qh;if(e[d(1262)](e[d(1578)](n,1),Jn))return zh}return fe[d(866)](e[d(1855)](e[d(762)](n,_e),0),e[d(751)](e[d(1691)](n,_e),0),s)}toNumber(){let n=t;return this.unsigned?e[n(863)](e[n(1312)](e[n(882)](this[n(1421)],0),_e),e.sUbaY(this[n(1713)],0)):e.vfqpl(this[n(1421)]*_e,this[n(1713)]>>>0)}[t(322)](){let n=t;return e[n(937)](e[n(806)],e[n(806)])?e[n(1729)](0,this.high)&&e[n(1729)](0,this[n(1713)]):e[n(1375)](this[n(472)+n(1235)],this[n(1466)+"s"].length)?!0:e[n(957)](this[n(1380)+n(508)+"riesCount"],this.maxRetries)}add(n){let s=t;if(e.gvrwI===e.gvrwI){fe[s(1688)](n)||(n=fe[s(1777)+"er"](n));let d=this[s(1421)]>>>16,u=e[s(1548)](65535,this[s(1421)]),h=e.fNgpP(this[s(1713)],16),m=e[s(1484)](65535,this[s(1713)]),E=n[s(1421)]>>>16,g=65535&n[s(1421)],k=e.qIbdx(n[s(1713)],16),P=e[s(1484)](65535,n.low),F=0,z=0,q=0,W=0;return W+=e[s(559)](m,P),q+=W>>>16,W&=65535,q+=e[s(1578)](h,k),z+=e[s(983)](q,16),q&=65535,z+=e[s(559)](u,g),F+=e[s(738)](z,16),z&=65535,F+=e[s(1578)](d,E),F&=65535,fe[s(866)](e.Vjmwe(q,16)|W,e[s(1081)](F,16)|z,this[s(1817)])}else return _0x350762.resolve()}[t(500)](n){let s=t;return fe[s(1688)](n)||(n=fe[s(1777)+"er"](n)),e[s(1837)](this[s(1817)],n[s(1817)])&&e.anFpE(e.NhFDI(this[s(1421)],31),1)&&e[s(1794)](e.fgruL(n[s(1421)],31),1)?!1:this[s(1421)]===n[s(1421)]&&e.HwCxT(this[s(1713)],n[s(1713)])}[t(555)](){let n=t;return e[n(1813)](-1,this[n(1713)])&&this.high===-1?fe[n(866)](0,0,this[n(1817)]):e.aDcpc(-1,this.low)?fe[n(866)](0,e[n(872)](this[n(1421)],1),this[n(1817)]):fe[n(866)](e[n(1647)](this[n(1713)],1),this[n(1421)],this.unsigned)}[t(1267)](n){return n?this[t(1342)+"E"]():this.toBytesBE()}[t(1342)+"E"](){let n=t,s=this.high,d=this.low;return[e[n(344)](255,d),e[n(822)](d,8)&255,d>>>16&255,e.doFCf(d,24),e[n(1374)](255,s),e[n(1469)](e.NhFDI(s,8),255),e[n(485)](e.doFCf(s,16),255),e.fNgpP(s,24)]}[t(536)+"E"](){let n=t,s={yorgI:function(d,u){return e.KOtGV(d,u)},VxRdl:e[n(564)],RsjfJ:"offline"};if(e.nIOSk(e.dpUEx,n(603))){let d=this[n(1421)],u=this.low;return[d>>>24,e[n(1239)](d>>>16,255),e[n(767)](e.KQXVU(d,8),255),255&d,e.NhFDI(u,24),u>>>16&255,e[n(1756)](e[n(1445)](u,8),255),e[n(1484)](255,u)]}else _0x5c6997.persisted&&(this[n(625)+n(580)]()&&(!this[n(965)]||this[n(965)].readyState!==this.OPEN||s[n(1464)](this._ws[n(1016)+"te"],this.CONNECTING))&&this[n(1681)+"nLine"](),this[n(1013)+"er"]&&_0x1f9db4[n(1256)+n(1165)](s[n(781)],this[n(1681)+n(1042)]),this._isBrowser&&_0x4ea55c[n(1256)+n(1165)](s[n(1015)],this[n(1681)+n(1675)]))}}let Ld=new fe(0,0,!1),Fh=new fe(0,0,!0),zh=fe[t(866)](-1,2147483647,!1),Uh=fe[t(866)](-1,-1,!0),qh=fe[t(866)](0,-2147483648,!1);var en=(function(a){let n=t,s=e.kkGyO.split("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(776)]]=5002]=e[n(776)];continue;case"1":a[a[e[n(529)]]=5004]=e[n(529)];continue;case"2":return a;case"3":a[a[e[n(1765)]]=5005]=n(1529)+"OR";continue;case"4":a[a[e[n(893)]]=5001]=e.NwHHz;continue;case"5":a[a[e.EUZZM]=5003]=e[n(378)];continue}break}})({});class Vn{constructor(n){let s=t,d={GTAMx:function(u,h){return u instanceof h},XffAl:function(u,h){return e[U(1047)](u,h)},eIRpA:e[s(1268)],xQTJf:e.uLWFZ,dGMxQ:s(1228),rjUDc:e[s(665)],WvxVZ:function(u,h,m,E){return e[s(1452)](u,h,m,E)}};if(s(1001)!==e[s(1574)])this[s(1271)]=n,this[s(903)]=null;else{let u=d[s(1112)](this[s(1444)][s(1e3)+s(898)],_0x1ce0d8)?{force:!!this[s(1444)][s(1e3)+s(898)].force,encoding:this[s(1444)][s(1e3)+s(898)][s(1752)]?this[s(1444)][s(1e3)+"ncoding"][s(1752)][s(1075)](/\s/g,"")["toLowerC"+s(975)]():""}:{force:!1,encoding:this[s(1444)][s(1e3)+s(898)]?this[s(1444)][s(1e3)+s(898)][s(1075)](/\s/g,"")[s(1119)+s(975)]():""},h=_0x328fa2["payloadE"+s(898)]?_0xd83226["payloadE"+s(898)][s(1075)](/\s/g,"")["toLowerC"+s(975)]():"",m=d[s(1219)](this[s(1444)]["payloadT"+s(1720)],_0xa9631e)?{force:!!this[s(1444)][s(1511)+s(1720)][s(985)],type:this._options["payloadT"+s(1720)][s(1271)]?this[s(1444)][s(1511)+s(1720)][s(1271)][s(1075)](/\s/g,"")[s(1119)+s(975)]():""}:{force:!1,type:this[s(1444)][s(1511)+s(1720)]?this[s(1444)][s(1511)+"ype"].replace(/\s/g,"")[s(1119)+s(975)]():""},E=_0x543006[s(1511)+s(1720)]?_0x18adf0[s(1511)+s(1720)][s(1075)](/\s/g,"")[s(1119)+s(975)]():"",g=m[s(985)]?m[s(1271)]:E||m.type,k=u[s(985)]?u[s(1752)]:h||u[s(1752)],P=["text/pla"+s(810)+s(944),d[s(1087)],d[s(498)],d[s(1090)]],F=["none_none",d[s(1369)]];this[s(1444)][s(1142)+s(1853)+s(966)+"ad"]&&P.includes(g)&&(!k||F[s(512)](k))?_0x3d08a0[s(1649)+s(1102)]=d[s(648)](_0xf66eb6,_0x12bb8e[s(1261)],0,_0x5f349c[s(1261)].byteLength):_0x1405e1[s(1649)+s(1102)]=""}}}class Nd extends Vn{constructor(n,s){let d=t;e.moNQa(e[d(421)],e[d(421)])?this[d(842)](_0x2903fe,_0x3f7bd7):(super(n),this[d(1197)]=s&&s[d(1197)]||null)}}class Md extends Vn{constructor(n,s){let d=t;super(n),this[d(1613)]=s&&s[d(1613)]||null,this.colno=s&&s[d(543)]||0,this[d(807)]=s&&s[d(807)]||"",this[d(515)]=s&&s[d(515)]||0,this[d(1197)]=s&&s.message||"",this[d(1725)]=s&&s.code||5001}}class Bd extends Vn{constructor(n,s){let d=t,u=e.qqtUk[d(726)]("|"),h=0;for(;;){switch(u[h++]){case"0":this[d(1562)+d(1648)]=s&&s[d(1562)+d(1648)]||!1;continue;case"1":super(n);continue;case"2":this.reason=s&&s[d(1105)]||"";continue;case"3":this[d(1530)]=s&&s.wasClean||!1;continue;case"4":this[d(1725)]=s&&s.code||0;continue}break}}}class Fd extends Vn{constructor(n,s){let d=t;super(n),this[d(1026)]=s&&s[d(1026)]||null}}class zd extends Fd{constructor(n,s){let d=t;super(n),this[d(1026)]=s&&s[d(1026)]||null,this[d(1197)]=s&&s[d(1197)]||null}}class Ud extends Vn{constructor(n,s){let d=t;super(n),this[d(1026)]=s&&s.data||null}}function at(a,{message:n,code:s,error:d}){let u=t;if(e[u(1837)](e[u(685)],e.tFQpt))return new Md(a,{message:n,code:s,error:d});{let h=new _0x8f9ae7(e.kpFjM(e[u(283)](e[u(1850)](_0x20efce[_0x45fc11+4],24)|_0x3a2af[e[u(354)](_0x4aeb0b,5)]<<16,e[u(1561)](_0x254df8[e.dTdkq(_0x2df2a4,6)],8)),_0x151811[e[u(1245)](_0x46c73a,7)]),e.QhXMu(e[u(736)](e.ONTLF(e.iEZvK(_0x481c32[e[u(1496)](_0x3a8df2,0)],24),_0x399aec[_0x582a61+1]<<16),e.SpNlY(_0x2e40e4[e[u(1746)](_0xf008ec,2)],8)),_0x36d456[e.QIWBf(_0x5aae87,3)]),!0);return _0x31e0a9+=8,{value:h,offset:_0x23588f+8}}}function ht(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new Bd(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function qd(a,{data:n,message:s}){let d=t,u={ISSSX:function(h,m){return e[U(1750)](h,m)}};if(e[d(1286)]!==e[d(912)])return new zd(a,{data:n,message:s});{let h=_0x7a812f[d(1061)+"g"](0,NVdxbt.ISSSX(4,_0x5ec76e[_0x56363d][d(1258)])),m=h[d(537)](_0x536257);_0x4d4982=_0xc86963[d(537)](m)}}function Gd(a,{data:n}){return new Ud(a,{data:n})}function na(a,{message:n}){return new Nd(a,{message:n})}class Hd{constructor(n,s){let d=t;this.endpoints=n,this[d(1064)+"es"]=s,this[d(472)+d(1235)]=0,this[d(1380)+"ndpointT"+d(1641)+"t"]=0}[t(382)+t(662)+"fig"](){let n=t;this[n(472)+n(1235)]=0,this["currentE"+n(508)+n(1641)+"t"]=0}[t(1249)+"es"](){let n=t;this[n(1380)+n(508)+n(1641)+"t"]=0}["getCurre"+t(1070)+"nt"](){let n=t;return this.endpoints[this[n(472)+n(1235)]]}[t(943)+t(1070)+"ntTriesC"+t(439)](){let n=t;return e.SIwos(e[n(1298)],e[n(1298)])?n(1323)+"_"+this._DBName:this[n(1380)+"ndpointT"+n(1641)+"t"]}[t(1706)+"chMaxTries"](){let n=t;return!!(this.currentIndex>=this.endpoints[n(1258)]||e.RCeRK(this[n(472)+n(1235)],this.endpoints[n(1258)]-1)&&e[n(817)](this[n(1380)+n(508)+n(1641)+"t"],this[n(1064)+"es"]))}[t(325)+t(1178)+"ointReac"+t(1360)+t(1348)](){let n=t;return e.spDJc(this[n(472)+n(1235)],this[n(1466)+"s"].length)?!0:e[n(1708)](this[n(1380)+"ndpointT"+n(1641)+"t"],this[n(1064)+"es"])}[t(1552)+t(1768)+t(1048)+t(1208)+"unt"](){let n=t;return this[n(1380)+n(508)+n(1641)+"t"]=1,this[n(472)+"ndex"]++,this[n(1466)+"s"][this.currentIndex]}[t(943)+"ntEndpoi"+t(409)+t(654)](){let n=t;return this[n(1380)+n(508)+n(1641)+"t"]++,this[n(943)+n(1070)+"nt"]()}}let Yn=(e.QECHz!=typeof globalThis&&e.XMiPG(e[t(324)],globalThis[t(1356)+t(1363)].name)||e[t(1791)]!=typeof window&&e[t(820)](e[t(324)],window[t(1356)+t(1363)][t(1776)]))&&e[t(1161)](e[t(1791)],typeof document),In=e[t(1833)](e[t(1791)],typeof globalThis)&&(e[t(1683)]===globalThis[t(1356)+t(1363)][t(1776)]||e[t(1602)](t(1816)+t(1388)+t(1474)+"pe",globalThis[t(1356)+"tor"][t(1776)]))&&e[t(712)](e[t(1791)],typeof tt),Gr=(e[t(300)](e[t(1791)],typeof globalThis)&&e[t(1735)](e.QbTFt,globalThis[t(1356)+"tor"][t(1776)])||e[t(619)](e[t(1791)],typeof globalThis)||e[t(1403)](t(569)+"d",typeof globalThis)&&!!globalThis.WeixinJSBridge)&&e[t(714)](e.QECHz,typeof wx),Hr=t(569)+"d"!=typeof globalThis&&(e[t(841)]===globalThis.constructor[t(1776)]||e[t(1020)](e.qwiYk,globalThis["construc"+t(1363)].name)||t(1118)+t(301)+t(1396)===globalThis[t(1356)+t(1363)][t(1776)])&&e[t(1737)](t(569)+"d",typeof self),Gh=e.JcsrB(e[t(1791)],typeof globalThis)&&e[t(332)](e[t(1683)],globalThis[t(1356)+"tor"].name)&&e[t(1791)]!=typeof global&&global[t(1356)+t(1363)][t(1776)]==="Object"&&e[t(724)](e[t(1791)],typeof process)&&!!process.version;class ra{constructor(){let n=t;this[n(1384)+"rs"]={}}emit(n,...s){let d=t,u=this._listeners[n];if(u)u.slice().forEach(h=>h.fn[d(1078)](h.ctx,s));else if(e[d(1830)](e[d(1822)],n)&&!this.onerror)if(e.qkSIK(e[d(1299)],e[d(1299)]))_0x340440.log(_0x3d5b0a);else{let h=s[d(1258)]&&s[0];if(e[d(1276)](h,Error))throw h;let m=new Error(e.COzpH+(h?e.LOobI(" (",h[d(1197)])+")":""));throw m[d(1680)]=h,h}return this}off(n,s){let d=t;if(e[d(749)](void 0,n))this[d(1384)+"rs"]={};else if(e[d(820)](void 0,s))this[d(1384)+"rs"][n]=null;else{let u=this[d(1384)+"rs"][n];if(u)for(let h=0;h<u[d(1258)];)e.RZyVx(u[h].fn,s)?u.splice(h,1):++h}return this}on(n,s,d){let u=t;if(e[u(1326)](e[u(1567)],e[u(980)]))return(this[u(1384)+"rs"][n]||(this._listeners[n]=[]))[u(1014)]({fn:s,ctx:d||this}),this;this[u(965)]&&this[u(965)][u(758)](_0x48f6ea),this[u(447)](e[u(1253)],_0xcc9c88)}}class Hh extends ra{[t(1493)+t(1008)+t(571)](n){let s=t,d={RRHqa:s(1693)+s(1252),SJEhz:s(1630),QDFPR:e[s(641)],ovGHD:"delete",SdGho:e.vHAtg,bwzoD:function(u){return e[s(1665)](u)},vzBQJ:function(u,h){return e[s(1513)](u,h)},gyoAJ:e[s(383)],Frgan:e[s(637)],gUjUN:e[s(1749)],GoIFk:e[s(1788)]};if(e[s(1257)]!==e[s(1835)])return n[s(1599)]||n.errNo?(s(1209)+" "+(n[s(1599)]||"")+" code: "+(n[s(436)]||""))[s(1160)]():JSON[s(1766)+"y"](n);{let u=d[s(646)][s(726)]("|"),h=0;for(;;){switch(u[h++]){case"0":_0x103cc6=new _0x2214f9;continue;case"1":_0x2fb1d1=[MohcHc.SJEhz,MohcHc[s(1294)],MohcHc.ovGHD,MohcHc[s(1227)]];continue;case"2":MohcHc[s(1398)](_0x5f59c0);continue;case"3":_0x281e9e();continue;case"4":MohcHc[s(1819)](_0x531d4f,m=>({...m,get:(E,g,k)=>_0x5d85a5(E,g)||m[s(1676)](E,g,k),has:(E,g)=>!!_0x2568fc(E,g)||m[s(846)](E,g)}));continue;case"5":_0x5ada07=["get",MohcHc[s(1721)],MohcHc[s(601)],MohcHc[s(287)],MohcHc[s(1079)]];continue}break}}}constructor(n,s,d){let u=t;super(),this[u(456)]=null,Gr&&wx[u(297)+u(433)]&&(this[u(456)]=wx[u(297)+"ocket"]({url:n,protocols:s,header:d,fail:this[u(289)+u(465)+u(967)][u(1840)](this),success:this[u(289)+u(1246)+u(594)+"ler"][u(1840)](this)})),In&&tt[u(297)+u(433)]&&(this[u(456)]=tt[u(297)+"ocket"]({url:n,protocols:s,header:d,fail:this[u(289)+"ocketFai"+u(967)][u(1840)](this),success:this["_createS"+u(1246)+"cessHand"+u(1098)][u(1840)](this)}))}[t(289)+t(1246)+t(594)+"ler"](){let n=t,s={zUpzh:function(d,u){return e[U(486)](d,u)},vFKdA:e[n(336)]};Promise[n(353)]()[n(756)](()=>{let d=n;s.zUpzh(s.vFKdA,s.vFKdA)?this._ws&&this._ws[d(567)](_0x53c07d,_0x39f7ce):this[d(982)+d(422)]()})}[t(289)+t(465)+t(967)](n){let s=t,d={ibwti:function(u,h,m){return e[U(720)](u,h,m)},xFXVR:e.LJHTj,ASHKY:function(u,h,m){return e.Sbgup(u,h,m)},QltYi:e[s(1009)]};Promise[s(353)]().then(()=>{let u=s,h=d.ibwti(at,u(1613),{message:this["_formatE"+u(1008)+u(571)](n)});this[u(1175)](d[u(319)],h);let m=d[u(1187)](ht,d[u(538)],{reason:this[u(1493)+u(1008)+"age"](n)});this.emit(d[u(538)],m)})}[t(982)+t(422)](){let n=t,s={GnUjA:e[n(1547)],rYxdz:function(d,u,h){return e[n(659)](d,u,h)},XDCBq:e.uTbsW,Naqui:function(d,u,h){return d(u,h)},EnWys:function(d,u){return e[n(384)](d,u)},yJKjq:e[n(1350)],GNvgC:e[n(1822)]};this._socket[n(1796)](d=>{let u=n;this[u(1175)](s.GnUjA,s[u(1532)](Gd,s[u(836)],{...d,data:d[u(1599)]||""}))}),this[n(456)].onClose(d=>{let u=n;this.emit(s[u(969)],s.Naqui(ht,s.XDCBq,{...d}))}),this[n(456)].onMessage(d=>{let u=n;this[u(1175)](e.QnCYk,e[u(1056)](qd,u(1197),{...d}))}),this[n(456)][n(1825)](d=>{let u=n,h={eIrOm:function(m,E){return s.EnWys(m,E)}};if(u(1104)===s[u(1537)])this[u(1175)](s[u(345)],s[u(1532)](at,s[u(345)],{...d,message:d.errMsg||""}));else{let m=this._qosDB[u(1041)+"geInfoSync"](this._prefix),E=_0x47c0a6[u(785)](h[u(636)](m,"{}"));return _0x3a1be4[u(1540)](E)}})}send(n){let s=t,d={lcReO:function(u,h,m){return u(h,m)},zHXxt:e[s(1822)]};if(e.LryJB(n,Uint8Array))if(e[s(709)](e.UcZmN,s(326))){let u=0,h=0;for(let m=0;e[s(794)](m,_0x1533c2.length);++m)h=_0x6aa822[s(1868)+"At"](m),e[s(1305)](h,128)?u+=1:e[s(337)](h,2048)?u+=2:e[s(525)](e[s(627)](64512,h),55296)&&e.QFYgT(64512,_0x5f260b[s(1868)+"At"](e[s(735)](m,1)))===56320?(++m,u+=4):u+=3;return u}else{let u=n[s(825)][s(1491)](n[s(1372)+"et"],e[s(666)](n[s(1346)+"th"],n[s(1372)+"et"]));this[s(456)]&&this[s(456)][s(758)]({data:u,fail:h=>{let m=s;if(e.gdbqD(e.CnTHY,e[m(1782)]))this[m(1175)](e[m(1822)],e[m(544)](at,m(1613),{message:this[m(1493)+m(1008)+m(571)](h)}));else return _0x484842?this[m(1342)+"E"]():this[m(536)+"E"]()}})}else this[s(456)]&&this[s(456)][s(758)]({data:n,fail:u=>{let h=s;this[h(1175)](h(1613),d[h(587)](at,d[h(1414)],{message:this[h(1493)+h(1008)+h(571)](u)}))}})}[t(567)](n,s){let d=t;this[d(456)]&&this._socket[d(567)]({code:n,reason:s})}[t(1256)+t(1165)](n,s){this.on(n,s)}[t(779)+t(1475)+t(294)](n,s){this.off(n,s)}get[t(1016)+"te"](){let n=t;if(e[n(1457)](e[n(459)],e[n(558)])){e[n(514)](_0x1f76d0,_0x5dcadf,42);let s=e.HbHnR(_0x165eed);_0x5e5794(_0x1479c4,s),e.WFCxj(_0x3e8b61,_0x8558c0,s.limit),_0x209b3d(_0x24e783,s),e[n(1170)](_0x313213,s)}else return this._socket[n(1016)+"te"]}get binaryType(){let n=t;if(e[n(323)](e.hWukd,n(801)))return this[n(456)].binaryType;jQxDdY[n(475)](_0x2befde),jQxDdY[n(1153)](_0x2a3d7f)}set binaryType(n){}get url(){let n=t;if(e[n(746)]!==e[n(746)])try{return!!this._qosDB}catch(s){return _0x38da58[n(1362)](s),!1}else return this[n(456)].url}get[t(1787)](){return this[t(456)].protocol}get[t(526)+"ns"](){let n=t;return this[n(456)][n(526)+"ns"]}get[t(860)+t(799)](){return 0}}function jh(a,n){let s=t;if(n)return new n(a[s(352)],a[s(1787)]);if(Gr||In)return new Hh(a[s(352)],a[s(1787)],a[s(482)]);if(e[s(384)](Yn,Hr)&&e[s(1833)](e[s(1791)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1787)+"s"])}function Wh(a){let n=t,s=e.vzALf[n(726)]("|"),d=0;for(;;){switch(s[d++]){case"0":return!1;case"1":if(e.wrUIi(Yn,Hr)&&e[n(712)](e[n(1791)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":if(In&&tt[n(297)+n(433)])return!0;continue;case"3":if(a)return!0;continue;case"4":if(Gr&&wx[n(297)+n(433)])return!0;continue}break}}function jd(a,n,s){let d=t,u={csuGL:function(h,m){return e[U(1697)](h,m)},VvMvD:function(h,m){return e.QqyZS(h,m)},TYcjU:function(h,m){return e[U(309)](h,m)}};if(e[d(519)]===e.tVhOV){let h=-1;async function m(E){let g=d;return u[g(1857)](E,h)?Promise[g(1217)](new Error(g(845)+g(1727)+g(1122)+g(718)+"process")):(h=E,u[g(545)](E,s[g(1258)])?Promise[g(353)]():s[E][g(1840)](a)(n,m[g(1840)](null,u[g(803)](E,1))))}e[d(1073)](m,0)}else _0x21b0bd[d(1649)+"oad"]="",_0xff2e49[d(1362)](_0x49ab93)}function Wd(a){let n=t,s=0,d=0;for(let u=0;e[n(499)](u,a[n(1258)]);++u)if(d=a[n(1868)+"At"](u),e[n(757)](d,128))s+=1;else if(e[n(337)](d,2048))s+=2;else if(e.ICrrD(e.VAWFm(64512,d),55296)&&e[n(1710)](64512,a[n(1868)+"At"](e.mqMGM(u,1)))===56320){if(e.moNQa("vYOaj",e[n(1784)]))return function(h,...m){let E=n,g=_0xd5b24e[E(452)](_0x3a1e66(this),h,...m);return _0x5599d1[E(589)](g,h.sort?h[E(815)]():[h]),_0x565601(g)};++u,s+=4}else s+=3;return s}function Kd(a,n,s){let d=t;if(e.OaAkq(s-n,1))return"";let u="";for(let h=n;h<s;){let m=a[h++];if(e[d(819)](m,127))u+=String[d(450)+d(1497)](m);else if(e.ftmdj(m,192)&&e[d(337)](m,224))u+=String[d(450)+"Code"](e.PTHUd(e[d(1524)](e[d(1671)](31,m),6),e.loAjF(63,a[h++])));else if(e[d(1036)](m,224)&&e[d(1508)](m,240))u+=String["fromChar"+d(1497)](e[d(789)](e[d(963)](e[d(921)](15,m)<<12,e[d(823)](e[d(910)](63,a[h++]),6)),e[d(616)](63,a[h++])));else if(e[d(763)](m,240))if(e[d(280)]==="fSmhF"){let E=e[d(473)](e[d(702)](e[d(702)](e[d(1785)](e[d(868)](7,m),18)|e[d(1761)](63&a[h++],12),e[d(1081)](63&a[h++],6)),63&a[h++]),65536);u+=String[d(450)+d(1497)](e.VlHcW(55296,e[d(1279)](E,10))),u+=String[d(450)+d(1497)](e[d(1293)](56320,e[d(1243)](1023,E)))}else{let E=_0x4f866a[d(452)](_0x7726d5(this),_0x3f560f,..._0x6e5d52);return _0x54cf5a[d(589)](E,_0xd7c9e2[d(815)]?_0x20679e[d(815)]():[_0xd81158]),jQxDdY.tuljJ(_0x1b46b9,E)}}return u}function ia(a,n,s){let d=t;if(e.PhLza(e.CyApH,e[d(1432)])){let u=s,h,m;for(let E=0;e[d(897)](E,a.length);++E)if(h=a[d(1868)+"At"](E),h<128)n[s++]=h;else if(e[d(1499)](h,2048))n[s++]=e.paKtW(e[d(1525)](h,6),192),n[s++]=e[d(638)](63&h,128);else if(e.STDpg(64512,h)===55296&&e[d(1664)](e.aJbmI(64512,m=a.charCodeAt(E+1)),56320)){let g=(d(308)+d(1054))[d(726)]("|"),k=0;for(;;){switch(g[k++]){case"0":++E;continue;case"1":n[s++]=e[d(1045)](e[d(1570)](h>>6,63),128);continue;case"2":h=e[d(1790)](65536,(1023&h)<<10)+(1023&m);continue;case"3":n[s++]=e[d(1556)](e[d(423)](h,18),240);continue;case"4":n[s++]=e[d(715)](h>>12&63,128);continue;case"5":n[s++]=63&h|128;continue}break}}else n[s++]=e[d(1436)](h>>12,224),n[s++]=e.hwHJa(e.YFTtK(h,6),63)|128,n[s++]=e.IJYnY(63,h)|128;return e[d(374)](s,u)}else this.on(_0x389c1f,_0x10822c)}async function $d(a){let n=t;if(e.KpOhi==typeof a){let s=new Uint8Array(e.LPjSO(Wd,a));return e[n(1554)](ia,a,s,0),s}return e[n(556)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(825)],a[n(1372)+"et"],a[n(1346)+"th"])}function Kh(a){let n=t;try{return n(1228)!=typeof a&&(e[n(1779)](a,ArrayBuffer)||a.buffer&&e[n(1779)](a.buffer,ArrayBuffer))||e[n(1833)](e[n(1754)],typeof a)?"":(JSON.parse(a),e[n(1268)])}catch{return e.MhzOl(e.KpOhi,typeof a)?e[n(770)]:""}}let $h=(a,n)=>{let s=t;switch(a){case s(1039):case e.EidDk:return{[s(974)+a]:1,"x-tt-env":n};default:return{}}};class Jh{constructor(n){let s=t;e[s(1400)](e[s(1191)],e[s(1608)])?(this[s(1314)+"ount"]=n,this[s(419)]=0):(_0x6aa16e[s(779)+"entListe"+s(294)](jQxDdY.lryQF,_0x419468),_0x41f46b[s(779)+"entListe"+s(294)](jQxDdY[s(1822)],_0x2022ab))}addCount(){this.count++}[t(1706)+"chMaxCount"](){let n=t;return e[n(1767)](this[n(419)],this[n(1314)+n(439)])}[t(1643)+"nter"](n=0){let s=t;this[s(1314)+s(439)]=n,this[s(419)]=0}}async function Vh(a){return new Promise(n=>{let s=U,d={rgjiM:function(u,h){return e[U(1423)](u,h)},suIHT:e.AxloT};if(!Yn)return e[s(1250)](n,e[s(1500)]);try{let u=document[s(1465)+s(1296)](s(884));window[s(1323)+s(1023)]=h=>{let m=s;document[m(1147)][m(290)+m(474)](u),window[m(1323)+m(1023)]=void 0,d.rgjiM(n,h&&h[m(1658)]||d[m(1154)])},u[s(1271)]=e.EsWGM,u[s(478)]=e[s(1790)](a[s(1075)](/^ws/,e[s(1127)]),e[s(1772)]);try{document[s(1147)][s(341)+s(474)](u)}catch{document[s(1147)][s(290)+s(474)](u)}}catch{window[s(1323)+s(1023)]=void 0,n(e[s(1500)])}})}function tn(a,n,s){let d=t,u={owRdO:function(h,m,E){return e.rqflg(h,m,E)},THLSj:e[d(1009)]};if(e.llGXI!==e.llGXI){if(this["_endpoin"+d(577)]?.[d(1706)+"chMaxTries"]()){let m=this["_endpoin"+d(577)]?.["getCurre"+d(1070)+"nt"]();this._dispatchCloseEvent(u[d(1347)](_0x5db288,u[d(962)],{code:1006,reason:d(1566)+m+(d(1387)+d(1477)+d(598)+d(431)),wasClean:!0}))}else{let m=this[d(1444)][d(551)+d(1454)+d(284)](_0x344957,_0x381a06);this[d(484)+d(865)+d(1144)](u.owRdO(_0x4a8afc,u[d(962)],{code:_0x520d47,reason:_0x1d7c01,wasClean:!0,willReconnect:m})),m&&this[d(1543)]()}return}else return!!a?.[d(1620)](h=>h[d(694)]===n&&h[d(1451)]===s)}function Zn(a,n){let s=t;return a?.[s(1620)](d=>d[s(694)]===n)?.value}let sa=null;async function Yh(){let a=t,n={dlZHK:function(s,d){return e[U(1677)](s,d)},WuFQq:function(s,d){return e[U(499)](s,d)},XuDnh:function(s,d){return s<<d},ehooE:function(s,d){return e[U(1600)](s,d)}};if(e[a(1467)](e[a(1848)],e[a(679)]))return sa||(sa=Promise[a(353)]()[a(756)](Nt[a(1840)](Nt,e.JEHgZ))),sa;{let s=0,d=0,u;do u=OUuILL[a(1352)](_0x170ee0,_0x2de0f4),OUuILL[a(1395)](s,32)&&(d|=OUuILL[a(1569)](OUuILL.ehooE(127,u),s)),s+=7;while(OUuILL.ehooE(128,u));return d}}class Zh extends ra{constructor(n,s){let d=t;super(),this._dbName=n,this[d(1603)]=s,this[d(1397)]=void 0,this[d(1100)+"mise"]=null}async[t(573)](){await this[t(864)]()}async[t(864)](){let n=t,s={nUqAN:function(d){return e[U(458)](d)},WetWu:function(d,u,h,m){return e.qhzZX(d,u,h,m)}};if(!this._qosDB){if(this[n(1100)+n(1690)])return this[n(1100)+"mise"];try{let d=this[n(320)],u=this._keyPath;this["_initPro"+n(1690)]=(async()=>{let h=n,{openDB:m}=await s.nUqAN(Yh);this[h(1397)]=await s[h(633)](m,h(1323)+"_"+d,1,{upgrade(E){E["createOb"+h(523)+"e"](d,{keyPath:u})}})})(),await this[n(1100)+"mise"]}catch(d){console.log(d)}finally{this[n(1100)+n(1690)]=null}}}async[t(1676)](n){let s=t;try{return await this._init(),this[s(1397)]?.[s(1676)](this._dbName,n)}catch(d){console.log(d)}}async[t(589)](n,s){let d=t;return await this[d(864)](),this[d(1397)]?.put(this[d(320)],n)}async[t(1424)](n){let s=t;try{return await this._init(),this[s(1397)]?.[s(1805)](this._dbName,n)}catch(d){console.log(d)}}async[t(1040)](){let n=t,s={JTJQf:function(d,u){return e.IEkrv(d,u)},tVHOw:function(d,u){return d+u},fwBqN:e[n(554)],ZhlbL:e[n(1565)],NyNZV:function(d,u){return e[n(314)](d,u)}};try{return e[n(939)](e[n(1831)],n(1138))?(await this._init(),this._qosDB?.[n(1040)](this[n(320)])):_0x3c9992(s.JTJQf(s.JTJQf(s[n(524)](s[n(293)](s[n(364)],_0x212803),s[n(707)])+s[n(1288)](_0x3203d6,1)," > "),_0xd72143))}catch(d){console[n(1362)](d)}}async[t(1540)](){let n=t,s={feGto:function(d,u){return e[U(463)](d,u)},lrisE:function(d,u){return e[U(1632)](d,u)},VcYyC:function(d,u){return e.sulbO(d,u)},jgMrH:function(d,u){return e.alcMf(d,u)},MSxiq:function(d,u){return e[U(471)](d,u)},FHKsr:function(d,u){return e.aWyRh(d,u)},ZGuSE:function(d,u){return d&u},AIvSB:function(d,u){return e[U(1291)](d,u)},zrzWW:function(d,u){return e.brLTk(d,u)},KszSK:function(d,u){return e[U(1169)](d,u)},JxATz:function(d,u){return e.iEZvK(d,u)},blHhO:function(d,u){return d&u},zuTjJ:function(d,u){return d|u},UdNTF:function(d,u){return d&u},AhWvp:function(d,u){return e[U(649)](d,u)},QdHMI:function(d,u){return d+u}};if(n(1692)!==e[n(380)])return await this._init(),this[n(1397)]?.[n(1155)+"ys"](this[n(320)]);{if(_0x5afb2b-_0x3f6c85<1)return"";let d="";for(let u=_0x156601;bUvPFf.feGto(u,_0x341a8d);){let h=_0x501f6c[u++];if(bUvPFf[n(755)](h,127))d+=_0x220b4a[n(450)+n(1497)](h);else if(bUvPFf[n(700)](h,192)&&bUvPFf[n(1031)](h,224))d+=_0x1579c0["fromChar"+n(1497)](bUvPFf[n(793)](bUvPFf[n(1733)](bUvPFf[n(483)](31,h),6),bUvPFf.ZGuSE(63,_0x5679de[u++])));else if(bUvPFf[n(700)](h,224)&&bUvPFf.AIvSB(h,240))d+=_0x1d76bb["fromChar"+n(1497)](bUvPFf.MSxiq(bUvPFf[n(1088)](bUvPFf[n(1146)](15&h,12),bUvPFf[n(305)](bUvPFf[n(483)](63,_0x196761[u++]),6)),bUvPFf.blHhO(63,_0x3de811[u++])));else if(h>=240){let m=bUvPFf.MSxiq(bUvPFf[n(1652)]((7&h)<<18|bUvPFf.KszSK(bUvPFf.blHhO(63,_0x53c0a7[u++]),12),(63&_0x48b781[u++])<<6),bUvPFf[n(1699)](63,_0x166c1d[u++]))-65536;d+=_0x508c8e.fromCharCode(bUvPFf.AhWvp(55296,m>>10)),d+=_0x1e6bca[n(450)+n(1497)](bUvPFf.QdHMI(56320,1023&m))}}return d}}async[t(1117)](){let n=t;if(e.iwmOd(e[n(1696)],n(365)))return await this[n(864)](),this[n(1397)]?.[n(1117)](this[n(320)]);e[n(1535)](_0x114eb8,_0x5cdb8a,10),e[n(873)](_0x342a53,_0x5377f4,_0x5e5158)}async[t(1202)](){let n=t;if(e[n(1067)](e.uMwpw,e[n(1405)]))this[n(1175)]("message",_0xecbc23),this[n(1203)+"e"]&&this[n(1203)+"e"](_0x3a2daa);else try{this._qosDB?.[n(567)](),this[n(1397)]=void 0}catch(s){console[n(1362)](s)}}get[t(885)](){let n=t;try{return!!this[n(1397)]}catch(s){return e.CWHKD(n(867),e[n(1173)])?(console[n(1362)](s),!1):this[n(1397)]?.get(_0x6076d0)}}}class Xh{constructor(n,s){let d=t;if(e[d(820)](e[d(1668)],e[d(667)])){this[d(484)+d(865)+d(1144)](e[d(278)](_0x38ddee,e[d(1009)],{code:1e3,reason:e.Xdadg})),this[d(854)+d(577)]?.["resetEndpointCon"+d(1428)](),this[d(1337)+"sCounter"]?.[d(1643)+d(528)]();return}else this[d(947)]=n,this[d(557)]=s,this[d(1397)]=localStorage}async openDB(){}get[t(420)](){return t(1323)+"_"+this._DBName}async[t(1676)](n){let s=t,d=this[s(1397)].getItem(this[s(420)]);return JSON.parse(d||"{}")[n]}async[t(589)](n,s){let d=t,u=this[d(1397)].getItem(this._prefix),h=JSON[d(785)](u||"{}");return h[s||n[this[d(557)]]]=n,this[d(1397)][d(1505)](this._prefix,JSON[d(1766)+"y"](h)),s||n[this[d(557)]]}async[t(1424)](n){let s=t,d={DzVTj:function(u,h){return e[U(1774)](u,h)},extdJ:function(u,h){return u|h},gLmpe:function(u,h){return e.VrCHO(u,h)},squjh:function(u,h){return e[U(574)](u,h)},XvxVx:function(u,h){return e[U(768)](u,h)}};if(e[s(1650)]("qNfzx",e[s(981)]))return new _0x378284(fPOaRo[s(505)](fPOaRo.extdJ(fPOaRo[s(505)](_0x1dc5e8[0],fPOaRo[s(1295)](_0x3b1211[1],8)),fPOaRo[s(1295)](_0x1bcab3[2],16)),_0xa38fd9[3]<<24),fPOaRo[s(505)](fPOaRo[s(1586)](_0x613a1d[4],_0x47ca61[5]<<8),fPOaRo[s(1295)](_0x2d3d12[6],16))|fPOaRo[s(348)](_0x2bebce[7],24),_0xa7d735);{let u=this[s(1397)][s(496)](this._prefix),h=JSON[s(785)](e[s(521)](u,"{}"));return h[n]=void 0,this[s(1397)][s(1505)](this[s(420)],JSON[s(1766)+"y"](h))}}async[t(1040)](){let n=t;return this[n(1397)][n(1040)]()}async[t(1540)](){let n=t,s=this._qosDB[n(496)](this[n(420)]),d=JSON[n(785)](e.ZfOlt(s,"{}"));return Object[n(1540)](d)}async getAll(){let n=t,s=this[n(1397)][n(496)](this[n(420)]),d=JSON[n(785)](s||"{}");return Object[n(1678)](d)}[t(1202)](){let n=t,s={bRwyO:e[n(1500)]};if(e[n(1860)](n(1053),e[n(426)]))return Promise[n(353)]();_0x2d91af[n(1147)][n(290)+n(474)](_0x43a8de),_0x20cabe[n(1323)+"JSONP"]=void 0,_0x260c46(_0x44a54f&&_0xf4fdf6[n(1658)]||JlJYRH[n(1080)])}get[t(885)](){return!!this._qosDB}}class Qh{constructor(n,s){let d=t;this._DBName=n,this[d(557)]=s,this[d(1397)]=In?tt:Gr?wx:null}async openDB(){}get[t(420)](){let n=t;if(e[n(1207)](e[n(1640)],"NQYQg"))++_0x276f0d,_0xcacc88+=4;else return n(1323)+"_"+this._DBName}async[t(1676)](n){let s=t,d=this[s(1397)][s(1041)+"geSync"](this[s(420)]);return JSON[s(785)](e[s(384)](d,"{}"))[n]}async[t(589)](n,s){let d=t,u=this[d(1397)][d(1041)+"geSync"](this[d(420)]),h=JSON.parse(e[d(1503)](u,"{}"));return h[s||n[this._pathKey]]=n,this[d(1397)][d(1732)+d(1338)](this._prefix,JSON[d(1766)+"y"](h)),s||n[this._pathKey]}async[t(1424)](n){let s=t;if(e[s(1624)](e[s(875)],e[s(875)]))try{return e[s(535)](e[s(1754)],typeof _0x1aff2a)&&(e.mVbMw(_0x5c99ee,_0xc585d5)||_0x53173c[s(825)]&&e[s(1171)](_0x28b9b4.buffer,_0x32de7e))||e[s(1161)](e[s(1754)],typeof _0x435105)?"":(_0x1c6df7[s(785)](_0x19abdd),e[s(1268)])}catch{return e.jzNEP(e[s(1754)],typeof _0x594a00)?e[s(770)]:""}else{let d=this[s(1397)][s(1041)+"geSync"](this._prefix),u=JSON[s(785)](e.ZfOlt(d,"{}"));return u[n]=void 0,this._qosDB["setStora"+s(1338)](this[s(420)],JSON.stringify(u))}}async[t(1040)](){let n=t;return this._qosDB[n(1247)+n(811)]()}async[t(1540)](){let n=t,s=this[n(1397)][n(1041)+"geInfoSync"](this[n(420)]),d=JSON[n(785)](e.iPRYd(s,"{}"));return Object[n(1540)](d)}async[t(1117)](){let n=t,s=this[n(1397)][n(1041)+n(586)+"nc"](this[n(420)]),d=JSON.parse(e.iPRYd(s,"{}"));return Object[n(1678)](d)}[t(1202)](){return Promise.resolve()}get[t(885)](){return!!this[t(1397)]}}function Jd(a,n){let s=t;if(In||In)return new Qh(a,n);if((Yn||Hr)&&e[s(797)](s(569)+"d",typeof indexedDB))return new Zh(a,n);if((Yn||Hr)&&e[s(1107)](e[s(1791)],typeof localStorage))return new Xh(a,n);throw new Error(e[s(1448)])}class ep{constructor(){let n=t;this["_interva"+n(675)+"Id"]=null,this[n(833)+"l"]=36e5,this._qosDB=Jd("qos",e[n(908)])}async[t(833)+t(741)](){let n=t;clearInterval(this[n(833)+"lTimeoutId"]),this["_interva"+n(675)+"Id"]=e[n(683)](setInterval,()=>{this["flushExp"+n(466)]()},this._interval)}async[t(573)](){let n=t;await this._qosDB[n(573)]().then(()=>{let s=n;this[s(833)+s(741)]()})}async[t(1351)+t(466)](){let n=t;(await this[n(1397)]?.getAll()||[])[n(1002)](({timestamp:u})=>u<Date[n(1821)]())[n(677)](u=>{let h=n;this[h(1397)]?.[h(1424)](u.message_id)})}async[t(1424)](n){let s=t;return this._qosDB?.[s(1424)](n)}async[t(589)](n,s){let d=t;return this[d(1397)]?.[d(589)]({message_id:n,timestamp:s})}async[t(1676)](n){let s=t;return this[s(1397)]?.[s(1676)](n)}async[t(1202)](){let n=t;e.xjfvY(clearInterval,this[n(833)+n(675)+"Id"]),await this[n(1397)]?.[n(1202)]()}get[t(885)](){let n=t;return this._qosDB?.[n(885)]}}function oa(a){let n=t,s=!!this._options[n(1662)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e.bHonk(tn,a.message[n(482)],e[n(1442)],"2"),u=d&&e[n(1554)](tn,a[n(1197)][n(482)],e[n(1827)],"1"),h=d&&e[n(1628)](tn,a[n(1197)][n(482)],e[n(1597)],"1"),m=h?e[n(719)](Zn,a.message[n(482)],e[n(1367)])?.[n(726)](",")[n(1002)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:h,ackMsgIds:m}}async function Vd(){let a=t;return this[a(958)+a(1646)]||(this["_QoSMana"+a(1646)]=new ep),this["_QoSMana"+a(1646)].isReady||await this[a(958)+"ger"].openDB(),this[a(958)+a(1646)]}async function tp(a,n){let s=t,{enableAutoAck:d}=this._options,u=e.WUAcD(tn,a.message[s(482)],e.zKHil,"1"),h=tn(a[s(1197)][s(482)],e[s(760)],"1"),m=oa[s(452)](this,a);if(e[s(1241)](d,u)){let{SeqID:E,LogID:g,service:k,LogIDNew:P,method:F}=a[s(1197)];this._sendAck({SeqID:E,LogID:g,LogIDNew:P,service:k,method:F,headers:[{key:s(605),value:"1"},{key:e[s(464)],value:e[s(640)](P,"")},{key:e[s(1843)],value:"0"}]})}h&&!m[s(1149)]&&this["_dispatc"+s(764)+"ageEvent"](a),e[s(393)](n)}async function np(a,n){let s=t;this[s(447)](e.momai,a.message),e[s(1153)](n)}async function rp(a,n){let s=t,d=e[s(812)](Xt,await $d(a[s(1026)]));try{if(d[s(1261)]instanceof Uint8Array)if(e.gdbqD(e[s(1333)],e[s(1333)])){let u=e[s(1047)](this[s(1444)]["payloadE"+s(898)],Object)?{force:!!this[s(1444)][s(1e3)+"ncoding"][s(985)],encoding:this[s(1444)][s(1e3)+s(898)][s(1752)]?this[s(1444)][s(1e3)+s(898)][s(1752)][s(1075)](/\s/g,"")[s(1119)+s(975)]():""}:{force:!1,encoding:this[s(1444)][s(1e3)+s(898)]?this[s(1444)][s(1e3)+s(898)].replace(/\s/g,"")[s(1119)+"ase"]():""},h=d[s(1e3)+s(898)]?d[s(1e3)+s(898)][s(1075)](/\s/g,"").toLowerCase():"",m=e[s(1589)](this[s(1444)][s(1511)+s(1720)],Object)?{force:!!this[s(1444)][s(1511)+s(1720)][s(985)],type:this._options["payloadT"+s(1720)][s(1271)]?this._options[s(1511)+s(1720)][s(1271)][s(1075)](/\s/g,"")["toLowerC"+s(975)]():""}:{force:!1,type:this[s(1444)][s(1511)+s(1720)]?this[s(1444)][s(1511)+s(1720)].replace(/\s/g,"")["toLowerC"+s(975)]():""},E=d[s(1511)+s(1720)]?d[s(1511)+s(1720)][s(1075)](/\s/g,"")[s(1119)+s(975)]():"",g=m[s(985)]?m[s(1271)]:E||m[s(1271)],k=u.force?u.encoding:h||u[s(1752)],P=[e.NPqRd,e[s(1268)],e.uLWFZ,e[s(1754)]],F=[s(1287)+"e",e[s(665)]];this._options["enableTr"+s(1853)+s(966)+"ad"]&&P[s(512)](g)&&(!k||F[s(512)](k))?d[s(1649)+s(1102)]=e[s(1619)](Kd,d[s(1261)],0,d[s(1261)].byteLength):d[s(1649)+"oad"]=""}else{if(_0xe35768<=-_0x22d702)return _0x183243;if(e.ajuNf(_0x4a197c,1)>=_0x29ff56)return _0x1560dc}else d["textPayl"+s(1102)]=""}catch(u){if(e.QqAHx(e.DZiys,e[s(1038)]))d[s(1649)+s(1102)]="",console[s(1362)](u);else{_0x44f6f4[s(1688)](_0x969d26)||(_0x38def2=_0x41649b[s(1777)+"er"](_0x5e5896));let h=this[s(1421)]>>>16,m=65535&this[s(1421)],E=e.fgruL(this[s(1713)],16),g=e.MwJrW(65535,this[s(1713)]),k=e[s(1445)](_0x43d965[s(1421)],16),P=e.VAWFm(65535,_0x456520[s(1421)]),F=_0x2d1ff0[s(1713)]>>>16,z=e.AWOmt(65535,_0x4c4458.low),q=0,W=0,le=0,G=0;return G+=g+z,le+=e.fNgpP(G,16),G&=65535,le+=E+F,W+=e[s(1851)](le,16),le&=65535,W+=m+P,q+=e[s(687)](W,16),W&=65535,q+=e.QIWBf(h,k),q&=65535,_0x1ef9aa[s(866)](e.xVjXc(e[s(690)](le,16),G),e[s(1769)](q,16)|W,this[s(1817)])}}a.message=d,e.UuvWQ(n)}function ip(a,n,s){let d=t,u={KfDcF:function(k,P){return e[U(595)](k,P)},BZAKA:function(k,P){return e.NuDlV(k,P)},fYUkg:function(k,P){return e.tdJqS(k,P)},JDILT:function(k,P){return e.AAfAA(k,P)},vqWVy:function(k,P){return e[U(583)](k,P)}},h=e.kvSrc(s,8192),m=e[d(882)](h,1),E=null,g=h;return function(k){let P=d;if(u[P(850)](k,1)||k>m)return a(k);u[P(1492)](u[P(951)](g,k),h)&&(E=u.JDILT(a,h),g=0);let F=n[P(452)](E,g,g+=k);return 7&g&&(g=u[P(1639)](7,g)+1),F}}let sp=4294967295;function op(a,n,s){let d=t;if(e[d(1616)](e[d(455)],e.CzeSZ)){let u=this[d(854)+d(577)]?.[d(943)+d(1070)+"nt"]();this["_dispatc"+d(865)+d(1144)](e[d(299)](_0xfa39bb,e[d(1009)],{code:1006,reason:"connect "+u+(d(1387)+", max re"+d(598)+d(431)),wasClean:!0}))}else return e.rmxlf(RangeError,e[d(1647)](e.mUDzy(e[d(997)](d(988)+d(584)+d(889),a),d(737))+(n||1),e[d(570)])+s)}function ap(a,n,s){let d=t,u={OJrMj:function(h,m){return e.MIbJM(h,m)},KLpKY:function(h,m){return e.Uzldi(h,m)}};if(d(905)===d(413))this[d(1314)+d(439)]=_0x598daf,this[d(419)]=0;else{if(e[d(1361)](s,sp))throw new Error(e.MxrMo);let h=3;for(;e[d(316)](h,0);){if(e.aDcpc(e.wmsZM,e.oXrpP))return cfXlaw[d(331)](cfXlaw[d(1516)](1e4,_0x4767c0.now()),_0x449d08[d(805)](cfXlaw[d(1516)](1e4,_0x5ab733[d(339)]())));{let m=e[d(1116)](255,s);e[d(1619)](ca,m,a,e[d(1790)](n,h)),s>>>=8,h--}}return n+4}}function cp(a,n){let s=t,d={KGQRs:e[s(1822)],aHgam:function(u,h,m){return e[s(581)](u,h,m)},iDhiZ:e.uTbsW};if(e[s(1050)]!==e.eWDak){let u=_0x2bb22d(FTJSTP[s(513)],{message:this["_formatE"+s(1008)+"age"](_0x17fe0e)});this[s(1175)](FTJSTP[s(513)],u);let h=FTJSTP.aHgam(_0x4efeec,FTJSTP[s(1481)],{reason:this[s(1493)+s(1008)+s(571)](_0x3b41ad)});this[s(1175)](FTJSTP[s(1481)],h)}else{let u=0,h=n,m=n+4;for(;h<m;){let{value:E,offset:g}=aa(a,h);h=g,u=e.fNgpP(e[s(1836)](u,8),0),u+=E}return{value:u,offset:m}}}function dp(a,n,s){let d=t,u=e[d(1847)].split("|"),h=0;for(;;){switch(u[h++]){case"0":return e.aVgCk(e[d(1628)](ia,a,n,s),s);case"1":if(n[d(1575)])return e[d(950)](n[d(1575)](a,s),s);continue;case"2":if(!a)return s;continue;case"3":if(n[d(1742)+"e"])return e[d(1194)](n[d(1742)+"e"](a,s),s);continue;case"4":if(a[d(1258)]<40)return e.yUAcu(ia,a,n,s)+s;continue}break}}function lp(a,n){let s=t,d=new fe(e[s(283)](a[e[s(913)](n,4)]<<24,e[s(1747)](a[e[s(389)](n,5)],16))|e[s(1836)](a[e[s(913)](n,6)],8)|a[e[s(835)](n,7)],e.yGbMw(e[s(702)](e.kDzVW(e[s(1656)](a[e[s(309)](n,0)],24),e[s(798)](a[e[s(1594)](n,1)],16)),e.aWyRh(a[e[s(363)](n,2)],8)),a[e[s(285)](n,3)]),!0);return n+=8,{value:d,offset:n+8}}function fp(a,n,s){let d=t,u=a[d(1713)],h=a.high;return n[s]=e[d(1544)](h,24),n[e[d(1629)](s,1)]=e.kOgJN(h,16)&255,n[s+2]=e[d(485)](h>>>8,255),n[e[d(855)](s,3)]=e.uIIGh(255,h),n[e[d(863)](s,4)]=e[d(1832)](u,24),n[e[d(1277)](s,5)]=e.OwMXF(e[d(1357)](u,16),255),n[s+6]=e[d(1010)](u,8)&255,n[s+7]=e.VAWFm(255,u),s+=8,s}function aa(a,n){let s=t;return a[s(766)+"8"]?{value:a.readUInt8(n),offset:e.vfqpl(n,1)}:{value:e[s(1374)](255,a[n]),offset:e[s(1746)](n,1)}}function ca(a,n,s){let d=t;return n[d(849)+"t8"]?n[d(849)+"t8"](a,s):n[s]=255&a,s+1}let up=function(a){let n=t,s={MbVTX:function(d,u,h){return d(u,h)},vdHWG:e[n(1869)],eNDZP:e[n(1621)]};if(e[n(1467)](e[n(1024)],e.Vueuw))return new Uint8Array(a);{let d=s[n(457)](_0x1a1845,s[n(1035)],{message:s[n(634)]});this[n(871)+n(911)]&&this["onStartR"+n(911)](d)}},xp=e[t(547)](e[t(1791)],typeof Buffer)?Buffer["allocUns"+t(1307)]:e[t(1303)](ip,up,Uint8Array[t(1609)+"e"].subarray);(()=>{let a=t,n={ZtGFQ:function(s,d){return s<d},ZJCbr:function(s,d){return e.nDxRR(s,d)},HAtIT:function(s,d){return s<d},CrqYE:function(s,d){return s|d},QLpjy:function(s,d){return e[U(823)](s,d)},JPJUA:function(s,d){return e[U(822)](s,d)},ELsEu:function(s,d){return s<<d},CyfxV:function(s,d){return e[U(910)](s,d)},GgNBX:function(s,d){return e.xDFxg(s,d)},NLfVm:function(s,d){return e[U(1371)](s,d)},rSvwf:function(s,d){return e.GLRKL(s,d)},eHLLK:function(s,d,u,h){return e[U(1260)](s,d,u,h)}};if(e[a(454)]!==a(313)){let s=4294967295;return function(d,u,h=!0){let m=a,E={zewTB:function(g,k){return n.ZtGFQ(g,k)},XqoDG:function(g,k){return n[U(329)](g,k)}};if(s=(127&d[u])>>>0,n[m(602)](d[u++],128))return{value:h?s:n.CrqYE(0,s),offset:u};if(s=n.CrqYE(s,n[m(1052)](127&d[u],7))>>>0,d[u++]<128)return{value:h?s:n[m(582)](0,s),offset:u};if(s=n[m(1021)](s|n.ELsEu(n[m(1657)](127,d[u]),14),0),n[m(1226)](d[u++],128))return{value:h?s:0|s,offset:u};if(s=n[m(582)](s,(127&d[u])<<21)>>>0,n.NLfVm(d[u++],128))return{value:h?s:0|s,offset:u};if(s=n[m(582)](s,n[m(530)](15&d[u],28))>>>0,d[u++]<128)return{value:h?s:n.CrqYE(0,s),offset:u};if(n[m(1110)](u+=5,d.length))if(n.ZJCbr("gDhNh","hKjjU")){let g=this[m(1384)+"rs"][_0x5c0051];if(g)for(let k=0;dvhuXN.zewTB(k,g[m(1258)]);)dvhuXN[m(368)](g[k].fn,_0x2aac0d)?g[m(1032)](k,1):++k}else throw u=d[m(1258)],n[m(1472)](op,u,10,d[m(1258)]);return{value:h?s:n[m(582)](0,s),offset:u}}}else return ve[a(1380)+a(508)+a(1641)+"t"]=1,ve[a(472)+a(1235)]++,ve[a(1466)+"s"][ve[a(472)+a(1235)]]})();let hp=16,da=32;function pp(a){let n=t,s=0,d={};for(let u=0;u<a.length;u++)n(607)===n(1311)?(_0x355ac9=e[n(1174)](e[n(698)](65536,e.sCErm(e[n(1710)](1023,_0xe84f54),10)),e[n(1456)](1023,_0x179f01)),++_0x34d936,_0x3aa03a[_0x315c9b++]=e[n(751)](e[n(1610)](_0x4ea42b,18),240),_0x3341fe[_0x2825dd++]=e[n(1366)](e[n(616)](e[n(651)](_0x1cfe75,12),63),128),_0x5f3e43[_0x4068d0++]=e[n(1068)](e[n(1600)](e[n(961)](_0x47a2fd,6),63),128),_0x52fefe[_0x24b345++]=e.DlYEF(e[n(1716)](63,_0xfb6d9a),128)):(d[a[u][n(808)+n(1304)]]=Wd(a[u]["cursor_n"+n(1304)]),s+=e[n(635)](14,d[a[u].cursor_name]));return[s,d]}function Yd(a,n,s){let d=t,u={pHCyq:e.QHBCf,nARNg:e[d(748)],gmPce:e[d(451)],rGaxO:function(k,P,F,z){return k(P,F,z)},XikmJ:e[d(1449)],wqqCO:function(k,P,F,z){return k(P,F,z)},DDJNI:function(k,P,F,z){return e[d(1452)](k,P,F,z)},fCMjB:e[d(377)],qfxGI:e[d(925)],MAlWS:d(1177)},[h,m]=e[d(1583)](pp,a),E=xp(h),g=0;return a[d(677)](k=>{let P=d;if(u[P(1568)]===P(1211))this._isBrowser&&_0x145d0a[P(779)+P(1475)+"ner"]("pagehide",this["_handleP"+P(689)]),this[P(1013)+"er"]&&_0x3aa3c1[P(779)+P(1475)+P(294)](u[P(1687)],this[P(489)+"ageShow"]),this[P(567)]();else{let F=u[P(549)][P(726)]("|"),z=0;for(;;){switch(F[z++]){case"0":g=u[P(600)](ap,E,g,k.service||0);continue;case"1":g=u.rGaxO(dp,k.cursor_name,E,g);continue;case"2":console[P(1362)](u.XikmJ,g);continue;case"3":g=u[P(411)](ca,0,E,g);continue;case"4":console[P(1362)](P(1776),g);continue;case"5":g=u.DDJNI(fp,fe.fromNumber(k[P(575)]||n),E,g);continue;case"6":console.log(u.fCMjB,g);continue;case"7":console[P(1362)](P(1459),g);continue;case"8":console[P(1362)](u[P(509)],k,k.service);continue;case"9":console[P(1362)](u[P(643)],g);continue;case"10":g=ca(m[k[P(808)+P(1304)]],E,g);continue}break}}}),{frameType:da,headers:[{key:e[d(1113)],value:s}],payload:E}}function gp(a){let n=t,s=0,d=[];for(;e[n(1310)](s,a[n(1346)+"th"]);){let{offset:u}=e[n(306)](aa,a,s);s=u;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:E}=e.ONvbA(cp,a,s);h.service=m,s=E;let{value:g,offset:k}=e[n(1412)](aa,a,s);s=k,h["cursor_n"+n(1304)]=e[n(1619)](Kd,a,s,e[n(635)](s,g)),s+=g;let{value:P,offset:F}=e[n(1781)](lp,a,s);h[n(575)]=P[n(1060)](),s=F,d[n(1014)](h)}return d}function mp(){return{frameType:da,headers:[{key:e[t(1113)],value:e.sEtec}],payload:void 0}}class wp{constructor(n,s,d){let u=t;this[u(1408)+u(1557)]=n,this[u(1563)+u(311)]=s,this["_message"+u(1306)]=d,this._qosDB=e[u(568)](Jd,this["_cursorN"+u(1557)],e.upbQd)}async[t(573)](){let n=t;await this[n(1397)][n(573)]()}async[t(1176)+"rs"](){let n=t,s={MUTEh:function(d,u,h){return e[U(1478)](d,u,h)},VKCfM:n(1613)};if(e[n(1224)](e.pQfVM,n(576))){let d=s.MUTEh(_0x5399f1,s.VKCfM,{message:_0x33362b[n(1197)],code:_0x1c869b[n(686)+n(445)],error:_0x59e6ea});this[n(484)+n(670)+"ent"](d)}else{if(!this._qosDB[n(885)])return;let d=this[n(1394)+n(1306)],u=await this[n(1397)][n(1117)]();switch(console.log(e[n(565)],u),d){case e[n(1128)]:return u&&u.length?e.yUAcu(Yd,u,0,this[n(1563)+n(311)]):void 0;case n(701):return;case e[n(708)]:return u&&u.length?Yd(u,0,this["_cursorF"+n(311)]):e[n(402)](mp)}}}async set(n,s,d){let u=t;return console[u(1362)](u(437),n,s,d),this[u(1397)][u(589)]({cursor_name:n,cursor:s,service:d})}async[t(645)+"rs"](n){let s=t,d=e[s(440)](gp,n);for(let u of d)console[s(1362)](e.mMyOR,d),await this[s(1397)][s(589)](u)}async[t(1676)](n){let s=t;return(await this[s(1397)][s(1676)](n))?.[s(575)]}async[t(1202)](){let n=t;await this[n(1397)][n(1202)]()}[t(992)+t(1335)+t(398)](n){let s=t;this["_cursorF"+s(311)]=n}get isReady(){let n=t;if(e[n(1359)]===e[n(1858)])throw _0x5b9bc8=_0x10fbe9.length,_0x14cfd5(_0x52214f,10,_0x557689.length);return this[n(1397)].isReady}}let _p=e[t(412)];async function Zd(a){let n=t,s={invbP:function(E,g,k){return e[U(1121)](E,g,k)},uffQb:e[n(1009)]};if(!this[n(1444)][n(1662)+"S"])return null;let{aID:d,fpID:u,messageStrategy:h}=this[n(1444)],m=e[n(314)](a,_p);try{return this[n(732)+"anager"]?a&&this[n(732)+n(1355)][n(992)+n(1335)+n(398)](a):this[n(732)+n(1355)]=new wp(u+"_"+d+"_"+m,m,h),this["_cursorM"+n(1355)].isReady||await this[n(732)+n(1355)][n(573)](),this[n(732)+n(1355)]}catch{if(e[n(1624)](n(639),e[n(588)]))return null;{let E=this["_endpoin"+n(577)]?.[n(943)+n(1070)+"nt"]();this[n(484)+n(865)+n(1144)](s[n(281)](_0x483f26,s.uffQb,{code:_0x3e2acc[n(1725)],reason:n(540)+n(366)+"d, unkno"+n(427)+n(1180)+n(739)+E})),this[n(854)+n(577)]?.[n(382)+"pointCon"+n(1428)](),this._pingLossCounter?.[n(1643)+n(528)]();return}}}async function yp(a,n){let s=t,d={FdYDU:function(q,W){return q+W},RmzLI:function(q,W){return q(W)},cKLHc:function(q,W,le){return q(W,le)}},u=e[s(1229)](tn,a[s(1197)][s(482)],e.GEABF,"-1"),h=e[s(1628)](tn,a[s(1197)][s(482)],e[s(760)],"1"),m=e[s(959)](Zn,a[s(1197)][s(482)],e[s(935)]),E=e.DMjpG(Number,e[s(1072)](Zn,a.message[s(482)],s(596)+"er_ttl"))||0,g=oa[s(452)](this,a),k=e[s(1628)](tn,a[s(1197)][s(482)],e.fBosO,"2"),P=Zn(a[s(1197)][s(482)],e[s(491)]),F=e[s(1123)](Number,Zn(a.message[s(482)],e.EkNek));if(g[s(1149)])return e[s(1409)](n);let z=g[s(1806)+s(1182)]?await Vd[s(452)](this):null;if(e[s(585)](a[s(1197)][s(1459)],0)&&h&&!u||e[s(1057)](a[s(1197)][s(1459)],0))if(e.lCWGX!==e[s(1510)]){if(m&&g[s(1806)+s(1182)]&&z)if(e[s(332)](e[s(1159)],e[s(1487)]))this[s(1337)+s(1812)]?.[s(1533)](),this[s(1175)](e[s(1846)],e[s(853)]),this["_pingLos"+s(1812)]?.["checkRea"+s(333)+"nt"]()?this[s(1811)+s(911)]():this[s(1231)]();else return!!!await z[s(1676)](m)&&(this[s(484)+s(442)+s(1156)](a),await z.set(m,Date[s(1821)]()+E)),n();if(k){let q=await Zd[s(452)](this);if(!q)return this[s(484)+s(442)+s(1156)](a),e[s(475)](n);let W=await q.get(P)??-1;if(e[s(337)](W,F))if(e[s(1616)](s(834),"RzRUB"))this["_dispatc"+s(442)+s(1156)](a),q[s(589)](P,F,a[s(1197)][s(1459)]);else return USdFWY.FdYDU(USdFWY[s(879)](_0x5555e7,8).join("0"),USdFWY[s(1220)](_0x41abb1,_0xfb9ed,10).toString(2))[s(1491)](-8);else throw new Error(s(1755)+s(1607)+s(1341)+F+(s(1349)+"than loc"+s(734)+"r ")+W);return e[s(475)](n)}return this[s(484)+s(442)+s(1156)](a),e.YsDUi(n)}else _0x175a77.log(_0x598c12)}async function bp(a,n){let s=t,d=oa[s(452)](this,a);if(!d[s(1806)+s(1182)])return n();let u=await Vd[s(452)](this);if(d["isAckCle"+s(1422)+"age"]&&d[s(862)+"s"][s(1258)])for(let h of d[s(862)+"s"])await u.del(h);e[s(1007)](n)}async function Ep(a,n){let s=t;if(e.IRALz!==e.WDRpi){let d=e[s(525)](a[s(1197)][s(298)+"e"],hp),u=e.nqGjQ(a[s(1197)][s(298)+"e"],da);if(!d&&!u)return e[s(642)](n);let h=e[s(1121)](Zn,a[s(1197)][s(482)],e[s(1113)]);if(!h)return e[s(1292)](n);let m=await Zd[s(452)](this,h);if(!m)return e[s(1336)](n);if(d){let E=await m.getCursors(),g={frameType:E?.[s(298)+"e"],SeqID:fe[s(1777)+"er"](this[s(1839)]++),LogID:fe[s(1777)+"er"](this._options[s(1468)+"erator"]()),service:9e3,method:5,headers:E?.[s(482)],payload:E?.[s(1261)]},k=A(g);this._ws&&this._ws[s(1016)+"te"]&&this[s(965)][s(758)](k)}if(u){let E=a[s(1197)][s(1261)];E&&m[s(645)+"rs"](E)}}else this[s(1162)]=!1,_0x1a5716(this["_connect"+s(838)+s(1834)]),_0x1c9fda()}let vp=async function(a,n){let s=t;this._isInit=!1,e[s(804)](clearTimeout,this[s(1543)+s(838)+s(1834)]),e[s(1336)](n)},Sp=async function(a,n){let s=t;if(!this[s(965)]||this[s(965)][s(1016)+"te"]!==this[s(321)])return e[s(1124)](n);let{pingInterval:d}=this._options;this[s(854)+s(577)]?.[s(382)+"pointCon"+s(1428)]();for(let h=0;e.lPyEz(h,this[s(1394)+s(1463)][s(1258)]);h++){let m=this["_message"+s(1463)][h];if(e.gdbqD(this[s(965)][s(1016)+"te"],this.OPEN)&&e.OfUjW(null,m))this[s(965)]&&this[s(965)].send(m),this[s(1394)+s(1463)][h]=null;else break}this[s(1394)+s(1463)]=this[s(1394)+s(1463)].filter(h=>!!h),this[s(392)+s(1091)+"Id"]=e[s(774)](setTimeout,()=>this[s(1231)](),d),this["_dispatc"+s(1626)+"nt"](a),this._isBrowser&&this[s(965)]&&(this[s(965)].binaryType=this[s(1802)+s(1720)]);let u=this._endpointManager?.[s(943)+s(1070)+"nt"]();this[s(447)](s(1329)+u+" success"),e[s(1596)](n)},Ip=async function(a,n){let s=t,d=this[s(854)+s(577)]?.["getCurre"+s(1070)+"nt"]();this[s(447)](s(1329)+d),e[s(1322)](n)};class Ap extends ra{constructor(n){let s=t,d={MsaQj:function(u,h,m,E){return u(h,m,E)},ySnYJ:function(u,h,m){return u(h,m)},QqOqc:function(u,h){return e.CWHKD(u,h)},jZEVp:e[s(1199)],pOgsd:function(u,h){return u===h},JIJEn:s(747),BItKe:e[s(852)],jexOM:e[s(1744)],Cvylf:function(u,h,m){return e[s(1443)](u,h,m)},FRfEB:function(u,h,m){return e[s(469)](u,h,m)},ptuIK:function(u,h,m){return u(h,m)},gtihK:function(u,h){return e[s(1193)](u,h)},fxePr:function(u,h,m){return u(h,m)},qyRGO:e[s(1494)],tjaPp:function(u,h){return e[s(1595)](u,h)},sBMuf:function(u,h){return e.SIwos(u,h)},EiejA:e.sykNN,JPfUZ:e[s(1722)],QEEDQ:e[s(1822)],NCBOF:e[s(1009)]};if(e.IERNI(s(795),s(795))){super(),this[s(1670)+s(1723)+s(282)]=!0,this._isBrowser=Yn,this[s(783)]=Gh,this[s(614)+"T"]=In,this._isMiniWX=Gr,this[s(1764)+"r"]=Hr,this[s(1394)+"Queue"]=[],this[s(854)+s(577)]=null,this[s(388)+s(1133)]=!1,this[s(1802)+s(1720)]=s(418)+"fer",this[s(1543)+s(745)]=!1,this[s(1543)+s(838)+s(1834)]=null,this[s(494)+s(814)+s(296)]=null,this[s(392)+s(1091)+"Id"]=null,this[s(1839)]=0,this[s(1162)]=!1,this._url="",this[s(958)+s(1646)]=null,this[s(732)+"anager"]=null,this[s(1337)+s(1812)]=null,this[s(362)+"ls"]=e[s(839)],this[s(593)]=3,this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this[s(531)]=E=>{let g=s;try{d[g(1759)](jd,this,E,[vp,Sp,Ip])}catch(k){let P=d[g(1504)](at,g(1613),{message:k[g(1197)],code:en[g(1529)+"OR"],error:k});this[g(484)+g(670)+"ent"](P)}},this[s(381)+"ge"]=async E=>{let g=s;if(d[g(623)](d[g(1653)],d.jZEVp))return this["_endpoin"+g(577)]?.["getCurre"+g(1070)+g(495)+"ount"]()||0;{let{pingInterval:k,pingFrequency:P}=this._options;if((d.pOgsd("hi",E.data)&&d[g(1581)](g(716),P)||d[g(552)]===P)&&(this._clearPingTimer(),this[g(1175)](d.BItKe,d.jexOM),this[g(392)+g(1091)+"Id"]=d[g(1829)](setTimeout,this[g(1231)].bind(this),k)),d[g(1581)]("hi",E.data))return;try{d[g(1759)](jd,this,E,[rp,tp,bp,Ep,yp,np])}catch(F){let z=d[g(1820)](at,g(1613),{message:F.message,code:en["MESSAGE_"+g(445)],error:F});this[g(484)+g(670)+g(1144)](z)}}},this[s(914)]=E=>{let g=s,k=this[g(854)+g(577)]?.[g(1706)+g(1027)+"es"](),P=this[g(854)+g(577)]?.[g(943)+"ntEndpoint"]();if(k&&!E[g(1197)]){let F=g(1566)+P+(g(1844)+g(1757)+g(1029)+"ed");this[g(484)+g(670)+"ent"](at(e[g(1822)],{message:F,code:en["MAX_RETR"+g(1300)+"R"],error:E}));return}this[g(965)]&&this[g(965)][g(1016)+"te"]===this[g(321)]&&this[g(1786)+g(1051)](),this[g(484)+"hErrorEv"+g(1144)](at(e[g(1822)],{message:E[g(1197)],code:en[g(1324)+g(1651)],error:E}))},this[s(1488)]=async E=>{let g=s,k={KLnZv:g(1613),ueeiA:function(F,z,q){return d[g(647)](F,z,q)}};this[g(371)+"mer"](),this[g(1546)+g(1237)](),this._removeWsListeners(),this[g(965)]=null,this["_connect"+g(745)]=!1;let P=this[g(854)+g(577)]?.checkReachMaxTries();if(!P&&this[g(625)+g(580)]()&&!this["_readyCl"+g(1133)]){let F=this[g(854)+"tManager"]?.[g(943)+g(1070)+"nt"](),z=this[g(1444)][g(551)+"tInterceptor"](E[g(1725)],E.reason);this[g(484)+"hCloseEv"+g(1144)](d[g(647)](ht,g(567),{code:1006,reason:E.reason||g(540)+g(366)+g(1593)+g(427)+"n, hostn"+g(739)+F,willReconnect:z})),z&&this._connect();return}if(d[g(1340)](1e3,E.code)&&this[g(388)+"osed"]){this[g(484)+g(865)+g(1144)](d[g(1419)](ht,g(567),{code:1e3,reason:d.qyRGO})),this[g(854)+g(577)]?.[g(382)+"pointCon"+g(1428)](),this["_pingLos"+g(1812)]?.[g(1643)+"nter"]();return}if(d.tjaPp(1e3,E.code)&&P)if(d[g(888)](d[g(1450)],d[g(1625)])){let F=this[g(854)+g(577)]?.[g(943)+g(1070)+"nt"](),z=E[g(1105)];z||(z=await Vh(this[g(895)])),z=g(540)+"ng failed, "+z+(g(1644)+g(1698))+F+(", max re"+g(598)+g(431)),this[g(484)+g(865)+g(1144)](d.fxePr(ht,g(567),{code:E[g(1725)],reason:z}));let q=g(1566)+F+(g(1844)+"ax retri"+g(1029)+"ed");this[g(484)+"hErrorEv"+g(1144)](d.ptuIK(at,d[g(1801)],{message:q,code:en[g(657)+"IES_ERROR"]})),this[g(854)+g(577)]?.[g(382)+g(662)+g(1428)](),this["_pingLos"+g(1812)]?.["resetCou"+g(528)]();return}else{let F=_0x3f0eac[g(825)][g(1491)](_0x2e9c57[g(1372)+"et"],_0x54038b.byteLength+_0x505685[g(1372)+"et"]);this[g(456)]&&this[g(456)][g(758)]({data:F,fail:z=>{let q=g;this.emit(adqVkV[q(1244)],adqVkV.ueeiA(_0x398d0b,adqVkV[q(1244)],{message:this["_formatE"+q(1008)+"age"](z)}))}})}if(d[g(623)](1e3,E[g(1725)])&&!E[g(1105)]){let F=this["_endpoin"+g(577)]?.["getCurre"+g(1070)+"nt"]();this[g(484)+g(865)+g(1144)](ht(d.NCBOF,{code:E.code,reason:g(540)+g(366)+g(1593)+g(427)+"n, hostn"+g(739)+F})),this[g(854)+"tManager"]?.[g(382)+g(662)+g(1428)](),this[g(1337)+g(1812)]?.[g(1643)+"nter"]();return}this[g(484)+g(865)+g(1144)](E),this[g(854)+"tManager"]?.[g(382)+g(662)+g(1428)](),this[g(1337)+g(1812)]?.["resetCou"+g(528)]()},this[s(902)]=null,this[s(656)]=null,this[s(1203)+"e"]=null,this[s(933)]=null,this[s(871)+s(911)]=null,this[s(813)+s(1460)]=null,this[s(1195)+s(546)+s(1192)+"ct"]=null,this["_handleO"+s(1042)]=this[s(1681)+s(1042)].bind(this),this[s(1681)+s(1675)]=this[s(1681)+s(1675)][s(1840)](this),this["_handleP"+s(689)]=this["_handleP"+s(689)].bind(this),this[s(489)+"ageShow"]=this[s(489)+s(1186)][s(1840)](this),this[s(1444)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength: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(449)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(708)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:h}=n,m=Array.isArray(u)?u:e[s(1225)](e.KpOhi,typeof u)?[u]:[];if(!m||e[s(1616)](0,m[s(1258)]))throw new Error(e[s(369)]);if(!e[s(622)](Wh,h))throw new Error(e[s(940)]);Object.assign(this._options,n),this[s(854)+"tManager"]=new Hd(m,this[s(1444)][s(1064)+"es"]),this[s(1337)+s(1812)]=new Jh(this[s(1444)][s(560)+"Count"]),this[s(1444)][s(1580)+s(1216)]&&(this[s(1162)]=!0,this._connect()),this._options["listenNetworkCha"+s(1536)]&&(this[s(614)+"T"]||this._isMiniWX?this[s(1339)+"etWorkChange"]():this[s(1013)+"er"]&&this[s(1183)+s(591)+"Listener"]())}else return this[s(1397)][s(1247)+"rageSync"]()}[t(1681)+t(1042)](){let n=t;this._options[n(703)+n(1539)+"nect"]||this[n(388)+n(1133)]||this[n(1811)+"econnect"]()}[t(1681)+t(1675)](){let n=t;this._destroyWebSocket();let s=e[n(469)](na,e[n(1869)],{message:e[n(881)]});this[n(1195)+n(546)+n(1192)+"ct"]&&this[n(1195)+n(546)+n(1192)+"ct"](s)}["_initGlobalEvent"+t(1165)](){let n=t;this[n(1013)+"er"]&&window.addEventListener(e[n(564)],this["_handleO"+n(1042)]),this._isBrowser&&window[n(1256)+"Listener"](e[n(566)],this[n(1681)+n(1675)]),this[n(1013)+"er"]&&window[n(1256)+n(1165)](e[n(706)],this[n(489)+"ageHide"]),this[n(1013)+"er"]&&window["addEvent"+n(1165)](e[n(429)],this[n(489)+n(1186)])}["_dropGlo"+t(591)+t(1165)](){let n=t;this[n(1013)+"er"]&&window[n(779)+n(1475)+n(294)](n(1005),this[n(1681)+n(1042)]),this[n(1013)+"er"]&&window[n(779)+n(1475)+n(294)](n(1430),this[n(1681)+"ffLine"]),this._isBrowser&&window[n(779)+n(1475)+"ner"](e.Tyimi,this["_handleP"+n(689)]),this._isBrowser&&window[n(779)+n(1475)+"ner"](e.QHBCf,this["_handleP"+n(1186)])}[t(489)+"ageHide"](n){let s=t;!n[s(1659)+"d"]&&(this[s(1013)+"er"]&&window["removeEv"+s(1475)+s(294)](e[s(706)],this[s(489)+s(689)]),this[s(1013)+"er"]&&window[s(779)+s(1475)+s(294)](e[s(429)],this[s(489)+s(1186)]),this.close()),this._isBrowser&&window["removeEventListe"+s(294)](s(1005),this[s(1681)+s(1042)]),this[s(1013)+"er"]&&window["removeEv"+s(1475)+s(294)](e[s(566)],this[s(1681)+"ffLine"])}_handlePageShow(n){let s=t;n[s(1659)+"d"]&&(this["_navigat"+s(580)]()&&(!this[s(965)]||e[s(1519)](this[s(965)].readyState,this[s(321)])||e[s(1686)](this[s(965)].readyState,this.CONNECTING))&&this[s(1681)+s(1042)](),this[s(1013)+"er"]&&window[s(1256)+s(1165)](e[s(564)],this[s(1681)+"nLine"]),this[s(1013)+"er"]&&window[s(1256)+"Listener"](e[s(566)],this[s(1681)+s(1675)]))}async["_generat"+t(1004)](n){let s=t,{fpID:d,deviceID:u,bddID:h,ttwID:m,accessKey:E,aID:g,customParams:k={},enableAutoAck:P,enableQoS:F,QoSLevel:z,env:q}=this[s(1444)],W,le,G;this[s(1013)+"er"]||this[s(340)+"X"]||this[s(614)+"T"]?(W=location&&e.jzNEP(e[s(1012)],location.protocol)?e[s(994)]:e[s(1778)],le=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),G=/^wss(.*:\/\/)/.test(n)?n:""+W+le):(W=s(631),le=n.replace(/(^http)((?:[s]*:\/\/))/,""),G=/(^ws)((?:[s]*:\/\/))/[s(1089)](le)?le:""+W+le);let $=h?e[s(1700)]:m?s(1037):e.lWGmb,Ke=h||m||u;if(e[s(1859)](!Ke,!$))throw new Error(e[s(628)]);let Tp=e.izaZy==typeof k?await e[s(1598)](k):k,Cp=q?e[s(493)]($h,q[s(1168)],q[s(1842)]):{},la=Object[s(995)]({device_platform:s(1571),version_code:e.NwqBz,access_key:E,fpid:d,aid:g,[$]:Ke,xsack:P?1:0,xaack:P?1:0,xsqos:F?1:0,qos_level:F?z:void 0,qos_sdk_version:2,...Cp},Tp),Dp=Object[s(1540)](la)[s(504)]((fa,ua)=>la[ua]!==void 0?""+fa+(fa?"&":"?")+ua+"="+la[ua]:fa,"");return G+"/ws/v2"+Dp}async _connect(){let n=t,s={ivCxr:function(d,u){return e.AuLiS(d,u)},agNmE:e[n(1744)],Mglbs:n(1084)+"e_success",uVlme:e.FOAeX};if(!(this[n(1543)+n(745)]||this[n(388)+n(1133)])){this[n(1543)+n(745)]=!0;try{if(e[n(1792)](e[n(644)],n(350))){let d=this[n(854)+n(577)]?.[n(325)+"rentEndp"+n(1473)+n(1360)+n(1348)](),{timeoutInterval:u}=this._options;if(d){let m=this[n(854)+n(577)]?.[n(943)+n(1070)+"nt"](),E=this[n(854)+n(577)]?.[n(1552)+n(1768)+n(1048)+n(1208)+n(1266)](),g=this[n(854)+n(577)]?.[n(943)+n(1070)+n(495)+n(439)]();if(E){let k=n(1566)+m+(n(1387)+n(1477)+n(598)+n(1071)+n(1210)+n(990)+n(906))+E+" to retry",P=at(e[n(1822)],{message:k,code:en[n(657)+n(1300)+"R"]});this[n(447)](k),this[n(484)+n(670)+n(1144)](P),this[n(895)]=await this[n(1714)+n(1004)](E),this[n(447)](n(1566)+E+" "+g+n(784)),this[n(462)+n(1824)+"rs"]()}else{let k=n(1566)+m+(" timeout"+n(1477)+n(598)+n(431));this[n(447)](k),this[n(484)+n(670)+n(1144)](e.nBYyM(at,e.LJHTj,{message:k,code:en["MAX_RETR"+n(1300)+"R"]}));return}}else{let m=this._endpointManager?.[n(943)+"ntEndpoi"+n(409)+n(654)](),E=this[n(854)+n(577)]?.[n(943)+n(1070)+n(495)+n(439)]();this._url=await this["_generat"+n(1004)](e.bETYy(m,"")),this[n(447)](n(1566)+m+" "+E+" times"),this[n(462)+n(1824)+"rs"]()}if(this[n(1162)])this._isInit=!1;else{let m=na(e[n(1869)],{message:e[n(1621)]});this[n(871)+"econnect"]&&this[n(871)+n(911)](m)}let h=this[n(854)+n(577)]?.[n(943)+n(1070)+n(495)+n(439)]()||0;h>1&&await this[n(1111)](e[n(374)](h,1)),this[n(447)](n(540)+n(989)+this._url+(n(379)+"ls: ")+this[n(362)+"ls"]),this._ws=jh({url:this._url,protocols:[this[n(362)+"ls"]],headers:this[n(1444)].miniProgramParams["customHt"+n(1564)]},this[n(1444)].ws),(this[n(1013)+"er"]||this[n(1764)+"r"])&&this._ws&&(this[n(965)][n(655)+"pe"]=this["_binaryT"+n(1720)]),this[n(982)+"steners"](),this["_connect"+n(838)+"utId"]=e[n(1515)](setTimeout,this[n(1528)+"ut"][n(1840)](this),u)}else{let d={kSFDP:function(m,E){return e[n(1073)](m,E)},oxzil:n(918),NQrBM:e.hdTWt,ohRbm:e[n(1846)]};this["_clearPi"+n(1237)](),this[n(392)+n(1091)+"Id"]=_0x18da46(this[n(1231)].bind(this),this[n(1444)]["pingInte"+n(1308)]);let u=()=>{let m=n;s[m(1506)](_0xcc5b06,s[m(725)]),this[m(842)](s.Mglbs,u),this.off(s[m(1059)],h)},h=()=>{let m=n;d[m(534)](_0x491749,d[m(1592)]),this[m(842)](d[m(688)],u),this[m(842)](d[m(1682)],h)};this.on(n(1084)+n(1661)+"s",u),this.on(e.FOAeX,h),this._ping()}}catch(d){throw this[n(1543)+"Lock"]=!1,d}}}_clearTimer(){let n=t;e[n(668)](clearTimeout,this[n(1543)+n(838)+n(1834)]),this[n(1543)+"ionTimeo"+n(1834)]=null}[t(1546)+"ngTimer"](){let n=t;e[n(1849)](clearTimeout,this["_pingPon"+n(1091)+"Id"]),e[n(1073)](clearTimeout,this[n(494)+n(814)+n(296)]),this["_pingPon"+n(1091)+"Id"]=null,this[n(494)+"ctTimeou"+n(296)]=null}[t(447)](...n){let s=t;this[s(1444)][s(1065)]&&console[s(1362)][s(1078)](console,[s(1269)+">",...n])}["_getInte"+t(682)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:h}=this[s(1444)],m=e[s(1312)](d,Math.pow(h,e[s(579)](n,1)));return e.RPnzF(m,u)?u:m}[t(1231)](){let n=t;if(this[n(965)]&&e.fRhyI(this[n(965)][n(1016)+"te"],this[n(1331)+"NG"])){this[n(1546)+n(1237)](),this[n(392)+"gTimeoutId"]=e[n(1577)](setTimeout,this[n(1231)][n(1840)](this),this[n(1444)][n(934)+n(1308)]);return}if(!this[n(965)]||e[n(1624)](this[n(965)][n(1016)+"te"],this[n(321)]))return void this["_handleR"+n(911)]();this[n(965)]&&this._ws[n(758)]("hi"),this[n(494)+n(814)+n(296)]=e[n(683)](setTimeout,this["_handleR"+n(911)+n(1523)][n(1840)](this),this[n(1444)]["pingTimeoutInter"+n(1826)])}[t(1811)+t(911)+t(1523)](){let n=t;this[n(1337)+n(1812)]?.[n(1533)](),this.emit(e[n(1846)],e[n(853)]),this._pingLossCounter?.["checkRea"+n(333)+"nt"]()?this[n(1811)+n(911)]():this[n(1231)]()}[t(625)+"orOnline"](){let n=t;return this[n(614)+"T"]||this[n(340)+"X"]?this[n(1670)+n(1723)+n(282)]:(this._isBrowser||this._isWorker)&&this[n(1444)][n(403)+n(1865)+n(1536)]?navigator.onLine:!0}[t(1811)+"econnect"](){let n=t;!this[n(625)+"orOnline"]()||this[n(388)+"osed"]||(this["_endpoin"+n(577)]?.[n(382)+n(662)+n(1428)](),this[n(1337)+n(1812)]?.["resetCou"+n(528)](),this[n(965)]?this[n(1786)+n(1051)](1001,e[n(1717)],!0):this[n(1543)]())}["_onPageN"+t(318)+t(1069)](){let n=t;this[n(614)+"T"]?tt["onNetwor"+n(1526)+n(1709)](({isConnected:s})=>{let d=n;this[d(1670)+d(1723)+d(282)]=s,s?this[d(1681)+d(1042)]():this[d(1681)+"ffLine"]()}):this[n(340)+"X"]&&wx["onNetwor"+n(1526)+n(1709)](({isConnected:s})=>{let d=n;this[d(1670)+d(1723)+"line"]=s,s?this[d(1681)+d(1042)]():this["_handleO"+d(1675)]()})}_wait(n){let s=t,d={xtPQl:function(u,h,m){return u(h,m)},Hgsho:function(u,h){return e[U(673)](u,h)}};return e.PRhSP!==e.ApLCj?new Promise(u=>{let h=U;d[h(511)](setTimeout,u,this[h(1273)+"rvalValue"](n))}):(_0x1f6524[s(1078)](DtBMcf[s(1809)](_0x2f6d9c,this),_0x4f6dd3),_0x612f4f(_0x41eb63[s(1676)](this)))}["_disconn"+t(1051)](n=1e3,s="",d=!1){let u=t;this._ws&&this[u(453)+u(355)+"t"](n,s,d)}[t(1528)+"ut"](){let n=t,s=this[n(854)+n(577)]?.["getCurre"+n(1070)+"nt"]();this._debug(n(1566)+s+n(1387)),this[n(1786)+n(1051)](1001,n(1559)+" try rec"+n(563)+"g",!0)}[t(1354)](n){let s=t,d=e[s(425)](Ft,n);this[s(965)]&&e.fRhyI(this[s(965)][s(1016)+"te"],this.OPEN)&&(this._ws&&this[s(965)][s(758)](d),this[s(447)]("send_ack",n))}["_removeW"+t(1824)+"rs"](){let n=t,s={eOeZX:function(d,u){return e.HXQeI(d,u)}};if(e[n(1558)]==="cnWcI"){let d=e[n(1627)][n(726)]("|"),u=0;for(;;){switch(d[u++]){case"0":this._ws[n(779)+"entListe"+n(294)](e[n(1822)],this[n(914)]);continue;case"1":if(!this[n(965)])return;continue;case"2":this[n(965)][n(779)+n(1475)+n(294)](n(567),this._onClose);continue;case"3":this[n(965)]["removeEv"+n(1475)+"ner"](e[n(1547)],this._onOpen);continue;case"4":this[n(965)][n(779)+n(1475)+n(294)](e.QnCYk,this[n(381)+"ge"]);continue}break}}else{let d=_0xd3a5ca.substring(0,YExPvf[n(1392)](4,_0x37c70c[_0x59e807][n(1258)])),u=d[n(537)](_0x39576b[_0x683f31]);_0x3dd9e5[n(1014)](u)}}[t(982)+"steners"](){let n=t,s=e.itNcC.split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(965)]["addEvent"+n(1165)](e[n(1572)],this[n(381)+"ge"]);continue;case"1":this[n(965)][n(1256)+"Listener"](e[n(1822)],this._onError);continue;case"2":if(!this[n(965)])return;continue;case"3":this._ws[n(1256)+n(1165)](n(567),this[n(1488)]);continue;case"4":this[n(965)][n(1256)+n(1165)](e.lVRBa,this._onOpen);continue}break}}_wsInstanceClose(n=1e3,s=""){let d=t;try{this[d(965)]&&this._ws[d(567)](n,s)}catch{}}["_destroy"+t(355)+"t"](n=1e3,s="",d=!1){let u=t,h={NqTqu:function(m,E){return e[U(757)](m,E)},LLdel:function(m,E){return m>E},mgCnQ:function(m,E){return e[U(1799)](m,E)},XmdoJ:function(m,E){return m+E},XAJlT:function(m,E){return e[U(1513)](m,E)},avEAI:function(m,E){return e[U(973)](m,E)}};if(this[u(1546)+u(1237)](),this[u(371)+u(916)](),this[u(462)+"sListeners"](),this[u(1184)+u(406)](1e3,s),this["_connect"+u(745)]=!1,d&&this[u(625)+"orOnline"]()&&!this[u(388)+u(1133)])if(e[u(1224)](e[u(1134)],e.CbxDf)){if(this["_endpoin"+u(577)]?.[u(1706)+u(1027)+"es"]()){let E=this[u(854)+u(577)]?.[u(943)+u(1070)+"nt"]();this["_dispatc"+u(865)+u(1144)](e[u(469)](ht,e.uTbsW,{code:1006,reason:u(1566)+E+(" timeout"+u(1477)+u(598)+u(431)),wasClean:!0}))}else{let E=this[u(1444)][u(551)+u(1454)+u(284)](n,s);this[u(484)+"hCloseEvent"](ht(e.uTbsW,{code:n,reason:s,wasClean:!0,willReconnect:E})),E&&this[u(1543)]()}return}else{if(TXkmKy.NqTqu(_0x38c256,1)||TXkmKy[u(1470)](_0x423097,_0x28f637))return TXkmKy[u(1803)](_0x5e8eb8,_0x271fbb);TXkmKy.LLdel(TXkmKy.XmdoJ(_0xcb28c9,_0x3eba79),_0x29329f)&&(_0x426a74=TXkmKy.XAJlT(_0x2acd47,_0x482def),_0x5b2714=0);let m=_0x2b4b62[u(452)](_0x3ce052,_0x152b96,_0x168c06+=_0x3b916f);return 7&_0x5b1b0a&&(_0xfd1a91=TXkmKy[u(821)](7|_0x130dbc,1)),m}this[u(625)+u(580)]()||this[u(388)+u(1133)]?this[u(484)+u(865)+u(1144)](e[u(315)](ht,e[u(1009)],{code:n,reason:u(1439)})):this[u(484)+"hCloseEv"+u(1144)](e.sSKxP(ht,"close",{code:1006,reason:"going away, netw"+u(310)+u(960)})),this[u(965)]=null,this[u(854)+u(577)]?.[u(382)+u(662)+"fig"](),this[u(1337)+u(1812)]?.[u(1643)+u(528)]()}[t(484)+t(1626)+"nt"](n){let s=t;this.emit(e[s(1547)],n),this.onopen&&this[s(933)](n)}[t(484)+t(442)+t(1156)](n){let s=t;this.emit(e[s(1572)],n),this[s(1203)+"e"]&&this[s(1203)+"e"](n)}[t(484)+t(764)+t(938)](n){let s=t;this[s(1175)](e.WKKJM,n),this["onReceiv"+s(1460)]&&this[s(813)+"eAck"](n)}[t(484)+"hErrorEv"+t(1144)](n){let s=t;this[s(1175)](s(1613),n),this.onerror&&this[s(656)](n)}[t(484)+t(865)+"ent"](n){let s=t;this[s(1175)](e[s(1009)],n),this.onclose&&this.onclose(n)}get[t(655)+"pe"](){let n=t,s={zYSeR:e.momai,GSBTR:function(d){return e.YsDUi(d)}};if(n(578)===e[n(1106)])this[n(447)](mxSMWg.zYSeR,_0x3e99df[n(1197)]),mxSMWg[n(288)](_0x9afea9);else return this[n(965)]?this[n(965)].binaryType:this[n(1802)+n(1720)]}set[t(655)+"pe"](n){let s=t;this["_binaryT"+s(1720)]=n,this[s(965)]&&(this[s(965)].binaryType=n)}get[t(1823)+"nt"](){let n=t;return this[n(854)+n(577)]?.["getCurre"+n(1070)+n(495)+n(439)]()||0}get[t(860)+t(799)](){let n=t,s={hdRLP:function(u,h,m,E){return e[U(1452)](u,h,m,E)}},d=this[n(1394)+n(1463)][n(504)]((u,h)=>{let m=n;if(e.ltrmw(e[m(831)],e[m(831)]))for(var E in _0x239afc)MZHGfI.hdRLP(_0xeab2a2,_0x3a4288,E,{get:_0x517f82[E],enumerable:!0});else return u+=h&&h.byteLength||0,u},0);return e[n(1818)](d,this[n(965)]?this[n(965)][n(860)+"Amount"]:0)}get[t(526)+"ns"](){let n=t;return this._ws?this[n(965)][n(526)+"ns"]:""}get[t(1787)](){let n=t,s={SDSAn:function(d,u){return e.tmCBi(d,u)},KvuoP:function(d,u){return e[U(1849)](d,u)},MZKfZ:function(d,u){return e[U(1708)](d,u)},tqabj:function(d,u){return e[U(1531)](d,u)},skhcv:function(d,u){return e[U(653)](d,u)},NZsKO:function(d,u){return e[U(1174)](d,u)},whZjZ:function(d,u){return e[U(727)](d,u)}};if(e[n(416)](e.KpzfD,e[n(1011)]))return this[n(965)]?this._ws.protocol:"";{let d=e.xFIaE(_0x310723,8192),u=e[n(1083)](d,1),h=null,m=d;return function(E){let g=n;if(E<1||PFynrT[g(1126)](E,u))return PFynrT[g(861)](_0x1d8174,E);PFynrT[g(461)](PFynrT[g(1719)](m,E),d)&&(h=_0x572826(d),m=0);let k=_0x419a4d[g(452)](h,m,m+=E);return PFynrT[g(1702)](7,m)&&(m=PFynrT.NZsKO(PFynrT[g(1804)](7,m),1)),k}}}get[t(1016)+"te"](){let n=t;return this[n(965)]?this[n(965)].readyState:this[n(1444)][n(1580)+"cOpen"]?this[n(1331)+"NG"]:this[n(593)]}get[t(352)](){return this[t(965)]?this._ws.url:this._url}[t(567)](n=1e3,s){let d=t,u=e[d(828)][d(726)]("|"),h=0;for(;;){switch(u[h++]){case"0":this[d(958)+"ger"]?.[d(1202)]();continue;case"1":this[d(1546)+d(1237)]();continue;case"2":this[d(1325)+d(591)+d(1165)]();continue;case"3":if(e.gMMTN(this[d(965)].readyState,this[d(593)])||this[d(965)].readyState===this[d(680)])return void this[d(447)](e[d(931)]);continue;case"4":this[d(388)+d(1133)]=!0;continue;case"5":if(!this[d(965)])return void this[d(447)](e.Jlofm);continue;case"6":this[d(371)+d(916)]();continue;case"7":this[d(453)+d(355)+"t"](n,s);continue}break}}async[t(758)](n,s){let d=t,u={ZGRmE:function(G,$){return e[U(789)](G,$)},lPysx:function(G,$){return e.Vjmwe(G,$)},ooLQH:function(G,$){return e[U(1158)](G,$)}};if(e.HIqzn(null,n))throw new Error(d(351)+d(1332)+d(357)+d(1238)+"a must b"+d(1131)+d(1101)+d(1201)+d(1378));e[d(501)](e.Bqhfe,typeof n)&&(n=JSON[d(1766)+"y"](n)),e[d(502)](d(1228),typeof n)&&!e[d(1047)](n,ArrayBuffer)&&!(n.buffer&&e[d(1589)](n[d(825)],ArrayBuffer))&&(n=JSON.stringify(n));let h=await e[d(1736)]($d,n),m=Kh(n),{method:E=0,service:g=this._options[d(1459)],logID:k=this[d(1444)][d(1468)+d(1724)](),headers:P=this[d(1444)][d(482)],payloadEncoding:F=this[d(1444)][d(1e3)+d(898)],payloadType:z=this[d(1444)][d(1511)+"ype"],logIDNew:q=this[d(1444)][d(424)+d(1025)]["enableAu"+d(987)+d(435)+"ew"]?e[d(1280)](i,this[d(1444)][d(424)+d(1025)][d(1703)]):""}=e[d(1862)](s,{});if(!g)throw new Error(e.qDLup);let W={SeqID:fe[d(1777)+"er"](this._seqId++),LogID:fe[d(1777)+"er"](k),service:g,method:E,headers:P,payloadEncoding:e.qeLAe(F,Object)?F[d(1752)]?F.encoding:"":F,payloadType:e[d(1047)](z,Object)?z.type?z[d(1271)]:m:z||m,payload:h,LogIDNew:q},le=Ft(W);return this[d(965)]&&e.fRhyI(this[d(965)].readyState,this.OPEN)?e[d(599)]!=="JhmyX"?(_0x11b48c=wvSgQE.ZGRmE(wvSgQE.lPysx(31&_0x1781ac,6),63&_0x421abb),wvSgQE[d(780)](_0x312467,128)?_0x18e100+=_0x4abba0:(_0x3c1094+=_0x3fb993(_0x3d055a),_0xcad912++)):(this[d(965)]&&this[d(965)][d(758)](le),this[d(447)](e[d(1521)],W)):e[d(1501)](this[d(1394)+d(1463)][d(1258)],this[d(1444)][d(840)+d(1512)+d(816)])?(this[d(1394)+d(1463)].push(le),this._debug(d(597),W)):(this._messageQueue[d(919)](),this._messageQueue.push(le)),{seqID:this[d(1839)],logID:k,logIDNew:q}}async[t(551)+"t"](n){let s=t,{url:d}=e[s(1099)](n,{}),u=Array[s(851)](d)?d:e[s(769)](e[s(1754)],typeof d)?[d]:[];n&&Object[s(995)](this[s(1444)],n),u&&u[s(1258)]?this[s(854)+s(577)]=new Hd(u,this._options.maxRetries):this[s(854)+s(577)]?.[s(382)+s(662)+"fig"](),this[s(1337)+s(1812)]?.[s(1643)+s(528)](this._options["pingLoss"+s(417)]),this._readyClosed=!1,this[s(965)]&&e[s(1467)](this[s(965)].readyState,this[s(593)])?this["_disconn"+s(1051)](1e3,e[s(1495)],!0):(this[s(1162)]=!0,this[s(1543)]())}async[t(1148)](){let n=t;if(!this[n(1543)+n(745)]){let s=(n(1234)+"1").split("|"),d=0;for(;;){switch(s[d++]){case"0":this["_endpoin"+n(577)]?.["resetEnd"+n(662)+n(1428)]();continue;case"1":this[n(1543)]();continue;case"2":this[n(388)+"osed"]=!1;continue;case"3":this[n(1337)+n(1812)]?.[n(1643)+n(528)]();continue;case"4":this[n(1162)]=!0;continue}break}}}["addEvent"+t(1165)](n,s){this.on(n,s)}[t(391)+t(1156)](n){let{type:s}=n;this.emit(s,n)}[t(779)+t(1475)+t(294)](n,s){this[t(842)](n,s)}pingOnce(){let n=t,s={BbWJj:function(d,u){return e[U(1423)](d,u)},VHxnm:n(918),lxlKw:n(1084)+n(1661)+"s",NtlGi:function(d,u,h){return e[n(774)](d,u,h)},YNFpO:e[n(1846)]};return new Promise((d,u)=>{let h=n,m={FhcHZ:h(1084)+"e_timeout"};this[h(1546)+h(1237)](),this["_pingPon"+h(1091)+"Id"]=s[h(949)](setTimeout,this[h(1231)][h(1840)](this),this[h(1444)][h(934)+h(1308)]);let E=()=>{let k=h;d(k(993)),this[k(842)](k(1084)+"e_success",E),this[k(842)](m[k(1852)],g)},g=()=>{let k=h;s[k(1611)](u,s.VHxnm),this.off(s[k(448)],E),this[k(842)](k(1084)+k(731)+"t",g)};this.on(h(1084)+h(1661)+"s",E),this.on(s[h(1284)],g),this[h(1231)]()})}}})(),ve[N(1270)+N(1758)]=ke[N(1270)+N(1758)],ve[N(926)+"rorEvent"]=ke[N(926)+N(1141)],ve[N(876)+"e"]=ke.ErrorCode,ve[N(1156)]=ke.Event,ve[N(1672)]=ke.FWS,ve[N(1642)+N(946)+N(612)]=ke[N(1642)+N(946)+N(612)],ve[N(946)+N(612)]=ke[N(946)+N(612)],ve[N(691)+"t"]=ke.OpenEvent,ve[N(609)+N(396)]=ke[N(609)+N(396)],ve[N(470)+"oseEvent"]=ke[N(470)+N(1758)],ve[N(809)+"rorEvent"]=ke[N(809)+N(1141)],ve[N(1814)+N(307)+"nt"]=ke[N(1814)+N(307)+"nt"],ve["createOp"+N(954)]=ke["createOp"+N(954)],ve[N(827)+"connectE"+N(612)]=ke["createRe"+N(972)+N(612)],ve[N(1164)+N(1666)]=ke[N(1164)+N(1666)],ve["encodeFr"+N(1304)]=ke["encodeFr"+N(1304)];for(mo in ke)[N(1270)+N(1758),N(926)+N(1141),N(876)+"e",N(1156),N(1672),N(1642)+"MessageE"+N(612),N(946)+"vent",N(691)+"t",N(609)+N(396),N(470)+N(1758),N(809)+N(1141),"createMessageEvent",N(778)+N(954),N(827)+"connectE"+N(612),N(1164)+N(1666),N(532)+N(1304)][N(1163)](mo)===-1&&(ve[mo]=ke[mo]);var mo;Object[N(971)+"operty"](ve,N(1591)+"le",{value:!0})});var $t=ae((LT,Ku)=>{"use strict";var ju=["nodebuffer","arraybuffer","fragments"],Wu=typeof Blob<"u";Wu&&ju.push("blob");Ku.exports={BINARY_TYPES:ju,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Wu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Fi=ae((NT,So)=>{"use strict";var{EMPTY_BUFFER:Db}=$t(),Qc=Buffer[Symbol.species];function Rb(t,e){if(t.length===0)return Db;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Qc(r.buffer,r.byteOffset,i):r}function $u(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Ju(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function kb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ed(t){if(ed.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Qc(t):ArrayBuffer.isView(t)?e=new Qc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ed.readOnly=!1),e}So.exports={concat:Rb,mask:$u,toArrayBuffer:kb,toBuffer:ed,unmask:Ju};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");So.exports.mask=function(e,r,i,o,c){c<48?$u(e,r,i,o,c):t.mask(e,r,i,o,c)},So.exports.unmask=function(e,r){e.length<32?Ju(e,r):t.unmask(e,r)}}catch{}});var Zu=ae((MT,Yu)=>{"use strict";var Vu=Symbol("kDone"),td=Symbol("kRun"),nd=class{constructor(e){this[Vu]=()=>{this.pending--,this[td]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[td]()}[td](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Vu])}}};Yu.exports=nd});var Rr=ae((BT,tx)=>{"use strict";var zi=ue("zlib"),Xu=Fi(),Pb=Zu(),{kStatusCode:Qu}=$t(),Ob=Buffer[Symbol.species],Lb=Buffer.from([0,0,255,255]),Ao=Symbol("permessage-deflate"),Jt=Symbol("total-length"),Cr=Symbol("callback"),En=Symbol("buffers"),Dr=Symbol("error"),Io,rd=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Io){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Io=new Pb(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Cr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Io.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Io.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=zi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Ao]=this,this._inflate[Jt]=0,this._inflate[En]=[],this._inflate.on("error",Mb),this._inflate.on("data",ex)}this._inflate[Cr]=i,this._inflate.write(e),r&&this._inflate.write(Lb),this._inflate.flush(()=>{let c=this._inflate[Dr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=Xu.concat(this._inflate[En],this._inflate[Jt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Jt]=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"?zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=zi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Jt]=0,this._deflate[En]=[],this._deflate.on("data",Nb)}this._deflate[Cr]=i,this._deflate.write(e),this._deflate.flush(zi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Xu.concat(this._deflate[En],this._deflate[Jt]);r&&(c=new Ob(c.buffer,c.byteOffset,c.length-4)),this._deflate[Cr]=null,this._deflate[Jt]=0,this._deflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};tx.exports=rd;function Nb(t){this[En].push(t),this[Jt]+=t.length}function ex(t){if(this[Jt]+=t.length,this[Ao]._maxPayload<1||this[Jt]<=this[Ao]._maxPayload){this[En].push(t);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][Qu]=1009,this.removeListener("data",ex),this.reset()}function Mb(t){if(this[Ao]._inflate=null,this[Dr]){this[Cr](this[Dr]);return}t[Qu]=1007,this[Cr](t)}});var kr=ae((FT,To)=>{"use strict";var{isUtf8:nx}=ue("buffer"),{hasBlob:Bb}=$t(),Fb=[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 zb(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function id(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function Ub(t){return Bb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}To.exports={isBlob:Ub,isValidStatusCode:zb,isValidUTF8:id,tokenChars:Fb};if(nx)To.exports.isValidUTF8=function(t){return t.length<24?id(t):nx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");To.exports.isValidUTF8=function(e){return e.length<32?id(e):t(e)}}catch{}});var dd=ae((zT,dx)=>{"use strict";var{Writable:qb}=ue("stream"),rx=Rr(),{BINARY_TYPES:Gb,EMPTY_BUFFER:ix,kStatusCode:Hb,kWebSocket:jb}=$t(),{concat:sd,toArrayBuffer:Wb,unmask:Kb}=Fi(),{isValidStatusCode:$b,isValidUTF8:sx}=kr(),Co=Buffer[Symbol.species],ft=0,ox=1,ax=2,cx=3,od=4,ad=5,Do=6,cd=class extends qb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Gb[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[jb]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ft}_write(e,r,i){if(this._opcode===8&&this._state==ft)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Co(i.buffer,i.byteOffset+e,i.length-e),new Co(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Co(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case ft:this.getInfo(e);break;case ox:this.getPayloadLength16(e);break;case ax:this.getPayloadLength64(e);break;case cx:this.getMask();break;case od:this.getData(e);break;case ad:case Do: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[rx.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=ox:this._payloadLength===127?this._state=ax:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let 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=od}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=od}getData(e){let r=ix;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&&Kb(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ad,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rx.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===ft&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ft;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=sd(i,r):this._binaryType==="arraybuffer"?o=Wb(sd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ft):(this._state=Do,setImmediate(()=>{this.emit("message",o,!0),this._state=ft,this.startLoop(e)}))}else{let o=sd(i,r);if(!this._skipUTF8Validation&&!sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ad||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ft):(this._state=Do,setImmediate(()=>{this.emit("message",o,!1),this._state=ft,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ix),this.end();else{let i=e.readUInt16BE(0);if(!$b(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Co(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=ft;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ft):(this._state=Do,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ft,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[Hb]=o,l}};dx.exports=cd});var ud=ae((qT,ux)=>{"use strict";var{Duplex:UT}=ue("stream"),{randomFillSync:Jb}=ue("crypto"),lx=Rr(),{EMPTY_BUFFER:Vb,kWebSocket:Yb,NOOP:Zb}=$t(),{isBlob:Pr,isValidStatusCode:Xb}=kr(),{mask:fx,toBuffer:Gn}=Fi(),ut=Symbol("kByteLength"),Qb=Buffer.alloc(4),Ro=8*1024,Hn,Or=Ro,vt=0,e1=1,t1=2,ld=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=vt,this.onerror=Zb,this[Yb]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||Qb,r.generateMask?r.generateMask(i):(Or===Ro&&(Hn===void 0&&(Hn=Buffer.alloc(Ro)),Jb(Hn,0,Ro),Or=0),i[0]=Hn[Or++],i[1]=Hn[Or++],i[2]=Hn[Or++],i[3]=Hn[Or++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||l)&&r[ut]!==void 0?f=r[ut]:(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 p=Buffer.allocUnsafe(o?f+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(f,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(fx(e,i,p,c,f),[p]):(fx(e,i,e,0,f),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=Vb;else{if(typeof e!="number"||!Xb(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={[ut]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==vt?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=Gn(e),o=e.length,c=Gn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Pr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?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=Gn(e),o=e.length,c=Gn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Pr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[lx.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=Gn(e),f=e.length,x=Gn.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 p={[ut]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Pr(e)?this._state!==vt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==vt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ut],this._state=t1,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(fd,this,f,o);return}this._bufferedBytes-=i[ut];let l=Gn(c);r?this.dispatch(l,r,i,o):(this._state=vt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(n1,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[lx.extensionName];this._bufferedBytes+=i[ut],this._state=e1,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");fd(this,x,o);return}this._bufferedBytes-=i[ut],this._state=vt,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===vt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ut],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ut],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)}};ux.exports=ld;function fd(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 n1(t,e,r){fd(t,e,r),t.onerror(e)}});var Ex=ae((GT,bx)=>{"use strict";var{kForOnEventAttribute:Ui,kListener:xd}=$t(),xx=Symbol("kCode"),hx=Symbol("kData"),px=Symbol("kError"),gx=Symbol("kMessage"),mx=Symbol("kReason"),Lr=Symbol("kTarget"),_x=Symbol("kType"),yx=Symbol("kWasClean"),Vt=class{constructor(e){this[Lr]=null,this[_x]=e}get target(){return this[Lr]}get type(){return this[_x]}};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[xx]=r.code===void 0?0:r.code,this[mx]=r.reason===void 0?"":r.reason,this[yx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[xx]}get reason(){return this[mx]}get wasClean(){return this[yx]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Nr=class extends Vt{constructor(e,r={}){super(e),this[px]=r.error===void 0?null:r.error,this[gx]=r.message===void 0?"":r.message}get error(){return this[px]}get message(){return this[gx]}};Object.defineProperty(Nr.prototype,"error",{enumerable:!0});Object.defineProperty(Nr.prototype,"message",{enumerable:!0});var qi=class extends Vt{constructor(e,r={}){super(e),this[hx]=r.data===void 0?null:r.data}get data(){return this[hx]}};Object.defineProperty(qi.prototype,"data",{enumerable:!0});var r1={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ui]&&o[xd]===e&&!o[Ui])return;let i;if(t==="message")i=function(c,l){let f=new qi("message",{data:l?c:c.toString()});f[Lr]=this,ko(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,ko(e,this,f)};else if(t==="error")i=function(c){let l=new Nr("error",{error:c,message:c.message});l[Lr]=this,ko(e,this,l)};else if(t==="open")i=function(){let c=new Vt("open");c[Lr]=this,ko(e,this,c)};else return;i[Ui]=!!r[Ui],i[xd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[xd]===e&&!r[Ui]){this.removeListener(t,r);break}}};bx.exports={CloseEvent:jn,ErrorEvent:Nr,Event:Vt,EventTarget:r1,MessageEvent:qi};function ko(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Po=ae((HT,vx)=>{"use strict";var{tokenChars:Gi}=kr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function i1(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,f,x=-1,p=-1,b=-1,_=0;for(;_<t.length;_++)if(p=t.charCodeAt(_),l===void 0)if(b===-1&&Gi[p]===1)x===-1&&(x=_);else if(_!==0&&(p===32||p===9))b===-1&&x!==-1&&(b=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_);let w=t.slice(x,b);p===44?(Bt(e,w,r),r=Object.create(null)):l=w,x=b=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(b===-1&&Gi[p]===1)x===-1&&(x=_);else if(p===32||p===9)b===-1&&x!==-1&&(b=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_),Bt(r,t.slice(x,b),!0),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),x=b=-1}else if(p===61&&x!==-1&&b===-1)f=t.slice(x,_),x=b=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(Gi[p]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);x===-1?x=_:i||(i=!0),o=!1}else if(c)if(Gi[p]===1)x===-1&&(x=_);else if(p===34&&x!==-1)c=!1,b=_;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(p===34&&t.charCodeAt(_-1)===61)c=!0;else if(b===-1&&Gi[p]===1)x===-1&&(x=_);else if(x!==-1&&(p===32||p===9))b===-1&&(b=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_);let w=t.slice(x,b);i&&(w=w.replace(/\\/g,""),i=!1),Bt(r,f,w),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),f=void 0,x=b=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");b===-1&&(b=_);let A=t.slice(x,b);return l===void 0?Bt(e,A,r):(f===void 0?Bt(r,A,!0):i?Bt(r,f,A.replace(/\\/g,"")):Bt(r,f,A),Bt(e,l,r)),e}function s1(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(", ")}vx.exports={format:s1,parse:i1}});var Mo=ae((KT,Nx)=>{"use strict";var o1=ue("events"),a1=ue("https"),c1=ue("http"),Ax=ue("net"),d1=ue("tls"),{randomBytes:l1,createHash:f1}=ue("crypto"),{Duplex:jT,Readable:WT}=ue("stream"),{URL:hd}=ue("url"),vn=Rr(),u1=dd(),x1=ud(),{isBlob:h1}=kr(),{BINARY_TYPES:Sx,CLOSE_TIMEOUT:p1,EMPTY_BUFFER:Oo,GUID:g1,kForOnEventAttribute:pd,kListener:m1,kStatusCode:w1,kWebSocket:Ge,NOOP:Tx}=$t(),{EventTarget:{addEventListener:_1,removeEventListener:y1}}=Ex(),{format:b1,parse:E1}=Po(),{toBuffer:v1}=Fi(),Cx=Symbol("kAborted"),gd=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],S1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,we=class t extends o1{constructor(e,r,i){super(),this._binaryType=Sx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Oo,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]),Dx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Sx.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new u1({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new x1(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ge]=this,c[Ge]=this,e[Ge]=this,o.on("conclude",T1),o.on("drain",C1),o.on("error",D1),o.on("message",R1),o.on("ping",k1),o.on("pong",P1),c.onerror=O1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Px),e.on("data",No),e.on("end",Ox),e.on("error",Lx),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){ot(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())}),kx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Oo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Oo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Oo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(we,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(we.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(we,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(we.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(we,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(we.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(we,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(we.prototype,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(we.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(we.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[pd])return e[m1];return null},set(e){for(let r of this.listeners(t))if(r[pd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[pd]:!0})}})});we.prototype.addEventListener=_1;we.prototype.removeEventListener=y1;Nx.exports=we;function Dx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:p1,protocolVersion:gd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!gd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${gd.join(", ")})`);let c;if(e instanceof hd)c=e;else try{c=new hd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",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;Lo(t,I);return}let p=l?443:80,b=l1(16).toString("base64"),_=l?a1.request:c1.request,A=new Set,w;if(o.createConnection=o.createConnection||(l?A1:I1),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(w=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=b1({[vn.extensionName]:w.offer()})),r.length){for(let I of r){if(typeof I!="string"||!S1.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}`),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[S,C]of Object.entries(I))i.headers[S.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=_(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=_(o);o.timeout&&v.on("timeout",()=>{ot(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Cx]||(v=t._req=null,Lo(t,I))}),v.on("response",I=>{let S=I.headers.location,C=I.statusCode;if(S&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){ot(t,v,"Maximum redirects exceeded");return}v.abort();let L;try{L=new hd(S,e)}catch{let D=new SyntaxError(`Invalid URL: ${S}`);Lo(t,D);return}Dx(t,L,r,i)}else t.emit("unexpected-response",v,I)||ot(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,C)=>{if(t.emit("upgrade",I),t.readyState!==we.CONNECTING)return;v=t._req=null;let L=I.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){ot(t,S,"Invalid Upgrade header");return}let y=f1("sha1").update(b+g1).digest("base64");if(I.headers["sec-websocket-accept"]!==y){ot(t,S,"Invalid Sec-WebSocket-Accept header");return}let D=I.headers["sec-websocket-protocol"],R;if(D!==void 0?A.size?A.has(D)||(R="Server sent an invalid subprotocol"):R="Server sent a subprotocol but none was requested":A.size&&(R="Server sent no subprotocol"),R){ot(t,S,R);return}D&&(t._protocol=D);let M=I.headers["sec-websocket-extensions"];if(M!==void 0){if(!w){ot(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=E1(M)}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(B);if(Z.length!==1||Z[0]!==vn.extensionName){ot(t,S,"Server indicated an extension that was not requested");return}try{w.accept(B[vn.extensionName])}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=w}t.setSocket(S,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Lo(t,e){t._readyState=we.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function I1(t){return t.path=t.socketPath,Ax.connect(t)}function A1(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ax.isIP(t.host)?"":t.host),d1.connect(t)}function ot(t,e,r){t._readyState=we.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[Cx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Lo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function md(t,e,r){if(e){let i=h1(e)?e.size:v1(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 T1(t,e){let r=this[Ge];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ge]!==void 0&&(r._socket.removeListener("data",No),process.nextTick(Rx,r._socket),t===1005?r.close():r.close(t,e))}function C1(){let t=this[Ge];t.isPaused||t._socket.resume()}function D1(t){let e=this[Ge];e._socket[Ge]!==void 0&&(e._socket.removeListener("data",No),process.nextTick(Rx,e._socket),e.close(t[w1])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ix(){this[Ge].emitClose()}function R1(t,e){this[Ge].emit("message",t,e)}function k1(t){let e=this[Ge];e._autoPong&&e.pong(t,!this._isServer,Tx),e.emit("ping",t)}function P1(t){this[Ge].emit("pong",t)}function Rx(t){t.resume()}function O1(t){let e=this[Ge];e.readyState!==we.CLOSED&&(e.readyState===we.OPEN&&(e._readyState=we.CLOSING,kx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function kx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Px(){let t=this[Ge];if(this.removeListener("close",Px),this.removeListener("data",No),this.removeListener("end",Ox),t._readyState=we.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Ge]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ix),t._receiver.on("finish",Ix))}function No(t){this[Ge]._receiver.write(t)||this.pause()}function Ox(){let t=this[Ge];t._readyState=we.CLOSING,t._receiver.end(),this.end()}function Lx(){let t=this[Ge];this.removeListener("error",Lx),this.on("error",Tx),t&&(t._readyState=we.CLOSING,this.destroy())}});var zx=ae((JT,Fx)=>{"use strict";var $T=Mo(),{Duplex:L1}=ue("stream");function Mx(t){t.emit("close")}function N1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Bx(t){this.removeListener("error",Bx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function M1(t,e){let r=!0,i=new L1({...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(Mx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Mx,i)}),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",N1),i.on("error",Bx),i}Fx.exports=M1});var wd=ae((VT,Ux)=>{"use strict";var{tokenChars:B1}=kr();function F1(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&&B1[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}Ux.exports={parse:F1}});var $x=ae((ZT,Kx)=>{"use strict";var z1=ue("events"),Bo=ue("http"),{Duplex:YT}=ue("stream"),{createHash:U1}=ue("crypto"),qx=Po(),Wn=Rr(),q1=wd(),G1=Mo(),{CLOSE_TIMEOUT:H1,GUID:j1,kWebSocket:W1}=$t(),K1=/^[+/0-9A-Za-z]{22}==$/,Gx=0,Hx=1,Wx=2,_d=class extends z1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:H1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:G1,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Bo.createServer((i,o)=>{let c=Bo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=$1(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=Gx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Wx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Hi,this);return}if(e&&this.once("close",e),this._state!==Hx)if(this._state=Hx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Hi,this):process.nextTick(Hi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Hi(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",jx);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||!K1.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)){ji(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=q1.parse(x)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let b=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&b!==void 0){let A=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let w=qx.parse(b);w[Wn.extensionName]&&(A.accept(w[Wn.extensionName]),_[Wn.extensionName]=A)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={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(A,(w,v,I,S)=>{if(!w)return ji(r,v||401,I,S);this.completeUpgrade(_,c,p,e,r,i,o)});return}if(!this.options.verifyClient(A))return ji(r,401)}this.completeUpgrade(_,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[W1])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gx)return ji(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${U1("sha1").update(r+j1).digest("base64")}`],b=new this.options.WebSocket(null,void 0,this.options);if(i.size){let _=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;_&&(p.push(`Sec-WebSocket-Protocol: ${_}`),b._protocol=_)}if(e[Wn.extensionName]){let _=e[Wn.extensionName].params,A=qx.format({[Wn.extensionName]:[_]});p.push(`Sec-WebSocket-Extensions: ${A}`),b._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&Xi(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 qp,mkdirSync as Hp}from"node:fs";import{join as jp}from"node:path";function el(t){let e=t.retentionDays??Kp,r=t.clock??(()=>An(new Date));es={bridgeSink:new Gr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Gr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();Xi(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])Xi(t.agentLogsDir(o),"agent",i,e)}function $p(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function tl(t){ma=t}function nl(t){return Qn[ma]<=Qn[t]}function rl(t,e){let r=Qn[t];return r===void 0?!0:r>=Qn[e]}function ts(t){Qd={...t}}function il(t){let e=(u,h=2)=>String(u).padStart(h,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${An(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Wr(t,e,r,i,o){try{let c=`${JSON.stringify({ts:il(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;Hp(t,{recursive:!0}),qp(jp(t,Xn("bridge",An(new Date))),c)}catch{}}function Jp(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function Qi(t,e,r,i,o){if(Qn[t]<Qn[ma])return;let c=`${JSON.stringify({ts:il(new Date),level:t,module:e,msg:r,...Qd,...i})}
|
|
12
|
+
`;if(es){let l=Jp(o,i),u=l?$p(es,l):es.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Wp.write(c):Gp.write(c)}function U(t,e){return{debug:(r,i)=>Qi("debug",t,r,i,e),info:(r,i)=>Qi("info",t,r,i,e),warn:(r,i)=>Qi("warn",t,r,i,e),error:(r,i)=>Qi("error",t,r,i,e),child:r=>U(`${t}.${r}`,e),forAgent:r=>U(t,r)}}var Qn,ma,Gp,Wp,Qd,Kp,es,te=Ze(()=>{"use strict";Zi();ga();Qn={debug:10,info:20,warn:30,error:40},ma=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gp=process.stdout,Wp=process.stderr,Qd={},Kp=Ft("COZE_BRIDGE_LOG_RETENTION_DAYS",30),es=null});var R,$e=Ze(()=>{"use strict";R=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var cl={};xa(cl,{ACP_WRAPPER_NPM_PACKAGES:()=>$r,_resetAcpInstallerForTests:()=>eg,_setBinaryPathCacheForTests:()=>tg,buildAcpSpawn:()=>Jr,ensureAcpInstalled:()=>er,getAcpBinaryPath:()=>ns,pickWhichLine:()=>ya,probeAcpVersion:()=>Qp,resolveAcpCommand:()=>al});import{readFileSync as sl}from"node:fs";import{createRequire as Vp}from"node:module";import{dirname as Yp,resolve as Zp}from"node:path";function ya(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 Xp(t){let e=ol.resolve(`${t.npmPackage}/package.json`),r=Yp(e),i=JSON.parse(sl(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 Zp(r,o)}async function er(t,e){let r=_a[t];if(!r)throw new R("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Kr.get(t);if(i)return i;try{let o=Xp(r);return Kr.set(t,o),wa.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw wa.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new R("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
|
|
13
|
+
`),{cause:o})}}async function Qp(t){let e=_a[t];if(e)try{let r=ol.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(sl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){wa.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ns(t){return Kr.get(t)}function al(t,e){if(e)return e;let r=ns(t);if(!r)throw new R("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Jr(t,e,r){if(e)return{command:e,args:[...r]};let i=al(t);return{command:process.execPath,args:[i,...r]}}function eg(){Kr.clear()}function tg(t,e){Kr.set(t,e)}var wa,_a,$r,ol,Kr,nn=Ze(()=>{"use strict";$e();te();wa=U("agents.acp-installer"),_a={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},$r=Object.values(_a).filter(t=>t!==void 0).map(t=>t.npmPackage),ol=Vp(import.meta.url),Kr=new Map});import{chmod as rg,mkdir as ig,readFile as sg,rename as ul,writeFile as fl}from"node:fs/promises";import{dirname as og}from"node:path";async function tr(t){try{let e=await sg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nr(t,e,r){await ig(og(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 fl(o,i,{encoding:"utf8",mode:r.mode}):await fl(o,i,"utf8"),await ul(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await ul(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Vr=Ze(()=>{"use strict"});import{promises as hl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as Re,resolve as xl}from"node:path";function Z(t){let e=t??cg(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function Xe(t,e=Z()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function rs(t=Z()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Yr(t,e){let r=await hl.realpath(xl(t)).catch(()=>null);if(!r)return!1;let i=await hl.realpath(xl(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+dg)}var Ne=Ze(()=>{"use strict"});var os={};xa(os,{AGENT_CONFIG_FILE_MODE:()=>is,enforceAgentConfigMode:()=>fg,loadAgentConfig:()=>Ge,persistAgentSessions:()=>Zr,persistAgentSkills:()=>ss,saveAgentConfig:()=>Qe});import{chmod as lg,stat as ug}from"node:fs/promises";function Ge(t,e){return tr(Xe(t,e).config)}function Qe(t,e){return nr(Xe(t.agentId,e).config,t,{mode:is})}async function fg(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await ug(r);if(!i.isFile())return;let o=i.mode&511;o!==is&&(await lg(r,is),pl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;pl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Zr(t,e,r){let i=await Ge(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function ss(t,e,r){let i=await Ge(t,r);i&&(i.skills=e,await Qe(i,r))}var pl,is,rn=Ze(()=>{"use strict";Vr();te();Ne();pl=U("agent-config"),is=384});var ba=ie((N1,_l)=>{_l.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var cs=ie(El=>{var yl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function 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(yl))El[t]=mg(yl[t])});var Al=ie((M1,Il)=>{var wg=ce("fs"),Le=ce("path"),bl=ba(),_g=cs(),yg=typeof process=="object"&&process.platform==="win32",vl=t=>typeof t=="object"&&t!==null,Sl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function ve(t){this.sep=Le.sep,this.fs=wg,vl(t)&&vl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Il.exports=ve;ve.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw _g.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Le.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};ve.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,h){if(l&&h.isDirectory())return o(!1);var p=Le.dirname(t);c.fs.exists(p,function(m){m||c.makeDir(p),c.fs.open(t,"w",438,function(E,T){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,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)})})})})}):T?c.fs.write(T,e,0,e.length,0,function(){c.fs.close(T,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let h=Le.join(i,u),p=e.fs.statSync(h);(!o||o.test(h))&&l.push(Le.normalize(h)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Le.join(t,u),r.fs.stat(u,function(h,p){if(h)return e(h);p&&(i.push(Le.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(m,E){if(m)return e(m);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return Sl[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case bl.STORED:return"STORED ("+t+")";case bl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.posix.join(".",e)};ve.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ve.sanitize=function(t,e){t=Le.resolve(Le.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Le.normalize(Le.join(t,r.slice(i,o).join(Le.sep)));if(c.indexOf(t)===0)return c}return Le.normalize(Le.join(t,Le.basename(e)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};ve.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};ve.isWin=yg;ve.crcTable=Sl});var Rl=ie((B1,Tl)=>{var Eg=ce("path");Tl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Eg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Dl=ie((z1,Cl)=>{Cl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=ie((F1,ir)=>{ir.exports=Al();ir.exports.Constants=ba();ir.exports.Errors=cs();ir.exports.FileAttr=Rl();ir.exports.decoder=Dl()});var Ol=ie((U1,kl)=>{var sn=sr(),F=sn.Constants;kl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,p=0,m=0,E=0,T=0,_=0,v=0;t|=sn.isWin?2560:768,r|=F.FLG_EFS;let I={extraLen:0},S=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,N=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&F.FLG_EFS)>0},set flags_efs(y){y?r|=F.FLG_EFS:r&=~F.FLG_EFS},get flags_desc(){return(r&F.FLG_DESC)>0},set flags_desc(y){y?r|=F.FLG_DESC:r&=~F.FLG_DESC},get method(){return i},set method(y){switch(y){case F.STORED:this.version=10;case F.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=S(y)},get timeHighByte(){return N(o>>>8)},get crc(){return c},set crc(y){c=S(y)},get compressedSize(){return l},set compressedSize(y){l=S(y)},get size(){return u},set size(y){u=S(y)},get fileNameLength(){return h},set fileNameLength(y){h=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return m},set commentLength(y){m=y},get diskNumStart(){return E},set diskNumStart(y){E=S(y)},get inAttr(){return T},set inAttr(y){T=S(y)},get attr(){return _},set attr(y){_=S(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return v},set offset(y){v=S(y)},get encrypted(){return(r&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+h+p+m},get realDataOffset(){return v+F.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var D=y.slice(v,v+F.LOCHDR);if(D.readUInt32LE(0)!==F.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=D.readUInt16LE(F.LOCVER),I.flags=D.readUInt16LE(F.LOCFLG),I.flags_desc=(I.flags&F.FLG_DESC)>0,I.method=D.readUInt16LE(F.LOCHOW),I.time=D.readUInt32LE(F.LOCTIM),I.crc=D.readUInt32LE(F.LOCCRC),I.compressedSize=D.readUInt32LE(F.LOCSIZ),I.size=D.readUInt32LE(F.LOCLEN),I.fnameLen=D.readUInt16LE(F.LOCNAM),I.extraLen=D.readUInt16LE(F.LOCEXT);let k=v+F.LOCHDR+I.fnameLen,M=k+I.extraLen;return y.slice(k,M)},loadFromBinary:function(y){if(y.length!==F.CENHDR||y.readUInt32LE(0)!==F.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(F.CENVEM),e=y.readUInt16LE(F.CENVER),r=y.readUInt16LE(F.CENFLG),i=y.readUInt16LE(F.CENHOW),o=y.readUInt32LE(F.CENTIM),c=y.readUInt32LE(F.CENCRC),l=y.readUInt32LE(F.CENSIZ),u=y.readUInt32LE(F.CENLEN),h=y.readUInt16LE(F.CENNAM),p=y.readUInt16LE(F.CENEXT),m=y.readUInt16LE(F.CENCOM),E=y.readUInt16LE(F.CENDSK),T=y.readUInt16LE(F.CENATT),_=y.readUInt32LE(F.CENATX),v=y.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(F.LOCHDR);return y.writeUInt32LE(F.LOCSIG,0),y.writeUInt16LE(e,F.LOCVER),y.writeUInt16LE(r,F.LOCFLG),y.writeUInt16LE(i,F.LOCHOW),y.writeUInt32LE(o,F.LOCTIM),y.writeUInt32LE(c,F.LOCCRC),y.writeUInt32LE(l,F.LOCSIZ),y.writeUInt32LE(u,F.LOCLEN),y.writeUInt16LE(h,F.LOCNAM),y.writeUInt16LE(I.extraLen,F.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(F.CENHDR+h+p+m);return y.writeUInt32LE(F.CENSIG,0),y.writeUInt16LE(t,F.CENVEM),y.writeUInt16LE(e,F.CENVER),y.writeUInt16LE(r,F.CENFLG),y.writeUInt16LE(i,F.CENHOW),y.writeUInt32LE(o,F.CENTIM),y.writeUInt32LE(c,F.CENCRC),y.writeUInt32LE(l,F.CENSIZ),y.writeUInt32LE(u,F.CENLEN),y.writeUInt16LE(h,F.CENNAM),y.writeUInt16LE(p,F.CENEXT),y.writeUInt16LE(m,F.CENCOM),y.writeUInt16LE(E,F.CENDSK),y.writeUInt16LE(T,F.CENATT),y.writeUInt32LE(_,F.CENATX),y.writeUInt32LE(v,F.CENOFF),y},toJSON:function(){let y=function(D){return D+" 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(u),fileNameLength:y(h),extraLength:y(p),commentLength:y(m),diskNumStart:E,inAttr:T,attr:_,offset:v,centralHeaderSize:y(F.CENHDR+h+p+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Nl=ie((q1,Pl)=>{var or=sr(),me=or.Constants;Pl.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(l,u){let h=l.toString(16).toUpperCase();for(;h.length<u;)h="0"+h;return"0x"+h};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Sa=ie(va=>{va.EntryHeader=Ol();va.MainHeader=Nl()});var Ml=ie((j1,Ll)=>{Ll.exports=function(t){var e=ce("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var p=0;p<c.length;p++){var m=c[p];m.copy(u,h),h+=m.length}i&&i(u)}),o.end(t)}}}});var zl=ie((G1,Bl)=>{var bg=+(process.versions?process.versions.node:"").split(".")[0]||0;Bl.exports=function(t,e){var r=ce("zlib");let i=bg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),p=0;h.fill(0);for(var m=0;m<l.length;m++){var E=l[m];E.copy(h,p),p+=E.length}o&&o(h)}),c.end(t)}}}});var jl=ie((W1,Hl)=>{"use strict";var{randomFillSync:Fl}=ce("crypto"),vg=cs(),Sg=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,Ul=(t,e)=>Sg[(t^e)&255]^t>>>8,Xr=()=>typeof Fl=="function"?Fl(Buffer.alloc(12)):Xr.node();Xr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ds={genSalt:Xr};function ls(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}ls.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ul(e[0],t),e[1]+=e[0]&255,e[1]=ql(e[1],134775813)+1,e[2]=Ul(e[2],e[1]>>>24),t};ls.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return ql(t,t^1)>>8&255};function Ig(t){let e=new ls(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Ag(t){let e=new ls(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ig(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Rg(t){Buffer.isBuffer(t)&&t.length>=12?ds.genSalt=function(){return t.slice(0,12)}:t==="node"?ds.genSalt=Xr.node:ds.genSalt=Xr}function Cg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ag(r),c=ds.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Hl.exports={decrypt:Tg,encrypt:Cg,_salter:Rg}});var Gl=ie(us=>{us.Deflater=Ml();us.Inflater=zl();us.ZipCrypto=jl()});var Aa=ie(($1,Wl)=>{var se=sr(),Dg=Sa(),Se=se.Constants,Ia=Gl();Wl.exports=function(t,e){var r=new Dg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),p=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:se.decoder;p=E.hasOwnProperty("efs")?E.efs:!1;function T(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(h=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(se.crc32(y)!==r.localHeader.crc)return!1}else{let D={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Se.LOCSIG||e.readUInt32LE(k)==Se.CENSIG)throw se.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Se.EXTSIG)D.crc=e.readUInt32LE(k+Se.EXTCRC),D.compressedSize=e.readUInt32LE(k+Se.EXTSIZ),D.size=e.readUInt32LE(k+Se.EXTLEN);else if(e.readUInt16LE(k+12)===19280)D.crc=e.readUInt32LE(k+Se.EXTCRC-4),D.compressedSize=e.readUInt32LE(k+Se.EXTSIZ-4),D.size=e.readUInt32LE(k+Se.EXTLEN-4);else throw se.Errors.DESCRIPTOR_UNKNOWN();if(D.compressedSize!==r.compressedSize||D.size!==r.size||D.crc!==r.crc)throw se.Errors.DESCRIPTOR_FAULTY();if(se.crc32(y)!==D.crc)return!1}return!0}function v(y,D,k){if(typeof D>"u"&&typeof y=="string"&&(k=y,y=void 0),c)return y&&D&&D(Buffer.alloc(0),se.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=T();if(M.length===0)return y&&D&&D(M),M;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw se.Errors.INVALID_PASS_PARAM();M=Ia.ZipCrypto.decrypt(M,r,k)}var B=Buffer.alloc(r.size);switch(r.method){case se.Constants.STORED:if(M.copy(B),_(B))return y&&D&&D(B),B;throw y&&D&&D(B,se.Errors.BAD_CRC()),se.Errors.BAD_CRC();case se.Constants.DEFLATED:var J=new Ia.Inflater(M,r.size);if(y)J.inflateAsync(function(V){V.copy(V,0),D&&(_(V)?D(V):D(V,se.Errors.BAD_CRC()))});else{if(J.inflate(B).copy(B,0),!_(B))throw se.Errors.BAD_CRC(`"${E.decode(i)}"`);return B}break;default:throw y&&D&&D(Buffer.alloc(0),se.Errors.UNKNOWN_METHOD()),se.Errors.UNKNOWN_METHOD()}}function I(y,D){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&D&&D(T()),T();if(l.length&&!c){var k;switch(r.method){case se.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),y&&D&&D(k),k;default:case se.Constants.DEFLATED:var M=new Ia.Deflater(l);if(y)M.deflateAsync(function(J){k=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(k),D&&D(k)});else{var B=M.deflate();return r.compressedSize=B.length,B}M=null;break}}else if(y&&D)D(Buffer.alloc(0));else return Buffer.alloc(0)}function S(y,D){return se.readBigUInt64LE(y,D)}function C(y){try{for(var D=0,k,M,B;D+4<y.length;)k=y.readUInt16LE(D),D+=2,M=y.readUInt16LE(D),D+=2,B=y.slice(D,D+M),D+=M,Se.ID_ZIP64===k&&N(B)}catch{throw se.Errors.EXTRA_FIELD_PARSE_ERROR()}}function N(y){var D,k,M,B;y.length>=Se.EF_ZIP64_SCOMP&&(D=S(y,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=D)),y.length>=Se.EF_ZIP64_RHO&&(k=S(y,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=k)),y.length>=Se.EF_ZIP64_DSN&&(M=S(y,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=M)),y.length>=Se.EF_ZIP64_DSN+4&&(B=y.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(y){i=se.toBuffer(y,E.encode);var D=i[i.length-1];c=D===47||D===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,C(y)},get comment(){return E.decode(o)},set comment(y){if(o=se.toBuffer(y,E.encode),r.commentLength=o.length,o.length>65535)throw se.Errors.COMMENT_TOO_LONG()},get name(){var y=E.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=se.toBuffer(y,se.decoder.encode),!c&&l.length?(r.size=l.length,r.method=se.Constants.DEFLATED,r.crc=se.crc32(y),r.changed=!0):r.method=se.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,D){r.changed?y(l):v(!0,y,D)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),D=se.Constants.CENHDR;return i.copy(y,D),D+=i.length,u.copy(y,D),D+=r.extraLength,o.copy(y,D),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let D=r.localHeaderToBinary(),k=Buffer.alloc(D.length+i.length+r.extraLocalLength);return D.copy(k,y),y+=D.length,i.copy(k,y),y+=i.length,h.copy(k,y),y+=h.length,k},toJSON:function(){let y=function(D){return"<"+(D&&D.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 Jl=ie((J1,$l)=>{var Kl=Aa(),kg=Sa(),We=sr();$l.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,u=null;let h=new Set,p=e,{noSort:m,decoder:E}=p;t?v(p.readEntries):l=!0;function T(){let S=new Set;for(let C of Object.keys(i)){let N=C.split("/");if(N.pop(),!!N.length)for(let y=0;y<N.length;y++){let D=N.slice(0,y+1).join("/")+"/";S.add(D)}}for(let C of S)if(!(C in i)){let N=new Kl(p);N.entryName=C,N.attr=16,N.temporary=!0,r.push(N),i[N.entryName]=N,h.add(N)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/We.Constants.CENHDR)throw We.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,C=0;C<r.length;C++){var N=S,y=new Kl(p,t);y.header=t.slice(N,N+=We.Constants.CENHDR),y.entryName=t.slice(N,N+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(N,N+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(N,N+y.header.commentLength)),S+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}h.clear(),T()}function v(S){var C=t.length-We.Constants.ENDHDR,N=Math.max(0,C-65535),y=N,D=t.length,k=-1,M=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(N=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===We.Constants.ENDSIG){k=C,M=C,D=C+We.Constants.ENDHDR,y=C-We.Constants.END64HDR;continue}if(t.readUInt32LE(C)===We.Constants.END64SIG){y=N;continue}if(t.readUInt32LE(C)===We.Constants.ZIP64SIG){k=C,D=C+We.readBigUInt64LE(t,C+We.Constants.ZIP64SIZE)+We.Constants.ZIP64LEAD;break}}if(k==-1)throw We.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,D)),c.commentLength&&(o=t.slice(M+We.Constants.ENDHDR)),S&&_()}function I(){r.length>1&&!m&&r.sort((S,C)=>S.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(S=>!h.has(S))},get comment(){return E.decode(o)},set comment(S){o=We.toBuffer(S,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||_(),i[S]||null},setEntry:function(S){l||_(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,C=!0){l||_();let N=i[S];this.getEntryChildren(N,C).map(D=>D.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||_();let C=i[S],N=r.indexOf(C);N>=0&&(r.splice(N,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,C=!0){if(l||_(),typeof S=="object")if(S.isDirectory&&C){let N=[],y=S.entryName;for(let D of r)D.entryName.startsWith(y)&&N.push(D);return N}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let C=this.getEntryChildren(S);return C.includes(S)?C.length-1:C.length}return 0},compressToBuffer:function(){l||_(),I();let S=[],C=[],N=0,y=0;c.size=0,c.offset=0;let D=0;for(let B of this.entries){let J=B.getCompressedData();B.header.offset=y;let V=B.packLocalHeader(),ee=V.length+J.length;y+=ee,S.push(V),S.push(J);let X=B.packCentralHeader();C.push(X),c.size+=X.length,N+=ee+X.length,D++}N+=c.mainHeaderSize,c.offset=y,c.totalEntries=D,y=0;let k=Buffer.alloc(N);for(let B of S)B.copy(k,y),y+=B.length;for(let B of C)B.copy(k,y),y+=B.length;let M=c.toBinary();return o&&o.copy(M,We.Constants.ENDHDR),M.copy(k,y),t=k,l=!1,k},toAsyncBuffer:function(S,C,N,y){try{l||_(),I();let D=[],k=[],M=0,B=0,J=0;c.size=0,c.offset=0;let V=function(ee){if(ee.length>0){let X=ee.shift(),ye=X.entryName+X.extra.toString();N&&N(ye),X.getCompressedDataAsync(function(fe){y&&y(ye),X.header.offset=B;let P=X.packLocalHeader(),q=P.length+fe.length;B+=q,D.push(P),D.push(fe);let W=X.packCentralHeader();k.push(W),c.size+=W.length,M+=q+W.length,J++,V(ee)})}else{M+=c.mainHeaderSize,c.offset=B,c.totalEntries=J,B=0;let X=Buffer.alloc(M);D.forEach(function(fe){fe.copy(X,B),B+=fe.length}),k.forEach(function(fe){fe.copy(X,B),B+=fe.length});let ye=c.toBinary();o&&o.copy(ye,We.Constants.ENDHDR),ye.copy(X,B),t=X,l=!1,S(X)}};V(Array.from(this.entries))}catch(D){C(D)}}}}});var Zl=ie((V1,Yl)=>{var _e=sr(),we=ce("path"),Og=Aa(),Pg=Jl(),Tn=(...t)=>_e.findLast(t,e=>typeof e=="boolean"),Vl=(...t)=>_e.findLast(t,e=>typeof e=="string"),Ng=(...t)=>_e.findLast(t,e=>typeof e=="function"),Lg={noSort:!1,readEntries:!1,method:_e.Constants.NONE,fs:null};Yl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Lg);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 Pg(r,i),{canonical:l,sanitize:u,zipnamefix:h}=_e;function p(_){if(_&&c){var v;if(typeof _=="string"&&(v=c.getEntry(we.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(v=c.getEntry(_.entryName)),v)return v}return null}function m(_){let{join:v,normalize:I,sep:S}=we.posix;return v(we.isAbsolute(_)?"/":".",I(S+_.split("\\").join(S)+S))}function E(_){return _ instanceof RegExp?(function(v){return function(I){return v.test(I)}})(_):typeof _!="function"?()=>!0:_}let T=(_,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",we.relative(_,v)+I};return{readFile:function(_,v){var I=p(_);return I&&I.getData(v)||null},childCount:function(_){let v=p(_);if(v)return c.getChildCount(v)},readFileAsync:function(_,v){var I=p(_);I?I.getDataAsync(v):v(null,"getEntry failed for:"+_)},readAsText:function(_,v){var I=p(_);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(_,v,I){var S=p(_);S?S.getDataAsync(function(C,N){if(N){v(C,N);return}C&&C.length?v(C.toString(I||"utf8")):v("")}):v("")},deleteFile:function(_,v=!0){var I=p(_);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(_){var v=p(_);v&&c.deleteEntry(v.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,v){var I=p(_);I&&(I.comment=v)},getZipEntryComment:function(_){var v=p(_);return v&&v.comment||""},updateFile:function(_,v){var I=p(_);I&&I.setData(v)},addLocalFile:function(_,v,I,S){if(o.fs.existsSync(_)){v=v?m(v):"";let C=we.win32.basename(we.win32.normalize(_));v+=I||C;let N=o.fs.statSync(_),y=N.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);N.isDirectory()&&(v+=o.sep),this.addFile(v,y,S,N)}else throw _e.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,v){_=typeof _=="object"?_:{localPath:_};let I=we.resolve(_.localPath),{comment:S}=_,{zipPath:C,zipName:N}=_,y=this;o.fs.stat(I,function(D,k){if(D)return v(D,!1);C=C?m(C):"";let M=we.win32.basename(we.win32.normalize(I));if(C+=N||M,k.isFile())o.fs.readFile(I,function(B,J){return B?v(B,!1):(y.addFile(C,J,S,k),setImmediate(v,void 0,!0))});else if(k.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),S,k),setImmediate(v,void 0,!0)})},addLocalFolder:function(_,v,I){if(I=E(I),v=v?m(v):"",_=we.normalize(_),o.fs.existsSync(_)){let S=o.findFiles(_),C=this;if(S.length)for(let N of S){let y=we.join(v,T(_,N));I(y)&&C.addLocalFile(N,we.dirname(y))}}else throw _e.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,v,I,S){S=E(S),I=I?m(I):"",_=we.normalize(_);var C=this;o.fs.open(_,"r",function(N){if(N&&N.code==="ENOENT")v(void 0,_e.Errors.FILE_NOT_FOUND(_));else if(N)v(void 0,N);else{var y=o.findFiles(_),D=-1,k=function(){if(D+=1,D<y.length){var M=y[D],B=T(_,M).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(M,function(J,V){J&&v(void 0,J),V.isFile()?o.fs.readFile(M,function(ee,X){ee?v(void 0,ee):(C.addFile(I+B,X,"",V),k())}):(C.addFile(I+B+"/",Buffer.alloc(0),"",V),k())}):process.nextTick(()=>{k()})}else v(!0,void 0)};k()}})},addLocalFolderAsync2:function(_,v){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=we.resolve(m(_.localPath));let{zipPath:S,filter:C,namefix:N}=_;C instanceof RegExp?C=(function(k){return function(M){return k.test(M)}})(C):typeof C!="function"&&(C=function(){return!0}),S=S?m(S):"",N=="latin1"&&(N=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof N!="function"&&(N=k=>k);let y=k=>we.join(S,N(T(localPath,k))),D=k=>we.win32.basename(we.win32.normalize(N(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?v(void 0,_e.Errors.FILE_NOT_FOUND(localPath)):k?v(void 0,k):o.findFilesAsync(localPath,function(M,B){if(M)return v(M);B=B.filter(J=>C(y(J))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(J,V){return function(ee,X){if(ee||X===!1)return setImmediate(J,ee,!1);I.addLocalFileAsync({localPath:V,zipPath:we.dirname(y(V)),zipName:D(V)},J)}},v))})})},addLocalFolderPromise:function(_,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},v),(C,N)=>{C&&S(C),N&&I(this)})})},addFile:function(_,v,I,S){_=h(_);let C=p(_),N=C!=null;N||(C=new Og(i),C.entryName=_),C.comment=I||"";let y=typeof S=="object"&&S instanceof o.fs.Stats;y&&(C.header.time=S.mtime);var D=C.isDirectory?16:0;let k=C.isDirectory?16384:32768;return y?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=C.isDirectory?493:420,D=(D|k<<16)>>>0,C.attr=D,C.setData(v),N||c.setEntry(C),C},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return p(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,v,I,S,C,N){S=Tn(!1,S),C=Tn(!1,C),I=Tn(!0,I),N=Vl(C,N);var y=p(_);if(!y)throw _e.Errors.NO_ENTRY();var D=l(y.entryName),k=u(v,N&&!y.isDirectory?N:I?D:we.basename(D));if(y.isDirectory){var M=c.getEntryChildren(y);return M.forEach(function(V){if(V.isDirectory)return;var ee=V.getData();if(!ee)throw _e.Errors.CANT_EXTRACT_FILE();var X=l(V.entryName),ye=u(v,I?X:we.basename(X));let fe=C?V.header.fileAttr:void 0;o.writeFileTo(ye,ee,S,fe)}),!0}var B=y.getData(c.password);if(!B)throw _e.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!S)throw _e.Errors.CANT_OVERRIDE();let J=C?_.header.fileAttr:void 0;return o.writeFileTo(k,B,S,J),!0},test:function(_){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,v,I,S){if(I=Tn(!1,I),S=Vl(I,S),v=Tn(!1,v),!c)throw _e.Errors.NO_ZIP();c.entries.forEach(function(C){var N=u(_,l(C.entryName));if(C.isDirectory){o.makeDir(N);return}var y=C.getData(S);if(!y)throw _e.Errors.CANT_EXTRACT_FILE();let D=I?C.header.fileAttr:void 0;o.writeFileTo(N,y,v,D);try{o.fs.utimesSync(N,C.header.time,C.header.time)}catch{throw _e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,v,I,S){if(S=Ng(v,I,S),I=Tn(!1,I),v=Tn(!1,v),!S)return new Promise((k,M)=>{this.extractAllToAsync(_,v,I,function(B){B?M(B):k(this)})});if(!c){S(_e.Errors.NO_ZIP());return}_=we.resolve(_);let C=k=>u(_,we.normalize(l(k.entryName))),N=(k,M)=>new Error(k+': "'+M+'"'),y=[],D=[];c.entries.forEach(k=>{k.isDirectory?y.push(k):D.push(k)});for(let k of y){let M=C(k),B=I?k.header.fileAttr:void 0;try{o.makeDir(M),B&&o.fs.chmodSync(M,B),o.fs.utimesSync(M,k.header.time,k.header.time)}catch{S(N("Unable to create folder",M))}}D.reverse().reduce(function(k,M){return function(B){if(B)k(B);else{let J=we.normalize(l(M.entryName)),V=u(_,J);M.getDataAsync(function(ee,X){if(X)k(X);else if(!ee)k(_e.Errors.CANT_EXTRACT_FILE());else{let ye=I?M.header.fileAttr:void 0;o.writeFileToAsync(V,ee,v,ye,function(fe){fe||k(N("Unable to write file",V)),o.fs.utimes(V,M.header.time,M.header.time,function(P){P?k(N("Unable to set times",V)):k()})})}})}}},S)()},writeZip:function(_,v){if(arguments.length===1&&typeof _=="function"&&(v=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(_,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(_,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((C,N)=>{!_&&i.filename&&(_=i.filename),_||N("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let D=k=>k?C(k):N("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,I,S,D)},N)})},toBufferPromise:function(){return new Promise((_,v)=>{c.toAsyncBuffer(_,v)})},toBuffer:function(_,v,I,S){return typeof _=="function"?(c.toAsyncBuffer(_,v,I,S),null):c.compressToBuffer()}}}});import{execFile as I_,spawn as A_,spawnSync as cA}from"node:child_process";import{promisify as T_}from"node:util";function C_(t){if(process.platform!=="win32")return!1;if(Kf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Kf,"").toLowerCase();return R_.has(r)}function $f(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return C_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function lt(t,e=[],r={}){return A_(t,e,$f(t,r))}function Jf(t,e=[],r={}){return D_(t,e,$f(t,r))}var R_,Kf,D_,yn=Ze(()=>{"use strict";R_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Kf=/\.(cmd|bat|ps1)$/i;D_=T_(I_)});var j0=ie(ke=>{"use strict";var L=H;(function(t,e){let r=H,i=t();for(;;)try{if(-parseInt(r(870))/1+parseInt(r(1234))/2+parseInt(r(1050))/3+-parseInt(r(1568))/4*(-parseInt(r(832))/5)+-parseInt(r(363))/6+-parseInt(r(829))/7+parseInt(r(1762))/8===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(yo,624207);var pE=Object[L(1529)+L(1021)],gE=Object[L(805)+"opertyNames"],z0=(t,e)=>function(){return t&&(e=(0,t[{PGlfz:function(c,l){return c(l)}}[L(388)](gE,t)[0]])(t=0)),e},mE=(t,e)=>{for(var r in e)pE(t,r,{get:e[r],enumerable:!0})};function wE(){return P0||(P0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _E(){let t=L;return N0||(N0=[IDBCursor[t(497)+"e"][t(392)],IDBCursor[t(497)+"e"].continue,IDBCursor.prototype[t(446)+t(1073)+"ey"]])}function yE(t){let e=L,r={wMXVM:"success",vXOJn:e(1304),PaBWC:function(o,c){return o(c)},MxnXh:function(o){return o()},ASoMO:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={atnMz:function(E,T){return r[H(1534)](E,T)},wtumj:function(E){return r[H(1289)](E)}},h=()=>{let E=H;t[E(1699)+E(1262)+"ner"](r.wMXVM,p),t[E(1699)+E(1262)+"ner"](r[E(1078)],m)},p=()=>{u[H(746)](o,u.atnMz(Mt,t.result)),h()},m=()=>{let E=H;u[E(746)](c,t[E(1304)]),u[E(1815)](h)};t[l(510)+l(1469)](r[l(1686)],p),t["addEvent"+l(1469)](r[l(1078)],m)});return i[e(1491)](o=>{let c=e;r[c(409)](o,IDBCursor)&&Xc[c(941)](o,t)})[e(1554)](()=>{}),bo[e(941)](i,t),i}function H(t,e){t=t-347;let r=yo(),i=r[t];if(H.kvCSId===void 0){var o=function(h){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let T=0,_,v,I=0;v=h.charAt(I++);~v&&(_=T%4?_*64+v:v,T++%4)?m+=String.fromCharCode(255&_>>(-2*T&6)):0)v=p.indexOf(v);for(let T=0,_=m.length;T<_;T++)E+="%"+("00"+m.charCodeAt(T).toString(16)).slice(-2);return decodeURIComponent(E)};H.cuUwva=o,H.AoSuSV={},H.kvCSId=!0}let c=r[0],l=t+c,u=H.AoSuSV[l];return u?i=u:(i=H.cuUwva(i),H.AoSuSV[l]=i),i}function EE(t){let e=L,r={jeztj:e(1304),QfBnB:"abort",ujDjM:function(o){return o()},mRxZs:e(542)+"or"};if(Eo.has(t))return;let i=new Promise((o,c)=>{let l=e,u=()=>{let m=H;t[m(1699)+m(1262)+m(1231)](m(479),h),t["removeEv"+m(1262)+"ner"](r[m(776)],p),t[m(1699)+m(1262)+m(1231)](r[m(1606)],p)},h=()=>{r[H(866)](o),u()},p=()=>{let m=H;c(t[m(1304)]||new DOMException(m(542)+"or",r[m(1290)])),r.ujDjM(u)};t[l(510)+l(1469)](l(479),h),t[l(510)+l(1469)](r[l(776)],p),t[l(510)+l(1469)](r.QfBnB,p)});Eo[e(941)](t,i)}function bE(t){vo={Faqpi:function(i,o){return i(o)}}[L(702)](t,vo)}function vE(t){let e=L,r={vZfrl:e(1646),RdvXP:function(i,o){return i(o)},krrLB:function(i,o){return i===o},EjBLD:function(i,o){return i in o},fWcyk:e(1072)+e(381),cnxDy:function(i){return i()}};return r.krrLB(t,IDBDatabase[e(497)+"e"]["transact"+e(564)])&&!r[e(781)](r.fWcyk,IDBTransaction[e(497)+"e"])?function(i,...o){let c=e;if(r[c(1115)]==="ssidx")_0x811d92.d=(l,u)=>{let h=c;for(var p in u)_0x214fd8.o(u,p)&&!_0x55cde0.o(l,p)&&_0x1f0828[h(1529)+h(1021)](l,p,{enumerable:!0,get:u[p]})};else{let l=t.call(Bi(this),i,...o);return Zc[c(941)](l,i.sort?i[c(894)]():[i]),r.RdvXP(Mt,l)}}:r[e(1312)](_E).includes(t)?function(...i){let o=e;return t[o(898)](Bi(this),i),Mt(Xc[o(633)](this))}:function(...i){return Mt(t[e(898)](Bi(this),i))}}function SE(t){let e=L,r={MBYqo:e(1588),hFXgQ:function(i,o){return i(o)},rBsfA:function(i,o){return i instanceof o},ZYBJk:function(i,o,c){return i(o,c)},wXeKV:function(i){return i()}};return typeof t===r.MBYqo?r[e(1308)](vE,t):(r[e(872)](t,IDBTransaction)&&r.hFXgQ(EE,t),r[e(1089)](F0,t,r.wXeKV(wE))?new Proxy(t,vo):t)}function Mt(t){let e=L,r={SYIYy:function(o,c){return o instanceof c},WnBWm:function(o,c){return o(c)},sreVW:function(o,c){return o!==c}};if(r[e(560)](t,IDBRequest))return yE(t);if(wo[e(1596)](t))return wo[e(633)](t);let i=r[e(1364)](SE,t);return r.sreVW(i,t)&&(wo[e(941)](t,i),bo[e(941)](i,t)),i}function yo(){let t=["zMzmAw5L","rwjmsem","tLnfqxq","Aw1LCYbPBIa","uM9OtLO","zxjYtM8","Avb5zwO","AwztqMi","s1LntLK","Dw50","A1nYu3u","quXiz2m","zxjFywnRx20","s3z1wMG","CMvpCKi","C2v0sxrLBq","ig1LC3nHz2u","z2v0sxrLBq","CIb0DhDjra","Cg9LDem","ChbmBui","yw1LoIa","mteWnZuYntz6z1Hqy3a","ueLYuuC","CgzsBKq","yMrKv3O","D3nZoI8V","BwLZzq","z1DlAva","zM9Yy2u","zufJAW","vw5PBxbSzw0","Cwz5wLy","BezSDxnO","Axzpwee","rLLMzNC","CKLWDhe","CMfUzg9T","yxLoAuu","CLb1rhO","sNLNwMS","CufRrgq","y3vYDMfSDwu","EKjrDwO","CNzHBa","rKHQq3m","q2fQyxi","reLXrve","x2n1CNnVCKy","ExvWC2u","CMLLC0nVDw4","wKToy0W","EMnuDgi","z2v0s2v5","m3W0Fdj8mhW","CKrQAMi","C2v0q3vYC28","vK1YChK","ChPkrLG","sKj4BfC","q1bPzg8","z2vtEw5J","yM9KEq","wxnbD1e","Dhr3Awq","Bwf4uMv0CMK","Exf0tui","DunHAfC","quXm","ihrPBwvZ","uvHvDLi","rMPNC2q","twLZC2LUzYa","zxjFAxnFywm","C0fbwvi","D3r1BwO","y1b6sui","x29UtwvZC2e","ExfirKy","CgvYC2LZDgu","qMPythe","tuntrvm","wfHLCui","C2HPzNq","ChjVy2vZCW","tLvStK0","C2HKDuy","y2uGBM90igK","D2LSBfjLy28","rvv6v20","x2LUAxq","uM9pu0u","yMfJA3vWigu","v054AvG","y2XVC2u","tKfUChe","wNP6vwG","AeLlsK8","y3ruAw1LB3u","ww1iq3G","s3bjqxm","x29UugfNzu4","CMvZzxruCMK","suvtx0vsuK8","sff0s0G","vwfjrKe","AhPPB3u","u3vTvxe","CMvHzhDYAxq","mdaWmdaWmda","A2v5","zuLZu1O","Ee1csNq","q0Xpu0ve","yLDRy1e","x3bYzwzPEa","tuztsvO","yNL0zu9MzNm","vhHREgW","q2Hqs3C","z2vY","Aw9xv2O","BwPyEw8","DeLUDgvYy2u","u0LcEgq","Ahb4DLG","v25vqw8","x3bHDgHlzxK","AxnAzxjV","zfnwDNy","DujhzfG","x2rLC3rYB3K","AxnmB25N","nJe2mZi0mMLkAgXetG","ENzqs0i","z2v0q3vYC28","DeLK","z3zkve0","uNjyyuq","mxWZFdr8mhW","ELvbtK4","r09guva","CK9kue8","nxWY","zg1RDNG","y29UC3rYDwm","zhvKqLy","wuryCNa","yxv0BW","BhPHsMu","DMfSDwu","B3jLtMfTzxm","BMnVzgLUzW","A1npC2W","tMn0vNy","qKjSsuO","rNvQBhu","EuH1wKO","ueDSzNO","vefzCgm","vgf3s2O","Bhzky3G","ywr2yw5Jzq","C1HivMi","Dg9cExrLCW","B25szwnLAxy","tMjfC3a","BxnN","zv90Aw1LB3u","BujSrKi","CMvWBgfJzui","DhjHBNnHy3q","t1bftL9fuLi","A2v0ignVBNm","CgLUz09Uy2u","ugPLwva","ALzcBfK","BNrLCG","CNjVCK1LC3m","qvnVtu8","AxDcr1a","rwX4q3q","vfDKCwG","x2vUzhbVAw4","BgvUz3rO","swvrzLK","swPXtKq","Bgzmqwq","wfnwz3C","Axnby2TdBgu","y2XVC2veqG","DKryENi","B25dBg9Zzq","m3WXFdj8nhW","qNjPzgDL","s0rcz2q","wKjVExa","x29UrxjYB3i","BuXcsNm","zuP4zNK","Bxv6swq","v3nxtMu","icSG","Cfz6y0m","igXHCMDLCIa","qLvJt24","zxjYtxnN","BKXPBMu","zhLJB3m","tgf0rhK","vfPLsuO","qKfRqNa","CMvZDwX0","y3jLyxrLrwW","A2TtwfK","rxjYB3jdB2q","y29UDgLUDwu","z2PAuMW","svfwwxe","CM92AwrLigi","wMfQqLi","tMv3qNa","wMHzshm","EhvPBvG","sgLqD0u","CMngshO","vKHVweO","y3vYC29Y","EerJEfK","CNjgBxu","qvDtq2W","s0zHuKC","Aw5JBhvKzxm","DxrMofDYAxq","r0f0AhC","tLjhqw8","qMrftw4","CNnVCL92ywW","CMvKDwnL","qNjsvwO","zfbnqu0","vwr5A00","CLzUqMy","z2vrDwv1zuW","DxLfEfy","r1fjAgy","DLnwtLO","zhP1yw8","s01bAfy","y29TCgXLDgu","C2X1tuG","y3jLyxrLq2W","q1bLsvu","BNzmteW","DhDVCMTdAge","Aw47y2HHCNm","zwn0","uK1tyxO","zKPiyuS","x2DLDeLUDgu","zgXLtgK","txnHB0m","sgDZB2m","swDPrKG","B25Uzwn0Aw4","DxnLCKLW","Ew1KD0G","ChjVDg90Exa","v1HVswi","qKDvz00","rxvzzwO","yMHxBhO","Ew9hBg8","Cg9W","rwPzr2i","Bg93","r3r0DxK","EwPntNi","qw1VDw50","CNnVCKzPBgu","ywrKrxzLBNq","B2LUDfjLywm","sw5Ry2m","DcbSAw1PDa","DfvZywy","x2nYzwf0zvm","D3n3r0m","seDnwfy","tuvtu0fhrv8","qu1Vq1q","lcbOB3n0BMe","mxW0Fda","u2rxy3i","t3jNwe0","AejHrhm","Du9zr0q","x2nSzwfYvgK","rNjVBNrPzxi","D3jPDgvvAw4","mNWW","BNruCMLLC0m","C3rYAw5NAwy","zNjVBu51Bwi","Bg9NsurozxC","yMXVy2TLza","zwnVBM5Ly3q","tg9Nsuq","DgfYz2v0","sNveA1m","zv9ZDwnJzxm","ugXmv2S","BwDYAuK","qwjVCNrfCNi","yw5ZzM9YBvq","x2rYB3bhBg8","x29Uq2XVC2u","rKfHCvG","sKPMBfy","z0TlvNK","D2HcqKq","CMvHzg9UBhK","zgfIzve","EefMwgS","EujTEey","BM5Ly3q","rxvZEM8","tvDvt0i","DLLxr2u","Dw5ZAwDUzwq","DfPlCM4","u1LjwxK","x2LZtwLUAvC","AefJA01LC3m","Au9VsvG","Aw9U","Dev2zw50","C2nYAxb0","EsbJBg9Zzwq","rvjst1i","Ce9vtxO","ExbZChC","CNzHBfzHBhu","qxHbEgG","C0TszNu","tw9KDwXL","nxWYFdz8m3W","Dg9Y","DgPjreK","vw5Oyw5KBgu","uxrhDLq","tKrPseK","Chf6s2q","uvDJqKy","s0DbtLm","C3bSAxq","qu5ouLG","AvHAu28","svzQt2K","EfH5qxu","B3bLBG","seHzvuu","Ae1LC3nHz2u","s3DQrKe","ywDLu2HVDW","DhnOweC","rLDt","zNH2vfa","twvZC2fNzuu","CNbTtuu","Ahn5Chq","r1PjDMq","rM5yBee","qvDVqKy","B2nRzxrtDwm","s1LpCuy","y29SBM8","CMvZzxrdB3u","uvfKCw8","yMjqDui","DgLTzw91DcW","rgXusgq","ihrVihjLDhi","sNjAqLm","De93CKW","suXgCw0","uMTSrhi","Aw5PDcbrB1m","zNDZxZeUmc4","ueXJBhu","rLHYt0O","yw5Nzq","tM1oB04","tMLnC0C","aaaaaaaaaaa","wK5Wuu0","CgfYC2u","zNb6Cfi","A0XcCwC","uer2AMC","CMvJzxzPzwq","DvjKEM0","x29Ut3bLBG","Bwv0Ag9K","z2v0","ywWGy3vYC28","x2HHBMrSzva","sefkDNG","q3vZDg9Tq2W","zMLSDgvY","CM92AwrLihy","D05szNu","AMLewee","Ec1TC2CTy3u","y3z1sMO","ufvbBMS","CuLXtfq","C3vJy2vZCW","x2nSzwfYugK","ywT1zwu","uxDvqK0","x2LUDgvYDMe","uLHHrK4","EKL1v1i","x3jLywr5q2W","sLnptLa","zxmGCMvHy2G","CMvTB3zLq2G","BMCGB3iGyw4","y2HLy2Tszwe","FdH8oxWY","yxnL","igzPzwXKoIa","t1PRyKK","CM11Ehu","DMX5wxy","v2zVy1C","senbsem","CgXLyxnLiha","tgP1y3m","EMXjrha","mNW1Fdf8na","AfrpzuK","yMjWreG","y3jLyxrLt3a","twTTuwO","v2XruKq","vff6AwW","B2zMC2v0","wvPvA0m","BNvTyMvY","tLP3CuO","B0noAMK","B25VCgvU","s01jDLy","ugn4rwG","AhLLuum","BNHuuLq","DgvZDa","DNnIA1G","z2v0qwXSs2u","vwzwuhy","x2HHBMrSzu8","wMHXEhG","y29UDgv4Da","Cu5IugO","Ahr0Chm6","zMX1C2HfEha","EwPKqK8","r1vZANq","y2XVC2uSihC","zKzqC2u","sK54Cem","rMfXCgK","AwXLx25HBwu","uhPKwha","ywnOzwqSihC","zcWG","ihjLy29UBMu","quTpD0q","A2jdyNy","yLzIAMK","CKLsDLG","zMzLCG","vxDWAgO","EK5nyu0","tNzlzMS","u2TPCcbWyxm","x3DZsw5ZDge","v3nTvNq","C3rYAw5N","zw5HyMXLuw8","rhrLAuK","rvrmCuy","q3nvA0i","AM9PBG","vgfN","z2v0q3vYCMu","C3bSAwnL","D2rmquK","B25JBg9Zzq","vMXssMW","C21xAMm","Aw5L","Dg9cExrLC0i","x3bPBMC","Dw5RBM93BIa","yxrLq291BNq","AwXLtMfTzq","ChvZAa","C2nHwgG","DMPyBK8","D3m6lY8","yw1owgO","wvLlr2i","A3rRvKW","q0Xpu0LorW","yxrUtxO","DfDwCu4","ru93yKK","ywnRtxnNswq","BfrPBwvVDxq","v3vxsKK","DvDev0K","y3jLyxrLrxi","BNjMCfO","uwnJywu","suHcs1y","Bg9N","sKX3AuK","z05eD0m","CgLUz0XVC3m","x19LC01Vzhu","yLfuAwO","x2LZsw5PDa","ExDRAwi","zMLvBvC","BMrSyNu","y1P5zu8","zw5XDwv1zq","u2zeqMy","sKj2DLa","q29UzMLN","CKHLCKy","BwLUAvbYB2C","EMXouNC","uNfuy3C","AMv6DgO","y29Kzq","B25TzxnZywC","AxjKy2K","sLzXCve","rwPcteq","Dujys0y","qKHcsMi","rhPnqxy","BwfW","C0XPC3rLBMu","mxWW","DxPUCeu","Def4ywm","Cgr3A3u","B3bLBKrc","ww96y1O","suTrrKe","ywXPzcb1CMW","wvPLD0S","tg9NsurozxC","ELPwt1O","whjzu1q","wxzbqLa","zMXYvKK","ELLMBMm","rMLACLK","Du5gseO","rezuzeC","z2v0t3DUuhi","tvfeEgm","CxPgs0m","AxnrB1nby2S","x0rctMfTzq","vu9uuee","zun0qxG","A3rTtve","DcbVzIbYyw4","A2rwAxC","zw1PDa","yxv0B21HDgK","ywDLrxzLBNq","DxjS","BeT5yxq","Ef9MCM9UDgK","weHYy0y","CffIsuS","C29NvvO","y2HLy2TdDxi","tffXyvq","Dg9oDw1Izxi","v25MzxG","x21LC3nHz2u","nte0nJq0ouPtvK5eCW","BefWt0i","BujWzg8","mJG1ntyZnuv0twfIrW","C3vIC3rYAw4","q3vZDg9Trxi","D09HwKS","BgLTAxq","qKjbEKW","uNjkvvK","sMP0EhG","pxv0zI04","BKPHAuO","Cgf5Bg9Hzfq","zK1JEMK","BgLUzw5V","sKvvD3C","AgvHzgvY","CgLUz19VBMm","y3Hdyw4","yxLmBfC","tNHgAwe","werTBw0","ywzL","yw5Hz2vY","C0z0CwO","B2nRzxrgywK","BgTsu2S","Avffz0q","AgDfy1y","z3Hithq","quvYEw8","uMvJB25Uzwm","x3DZ","u29nz1m","CM92AwrLihC","y3vYCMvUDeK","DwPeAK0","x3bYB3rVy28","DMvYC2LVBMm","BeTWswG","nZK4otC5tKDwEKLe","vfzTuxG","CKjZzKe","u0PfqKq","r2Dqr2i","x2fKzfDZtgK","yMrFzgLK","zxHWB3j0CW","ruP3yvm","CgTQvNy","B25cvKq","sMnrsMe","x21PBMLoyxy","Dg9tDhjPBMC","t2vdr28","v1jhs3y","vejfB0q","BwvZC2fNztO","CMTLCKDSB2i","CgrxANi","uMvHzcbWyxm","zgv2AwnLx2K","DhjPBq","D3jPDgu","C29YDa","q0vwuNO","uufVD3m","wMHSqK8","yxbWBhK","yNL0zxm","te1Otey","wLvvAhy","vu5Yq1u","zM9YrwfJAa","DNDIvKe","zMLSzw5HBwu","Dgv4DfbHEwW","x2LZtM9Kzq","u0TIqLG","BML0AwfSAxO","AfjeEw8","x2n1CNnVCK4","zw5wEKq","CM92AwrLige","z2v0u3rVCMe","sfLps3i","C2vAsNu","qMPMBfC","wxziuNG","rur5C2K","EuDyqvG","uMnRwvK","BeHHBMrSzxi","mxWZFdv8nhW","ysbTDxn0igi","z3HQzwS","x3nLBMrby2S","y3vYCMvUDeu","BMv4DcGPigm","BgPovw0","BM93","BwvKAwf0zwW","y291BNq","teD2EK4","C3rVCMu","vwjVyKO","v0L4Cfa","sLLJuxG","EgnzzhO","zNnvzgW","zMDrvKG","C2v0","AfrUD08","mhWXFdn8nhW","ruzyvwm","zgTmqLG","rwDxvLK","zwjJB3C","AhDky3C","Dfn1tvK","B21itMS","D0rJB3K","t3bLBKv2zw4","swj1tuG","rMLjt0S","x194x21Zz18","DgT5z3C","CLzHBhvLCW","BLveCha","z29UBMy","AwDHDg9Yt24","uuL0EvK","uePxue8","sMHXtNy","z1rqwu4","x29WDgLVBNm","B2fK","Cgu6ia","zw50","uezKreO","rw1ewe4","v1zuqNm","rgfXu28","yxbWzw5Kq2G","qNDhCgS","q291BNq","Exn6CwS","zfDVCMTLCKC","uwvgrMe","C3nHz2vfDMu","wgzOAhq","B3jRig9MzMW","thb1swe","Chv0","u3vkC3y","CwHxDvC","BNrfBMrWB2K","ExbL","Cg14Dha","C2TXufC","zxbxC2K","rgvKAwnHDgu","A0P2whu","tufyx1jfvfi","CMvJzwL2zwq","nhWZFdf8mNW","x25HDMLNyxq","shbYuxO","CMvHzhLtDge","BePWC08","ignVzgu6ia","yurJqM4","Ee9Hzu8","t01Qy2q","Bg5gq0i","reLWDfe","rxn0wKO","ALDXz2S","yNPtANy","wNfPA2m","q09otKvdveK","DgLUzYbZzxi","BK9pAwC","uev5zMm","sKH0Eve","x2LZtwLUAvq","CMToveu","sfjksvu","Cw9Zx18","re1XDM8","AwXK","B3bLCNr5","C2v0zgi","Dg1JzxK","whLcENO","r3L6qum","yw1L","BxnNsuq","vfbWvKy","AenSB3nLrxy","tuTZq3i","veDLr3e","C0nVDw50zxi","zMzMzG","zer0qvO","B3jpBMXPBMu","q2fWwuC","CMv0CNLdB3u","wvr6Bui","BLrUuuC","quPqveC","AgfZt3DUuhi","CunNCfe","zxjFDhrS","DxDtDeO","v1jZv3i","terYCxe","A0nmq1i","Cg93","x3DHAxq","ndaWmdHxue1jENm","Aw9Ul2PZB24","yMLUza","yNvMzMvY","sNrgA0G","Aw9UvgLTzw8","BKjUCve","v05ewMy","zwjdyuW","yw51Ce1LC3m","t1bftG","uMvhwhe","zNjVBuj5Dgu","mNW0Fdf8mhW","uurIv20","y2Lvywy","qLH1Aeq","qwXRruy","wgT5DhK","u1LmCe0","A3LcAwe","m3W0Fdf8mhW","B2jQzwn0u3q","uhjPBwfYEuS","zw5JB2rPBMC","rffvzxe","sxnICMW","lcbxzwjtB2m","DLHpsM4","BLHKrxK","qMHmrve","y29UBMvJDca","r2zfC0y","zgvIDwC","ywDLsgLKzq","uMLdExy","AgfUz2u","Aw5KzxHpzG","ywXty29Wzq","wLLcsMS","C01Usei","vhPvyxC","t0PrAwS","v2LUzg93","D1vNDLu","EMHVsvK","DMffzhO","DgLLCKPtt04","twvtDw4","Dg9iyxnO","Dg9VigXHCMC","BMTWvhK","ruPPDNC","EwXKtKC","CMvHzfvjBNq","AxjLza","EuDLwhi","B0XQq2u","tvbdB24","y3bZC00","x2zVCM1HDeu","u0XNsw8","z2u6ia","yxnJCMLWDa","mhW1Fdf8mta","DLPMCMW","y3jLyxrLtwu","y2HHCKnVzgu","BwX1vxi","CgfNzxnOB3C","s0LTA1m","q1DdAfa","AM1TBLK","vvn6EuO","rwvPquW","CLrwy3a","sfzmzKC","AvD3ywu","BwvZC2fNzq","B3nLrxzLBNq","C2v0y3vYC28","ExztEvC","B25tDgfYDfi","zsbHihn0CMK","x2TLEvbHDgG","zvvXtvK","AgvHzgvYCW","t3nUBfO","zK5vyvC","x2LUAxrhBg8","z0rUwu0","zhfjA20","x2rLyNvN","rfHQCMy","v0LTqM8","ChjVDg9JB2W","AxnrB1nnzxm","AhfYzuW","rLjptLrjrvi","ihzHBgLKigq","ywrK","ANnrCNO","t3DLC1K","tLzpsMu","uLrbCxK","BIWGAg9ZDg4","x2n1CNnVCK0","BwvY","q29Kzq","AxmGDw5Kzwy","BNnKwfC","C3rLBMvYCW","Cg5TAMu","ywnR","BhnZt2q","Efz4s2u","Au9nufK","Aw5KzxG","B2jXD28","A09myMS","yM1ct2q","D2vI","AgzXAKe","zw5KCg9PBNq","A2vzv2G","B05PB1e","wej5t1e","zNbZqxu","y3HoD1i","DgLTzw91Da","D2vQEKq","D0nTswq","B2zMBgLUzq","zxrxB3jRq2G","x2rPC3bHDgm","AeHvswq","q3LhANK","D21Xq0y","x3bPBMDqB24","zePOtLi","vufuzgO","vvr1BNi","BhfJzLK","CMvXDwLYzwq","zgvJB2rLzey","y3j6Eva","zK1qu1O","BMCGzMfPBgu","uKvxswq","AvLcwfe","vhP3zgy","Avz4Bhy","rLb2zgG","Evj5vfi","uu9sAhu","CMvHC29U","Cgf5Bg9Hza","AevYCM9Yrxy","AuXyAxC","x2LZqNjVD3m","yNvMzMvYzwq","Cg9PBNrdB24","uur5q0q","yMLMuMO","rfb6suu","wNrQzM0","C3vIyxjYyxK","yxnZAwDU","yxbWBgLJyxq","ywDL","x2HHBMrSzvi","y2XLyxi","BhLJz1i","DMHVBfG","x3fVC0rc","DMfSDwvZ","ywrKt25L","yNL0zuXLBMC","AKT1wge","BM9Uzv9UB24","weTurge","BMvY","ugLkvuC","wg1vsfm","mJqZmZq2mgHLuNL6wq","tKTSyNO","suHds3y","uxfMBhK","v3Hwufe","BKnnweq","CMvZB2X2zq","yxjYyxLIDwy","wMreEgK","CMfTugfYyw0","y3fHshe","vxj4qu0","Bhm6ia","yxKSig5LDhC","wNzPvKm","qvbUBgO","v1H2A3e","C29Tzq","DwXNA3m","vxbKyxrLq28","tgr4zxC","twTJwLG","yvHvAei","x3nVy2TLDa","CMvUDevUzha","EvDlz3y","Cxjdsuq","ExzOAem","zw50tgLZDgu","z3PkD24","mdaWma","u2HHCMvKv28","EuDNAu0","zw5fDMvUDa","zcWGDw5RBM8","yvfMCwm","vuHZr2K","DhLWzq","wuTnuMO","rwndDNG","D1nbqLC","A1n0yxr1C0m","zgvSzxrL","sxbuquq","quzstM4","C2vUzf9Hy2S","DMvUDa","Ag9zEve","rMTZBuq","vLnkwLm","zMXVB3i","x3jLy29UBMu","ruDOBw8","Bg9IywXty28","wuvzB08","txHUwgG","Bvj4wNm","z2LREMm","q0jRueC","tKfdtNG","ruHAvLi","tfL6Axe","zvfSqLa","tMn4uKu","sMv0q0i","reXmD3G","Eu9jAhy","C0jf","ChrVCG","EgPgDwC","zxjYB3i","yKHvCfy","DhbizwfKzxi","su5tvefova","Aezyz1e","tg1dtNu","BMfTzq","C2vUDa","y254rhK","tKzKDge","ihzHBgLKihm","q2Tuvxm","q2L1EMy","uLPJB1i","wvvsExG","y2HnyxHuCMK","CMXOzfu","BwvZC2fNzv8","vuLTsuO","DNzXt1m","zLDKzem","zNjVBunOyxi","ywXSzwqGBxu","zfbQuNO","igfYCMf5yNu","yKTIzgm","r3Pfv00","vKzqt2O","wLDSvKq","D2fZq2XLyw4","Dhr4CgW","y3vYC29Yx2y","CMvWBgfJzq","u2juwgC","u0LQuhu","Bw5fA2y","rxbds0q","CuL1rhO","zuzXBKq","id4G","C252qxu","sfHmu24","z3vtDKm","zNjVBNrPzxi","yMnrs1G","uLnfqxu","B3HTtgy","DgXnC3G","y0DTB0y","A1PvC1e","y29UBMvJDfm","y3vYC29YlNm","qLDVAuO","vMPYv1m","x2DLBMvYyxq","DKPQA0C","su9bueC","t0LgsNC","qKjJBu8","DhPWzfO","v25cv20","zMLUza","EKXSs3e","BgvY","vfLHAw8","r2res3a","tKDFrvjst1i","z0r4AMu","wwTXwNO","C2vYDMLJzq","v05WEMm","uxvLDwu","AgLNAa","CM9YrxzLBNq","uNzqtKu","rMP2D1y","BKneu0W","rNf5yMu","B25ozxr3B3i","ueXNrM4","ELnxB1O","DxrVuMvJB24","uM5tru8","wMvYse8","A2H4u3C","zxjHDg9Y","yK1pv3e","CvbUAhe","rKjiB0O","C2XPy2u","CgLUz0LUDgu","v1rQs2u","zxvZzeK","AxnszwfKEq","y09Wzw4","CNnVCL9Uyw0","AxnFywnR","C2v0u3rVCMe","BwLUzW","AMvNu3i","yw1Lu3bHy2u","BhrPCgXLihq","AxPowgm","vNzMu2K","x2rPC2nVBM4","CMfTzq","CvDWzwS","x3bPBMDmB3m","DgfIyxnL","rhHbve0","q09oveLovuu","zMPOtva","DxbKyxrLq3u","B3H0BxG","D0Hpr0i","sejVyKW","Cg1TDg4","A053B24","CMvJB25Uzwm","wuPICu0","yMfSrxzLBNq","x3nLCuLK","y29UBMvJDa","BMrWB2LUDca","y3r4","z2TJwhO","zg9Uzq","DhDLzgC","zNjVBujPDhm","BKvJB20","y0nivuu","CYbPBNn0yw4","swPzseC","zNjHBwvuExa","uw1QBgS","zxjFCw9Z","Cwn6qwO","r1jpuxa","Bg9Nsurhzw4","DNDlEvC","tvLYzgK","BMvJDa","EhLgq1i","t2jQzwn0","zxfOzha","BMrWB2LUDfq","zvvYBa","DhLiDuC","CxztALK","zgXpswO","zvr4tuu","A0nfCfe","rwTmqxq","tMfTzq","DMjOBLG","vKzftwu","x2jPBMfYEvq","B2frvuq","A2v5CW","wejyCvm","tgHUuu4","CeLgwxO","B3nLza","AxnbCNjHEq","wNr2EKO","tgLZDgvUzxi","sNLyuwu","C2fNzq","y3LKq3q","Dgv4Dc9WBge","uLP3vhq","uerqsuG","ihn1y2nLC3m","B25tDg9Wsw0","zw5JB2rLrNi","zgf0yq","A3HjBMm","z2v0qwXS","qMHushG","ANLTuNC","ChPdrvu","yMLUyxj5vhK","DMvY","CufHu0u","C3rVCcbPBw0","y3vZDg9Tshq","yNLL","DgHLBG","z1rPBwvVDxq","AgvKtwf4uMu","B3LRv2u","DhjPzxmGCMu","DMrmEMW","z09nCuG","A2HkEg4","rxzLBNq","DMLJzuLeig8","C2vYDMvYvgK","AufrD2C","zxH0ugf5Bg8","yxKSihrYEsa","A3HZB2m","ywnOzwq","B2HjBhO","DxDrtNe","Ae9Wzw5fDMu","qNvHuNO","wuDmreq","tM1Wy1O","shz4AuC","ruPRq1y","uMH0v2i","Ce1bv2q","zw50zwqGDhK","BMrLEa","BgTTDfC","Dgv4Dc9Qyxy","tKXdq2C","B25pCgvU","C0zbELa","y3jLyxrLt2i","y2fSBa","B2rTAfi","D24GCMvHC28","x2XPC3rLBMu","zgvMAw5Luhi","ENbozNC","zcbLCNjVCI4","AwrI","EM56r1G","ugfcv0m","zerRsNK","t0D5z2m","tg9JAW","De1HBMfNzxi","BwT0ufm","tNP3Ee0","lcbTyxGGCMu","zMvY","rMPPuva","zezpuLG","svDWBMi","u3rYyxrLz3K","DhvsD0y","Dxrjza","y2vZC0HHBMq","DMfS","C0j0y2S","r0TVELe","zxf1ywXZ","y2f0y2G","x2rItMfTzq","ywXSq3vYC28","BMDLza","shvPzLG","zKHPrKS","vKPWz0G","uxDPCwK","uLnxrKi","DeTcDK4","ywXSB2nvBNm","wgntDfO","zu9Lr2m","DLPbAxC","neDIEeTIBa","EePlBvm","vNjouK0","B3bLBIa","C0Xf","C2vUza","rhrJuvG","Dg9mB3DLCKm","qwvbB3q","ww5hwum","BNrbBMrvCgq","B2XKvMvYC2K","rhjjvxC","zwrPyxrLBhK","v0TMC0y","qMndthO","ywnRDxbfBMq","B2nRzxq","zgLZywjSzue","BuXxsem","zNvUy3rPB24","x2LUAxrqCM8","CMvxAwK","nNWZFdD8mhW","x2nVBM5Ly3q","uNrNu1m","rvveEeG","DeHwr1i","AgfZ","CMvQzwn0","q0D2rfO","rurZAK4","CvfVC08","B25fCNjVCG","z0vWuvi","zgDMEwS","BgLUzq","y29UBMvJDgK","uwzcBKi","C0vZyuG","BMX0zwq","C3jJ","ywnRpwzYB24","Du5oCfG","rgDoEhm","EuLfqNa","y29UBMvJDeu","zKjIEKe","C2DPza","Dg56Bxu","BMrkv0O","D3PIsfK","BMnLq2XVC2u","z2vjBMzVu3K","Ahr0Ca","yufzDgi","Bwf4twvZC2e","ywrKq291BNq","yMfSu2nVCgu","Cgf5Bg9Hzeu","CgfNzwHPzgu","zMLN","ign1CNnVCIa","wKDMqwu","s1LLBha","vvjkvhO","CgjICdi","zgvS","tKfusvzfx0u","x3jLBw92zvC","z29PBMCGyxC","rfbirKm","ihbYB3rVy28","rKXmsgm","v2vIu29JA2u","x2LZv29YA2u","q3L5v2C","CMvZzxrfBMq","D3bHzLq","wNPtu1C","A0Pxs0W","rwLICKu","vKPjC28","Exr1we0","u2r2De4","t2X4AvG","zwzPzMS","AgP4D0W","DMPsqKS","Dw5KzwzPBMu","tgn6Ehi","uKnnv1i","EvjLy29UBMu","vxfHCM0","CgLUz1rPBwu","ihrPBwvVDxq","Bwf4tg9ZC0m","BMHrELO","wNjYzNO","swnwD0S","BxzZBvi","y3jLyxrLuMu","ywXS","B2zM","qxvdqNi","ruf5zKi","qKzAvNq","EMjAwgK","AfDztMW","u2fWCNO","Cg9PBNrbBMq","x1fVu01HBMe","sKPuD1q","ywLfzw8","wKPVDgK","DhjPzxm","u2vXsuq","A3zHvfC","D01yvK0","u05ot2K","yxGGCMv0CMK","vxjsDgW","r0TXDwi","ueX6D2i","CvnPyMy","C3rHCNq","rhfbBfq","y3vYC29Yx24","ywnRx2nVzgu","x3vYBa","rxzrwhu","CMvTB3zLrxy","u3ftAuq","wwL0thO","jMPZy2fSBgi","zgvSzxrLrge","yMLUyxj5","vgLTzw91Da","uvf5qLe","z2DxzxO","BMDuAw1LCG","v2zOsxm","qNHvsxm","BMCGDxjSoIa","B25LCNjVCG","D1b2C04","y29Uy2f0","vKrxzM8","m3WYFdr8nxW","igzHAwWSig0","uLLzy04","DwfPvKG","B3vUDa","DgvmB2Djre4","CxjLEKy","B1HXyuW","ENjeD0K","Bwu6ia","CYbHBhjLywq","swfHr1q","sxfkzKW","wNL3wMK","rfz4tve","sejeAuC","u0jYy04","zxH0zw5ZAw8","wKHxAhi","s2DWzem","DgPiteG","wLr1v0i","t2fTr1q","vwLXC3e"];return yo=function(){return t},yo()}var F0,P0,N0,Xc,Eo,Zc,wo,bo,vo,Bi,L0=z0({"node_modules/idb/build/wrap-idb-value.js"(){let t=L,e={skqPW:function(r,i){return r instanceof i},dudBV:function(r,i){return r!==i},eGRhI:t(1789),tjIDI:t(1334),OsnlZ:function(r,i){return r===i},FjvwV:t(1430),rVnBf:t(1072)+t(381),UrRtl:t(934),CPido:function(r,i){return r(i)},YtpJo:function(r,i){return r in i}};F0=(r,i)=>i[t(1251)](o=>r instanceof o),Xc=new WeakMap,Eo=new WeakMap,Zc=new WeakMap,wo=new WeakMap,bo=new WeakMap,vo={get(r,i,o){let c=t;if(e[c(989)](r,IDBTransaction))if(e[c(376)](e.eGRhI,e[c(577)])){if(e[c(1137)](i,e[c(1379)]))return Eo[c(633)](r);if(e[c(1137)](i,e[c(472)]))return r[c(1072)+c(381)]||Zc[c(633)](r);if(i===e.UrRtl)return o[c(1072)+c(381)][1]?void 0:o[c(1072)+"ore"](o["objectSt"+c(381)][0])}else _0x1d875f.log(_0xca51c2);return e[c(1800)](Mt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(989)](r,IDBTransaction)&&(e.OsnlZ(i,e[o(1379)])||i===e[o(1689)])?!0:e.YtpJo(i,r)}},Bi=r=>bo[t(633)](r)}}),U0={};mE(U0,{deleteDB:()=>AE,openDB:()=>IE,unwrap:()=>Bi,wrap:()=>Mt});function IE(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=L,u={hwJcw:function(m,E){return m!==E},dmkvx:"MrMxN",PEyfc:function(m,E,T,_,v){return m(E,T,_,v)},DteiI:function(m,E){return m(E)},SYLpM:function(m,E){return m(E)},IWpnb:function(m,E){return m===E},ZTuWB:function(m,E){return m===E},uznpE:function(m,E){return m===E},xjFug:l(1034),OlxiX:l(1797),snvAu:l(1834),LMhLF:l(868)+l(1086),RCMWR:"upgradeneeded",sKRfu:"blocked"},h=indexedDB[l(589)](t,e),p=Mt(h);return i&&h["addEvent"+l(1469)](u[l(1659)],m=>{let E=l;if(u[E(948)](u[E(374)],u.dmkvx))return new _0x5ffe12(_0x6e7563,{code:_0x50c4a4,reason:_0x2fed3a,wasClean:_0x5cfe5b,willReconnect:_0x503a24});u[E(1013)](i,u[E(721)](Mt,h[E(442)]),m[E(1579)+"on"],m.newVersion,u[E(1069)](Mt,h[E(401)+E(564)]))}),r&&h[l(510)+l(1469)](u[l(573)],()=>r()),p[l(1491)](m=>{let E=l,T={cxNwR:function(_,v){return _!==v},zcTtb:function(_,v){return u[H(1545)](_,v)},YsAwQ:function(_,v){return _>>>v},LDrqq:function(_,v){return u[H(1737)](_,v)}};if(u[E(788)](u[E(1303)],u[E(1653)]))return _0x2caca5[E(362)](_0x56d4a1)||(_0x6895e4=_0xdbec04[E(532)+"er"](_0x24ee67)),T[E(1178)](this[E(558)],_0x539223.unsigned)&&T.zcTtb(T[E(1803)](this[E(1376)],31),1)&&T[E(1792)](_0x184730.high>>>31,1)?!1:this[E(1376)]===_0x21bc44.high&&T[E(1046)](this[E(505)],_0xed7add[E(505)]);c&&m["addEvent"+E(1469)](u[E(1344)],()=>c()),o&&m[E(510)+E(1469)](u[E(900)],()=>o())})[l(1554)](()=>{}),p}function AE(t,{blocked:e}={}){let r=L,i={UNrCU:function(c,l){return c(l)}},o=indexedDB[r(1703)+r(1412)](t);return e&&o[r(510)+"Listener"](r(534),()=>e()),i[r(902)](Mt,o)[r(1491)](()=>{})}function M0(t,e){let r=L,i={obqwo:r(1848)+"e",QwUBM:r(550),UUwto:function(h,p){return h instanceof p},oykWe:function(h,p){return h in p},CBkPG:function(h,p){return h===p},bhWlz:r(719)};if(!(i.UUwto(t,IDBDatabase)&&!i[r(1494)](e,t)&&i[r(1292)](typeof e,i[r(501)])))return;if(_o[r(633)](e))return _o.get(e);let o=e[r(1336)](/FromIndex$/,""),c=e!==o,l=H0[r(462)](o);if(!i[r(1494)](o,(c?IDBIndex:IDBObjectStore)[r(497)+"e"])||!(l||q0.includes(o)))return;let u=async function(h,...p){let m=r,E=this[m(401)+m(564)](h,l?i[m(1168)]:i[m(649)]),T=E[m(934)];return c&&(T=T[m(1167)](p[m(1823)]())),(await Promise[m(1670)]([T[o](...p),l&&E[m(1430)]]))[0]};return _o[r(941)](e,u),u}var q0,H0,_o,TE=z0({"node_modules/idb/build/index.js"(){let t=L,e={Pczmk:t(1071)+t(373),MsaoC:t(1150),DLLwx:t(1221),eusdI:t(633),ulgks:t(1793),zrDwI:t(1481),sFAzP:t(689)+"ys",UOTPA:t(932),Ztjfm:function(o){return o()}},r=e.Pczmk[t(584)]("|"),i=0;for(;;){switch(r[i++]){case"0":H0=[t(983),e[t(491)],t(1276),e[t(1299)]];continue;case"1":q0=[e[t(1396)],e[t(1252)],e[t(1724)],e[t(1523)],e[t(810)]];continue;case"2":bE(o=>({...o,get:(c,l,u)=>M0(c,l)||o[t(633)](c,l,u),has:(c,l)=>!!M0(c,l)||o[t(1596)](c,l)}));continue;case"3":e[t(1215)](L0);continue;case"4":L0();continue;case"5":_o=new Map;continue}break}}}),RE={idb:function(t){let e=L;t.exports=Promise[e(1240)]()[e(1491)](()=>(TE(),U0)).then(function(r){return r})}},B0={};function Lt(t){let e=L,r={vDJCv:e(1794)+"1"},i=r.vDJCv.split("|"),o=0;for(;;){switch(i[o++]){case"0":RE[t](c,c[e(877)],Lt);continue;case"1":return c.exports;case"2":var c=B0[t]={exports:{}};continue;case"3":var l=B0[t];continue;case"4":if(l!==void 0)return l.exports;continue}break}}(()=>{let t=L,e={eOeGc:function(r,i){return r===i},whBBD:t(370),TmJdb:"zDcoz"};Lt.d=(r,i)=>{let o=t;if(e[o(1566)](e[o(549)],e.TmJdb))return"frontier_"+ke._DBName;for(var c in i)Lt.o(i,c)&&!Lt.o(r,c)&&Object[o(1529)+o(1021)](r,c,{enumerable:!0,get:i[c]})}})(),(()=>{let t=L;Lt.o=(e,r)=>Object.prototype[t(1041)+t(1021)][t(1525)](e,r)})(),(()=>{let t=L,e={kCLCR:function(r,i){return r!=i},kyBia:t(1657)+"d"};Lt.r=r=>{let i=t;e[i(1047)](e[i(1070)],typeof Symbol)&&Symbol[i(883)+"Tag"]&&Object[i(1529)+i(1021)](r,Symbol[i(883)+i(725)],{value:i(574)}),Object[i(1529)+i(1021)](r,i(761)+"le",{value:!0})}})();var De={};(()=>{let t=L,e={fNUaW:function(a,n){return a(n)},XHrcF:function(a,n){return a+n},HBobL:function(a,n){return a+n},pqzKd:function(a,n){return a+n},khJxn:function(a,n){return a*n},KvlwQ:function(a,n){return a*n},PZzSc:function(a,n){return a*n},SbTXg:function(a,n){return a>>>n},HprQz:function(a,n){return a(n)},RtgSS:function(a,n,s){return a(n,s)},DVxMQ:function(a,n){return a!==n},ypspw:"QckaE",SdWcr:function(a,n){return a+n},DlTHd:"0000",YZUkC:t(1033),yvhhC:function(a,n){return a(n)},EhWQo:function(a,n){return a(n)},JkTNz:t(1849)+t(1849)+t(1849)+t(1849),oaQUD:function(a,n){return a>n},EeiAL:function(a,n){return a<n},JrZBS:function(a,n){return a>n},VrNRM:function(a,n){return a<n},KGANS:function(a,n){return a-n},cGmoF:function(a,n){return a===n},fJHaK:function(a,n){return a-n},JyXQe:function(a,n){return a!==n},jsQrz:t(735)+t(1205),GBNNn:t(1085),teqJw:t(831),rHerF:function(a,n,s){return a(n,s)},rIRvX:function(a,n){return a(n)},Isbrl:function(a,n,s){return a(n,s)},yGgiM:function(a,n){return a&n},Jjtxx:t(1812)+t(1193)+t(661)+t(1850),XSVgw:function(a){return a()},Tzwdf:function(a,n){return a!==n},ZJoti:function(a,n,s){return a(n,s)},UImIJ:function(a,n){return a!==n},dJhNR:function(a,n,s){return a(n,s)},WXoIb:function(a,n,s){return a(n,s)},XyBzz:function(a,n){return a(n)},MCSES:function(a,n){return a!==n},EkLAt:function(a,n,s){return a(n,s)},qAkDd:function(a,n,s){return a(n,s)},GKozQ:function(a,n,s){return a(n,s)},tmcey:function(a,n,s){return a(n,s)},yBmxF:function(a,n,s){return a(n,s)},cPzIB:t(921),Lczxr:function(a,n,s){return a(n,s)},yvSyW:function(a,n,s){return a(n,s)},NewBp:function(a,n){return a!==n},nmiQz:"ZeaMj",zmpFm:t(669),jbYOx:function(a,n){return a!==n},ZBoyp:function(a,n){return a(n)},GzEWM:function(a,n){return a(n)},WfocW:function(a,n){return a(n)},MKsCr:function(a,n){return a>>>n},nxXIL:function(a,n){return a(n)},IjYHG:function(a,n){return a(n)},dabeQ:function(a,n){return a(n)},CPeIU:function(a,n,s){return a(n,s)},nCDSL:function(a,n){return a(n)},DwzRH:function(a,n){return a(n)},NctVv:function(a,n,s){return a(n,s)},yqtMB:function(a,n){return a(n)},ivOXA:function(a,n,s){return a(n,s)},vSVNZ:function(a,n,s){return a(n,s)},PxTHl:"Missing required"+t(661)+t(1684),bcQKX:"Missing required"+t(661)+t(536),KFaRG:t(1812)+t(1193)+t(661)+t(1373),yqHFF:"Missing required"+t(661)+"method",OwesY:function(a,n,s){return a(n,s)},cxCan:function(a,n){return a>>n},iwBGP:function(a,n){return a>=n},lfLAd:function(a,n){return a===n},EstZJ:function(a,n){return a>n},QkoLy:t(716)+t(513),WRsWr:function(a,n){return a>=n},YURyx:t(1464),iOMPY:function(a,n){return a*n},bmBOd:t(990),ALHgc:function(a,n){return a>n},DPHFC:t(890)+t(513),wdLAI:function(a,n){return a+n},PDPIH:function(a,n,s,d){return a(n,s,d)},NiMsG:function(a,n){return a===n},fMPSZ:"hpdNX",AFRNn:"MXuUo",wNRfu:function(a,n,s){return a(n,s)},aAYtb:function(a,n){return a<n},Zqikc:function(a,n){return a===n},eqhdp:function(a,n){return a>=n},tlMsx:function(a,n){return a+n},IHBKV:function(a,n){return a+n},lkmtW:function(a,n){return a!==n},XrYST:function(a,n){return a|n},GQIhf:function(a,n){return a<<n},TQzil:function(a,n){return a&n},pzJFX:function(a,n){return a(n)},dPMAM:function(a,n){return a==n},xJKmS:t(626),efifk:function(a,n){return a|n},EibrE:function(a,n){return a&n},ndJWJ:function(a,n){return a<<n},Qwiqi:function(a,n){return a&n},UaIFA:function(a,n){return a(n)},kZUsQ:function(a,n){return a&n},BUcOn:function(a,n){return a+n},FPvdh:function(a,n){return a+n},hoYyQ:function(a,n){return a+n},dDkJy:function(a,n){return a+n},HRJIU:function(a,n){return a&n},MQDxc:function(a,n){return a<<n},GUsjt:function(a,n){return a&n},pVzcC:function(a,n){return a<n},hBaDs:function(a,n,s){return a(n,s)},tUsaf:function(a,n){return a+n},GzYWT:t(423)+"0",uRdzm:function(a,n){return a<n},GyzAC:function(a,n){return a<=n},EGhmo:function(a,n){return a<<n},wCmId:function(a,n){return a<n},nJaiJ:function(a,n,s){return a(n,s)},XKTDa:function(a,n){return a<n},RTAqy:function(a,n){return a<n},AJPTG:function(a,n){return a|n},nUDpp:function(a,n){return a<n},flrVI:function(a,n){return a===n},GAIvm:t(1507),zlNRw:function(a,n){return a&n},pdwku:function(a,n){return a>>n},tyHuG:function(a,n){return a&n},odmhR:function(a,n){return a&n},Ciuzf:function(a,n,s){return a(n,s)},eJxfy:function(a,n){return a+n},dlwsE:function(a,n,s){return a(n,s)},VDWfo:function(a,n){return a===n},WsmVt:t(1651),OMjcd:function(a,n){return a<n},RZwTt:function(a,n){return a<<n},YZewK:function(a,n){return a&n},kkSXY:function(a,n,s){return a(n,s)},seZJu:"undefined",qfyZV:t(574),GAthw:t(761)+"le",FiZrY:t(1814),mdlQY:t(879),Uwphj:function(a,n){return a<<n},kbCbv:function(a,n){return a&n},SoMgS:function(a,n){return a<<n},DtcQX:function(a,n){return a&n},PLclu:function(a,n){return a&n},QQyBQ:t(1203),IqJfL:function(a,n){return a(n)},SfDBf:function(a,n){return a&n},nrfpZ:function(a,n){return a<<n},sMnHB:function(a,n){return a|n},smWjc:function(a,n){return a>>>n},ljNUm:t(479),CWChP:"abort",RklDr:t(1381),KlHUp:t(1739),DqAlT:function(a,n){return a|n},hLDdi:function(a,n){return a>>>n},pzCEU:function(a,n){return a===n},FXrOJ:function(a,n){return a<n},jiDXA:function(a,n){return a<n},YTzmB:function(a,n){return a<n},tHVGR:function(a,n,s){return a(n,s)},EOwbI:function(a,n){return a&n},BNrNS:function(a,n){return a!==n},eFqnD:function(a,n){return a+n},bbPuB:function(a,n){return a>>>n},nEcom:function(a,n){return a!==n},sBtck:function(a,n){return a+n},UogJe:function(a,n){return a>>>n},dSVvv:function(a,n){return a>>>n},PJWPO:function(a,n){return a+n},znzGX:function(a,n){return a!==n},khxSw:function(a,n){return a&n},kCEpQ:function(a,n){return a>>>n},GZIvd:function(a,n){return a+n},SDuaW:function(a,n){return a>>>n},OIFJw:function(a,n){return a&n},HQtKH:function(a,n){return a>>>n},vwbVA:function(a,n){return a|n},KImkS:function(a,n){return a&n},SBrcN:function(a,n){return a|n},tkygw:function(a,n){return a(n)},ggWez:function(a,n){return a(n)},iAQwg:function(a,n){return a|n},kSrSu:function(a,n){return a===n},RrXaD:function(a,n){return a|n},BxUIs:function(a,n){return a|n},eIsSZ:function(a,n){return a|n},mktPS:function(a,n){return a<<n},tzpdZ:function(a,n){return a<<n},MeSun:function(a,n){return a|n},dkLBX:function(a,n){return a<<n},gNDwC:function(a,n){return a<<n},EvQXu:function(a,n){return a|n},ZrHkh:function(a,n){return a<<n},NUlNM:function(a,n){return a>>>n},HXLSn:function(a,n){return a|n},iLXiw:function(a,n){return a<<n},dvHpJ:function(a,n){return a&n},kLBqg:function(a,n){return a&n},nTnQG:function(a,n){return a&n},sqldc:function(a,n){return a>>>n},TzUaw:function(a,n){return a>>>n},HAJvx:function(a,n){return a>>>n},SuJsv:function(a,n){return a&n},itUUT:function(a,n){return a>=n},ciUaf:function(a,n){return a<=n},HVLfG:function(a,n){return a+n},TWdqh:function(a,n){return a|n},ifSBb:function(a,n){return a|n},qSibf:function(a,n){return a/n},keYWh:function(a,n){return a+n},wDcoy:function(a,n){return a+n},uaiVH:function(a,n){return a>>>n},oNioQ:function(a,n){return a>>>n},RnSEO:function(a,n){return a+n},wmctd:function(a,n){return a>>>n},cvuJj:function(a,n){return a<<n},bQTij:function(a,n){return a<<n},ymdwH:function(a,n){return a!==n},URJTz:function(a,n){return a===n},kxInc:function(a,n){return a===n},muzId:function(a,n){return a===n},KpIAs:function(a,n){return a===n},YmHCx:function(a,n){return a+n},KYelp:function(a,n){return a+n},eTxME:function(a,n){return a&n},pmxtp:function(a,n){return a>>>n},Euszo:function(a,n){return a&n},wmqCF:function(a,n){return a>>>n},iHMqu:function(a,n){return a>>>n},vvqOS:function(a,n){return a&n},zZVOZ:function(a,n){return a>>>n},hpxvX:function(a,n){return a&n},jmmnY:function(a,n){return a&n},WNpzc:t(1010)+t(1370),WIllv:t(1636)+"RROR",GJepP:t(993)+"IES_ERROR",IrNUG:"MESSAGE_ERROR",dzuao:t(369)+"2",BeqOk:function(a,n,s){return a(n,s)},JuDkS:function(a,n,s){return a(n,s)},LmCNu:t(1516),LQqaT:function(a,n){return a<n},APnlj:function(a,n,s){return a(n,s)},fHiFK:function(a,n,s){return a(n,s)},gzJwn:t(1384),TYaio:t(1304),Ljucs:function(a,n){return a!==n},WVTBs:t(372),crzyP:"tKGTM",ZUUhv:function(a,n){return a+n},xjtnz:t(1441),JetCB:function(a,n){return a>=n},oxtmx:function(a,n){return a==n},VJIso:function(a,n){return a>n},AlkEF:function(a,n){return a+n},PzBcB:function(a,n){return a===n},JLwiI:t(646),JEUww:t(1602),enZly:"GChUH",ETLqF:function(a,n){return a instanceof n},iHrHj:function(a,n){return a+n},XlaQT:t(578)+t(1531),iOoIX:function(a,n){return a+n},IHCKv:function(a,n){return a+n},ikLtN:function(a,n){return a&n},iQEgD:function(a,n){return a<n},JNxpC:function(a,n){return a|n},TBEoD:function(a,n){return a>>>n},gkcXz:function(a,n){return a<<n},bjiZu:function(a,n){return a<<n},EbLHC:function(a,n){return a|n},dLzMf:function(a,n){return a>>>n},NKlbz:function(a,n){return a|n},BjXLq:function(a,n){return a<n},qCgpQ:function(a,n){return a>>>n},WfhIs:function(a,n,s,d){return a(n,s,d)},ZerHO:function(a,n){return a|n},OeCGo:t(1677),FBHoJ:"KYWST",xtfws:function(a,n){return a===n},wJLbG:function(a,n){return a===n},gjZRl:t(1834),BAkBp:function(a,n,s){return a(n,s)},Txkxl:t(1128),DXjrf:t(589),MkmQj:function(a,n){return a instanceof n},gTPYN:function(a,n){return a<<n},JJflV:t(976),ktmMQ:t(961),EJwaS:t(978),OJQik:function(a,n){return a===n},vsbkX:function(a,n){return a!==n},shduF:t(1349),rDjjb:function(a,n){return a||n},NACNx:function(a,n){return a!=n},IcVwK:t(995)+"0",aXUhB:function(a,n){return a||n},tjHLH:t(928)+t(1326)+t(1405)+t(1743)+t(1824),oCNji:function(a,n){return a<n},CGvDZ:function(a,n){return a&n},IgiFH:function(a,n){return a(n)},dycos:function(a,n){return a===n},tWVqN:t(1279),llaTr:t(1056),XByOQ:"qkcZp",tOwrL:function(a,n){return a<n},rcjpA:function(a,n){return a>=n},Qqfly:function(a,n){return a&n},AEryo:function(a,n){return a<n},RYYcN:function(a,n){return a|n},EJkCV:function(a,n){return a&n},tmscF:function(a,n){return a&n},poetC:function(a,n){return a&n},xAfXk:function(a,n){return a-n},gDxje:function(a,n){return a<<n},FAaqX:function(a,n){return a&n},KMIvV:function(a,n){return a<<n},ndlbu:function(a,n){return a&n},YozcZ:function(a,n){return a<n},GgPGb:function(a,n){return a|n},PDvjg:function(a,n){return a===n},sXHVb:"5|3|2|4|"+t(787),SxStB:function(a,n){return a|n},jVBlY:function(a,n){return a|n},SIjPu:function(a,n){return a&n},ypVOG:function(a,n){return a>>n},PcxEh:function(a,n){return a+n},yHuZJ:function(a,n){return a<<n},kFYwS:function(a,n){return a|n},Fjgsd:function(a,n){return a>>n},WaMHe:function(a,n){return a|n},PUAnk:function(a,n){return a&n},uNFHJ:t(719),vvPRL:"XnOTf",Uqarm:function(a,n){return a(n)},vZAiw:t(450),HHYUE:t(985),QKKHU:t(1218)+"ion/json",tshXG:t(1473)+t(485)+"et=utf-8",JfjXZ:"boe",nsdXW:"ppe",KYMNY:function(a,n){return a!==n},ayNiE:"WciJT",pfRnD:t(1465),MPCon:function(a,n){return a(n)},rcFHz:"text/jav"+t(1113),XbBUq:t(1702)+t(1610)+t(1097)+"P",NRGAo:function(a,n){return a===n},bifRj:t(469),BuaRz:function(a){return a()},WlQRD:function(a,n,s,d){return a(n,s,d)},mnEkf:function(a,n,s){return a(n,s)},IKQFA:t(1360),yWKgv:t(1125),gxjek:function(a,n,s){return a(n,s)},PjeYP:function(a,n){return a<=n},iPyej:function(a,n){return a>=n},YnGYC:t(500),PiJUG:t(1057),EAyfB:t(516),ioWWj:t(1423),lssOd:t(1430),nOOig:function(a,n){return a===n},oHwWd:function(a,n){return a in n},BWoiJ:t(1594),QDyCD:function(a,n){return a||n},nvLLL:function(a,n){return a||n},KnWPp:function(a,n){return a||n},pdWjr:function(a,n){return a||n},RhtWb:function(a,n){return a(n)},ppLmB:"KjuyD",NDiHI:function(a,n){return a||n},xYYUA:function(a,n){return a||n},GdDKp:function(a,n){return a!=n},QtGvT:t(616)+"DB failed",WXvkq:t(1754),HuifX:function(a,n){return a(n)},FHjCs:function(a,n){return a+n},qIuDz:"gBKdV",COJyp:t(1854),ANNRX:function(a,n,s){return a(n,s)},ReGXq:t(1727),VjrWS:"FILE_NOT_EXIST",vholX:t(1066),XEOOA:function(a,n){return a!==n},qvSjY:t(1005),yOIhv:"EwvDC",PzdXp:"x_fronti"+t(1439),KvuZh:t(820)+"er_qos_ack",vlyYv:function(a,n,s){return a(n,s)},JBvvP:t(820)+t(1752)+t(1616),IeQfY:function(a,n){return a&&n},EcCvx:t(1400),yldNG:"ack_id",DFsME:t(1696),ZHWhr:t(994),rkNTE:t(1704),CyyWg:function(a,n,s,d){return a(n,s,d)},fsUdl:function(a){return a()},uBGdX:function(a,n){return a<n},DQUeq:function(a,n){return a+n},MjRDU:function(a,n){return a&n},qPnhq:function(a,n){return a||n},NmpcZ:function(a,n){return a+n},FksmD:t(432),zbZXi:function(a,n){return a||n},uyExV:t(1343),KCvfV:t(1532),CEVRz:function(a,n){return a===n},FiIOK:t(456),OGygc:t(1095),tSuMY:t(541),nkpTy:function(a,n,s,d){return a(n,s,d)},FYffw:function(a,n){return a|n},RrJUY:function(a,n){return a|n},rlhdU:function(a,n){return a<<n},NLCCg:function(a,n){return a<<n},DPzIE:function(a,n){return a+n},nlted:function(a,n){return a<<n},CyGjy:function(a,n){return a+n},lzaJe:function(a,n){return a<<n},AWoBF:function(a,n){return a+n},lKpIh:function(a,n){return a<<n},RohNZ:function(a,n){return a+n},WImBo:function(a,n){return a+n},YTQdm:function(a,n,s){return a(n,s)},VYenR:function(a,n){return a+n},WNxiX:"yzscE",YWAHh:function(a,n){return a&n},UbobJ:function(a,n){return a>>>n},fjhMP:function(a,n){return a&n},hRDyo:function(a,n){return a&n},eCtAx:function(a,n){return a+n},wOaZK:function(a,n){return a&n},VJpgH:function(a,n){return a>>>n},fxvTP:function(a,n){return a&n},xyFCR:function(a,n){return a&n},Xfhht:function(a,n){return a>>>n},ZtzBQ:function(a,n){return a+n},bzSjv:function(a,n){return a<n},onBVD:function(a,n){return a|n},JHtyQ:function(a,n){return a<n},zcTUA:function(a,n){return a|n},xgTcl:function(a,n){return a<<n},ARxGw:t(1080),mLBJs:"ImrFk",xVxKe:function(a,n){return a!==n},hsypt:t(504),bddWz:t(452),gvJTM:function(a,n){return a+n},kJvXu:function(a,n){return a!==n},JYcQx:"QboVY",ELQDt:t(1373),wQrjw:t(1355)+"ervice",ChPKw:t(846),EcuUH:"name",amNXj:function(a,n){return a(n)},TPpVF:function(a,n,s){return a(n,s)},zCyVp:function(a,n){return a===n},aQfqc:t(416),pXrNp:function(a,n){return a+n},EJivw:function(a,n,s){return a(n,s)},oaBXu:t(1335)+t(703),scaXh:function(a,n,s){return a(n,s)},WuWJI:"cursor_n"+t(1026),lnFCB:t(1556)+t(957),PlLWk:t(1808),rIptq:t(1307),rrFmu:t(1414),qzFKC:t(1022),rpmME:function(a,n){return a+n},uBXKF:function(a,n){return a+n},GOFQP:function(a,n){return a&n},vqkFu:function(a,n){return a<<n},OZkbI:function(a,n){return a<<n},ZzzUh:function(a,n){return a&n},rPuDz:function(a,n){return a&n},yjMNr:function(a,n){return a>=n},QWcBF:function(a,n){return a<=n},Xkyty:function(a,n){return a(n)},YvHRx:function(a,n){return a===n},RvPNE:t(651),BHBJb:"JgvTj",hIKJO:t(777),bVbji:function(a,n,s){return a(n,s)},zNMaM:t(820)+"er_msgid",vjRBK:function(a,n){return a(n)},BghyF:t(820)+t(1043),TAYpc:"x-msg-qos",PLgFn:t(642)+t(1399)+"e",UtKre:function(a,n){return a(n)},LGvzN:t(642)+t(467)+"ue",Yaqez:function(a,n){return a>n},OrgXM:function(a,n){return a!==n},ebCaL:"WNUuG",sTLIz:t(784),TawKj:function(a){return a()},BtQNA:"qIzgT",ZviVC:t(1463),TxkSH:function(a,n){return a<n},qrezF:function(a,n){return a&&n},SLgIo:function(a){return a()},iWwae:function(a){return a()},Wnfex:function(a,n){return a(n)},qAaSE:function(a){return a()},nCMXD:function(a,n){return a!==n},iXZSo:function(a){return a()},dqIkm:function(a,n){return a<n},YYKGb:function(a,n,s){return a(n,s)},kNwon:function(a){return a()},PFdDJ:function(a,n,s){return a(n,s)},YitLz:t(923)+t(529),QORhu:function(a){return a()},UfVPv:t(983),IVjOi:t(1150),EDysi:t(1221),KMAhV:t(689)+"ys",wSABW:t(932),CapYG:function(a,n){return a===n},lycgR:function(a,n){return a===n},ZNpQM:function(a,n){return a!==n},BGUgM:t(847)+t(539)+"s",gOMqH:function(a,n){return a+n},HCAHC:t(897),aiEeo:function(a,n){return a===n},NbEsp:t(1490),oLOOh:function(a,n){return a(n)},REWId:function(a,n){return a!==n},hjxwL:t(1241)+t(1542),lKyat:t(1634),HQmyD:function(a,n){return a==n},TOTOf:t(667)+t(864)+"s params"+t(1077)+t(403)+"tructor "+t(1159)+"ined",zvPKB:function(a,n,s){return a(n,s)},vwKyW:t(1587),gDnYM:"reconnect",jegSr:t(1488)+t(1581)+t(707)+"ct",XXeqB:"online",uwQNq:t(1182),NmNoN:t(1628),xDcxY:t(1119),fBbzA:function(a,n){return a!=n},vaEdz:"yEWfc",HYOKr:function(a,n,s){return a(n,s)},fFPse:"teJYK",TGeGq:function(a,n){return a==n},tMeGm:t(695),XYmXL:t(1766),jKuXa:t(876),NFdta:t(1804),ZywZi:t(891)+"d",lJpsO:t(667)+t(449)+"ddID, de"+t(1500)+t(1758),BBlIJ:function(a,n,s){return a(n,s)},hqreL:t(1171),gonnf:t(617)+"0",AWSCl:function(a,n){return a===n},MTCoz:"zLlKq",YvABP:function(a,n,s){return a(n,s)},iVxlv:function(a,n){return a||n},mlUnQ:t(1799),tnzmu:t(1693),dlOIj:function(a,n){return a>n},bbpDH:function(a,n,s){return a(n,s)},NxFia:function(a,n){return a(n)},TZeIJ:t(1148)+">",BBcmO:function(a,n){return a*n},qQosO:function(a,n){return a-n},zpNfw:function(a,n,s){return a(n,s)},FnXlA:t(847)+"e_timeout",WTjKe:t(1179),ZDCUY:function(a,n){return a&n},dPjRz:function(a,n){return a+n},Qmjlk:function(a,n){return a!==n},IQVYq:t(607),pOUMz:t(609)+" try rec"+t(494)+"g",nXdEy:function(a,n){return a!==n},HiPwE:t(1329),DaqSo:function(a,n,s){return a(n,s)},cCHUE:t(421),ywkib:t(1580),cqaHq:function(a,n,s){return a(n,s)},ktkVL:t(1638)+t(1247)+t(981)+t(732),IFESq:function(a,n){return a||n},guSvC:t(1768),zBQuj:function(a,n,s,d){return a(n,s,d)},vdLzl:t(1713),KRVHO:t(399),QDbWm:t(1163),mluUr:t(1324),AMoCT:function(a,n){return a+n},TpbmG:function(a,n){return a<n},YkqZz:function(a,n){return a&n},RMSaz:function(a,n){return a&n},xXyAu:t(1277),jWqgk:function(a,n,s){return a(n,s)},SdvtN:function(a,n){return a===n},RoOSE:t(1255),EFXUc:t(920),EmDXN:t(1591)+t(670),kSOsl:"close, w"+t(1726)+t(567),lqcfY:t(699)+t(1435)+t(1827)+t(909)+"ed",bMOWq:t(667)+t(913)+t(1149)+"ata, dat"+t(924)+t(1133)+t(657)+t(1328)+t(712),NVOJe:t(679),QSYit:function(a,n){return a!=n},YEYoO:function(a,n){return a instanceof n},hyeQC:function(a,n){return a instanceof n},yJero:function(a,n){return a(n)},SumUq:function(a,n){return a||n},YaWya:t(667)+t(913)+t(1314)+"ervice",SJEBD:function(a,n){return a instanceof n},fpsAu:function(a,n){return a===n},IhGFs:t(680),oxmLf:t(768),HkfWs:function(a,n){return a==n},VFEMe:function(a,n){return a!==n},EDsjN:"manual r"+t(535)+"ing",hjjLf:function(a,n,s){return a(n,s)},GKqub:function(a){return a()},JhqNv:function(a,n,s){return a(n,s)},AKOwD:function(a,n,s){return a(n,s)},pmmtn:"WMWnq",YDXrp:t(1063)+"3",KeOWc:function(a,n){return a!==n},qrCID:t(1191),kxsoc:function(a,n){return a*n},VvfSi:t(1093),AuCBr:function(a,n){return a===n},UATdj:function(a,n){return a===n},JygZk:"Object",vYWGe:t(991)+t(977)+t(1287)+"pe",WnUAo:function(a,n){return a!=n},YKMRj:"ServiceWorkerGlo"+t(1626),ElxCt:function(a,n){return a!=n},uAIgB:function(a,n){return a!=n},PBLSD:function(a,n){return a!=n},LjhhO:t(955)+t(1018)};Lt.r(De),Lt.d(De,{FWS:()=>Ap,CustomErrorEvent:()=>Md,createCloseEvent:()=>xt,ReconnectEvent:()=>Ld,createErrorEvent:()=>at,decodedFrame:()=>Xt,createOpenEvent:()=>Hd,CustomCloseEvent:()=>Bd,createReconnectEvent:()=>na,FrontierMessageEvent:()=>Fd,encodeFrame:()=>zt,createMessageEvent:()=>qd,OpenEvent:()=>Ud,ErrorCode:()=>en,Event:()=>Vn,MessageEvent:()=>zd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(930)](),f=r||(r=e[n(1138)](h,a)),g=Math[n(1777)]()[n(883)](16)[n(1393)](-6);return e[n(821)](e[n(1419)](s+d,f),g)}function o(){let a=t;return e.pqzKd(e[a(1498)](1e4,Date[a(930)]()),Math[a(1284)](e.KvlwQ(1e4,Math.random())))}function c(a){let n=t;return e.HBobL(Array(8)[n(724)]("0"),parseInt(a,10)[n(883)](2))[n(1393)](-8)}function l(a){let n=t,s={eUqMY:function(d,f){return e[H(581)](d,f)},kJWKL:function(d,f){return e.PZzSc(d,f)},BjflW:function(d,f){return e.SbTXg(d,f)}};return n(1700)!==n(466)?e[n(581)](e.HprQz(Array,4)[n(724)]("0"),e.RtgSS(parseInt,a,2)[n(883)](16))[n(1393)](-4):this.unsigned?s.eUqMY(s[n(1648)](this[n(1376)]>>>0,_0x3dfc35),s[n(917)](this[n(505)],0)):s[n(1135)](s[n(1648)](this[n(1376)],_0x1197e4),this.low>>>0)}function u(a){let n=t;if(e[n(1730)](n(1440),e[n(570)])){let s=a[n(584)](/\./)[n(785)](g=>c(g)),d=[];return d[0]=e[n(997)](l,e[n(522)](s[0],s[1])),d[1]=l(e[n(581)](s[2],s[3])),[e[n(610)],e[n(610)],e[n(610)],e[n(610)],e[n(610)],e[n(678)],d[0],d[1]][n(724)]("")}else return _0x34dfe3||(_0x2a2939=[_0x2b1042,_0x30be63,_0x4bafca,_0x1d6238,_0x5e3c43])}function h(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(687)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(687)](a);return s?e.yvhhC(u,a):d?e.EhWQo(p,a):e.JkTNz}function p(a){let n=t,s="",d=[],f=0,g=0,w=!0,b="0000";if(e[n(1461)](a[n(1087)]("::"),-1)){let x=a[n(584)]("::");for(let O=0;e.EeiAL(O,x[n(414)]);O++){let z=x[O];if(e[n(612)](z.indexOf(":"),0)){let G=z[n(584)](":");w&&(f=G.length),g+=G[n(414)];for(let K=0;e[n(1570)](K,G[n(414)]);K++)if(e[n(1730)](4,G[K][n(414)])){let he=b[n(833)+"g"](0,e[n(583)](4,G[K][n(414)])),Ee=he[n(1714)](G[K]);d[n(738)](Ee)}else d[n(738)](G[K]);w=!1}else{if(e[n(1730)](4,z[n(414)])){let G=b[n(833)+"g"](0,4-z[n(414)]),K=G[n(1714)](z);d[n(738)](K)}else d[n(738)](z);w&&(f+=1),g+=1,w=!1}}let A="";for(let O=0;e.VrNRM(O,8-g);O++)A=A.concat(b);for(let O=0;e[n(1124)](O,d[n(414)]);O++)e[n(1352)](O,f)?(s=s[n(1714)](A),s=s[n(1714)](d[O])):s=s.concat(d[O]);return s}{let x=a[n(584)](":");for(let A=0;A<x[n(414)];A++){let O=x[A];if(e[n(1730)](4,x[A][n(414)])){let z=b[n(833)+"g"](0,e[n(488)](4,x[A][n(414)])),G=z[n(1714)](O);s=s[n(1714)](G)}else s=s[n(1714)](O)}return s}}function m(a,n){let s=t,d=a[s(1850)];e[s(1470)](void 0,d)&&(e[s(1593)](le,n,10),q(n,d));let f=a[s(380)];e.JyXQe(void 0,f)&&(e[s(1593)](le,n,18),e[s(1593)](q,n,f))}function E(a){let n=t;if(e[n(1352)](n(1109),e.GBNNn))return new _0x3b3490(_0x3d5461,{data:_0x35df42,message:_0x524d56});{let s={};e:for(;!V(a);)if(e[n(1352)](e.teqJw,n(1054)))_0xf2e8b0[n(1347)+"JSONP"]=void 0,e[n(1138)](_0x2b7128,e[n(1151)]);else{let d=de(a);switch(e[n(1337)](d,3)){case 0:break e;case 1:s[n(1850)]=e[n(1593)](P,a,e[n(1261)](de,a));break;case 2:s.value=e.rHerF(P,a,e[n(711)](de,a));break;default:e.Isbrl(C,a,e[n(1266)](7,d))}}if(s.key===void 0)throw new Error(e[n(839)]);if(s.value===void 0)throw new Error(n(1812)+"required field: "+n(380));return s}}function T(a){let n=t,s=e[n(418)](D);return _(a,s),e[n(711)](B,s)}function _(a,n){let s=t,d={Ldxew:function(be,Ie){return e[H(1570)](be,Ie)}},f=a[s(1684)];e[s(1200)](void 0,f)&&(e[s(1682)](le,n,8),e[s(772)](ht,n,f));let g=a.LogID;e[s(1730)](void 0,g)&&(le(n,16),ht(n,g));let w=a[s(1373)];e[s(1322)](void 0,w)&&(e[s(1076)](le,n,24),e[s(1189)](ht,n,e.HprQz(N,w)));let b=a[s(632)];e[s(1200)](void 0,b)&&(le(n,32),e[s(498)](ht,n,e[s(1024)](N,b)));let x=a.headers;if(e[s(1200)](void 0,x))for(let be of x){e[s(1076)](le,n,42);let Ie=e.XSVgw(D);e[s(498)](m,be,Ie),e[s(1189)](le,n,Ie[s(836)]),e[s(1189)](W,n,Ie),k(Ie)}let A=a["payloadE"+s(382)];e[s(1821)](void 0,A)&&(e[s(498)](le,n,50),e[s(1456)](q,n,A));let O=a[s(842)+s(987)];e[s(1821)](void 0,O)&&(e[s(1781)](le,n,58),e[s(1552)](q,n,O));let z=a.payload;e.UImIJ(void 0,z)&&(e[s(1023)](le,n,66),e[s(553)](le,n,z.length),e.qAkDd(fe,n,z));let G=a[s(796)];if(e[s(1821)](void 0,G))if(e[s(1352)](e[s(1816)],e.cPzIB))e[s(1658)](le,n,74),q(n,G);else{let be=0,Ie={};for(let Ye=0;d[s(1254)](Ye,_0x22e3a7[s(414)]);Ye++)Ie[_0x3f7242[Ye][s(1695)+s(1026)]]=_0x529281(_0x52afa7[Ye]["cursor_n"+s(1026)]),be+=14+Ie[_0x4dbb7d[Ye][s(1695)+s(1026)]];return[be,Ie]}let K=a[s(1501)+s(1402)];e[s(1730)](void 0,K)&&(e[s(1131)](le,n,82),e[s(1131)](q,n,K));let he=a[s(1027)];if(e[s(451)](void 0,he)){if(e.nmiQz===e.zmpFm)return this.count>=this[s(1664)+"ount"];e[s(553)](le,n,90),e[s(1682)](q,n,he)}let Ee=a[s(1437)+"e"];e.jbYOx(void 0,Ee)&&(e.yBmxF(le,n,96),ht(n,e[s(426)](N,Ee)))}function v(a){let n=t;return e[n(1330)](I,e[n(1261)](M,a))}function I(a){let n=t,s={};e:for(;!e[n(665)](V,a);){let d=e[n(711)](de,a);switch(e[n(1030)](d,3)){case 0:break e;case 1:s.SeqID=St(a,!0);break;case 2:s[n(536)]=St(a,!0);break;case 3:s.service=e.nxXIL(de,a);break;case 4:s[n(632)]=e[n(1436)](de,a);break;case 5:{let f=e[n(426)](S,a);(s[n(1136)]||(s[n(1136)]=[])).push(e[n(1024)](E,a)),a[n(836)]=f;break}case 6:s[n(1627)+n(382)]=e[n(553)](P,a,e.dabeQ(de,a));break;case 7:s[n(842)+n(987)]=e[n(482)](P,a,e[n(1380)](de,a));break;case 8:s.payload=ye(a,e.DwzRH(de,a));break;case 9:s[n(796)]=e[n(384)](P,a,e[n(1806)](de,a));break;case 10:s.serverTiming=e[n(1131)](P,a,de(a));break;case 11:s[n(1027)]=e.ivOXA(P,a,e.DwzRH(de,a));break;case 12:s[n(1437)+"e"]=de(a);break;default:e.vSVNZ(C,a,e[n(1266)](7,d))}}if(s[n(1684)]===void 0)throw new Error(e.PxTHl);if(e[n(1352)](void 0,s[n(536)]))throw new Error(e[n(1348)]);if(s[n(1373)]===void 0)throw new Error(e[n(461)]);if(e[n(1352)](void 0,s.method))throw new Error(e[n(1818)]);return s}function S(a){let n=t,s=de(a),d=a[n(836)];return a[n(836)]=a[n(677)]+s,d}function C(a,n){let s=t;switch(n){case 0:for(;e[s(1266)](128,e.XyBzz(re,a)););break;case 2:e[s(1152)](J,a,e[s(1024)](de,a));break;case 5:e[s(1456)](J,a,4);break;case 1:J(a,8);break;default:throw new Error(e.pqzKd(s(1771)+s(1517)+s(967),n))}}function N(a){let n=t;return a|=0,{low:a,high:e[n(848)](a,31),unsigned:e.iwBGP(a,0)}}let y=[];function D(){let a=t,n=y[a(503)]();return n?(n[a(677)]=n[a(836)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){y[t(738)](a)}function M(a){return{bytes:a,offset:0,limit:a[t(414)]}}function B(a){let n=t,s=a.bytes,d=a[n(836)];return e[n(417)](s[n(414)],d)?s:s[n(1216)](0,d)}function J(a,n){let s=t;if(e[s(1006)](e[s(522)](a[s(677)],n),a[s(836)]))throw new Error(e.QkoLy);a[s(677)]+=n}function V(a){let n=t;return e[n(1045)](a[n(677)],a[n(836)])}function ee(a,n){let s=t,d={zIuWR:function(f,g){return f instanceof g},WxVPQ:function(f,g){return e.yvhhC(f,g)},fiUmW:function(f,g){return e[H(551)](f,g)},xcYdz:function(f,g){return f!==g}};if(e[s(1352)](e.YURyx,e[s(1318)])){let f=a[s(899)],g=a.offset,w=a[s(836)],b=e[s(821)](g,n);if(e[s(612)](b,f[s(414)])){let x=new Uint8Array(e[s(1166)](2,b));x[s(941)](f),a.bytes=x}return a[s(677)]=b,e[s(1006)](b,w)&&(a.limit=b),g}else{if(JMYGgu[s(652)](_0x385b15,_0x44bbe2))return JMYGgu[s(1238)](_0x16322c,_0x1879df);if(_0x4dfd30[s(1596)](_0x52ae5b))return _0x15bd70[s(633)](_0x40e067);let f=JMYGgu[s(765)](_0x4d7ec2,_0x283508);return JMYGgu[s(938)](f,_0x5351bf)&&(_0x6e6dd8[s(941)](_0x351f17,f),_0x2117ab[s(941)](f,_0x281d73)),f}}function X(a,n){let s=t;if(e.bmBOd!==e[s(1170)]){let d=_0x172f5e.pop();return d?(d.offset=d[s(836)]=0,d):{bytes:new _0x3e289e(64),offset:0,limit:0}}else{let d=a.offset;if(e[s(1751)](d+n,a.limit))throw new Error(e[s(1639)]);return a.offset+=n,d}}function ye(a,n){let s=t,d=X(a,n);return a.bytes[s(1216)](d,e[s(728)](d,n))}function fe(a,n){let s=t;if(e[s(622)](e[s(1196)],e[s(1278)]))e[s(1475)](_0x51a6f0,this,_0x4fbd27,[_0x167102,_0x3bb9ae,_0x156456,_0x323018,_0x207a49,_0x244ea1]);else{let d=e[s(640)](ee,a,n[s(414)]);a.bytes[s(941)](n,d)}}function P(a,n){let s=t,d=X(a,n),f=String[s(1325)+s(1158)],g=a.bytes,w="\uFFFD",b="";for(let x=0;e.aAYtb(x,n);x++){let A=g[x+d],O,z,G,K;if(e.yGgiM(128,A)===0)b+=e[s(1436)](f,A);else if(e[s(1009)](e.yGgiM(224,A),192))e[s(1448)](e[s(1351)](x,1),n)?b+=w:(O=g[e[s(728)](e[s(756)](x,d),1)],e[s(1519)](e[s(1266)](192,O),128)?b+=w:(K=e[s(798)](e[s(475)](e[s(676)](31,A),6),63&O),K<128?b+=w:(b+=e[s(1798)](f,K),x++)));else if(e.dPMAM(e.yGgiM(240,A),224)){if(e[s(1045)](e.SdWcr(x,2),n))b+=w;else if(e[s(1352)](e.xJKmS,e[s(1569)]))O=g[e.tlMsx(x,d)+1],z=g[e[s(522)](e.XHrcF(x,d),2)],e.yGgiM(O|e[s(475)](z,8),49344)!==32896?b+=w:(K=e[s(798)](e.efifk(e[s(475)](e[s(1649)](15,A),12),e.ndJWJ(e.Qwiqi(63,O),6)),63&z),K<2048||e[s(410)](K,55296)&&K<=57343?b+=w:(b+=e.UaIFA(f,K),x+=2));else if(_0x42dc3a>=_0x2dd8b6)return _0x4bc1ab}else e[s(1353)](248,A)==240?e[s(410)](e.BUcOn(x,3),n)?b+=w:(O=g[e[s(522)](x+d,1)],z=g[e[s(435)](e[s(1202)](x,d),2)],G=g[e[s(1281)](e.dDkJy(x,d),3)],e.HRJIU(e[s(798)](e.efifk(O,z<<8),e[s(475)](G,16)),12632256)!==8421504?b+=w:(K=e.efifk(e.efifk(e[s(798)](e[s(475)](7&A,18),e[s(806)](e[s(1649)](63,O),12)),e[s(475)](e[s(698)](63,z),6)),63&G),e[s(433)](K,65536)||K>1114111?b+=w:(K-=65536,b+=e[s(524)](f,e.HBobL(K>>10,55296),e[s(514)](e[s(1561)](1023,K),56320)),x+=3))):b+=w}return b}function q(a,n){let s=t,d={Inkcc:e.GzYWT},f=n[s(414)],g=0;for(let x=0;e[s(630)](x,f);x++){let A=n[s(1117)+"At"](x);e[s(1448)](A,55296)&&e.GyzAC(A,56319)&&e[s(433)](x+1,f)&&(A=e[s(1351)](e.EGhmo(A,10),n.charCodeAt(++x))-56613888),g+=e.aAYtb(A,128)?1:e[s(1623)](A,2048)?2:e[s(1181)](A,65536)?3:4}le(a,g);let w=e[s(841)](ee,a,g),b=a[s(899)];for(let x=0;e[s(1230)](x,f);x++){let A=n.charCodeAt(x);if(e[s(1045)](A,55296)&&e[s(1025)](A,56319)&&e.pVzcC(x+1,f)&&(A=e[s(583)](e[s(821)](e[s(1618)](A,10),n.charCodeAt(++x)),56613888)),e[s(1154)](A,128))b[w++]=A;else{if(A<2048)b[w++]=e[s(1040)](e[s(676)](e[s(848)](A,6),31),192);else{if(e[s(958)](A,65536))b[w++]=e[s(798)](A>>12&15,224);else if(e.flrVI(e.GAIvm,e.GAIvm))b[w++]=e[s(1654)](e[s(774)](e[s(790)](A,18),7),240),b[w++]=e[s(1451)](e[s(848)](A,12),63)|128;else if(!this[s(1592)+s(1537)]){let O=d[s(512)][s(584)]("|"),z=0;for(;;){switch(O[z++]){case"0":this[s(1592)]();continue;case"1":this[s(1411)+s(1032)]?.[s(606)+s(407)]();continue;case"2":this["_readyCl"+s(1466)]=!1;continue;case"3":this[s(413)+s(1538)]?.["resetEndpointCon"+s(1629)]();continue;case"4":this[s(763)]=!0;continue}break}}b[w++]=e.pdwku(A,6)&63|128}b[w++]=e[s(1654)](e[s(1526)](63,A),128)}}}function W(a,n){let s=t,d=e[s(1316)](ee,a,n[s(836)]),f=a.bytes,g=n[s(899)];for(let w=0,b=n[s(836)];e[s(1623)](w,b);w++)f[e.eJxfy(w,d)]=g[w]}function re(a){return a[t(899)][e.dlwsE(X,a,1)]}function Ve(a,n){let s=t,d=e[s(476)](ee,a,1);a.bytes[d]=n}function de(a){let n=t,s=0,d=0,f;do if(e[n(1470)](e[n(718)],e[n(718)])){if(e[n(1715)](void 0,_0x3dc0e5))this._listeners={};else if(e[n(622)](void 0,_0x28826c))this[n(1528)+"rs"][_0x130eda]=null;else{let g=this[n(1528)+"rs"][_0x332868];if(g)for(let w=0;e[n(433)](w,g[n(414)]);)e[n(1009)](g[w].fn,_0x38f48b)?g[n(727)](w,1):++w}return this}else f=e.nxXIL(re,a),e[n(1003)](s,32)&&(d|=e[n(1474)](127&f,s)),s+=7;while(e.HRJIU(128,f));return d}function le(a,n){let s=t;for(n>>>=0;n>=128;)e[s(1552)](Ve,a,e[s(1654)](e[s(795)](127,n),128)),n>>>=7;e[s(444)](Ve,a,n)}function St(a,n){let s=t,d=0,f=0,g=0,w;if(w=e[s(1330)](re,a),d=e[s(676)](127,w),128&w)if(e[s(1821)](e[s(802)],e.mdlQY)){if(w=re(a),d|=e[s(713)](e[s(1266)](127,w),7),e.zlNRw(128,w)&&(w=e.dabeQ(re,a),d|=(127&w)<<14,e[s(709)](128,w)&&(w=re(a),d|=e[s(863)](e[s(774)](127,w),21),128&w&&(w=re(a),f=e.zlNRw(127,w),e[s(1561)](128,w)&&(w=e[s(997)](re,a),f|=e[s(863)](e[s(1574)](127,w),7),e[s(618)](128,w))))))if(e[s(800)](e[s(1706)],s(1444))){let b={ZzSSW:sRXERx[s(916)],Hgsoc:sRXERx[s(1772)],hfqjA:sRXERx[s(464)]};_0x1638c7.r=x=>{let A=s;b[A(1647)]!=typeof _0x56255d&&_0x23ffcc[A(883)+A(725)]&&_0x3f6669[A(1529)+A(1021)](x,_0x134dca[A(883)+A(725)],{value:b[A(492)]}),_0x35e5eb[A(1529)+A(1021)](x,b[A(1172)],{value:!0})}}else w=e[s(1845)](re,a),f|=e[s(863)](e[s(1574)](127,w),14),128&w&&(w=e[s(1436)](re,a),f|=e.RZwTt(e[s(1017)](127,w),21),e.Qwiqi(128,w)&&(w=e[s(1728)](re,a),g=e[s(1561)](127,w),e[s(769)](128,w)&&(w=re(a),g|=e[s(754)](127&w,7))))}else _0x41fd2b[s(906)+s(966)]="",_0x394d3a.log(_0x59d27e);return{low:e[s(1090)](d,e[s(475)](f,28)),high:e[s(798)](e.smWjc(f,4),e[s(754)](g,24)),unsigned:n}}function ht(a,n){let s=t,d={EUzWm:function(f){return e.XSVgw(f)},xRDyy:function(f,g){return f(g)},DFTdG:e[s(929)],AxAxh:e[s(1121)]};if(e[s(615)]!==e.KlHUp){let f=n[s(505)]>>>0,g=e[s(1030)](e[s(1694)](e.hLDdi(n.low,28),e[s(1474)](n[s(1376)],4)),0),w=e[s(731)](n.high,24),b=e.pzCEU(0,w)?g===0?f<16384?f<128?1:2:f<2097152?3:4:e[s(619)](g,16384)?e[s(641)](g,128)?5:6:e[s(1154)](g,2097152)?7:8:e[s(1038)](w,128)?9:10,x=e.tHVGR(ee,a,b),A=a.bytes;switch(b){case 10:A[e.FPvdh(x,9)]=e.EOwbI(w>>>7,1);case 9:A[e[s(429)](x,8)]=e.BNrNS(9,b)?128|w:e.EOwbI(127,w);case 8:A[e[s(1342)](x,7)]=e[s(1322)](8,b)?e.XrYST(g>>>21,128):e[s(608)](g,21)&127;case 7:A[e.tUsaf(x,6)]=e.nEcom(7,b)?e[s(1090)](g>>>14,128):e[s(769)](g>>>14,127);case 6:A[e[s(1551)](x,5)]=b!==6?e.UogJe(g,7)|128:e.Qwiqi(e.dSVvv(g,7),127);case 5:A[e.BUcOn(x,4)]=e[s(1322)](5,b)?e[s(1090)](128,g):e[s(1649)](127,g);case 4:A[e[s(962)](x,3)]=e[s(1533)](4,b)?e[s(1090)](f>>>21,128):e.khxSw(e.kCEpQ(f,21),127);case 3:A[e[s(600)](x,2)]=b!==3?e[s(1090)](e.SDuaW(f,14),128):e[s(1361)](e[s(1844)](f,14),127);case 2:A[x+1]=b!==2?e.vwbVA(e.UogJe(f,7),128):e[s(1120)](f>>>7,127);case 1:A[x]=b!==1?e[s(1732)](128,f):127&f}}else{let f={yoGlo:"error",tZKrn:function(x){let A=s;return aKvhWu[A(1829)](x)},Zrrfz:function(x){let A=s;return aKvhWu[A(1829)](x)},dRBDR:function(x,A){return aKvhWu.xRDyy(x,A)},BwGpk:s(542)+"or"},g=()=>{let x=s;_0x212e5d[x(1699)+x(1262)+x(1231)](x(479),w),_0x4fef7a[x(1699)+x(1262)+x(1231)](f[x(502)],b),_0xca5462["removeEventListe"+x(1231)]("abort",b)},w=()=>{let x=s;f[x(559)](_0x155707),f[x(1666)](g)},b=()=>{let x=s;f.dRBDR(_0xb908a6,_0x14bb53[x(1304)]||new _0x255be8(f[x(974)],x(542)+"or")),g()};_0x1a6cd6[s(510)+"Listener"](aKvhWu[s(804)],w),_0x4dac92[s(510)+s(1469)](s(1304),b),_0x1ff27c[s(510)+s(1469)](aKvhWu[s(572)],b)}}function Xt(a){return e[t(956)](v,a)}function zt(a){return e[t(1707)](T,a)}let Qt=65536,qr=t(623),ge=e.BBcmO(Qt,Qt),Te=e[t(1505)](ge,ge),Jn=Te/2,Pe=String[t(497)+"e"][t(1117)+"At"];class ae{constructor(n,s,d){let f=t;this[f(362)]=!0,this[f(505)]=e[f(1090)](0,n),this[f(1376)]=e[f(1502)](0,s),this.unsigned=!!d}static isLong(n){let s=t;return n&&e[s(1750)](!0,n[s(362)])}static fromBits(n,s,d){return new ae(n,s,d)}static[t(1062)+"s"](n,s,d){let f=t;return d?ae[f(1062)+"sLE"](n,s):ae["fromByte"+f(1301)](n,s)}static["fromByte"+t(1572)](n,s){let d=t;return new ae(e[d(368)](e[d(904)](n[0],e[d(475)](n[1],8))|e[d(475)](n[2],16),e.nrfpZ(n[3],24)),e.BxUIs(e.eIsSZ(n[4],e[d(1539)](n[5],8)),e[d(1363)](n[6],16))|e[d(1618)](n[7],24),s)}static[t(1062)+t(1301)](n,s){let d=t;return new ae(e[d(1098)](e.iAQwg(e[d(1732)](n[4]<<24,e[d(945)](n[5],16)),n[6]<<8),n[7]),e[d(1710)](e[d(1694)](e[d(1474)](n[0],24),e[d(759)](n[1],16)),e[d(713)](n[2],8))|n[3],s)}static fromHash(n){let s=t;return n===qr?Nd:new ae(e[s(1455)](e[s(1698)](e.DqAlT(e[s(1694)](Pe[s(1525)](n,0),Pe[s(1525)](n,1)<<8),e[s(475)](Pe[s(1525)](n,2),16)),e.ZrHkh(Pe[s(1525)](n,3),24)),0),e[s(1825)](e[s(1732)](e.HXLSn(e[s(1694)](Pe.call(n,4),Pe[s(1525)](n,5)<<8),Pe[s(1525)](n,6)<<16),e[s(1208)](Pe[s(1525)](n,7),24)),0),!0)}[t(1099)](){let n=t;return String["fromChar"+n(1158)](e.dvHpJ(255,this[n(505)]),e[n(627)](e[n(1844)](this[n(505)],8),255),e.nTnQG(e.sqldc(this.low,16),255),e[n(1091)](this[n(505)],24),255&this.high,e[n(636)](this[n(1376)],8)&255,e[n(984)](this.high>>>16,255),e[n(636)](this[n(1376)],24))}static[t(532)+"er"](n,s=!0){let d=t;if(isNaN(n))return s?zx:Nd;if(s){if(e.itUUT(n,Te))return Ux}else{if(e[d(1065)](n,-Jn))return qx;if(e[d(1448)](e[d(1126)](n,1),Jn))return Fx}return ae[d(1432)](e[d(412)](n%ge,0),e[d(1747)](e[d(1692)](n,ge),0),s)}[t(826)](){let n=t;return this[n(558)]?e[n(1174)](e[n(1166)](e.kCEpQ(this[n(1376)],0),ge),e[n(1455)](this[n(505)],0)):e[n(951)](e.PZzSc(this[n(1376)],ge),e.uaiVH(this.low,0))}[t(358)](){let n=t;return e[n(1750)](0,this.high)&&e[n(1484)](0,this[n(505)])}[t(1150)](n){let s=t;ae.isLong(n)||(n=ae[s(532)+"er"](n));let d=e.SDuaW(this.high,16),f=e[s(1388)](65535,this[s(1376)]),g=e[s(1175)](this[s(505)],16),w=65535&this[s(505)],b=n.high>>>16,x=e[s(1039)](65535,n[s(1376)]),A=e[s(1719)](n[s(505)],16),O=65535&n[s(505)],z=0,G=0,K=0,he=0;return he+=e[s(522)](w,O),K+=e[s(359)](he,16),he&=65535,K+=e[s(1419)](g,A),G+=K>>>16,K&=65535,G+=e[s(1386)](f,x),z+=e.wmctd(G,16),G&=65535,z+=e[s(581)](d,b),z&=65535,ae.fromBits(e[s(643)](K,16)|he,e[s(1040)](e[s(762)](z,16),G),this[s(558)])}[t(1553)](n){let s=t;return ae[s(362)](n)||(n=ae[s(532)+"er"](n)),e[s(496)](this[s(558)],n.unsigned)&&e[s(1337)](this.high,31)===1&&e.URJTz(e[s(1337)](n.high,31),1)?!1:this.high===n[s(1376)]&&e[s(1480)](this.low,n.low)}[t(1226)](){let n=t;return e.muzId(-1,this.low)&&e.KpIAs(-1,this[n(1376)])?ae[n(1432)](0,0,this[n(558)]):this.low===-1?ae.fromBits(0,e.YmHCx(this[n(1376)],1),this[n(558)]):ae[n(1432)](e[n(1632)](this[n(505)],1),this[n(1376)],this[n(558)])}[t(394)](n){return n?this.toBytesLE():this.toBytesBE()}toBytesLE(){let n=t,s=this[n(1376)],d=this[n(505)];return[255&d,e[n(1825)](d,8)&255,e.eTxME(e[n(988)](d,16),255),e[n(608)](d,24),255&s,e[n(1526)](e[n(1844)](s,8),255),e[n(555)](s>>>16,255),s>>>24]}[t(733)+"E"](){let n=t,s=this[n(1376)],d=this[n(505)];return[e[n(731)](s,24),e[n(1187)](s,16)&255,e[n(709)](e.iHMqu(s,8),255),e[n(748)](255,s),d>>>24,e[n(1323)](e[n(797)](d,16),255),e[n(355)](d>>>8,255),e[n(1122)](255,d)]}}let Nd=new ae(0,0,!1),zx=new ae(0,0,!0),Fx=ae[t(1432)](-1,2147483647,!1),Ux=ae[t(1432)](-1,-1,!0),qx=ae[t(1432)](0,-2147483648,!1);var en=(function(a){let n=t,s=(n(1716)+"0|1")[n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[n(402)+"OR"]=5005]="OPEN_ERROR";continue;case"1":return a;case"2":a[a[e.WNpzc]=5002]=e[n(1374)];continue;case"3":a[a[e.WIllv]=5001]=e.WIllv;continue;case"4":a[a[e.GJepP]=5003]=n(993)+n(1843)+"R";continue;case"5":a[a[e.IrNUG]=5004]=n(518)+"ERROR";continue}break}})({});class Vn{constructor(n){let s=t;this[s(1271)]=n,this[s(537)]=null}}class Ld extends Vn{constructor(n,s){let d=t;super(n),this[d(1128)]=s&&s.message||null}}class Md extends Vn{constructor(n,s){let d=t,f=(d(575)+d(521)).split("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(777)]=s&&s[d(777)]||5001;continue;case"1":this[d(844)]=s&&s.lineno||0;continue;case"2":this[d(1304)]=s&&s[d(1304)]||null;continue;case"3":this[d(905)]=s&&s.filename||"";continue;case"4":this[d(1128)]=s&&s[d(1128)]||"";continue;case"5":super(n);continue;case"6":this[d(605)]=s&&s[d(605)]||0;continue}break}}}class Bd extends Vn{constructor(n,s){let d=t,f=e[d(477)][d(584)]("|"),g=0;for(;;){switch(f[g++]){case"0":this.wasClean=s&&s[d(1333)]||!1;continue;case"1":super(n);continue;case"2":this[d(1828)+d(554)]=s&&s[d(1828)+d(554)]||!1;continue;case"3":this[d(777)]=s&&s.code||0;continue;case"4":this[d(1205)]=s&&s[d(1205)]||"";continue}break}}}class zd extends Vn{constructor(n,s){let d=t;super(n),this[d(1479)]=s&&s[d(1479)]||null}}class Fd extends zd{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1479)]||null,this[d(1128)]=s&&s[d(1128)]||null}}class Ud extends Vn{constructor(n,s){let d=t;super(n),this[d(1479)]=s&&s[d(1479)]||null}}function at(a,{message:n,code:s,error:d}){return new Md(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){let g=t;if(e[g(1519)](e[g(1309)],"pMAWd"))e.BeqOk(_0x754f9b,_0xc81b01,32),e[g(538)](_0x320b1f,_0x28afd1,_0x5d16b6(_0x1a77cc));else return new Bd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function qd(a,{data:n,message:s}){return new Fd(a,{data:n,message:s})}function Hd(a,{data:n}){let s=t,d={sogUZ:function(f,g){return e[H(825)](f,g)},uOYGD:function(f,g,w){return e[H(1249)](f,g,w)},hTOeI:function(f,g,w){return e[H(1559)](f,g,w)},uxWIe:function(f,g,w,b){return e[H(1475)](f,g,w,b)},XcStZ:function(f,g){return f+g}};if(e[s(1263)]==="zSWoZ")return new Ud(a,{data:n});{let f=0,g=[];for(;d[s(823)](f,_0x16411e[s(1227)+"th"]);){let{offset:w}=d[s(525)](_0x5050ac,_0x265a40,f);f=w;let b={cursor_name:"",cursor:0,service:0},{value:x,offset:A}=_0x1441ad(_0x21e437,f);b.service=x,f=A;let{value:O,offset:z}=d[s(671)](_0xf0298b,_0x4cec40,f);f=z,b[s(1695)+s(1026)]=d.uxWIe(_0x2288b6,_0x447fb3,f,d[s(1565)](f,O)),f+=O;let{value:G,offset:K}=d.hTOeI(_0x578d55,_0x195d86,f);b[s(457)]=G[s(826)](),f=K,g[s(738)](b)}return g}}function na(a,{message:n}){let s=t,d={EEHmG:function(f,g,w){return f(g,w)},hgEcV:e.TYaio,enVzD:function(f,g){return e[H(1009)](f,g)},EgWVY:function(f,g,w){return e[H(1658)](f,g,w)}};if(e[s(668)](e[s(971)],e[s(1195)]))return new Ld(a,{message:n});{let f=this[s(413)+s(1538)]?.[s(658)+s(1319)+"es"](),g=this[s(413)+s(1538)]?.[s(726)+s(986)+"nt"]();if(f&&!_0x4b8310[s(1128)]){let w=s(1081)+g+(s(1717)+s(1688)+s(655)+"ed");this[s(1184)+s(1207)+s(968)](d.EEHmG(_0x5cdec6,d[s(858)],{message:w,code:_0x34b1d4[s(993)+s(1843)+"R"],error:_0xd890a6}));return}this[s(862)]&&d[s(912)](this[s(862)][s(998)+"te"],this.OPEN)&&this[s(1408)+s(486)](),this["_dispatc"+s(1207)+s(968)](d[s(946)](_0x29b139,d.hgEcV,{message:_0x118543[s(1128)],code:_0x155daa.NATIVE_ERROR,error:_0x51a0d1}))}}class jd{constructor(n,s){let d=t;this.endpoints=n,this[d(1805)+"es"]=s,this[d(865)+d(1518)]=0,this["currentE"+d(1449)+d(1790)+"t"]=0}[t(1645)+t(1211)+"fig"](){let n=t;this[n(865)+n(1518)]=0,this[n(927)+n(1449)+n(1790)+"t"]=0}[t(1842)+"es"](){let n=t;if(e.xjtnz===n(1441))this[n(927)+"ndpointT"+n(1790)+"t"]=0;else{let d=""+_0x895839[n(930)](),f=_0x17887c||(_0x33431e=_0x4cf285(_0x27b07f)),g=_0x13be4b.random().toString(16)[n(1393)](-6);return e.KYelp(e[n(901)]("02",d),f)+g}}[t(726)+t(986)+"nt"](){let n=t;return this[n(1173)+"s"][this[n(865)+n(1518)]]}[t(726)+"ntEndpoi"+t(530)+t(1720)](){let n=t;return this[n(927)+n(1449)+"riesCount"]}[t(658)+t(1319)+"es"](){let n=t;return!!(e[n(1298)](this[n(865)+n(1518)],this[n(1173)+"s"].length)||e[n(1750)](this.currentIndex,e[n(488)](this.endpoints[n(414)],1))&&this["currentE"+n(1449)+n(1790)+"t"]===this[n(1805)+"es"])}[t(824)+t(1258)+t(511)+"hedMaxRe"+t(1683)](){let n=t;return e[n(1417)](this[n(865)+n(1518)],this[n(1173)+"s"].length)?!0:e[n(1650)](this[n(927)+n(1449)+n(1790)+"t"],this[n(1805)+"es"])}[t(400)+t(1584)+t(1678)+"UpdateCo"+t(1749)](){let n=t;if(e.PzBcB(n(663),n(1107)))_0x193814-=65536,_0x410765+=e[n(1595)](_0x192a50,e[n(1351)](_0x1dabbc>>10,55296),e.AlkEF(e.HRJIU(1023,_0x22c438),56320)),_0x4baa46+=3;else return this[n(927)+n(1449)+n(1790)+"t"]=1,this[n(865)+n(1518)]++,this[n(1173)+"s"][this.currentIndex]}[t(726)+t(986)+t(1578)+t(736)](){let n=t;return this[n(927)+n(1449)+n(1790)+"t"]++,this[n(726)+"ntEndpoint"]()}}let Yn=(e[t(1615)]("undefined",typeof globalThis)&&e[t(1012)](e[t(1407)],globalThis["construc"+t(576)][t(1310)])||e.QSYit(t(1657)+"d",typeof window)&&e[t(1672)](e[t(1407)],window["construc"+t(576)][t(1310)]))&&e.GdDKp(e[t(916)],typeof document),In=e[t(916)]!=typeof globalThis&&(e[t(1190)](e[t(1780)],globalThis[t(375)+t(576)][t(1310)])||e[t(557)]===globalThis[t(375)+"tor"].name)&&e[t(356)](e[t(916)],typeof tt),Hr=(e[t(1293)](e[t(916)],typeof globalThis)&&e.aiEeo(e[t(1780)],globalThis[t(375)+t(576)].name)||e[t(1031)](e[t(916)],typeof globalThis)||e.QSYit(e[t(916)],typeof globalThis)&&!!globalThis["WeixinJS"+t(424)])&&e[t(916)]!=typeof wx,jr=e[t(1615)]("undefined",typeof globalThis)&&(e[t(557)]===globalThis[t(375)+t(576)][t(1310)]||t(1265)+t(888)+t(1088)===globalThis[t(375)+"tor"][t(1310)]||e.PzBcB(e[t(1272)],globalThis[t(375)+"tor"][t(1310)]))&&e[t(916)]!=typeof self,Hx=e[t(411)](e[t(916)],typeof globalThis)&&e[t(1780)]===globalThis[t(375)+t(576)][t(1310)]&&e.uAIgB(e.seZJu,typeof global)&&e.aiEeo(t(1447),global["construc"+t(576)][t(1310)])&&e[t(411)](e[t(916)],typeof process)&&!!process.version;class ra{constructor(){let n=t;this[n(1528)+"rs"]={}}[t(815)](n,...s){let d=t,f=this[d(1528)+"rs"][n];if(f)f.slice().forEach(g=>g.fn[d(898)](g[d(1428)],s));else if(d(1304)===n&&!this.onerror)if(e[d(845)]===e.enZly)_0x682def[d(1699)+"entListe"+d(1231)](sRXERx[d(758)],_0x56735a),_0xdc15b2[d(1699)+d(1262)+d(1231)](d(1304),_0xa4de49);else{let g=s[d(414)]&&s[0];if(e[d(722)](g,Error))throw g;let w=new Error(e.iHrHj(e.XlaQT,g?e[d(563)](e[d(1236)](" (",g[d(1128)]),")"):""));throw w[d(693)]=g,g}return this}[t(1671)](n,s){let d=t;if(e[d(1750)](e[d(884)],e[d(1392)])){if(_0x494514=e.ikLtN(127,_0x5a344a[_0x41306b])>>>0,e[d(857)](_0x56807f[_0xca022d++],128))return{value:_0x145d06?_0x470283:e[d(701)](0,_0x5c7497),offset:_0x144095};if(_0x274e2c=e[d(886)](e[d(1090)](_0x1106d9,e[d(1429)](e.ikLtN(127,_0x1ab2c6[_0x37d208]),7)),0),e[d(1154)](_0x3d89c1[_0xd493b5++],128))return{value:_0x447989?_0x2b26ad:0|_0x34d307,offset:_0x21f5df};if(_0x2d9d49=e[d(1747)](_0x1d2968,e.bjiZu(e.eTxME(127,_0x63c9c8[_0x18a71e]),14))>>>0,e[d(619)](_0x7dbc79[_0x2bcaf2++],128))return{value:_0x33fe77?_0x2ffc79:e[d(1741)](0,_0x14c616),offset:_0x53d204};if(_0x6ae20=e.dLzMf(e[d(1235)](_0x1eca09,e.TQzil(127,_0x45d65f[_0x5100d8])<<21),0),e[d(1820)](_0xb1e5a6[_0x5b81a8++],128))return{value:_0x5d1dc7?_0x3393bc:e[d(1851)](0,_0x124f4a),offset:_0x405c36};if(_0x5a3ca0=e[d(1042)](_0x160380|e.eTxME(15,_0x412923[_0xf35817])<<28,0),e.wCmId(_0x3469d1[_0x93a783++],128))return{value:_0x25af23?_0x17076b:0|_0x104b45,offset:_0x1b6d1b};if((_0x3a8d4f+=5)>_0x56c603.length)throw _0x235fb3=_0x21d30c[d(414)],e[d(1709)](_0x36fecb,_0x2db20f,10,_0x229f5c[d(414)]);return{value:_0x5f311c?_0x481829:e[d(1387)](0,_0x16b7b8),offset:_0x407dca}}else{if(e.xtfws(void 0,n))this._listeners={};else if(e.wJLbG(void 0,s))this._listeners[n]=null;else{let f=this._listeners[n];if(f)for(let g=0;e[d(433)](g,f[d(414)]);)e[d(1480)](f[g].fn,s)?f[d(727)](g,1):++g}return this}}on(n,s,d){let f=t;return(this._listeners[n]||(this[f(1528)+"rs"][n]=[]))[f(738)]({fn:s,ctx:d||this}),this}}class jx extends ra{[t(1110)+"rrorMess"+t(1219)](n){let s=t;return n[s(436)]||n.errNo?(s(887)+" "+(n[s(436)]||"")+s(1e3)+(n[s(1745)]||""))[s(892)]():JSON[s(531)+"y"](n)}constructor(n,s,d){let f=t;super(),this._socket=null,Hr&&wx[f(1354)+f(1585)]&&(this[f(1257)]=wx[f(1354)+"ocket"]({url:n,protocols:s,header:d,fail:this["_createS"+f(855)+f(922)][f(1052)](this),success:this[f(515)+f(603)+f(1549)+f(1367)][f(1052)](this)})),In&&tt[f(1354)+"ocket"]&&(this._socket=tt[f(1354)+f(1585)]({url:n,protocols:s,header:d,fail:this[f(515)+f(855)+f(922)][f(1052)](this),success:this["_createS"+f(603)+f(1549)+f(1367)].bind(this)}))}[t(515)+t(603)+"cessHand"+t(1367)](){Promise.resolve().then(()=>{this[H(875)+"steners"]()})}[t(515)+t(855)+t(922)](n){let s=t,d={reWii:e[s(1368)],ayLlW:e.gjZRl};Promise[s(1240)]().then(()=>{let f=s,g=at(d[f(1590)],{message:this[f(1110)+"rrorMess"+f(1219)](n)});this[f(815)](f(1304),g);let w=xt(d[f(849)],{reason:this[f(1110)+f(408)+f(1219)](n)});this[f(815)](d[f(849)],w)})}["_addWsLi"+t(1161)](){let n=t,s={kOLbk:e[n(1143)],sSTWX:function(d,f,g){return d(f,g)},PLzwb:n(1304)};this[n(1257)][n(1522)](d=>{let f=n;this[f(815)](s.kOLbk,s.sSTWX(Hd,s[f(1169)],{...d,data:d[f(436)]||""}))}),this[n(1257)][n(422)](d=>{let f=n;this.emit(e[f(447)],e[f(538)](xt,e[f(447)],{...d}))}),this._socket.onMessage(d=>{let f=n;this[f(815)](f(1128),e[f(441)](qd,e[f(348)],{...d}))}),this[n(1257)][n(1601)](d=>{let f=n;this[f(815)](s[f(1691)],at(s.PLzwb,{...d,message:d.errMsg||""}))})}[t(1573)](n){let s=t;if(e[s(674)](n,Uint8Array)){let d=n[s(1053)][s(1393)](n.byteOffset,e[s(600)](n[s(1227)+"th"],n[s(347)+"et"]));this[s(1257)]&&this[s(1257)][s(1573)]({data:d,fail:f=>{let g=s;this[g(815)](e.TYaio,at(g(1304),{message:this[g(1110)+g(408)+"age"](f)}))}})}else this[s(1257)]&&this[s(1257)][s(1573)]({data:n,fail:d=>{let f=s;this[f(815)](e[f(1368)],at(e[f(1368)],{message:this["_formatE"+f(408)+"age"](d)}))}})}[t(1834)](n,s){let d=t;this._socket&&this._socket[d(1834)]({code:n,reason:s})}[t(510)+t(1469)](n,s){let d=t;if(e.UImIJ(e[d(547)],d(648)))this.on(n,s);else{let{value:f,offset:g}=e[d(1131)](_0x33b584,_0x48da51,_0x5a51ea);_0x2f3579=g,_0x21eb37=e[d(636)](e[d(964)](_0x3bd4a0,8),0),_0x49700c+=f}}[t(1699)+"entListe"+t(1231)](n,s){this[t(1671)](n,s)}get readyState(){let n=t;return this[n(1257)][n(998)+"te"]}get binaryType(){let n=t;return e[n(812)]===e[n(878)]?_0x1009d1.readUInt8?{value:_0x24e2fe[n(1104)+"8"](_0xb130cf),offset:_0x30ead1+1}:{value:e.HRJIU(255,_0x48c5dc[_0x4885ad]),offset:e[n(1067)](_0x53dbdc,1)}:this[n(1257)].binaryType}set[t(1485)+"pe"](n){}get[t(818)](){let n=t;return this._socket[n(818)]}get[t(1145)](){let n=t;return this[n(1257)][n(1145)]}get[t(1733)+"ns"](){let n=t,s={sWlPW:function(d,f){return e[H(1092)](d,f)}};return e[n(688)](e[n(1826)],e[n(1826)])?KgtjWn.sWlPW(0,this[n(1376)])&&KgtjWn.sWlPW(0,this[n(505)]):this[n(1257)][n(1733)+"ns"]}get[t(1210)+t(508)](){return 0}}function Gx(a,n){let s=t;if(n)return new n(a[s(818)],a[s(1145)]);if(e[s(1795)](Hr,In))return new jx(a[s(818)],a[s(1145)],a.headers);if((Yn||jr)&&e.NACNx("undefined",typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1145)+"s"])}function Wx(a){let n=t,s=e[n(1667)][n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":return!1;case"1":if(In&&tt[n(1354)+n(1585)])return!0;continue;case"2":if(e[n(1256)](Yn,jr)&&e[n(1293)](e[n(916)],typeof WebSocket)&&WebSocket)return!0;continue;case"3":if(Hr&&wx[n(1354)+n(1585)])return!0;continue;case"4":if(a)return!0;continue}break}}function Gd(a,n,s){let d=t,f=-1;async function g(w){let b=H;return e[b(1025)](w,f)?Promise[b(1597)](new Error(e[b(1736)])):(f=w,e[b(1484)](w,s[b(414)])?Promise[b(1240)]():s[w].bind(a)(n,g.bind(null,e[b(1067)](w,1))))}e[d(997)](g,0)}function Wd(a){let n=t,s=0,d=0;for(let f=0;e.XKTDa(f,a[n(414)]);++f)d=a[n(1117)+"At"](f),e[n(681)](d,128)?s+=1:d<2048?s+=2:e[n(1633)](e[n(355)](64512,d),55296)&&e[n(417)](e[n(1598)](64512,a[n(1117)+"At"](f+1)),56320)?(++f,s+=4):s+=3;return s}function Kd(a,n,s){let d=t,f={NNARl:function(g,w){return e[H(493)](g,w)},vJjkG:function(g,w){return e[H(438)](g,w)},QXUvR:e[d(747)]};if(e[d(1433)](e.llaTr,e[d(1176)])){if(e[d(1570)](e.fJHaK(s,n),1))return"";let g="";for(let w=n;e[d(613)](w,s);){let b=a[w++];if(b<=127)g+=String[d(1325)+d(1158)](b);else if(e.rcjpA(b,192)&&e[d(1181)](b,224))g+=String[d(1325)+d(1158)]((31&b)<<6|e[d(1237)](63,a[w++]));else if(e.eqhdp(b,224)&&e[d(860)](b,240))g+=String[d(1325)+d(1158)](e[d(1718)](e[d(1694)](e[d(1514)](15,b)<<12,e[d(1363)](e.tmscF(63,a[w++]),6)),e[d(1759)](63,a[w++])));else if(e[d(1298)](b,240)){let x=e[d(552)](e.sMnHB(e[d(1040)](e[d(1747)](e[d(1371)](e[d(546)](7,b),18),e[d(683)](e[d(766)](63,a[w++]),12)),e[d(1353)](63,a[w++])<<6),63&a[w++]),65536);g+=String[d(1325)+d(1158)](55296+e[d(848)](x,10)),g+=String[d(1325)+d(1158)](e[d(600)](56320,1023&x))}}return g}else{let g=f.NNARl(_0x4448cf,_0x1c5241);this[d(862)]&&f[d(1359)](this[d(862)][d(998)+"te"],this[d(1060)])&&(this._ws&&this[d(862)][d(1573)](g),this[d(1142)](f[d(1810)],_0x47f8fd))}}function ia(a,n,s){let d=t,f=s,g,w;for(let b=0;b<a[d(414)];++b)if(g=a[d(1117)+"At"](b),g<128)n[s++]=g;else if(e[d(792)](g,2048))n[s++]=e[d(874)](e[d(848)](g,6),192),n[s++]=e[d(1732)](e[d(1454)](63,g),128);else if(e[d(628)](e[d(1237)](64512,g),55296)&&e.kSrSu(64512&(w=a.charCodeAt(b+1)),56320)){let x=e[d(393)][d(584)]("|"),A=0;for(;;){switch(x[A++]){case"0":n[s++]=e.SxStB(63&g,128);continue;case"1":n[s++]=e[d(406)](e[d(1338)](e.ypVOG(g,6),63),128);continue;case"2":n[s++]=e[d(1345)](g>>18,240);continue;case"3":++b;continue;case"4":n[s++]=g>>12&63|128;continue;case"5":g=e[d(435)](e[d(684)](65536,e[d(387)](1023&g,10)),e[d(627)](1023,w));continue}break}}else n[s++]=e.kFYwS(g>>12,224),n[s++]=e[d(1811)](g,6)&63|128,n[s++]=e.WaMHe(e[d(644)](63,g),128);return e[d(583)](s,f)}async function $d(a){let n=t;if(e[n(803)]==typeof a)if(e[n(622)](n(789),e.vvPRL))_0xf46297[n(1802)][n(973)+"ild"](_0x3a03d1);else{let s=new Uint8Array(e[n(1661)](Wd,a));return e.PDPIH(ia,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a[n(347)+"et"],a[n(1227)+"th"])}function Kx(a){let n=t,s={aQhNT:function(d,f){return e[H(612)](d,f)},UrxAM:n(716)+n(513)};if(e[n(1009)](e[n(1567)],e[n(590)])){if(GqtrkV.aQhNT(_0x1ab5ac.offset+_0x4ed3c9,_0xfc24eb[n(836)]))throw new _0x583cdd(GqtrkV[n(1245)]);_0x19c6eb[n(677)]+=_0x4b0ca4}else try{return e[n(1293)](e.uNFHJ,typeof a)&&(a instanceof ArrayBuffer||a[n(1053)]&&e.MkmQj(a[n(1053)],ArrayBuffer))||e[n(803)]!=typeof a?"":(JSON.parse(a),e.QKKHU)}catch{return n(719)==typeof a?e[n(594)]:""}}let $x=(a,n)=>{let s=t;switch(a){case e.JfjXZ:case e[s(1160)]:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class Jx{constructor(n){let s=t;this[s(1664)+s(1720)]=n,this.count=0}[t(1625)](){let n=t;if(e[n(1748)](e[n(1778)],e[n(1764)]))this[n(932)]++;else{let s=_0x34938b[n(833)+"g"](0,4-_0x54f4cf[_0xa87235][n(414)]),d=s[n(1714)](_0x34f7bb);_0x2ee725=_0x56f408[n(1714)](d)}}[t(658)+"chMaxCount"](){let n=t;return this.count>=this[n(1664)+n(1720)]}[t(606)+t(407)](n=0){let s=t;this[s(1664)+s(1720)]=n,this.count=0}}async function Vx(a){let n=t,s={xOaeO:function(d,f){return e[H(1108)](d,f)},ZGfAe:e[n(1151)],USzyJ:function(d,f,g){return e[n(1131)](d,f,g)},FjiQP:function(d,f){return e[n(1730)](d,f)},evjtL:n(1613),EuvAC:"ioWlR",ggnst:e[n(455)],VlRJl:n(1622),AeAot:e.XbBUq,cREJj:function(d,f){return e[n(493)](d,f)}};return new Promise(d=>{let f=n,g={fgQVH:function(w,b,x){return s[H(1123)](w,b,x)},zYfnc:function(w,b){return w+b}};if(s[f(1543)](s.evjtL,s.EuvAC)){if(!Yn)return d(s.ZGfAe);try{let w=document[f(443)+"ement"](f(566));window[f(1347)+f(654)]=b=>{let x=f;document[x(1802)][x(656)+x(1020)](w),window[x(1347)+x(654)]=void 0,s[x(1002)](d,b&&b[x(397)]||s.ZGfAe)},w[f(1271)]=s.ggnst,w.src=a[f(1336)](/^ws/,s[f(730)])+s[f(1576)];try{document[f(1802)].appendChild(w)}catch{if(s.FjiQP(f(1294),f(1406)))document.body[f(656)+f(1020)](w);else{let b=jqTnpY[f(940)](_0x4c3ebc,_0x1daaa3,_0x3d39f9);return _0x456313[f(899)][f(1216)](b,jqTnpY[f(801)](b,_0x2a3314))}}}catch{window[f(1347)+f(654)]=void 0,s.cREJj(d,s[f(1631)])}}else this[f(809)]=_0x423ea9,this[f(357)]=_0x135641,this[f(1224)]=_0x1887e6?_0x1a3c88:_0x533f3e?_0x55e407:null})}function tn(a,n,s){let d=t;return!!a?.[d(1365)](f=>f.key===n&&f[d(380)]===s)}function Zn(a,n){let s=t;return a?.find(d=>d[s(1850)]===n)?.[s(380)]}let sa=null;async function Yx(){let a=t;if(e[a(465)](e.bifRj,e[a(1213)]))return sa||(sa=Promise.resolve()[a(1491)](Lt[a(1052)](Lt,"idb"))),sa;if(this[a(965)][a(1586)+a(1385)+a(1445)]||this[a(653)+a(1466)])return;this[a(1220)+a(535)]()}class Zx extends ra{constructor(n,s){let d=t;super(),this[d(1555)]=n,this[d(1134)]=s,this[d(1224)]=void 0,this[d(1589)+d(1767)]=null}async[t(791)](){await this._init()}async[t(1830)](){let n=t,s={irdci:function(d,f,g){return e.mnEkf(d,f,g)}};if(e[n(451)](e[n(793)],n(947))){if(this._qosDB)return;if(this["_initPro"+n(1767)])return this["_initPro"+n(1767)];try{let d=this._dbName,f=this._keyPath;this[n(1589)+"mise"]=(async()=>{let g=n,{openDB:w}=await e[g(1510)](Yx);this._qosDB=await e.WlQRD(w,g(1347)+"_"+d,1,{upgrade(b){b[g(1524)+"jectStore"](d,{keyPath:f})}})})(),await this["_initPro"+n(1767)]}catch(d){console[n(757)](d)}finally{this[n(1589)+n(1767)]=null}}else hmBCwM.irdci(_0x4e6918,_0x3b6559,10),hmBCwM[n(779)](_0x40438e,_0x33f1c4,_0x58f7de)}async[t(633)](n){let s=t;try{if(e[s(1484)]("rTVcp",e[s(1259)]))return await this[s(1830)](),this._qosDB?.[s(633)](this._dbName,n);e[s(538)](_0x47de9a,_0x5550e2,82),_0x41f98e(_0x5cfac6,_0x8b156a)}catch(d){console[s(757)](d)}}async set(n,s){let d=t;return await this._init(),this[d(1224)]?.[d(983)](this[d(1555)],n)}async[t(1635)](n){let s=t;try{return await this[s(1830)](),this[s(1224)]?.[s(1276)](this._dbName,n)}catch(d){console[s(757)](d)}}async[t(1221)](){let n=t;try{return await this[n(1830)](),this[n(1224)]?.[n(1221)](this[n(1555)])}catch(s){console[n(757)](s)}}async[t(1462)](){let n=t;return await this[n(1830)](),this[n(1224)]?.[n(689)+"ys"](this[n(1555)])}async[t(1481)](){let n=t;return await this._init(),this[n(1224)]?.[n(1481)](this[n(1555)])}async[t(420)](){let n=t,s={XmUHS:function(d,f){return e.pqzKd(d,f)},DxATM:function(d,f){return e[H(1845)](d,f)},uWDWI:function(d,f,g){return e[H(925)](d,f,g)},HBDiG:function(d,f){return e[H(405)](d,f)},ZWlVD:function(d,f){return e[H(1746)](d,f)}};if(e[n(1533)]("EuYej",e[n(1577)]))return this._ws?this._ws[n(818)]:this._url;try{if(e[n(1232)]===e[n(1673)])return QqblMI[n(1233)](QqblMI[n(1413)](_0x275c3d,4)[n(724)]("0"),QqblMI[n(752)](_0x35ee15,_0x5e4601,2).toString(16))[n(1393)](-4);this._qosDB?.[n(1834)](),this[n(1224)]=void 0}catch(d){if(e[n(351)]===n(1423))console[n(757)](d);else{if(QqblMI[n(1731)](_0x572991,-_0x214c6a))return _0x5ad66f;if(QqblMI[n(1332)](_0x28fa05+1,_0x19e0ca))return _0x42cea9}}}get isReady(){let n=t;try{return!!this[n(1224)]}catch(s){return console[n(757)](s),!1}}}class Xx{constructor(n,s){let d=t;this[d(809)]=n,this._pathKey=s,this[d(1224)]=localStorage}async[t(791)](){}get[t(1855)](){let n=t;return n(1347)+"_"+this[n(809)]}async[t(633)](n){let s=t,d={dUcIh:e[s(1164)],DMqvo:function(f,g){return e.nOOig(f,g)},iYBXQ:function(f,g){return e.oHwWd(f,g)}};if(e.KpIAs(e[s(1356)],e[s(1356)])){let f=this[s(1224)][s(1757)](this[s(1855)]);return JSON.parse(e.QDyCD(f,"{}"))[n]}else return _0x5dad47 instanceof _0x42e4ca&&(_0x306a1a===OybBTB.dUcIh||OybBTB[s(1019)](_0x59208c,s(934)))?!0:OybBTB[s(1199)](_0x1683e1,_0x46247f)}async[t(941)](n,s){let d=t,f=this[d(1224)][d(1757)](this[d(1855)]),g=JSON.parse(f||"{}");return g[s||n[this[d(357)]]]=n,this[d(1224)][d(1755)](this[d(1855)],JSON[d(531)+"y"](g)),s||n[this[d(357)]]}async del(n){let s=t,d=this._qosDB[s(1757)](this[s(1855)]),f=JSON[s(625)](e[s(1256)](d,"{}"));return f[n]=void 0,this._qosDB[s(1755)](this[s(1855)],JSON[s(531)+"y"](f))}async[t(1221)](){let n=t;return this[n(1224)][n(1221)]()}async[t(1462)](){let n=t,s=this[n(1224)][n(1757)](this[n(1855)]),d=JSON.parse(e[n(483)](s,"{}"));return Object[n(1462)](d)}async getAll(){let n=t,s=this[n(1224)][n(1757)](this[n(1855)]),d=JSON[n(625)](e.KnWPp(s,"{}"));return Object.values(d)}[t(420)](){return Promise[t(1240)]()}get[t(1397)](){return!!this._qosDB}}class Qx{constructor(n,s){let d=t;this._DBName=n,this[d(357)]=s,this[d(1224)]=In?tt:Hr?wx:null}async openDB(){}get[t(1855)](){let n=t;return n(1347)+"_"+this[n(809)]}async[t(633)](n){let s=t,d=this[s(1224)][s(914)+s(1801)](this[s(1855)]);return JSON[s(625)](e.pdWjr(d,"{}"))[n]}async[t(941)](n,s){let d=t,f=this._qosDB[d(914)+d(1801)](this[d(1855)]),g=JSON[d(625)](e[d(1212)](f,"{}"));return g[s||n[this[d(357)]]]=n,this._qosDB[d(1401)+d(1801)](this[d(1855)],JSON[d(531)+"y"](g)),s||n[this[d(357)]]}async[t(1635)](n){let s=t,d=this[s(1224)][s(914)+"geSync"](this[s(1855)]),f=JSON[s(625)](e.KnWPp(d,"{}"));return f[n]=void 0,this[s(1224)][s(1401)+s(1801)](this[s(1855)],JSON.stringify(f))}async clear(){return this[t(1224)].clearStorageSync()}async[t(1462)](){let n=t,s={hyuTC:function(d,f){return e[H(1515)](d,f)},XSvpN:n(1520)+"ascript",hLnWW:function(d,f){return e[n(951)](d,f)}};if(e[n(1012)](e[n(1760)],e[n(1760)])){let d=this._qosDB.getStorageInfoSync(this[n(1855)]),f=JSON[n(625)](d||"{}");return Object[n(1462)](f)}else{let d={KwjFA:function(g,w){return MmcAUS.hyuTC(g,w)},qIqLT:n(735)+"reason"},f=_0x28aacc[n(443)+"ement"]("script");_0x2a5b70[n(1347)+n(654)]=g=>{let w=n;_0xb3772f[w(1802)][w(656)+"ild"](f),_0x16dda9.frontierJSONP=void 0,d[w(592)](_0x23a0f6,g&&g[w(397)]||d[w(645)])},f.type=MmcAUS.XSvpN,f[n(1609)]=MmcAUS.hLnWW(_0x4882fe[n(1336)](/^ws/,n(1622)),n(1702)+n(1610)+n(1097)+"P");try{_0x37e359[n(1802)][n(973)+n(1020)](f)}catch{_0x31d98a.body[n(656)+"ild"](f)}}}async[t(1481)](){let n=t,s=this[n(1224)][n(914)+n(1621)+"nc"](this[n(1855)]),d=JSON[n(625)](s||"{}");return Object[n(1225)](d)}[t(420)](){return Promise[t(1240)]()}get[t(1397)](){return!!this[t(1224)]}}function Jd(a,n){let s=t;if(e[s(580)](In,In))return new Qx(a,n);if((Yn||jr)&&e[s(1293)](s(1657)+"d",typeof indexedDB))return new Zx(a,n);if(e.xYYUA(Yn,jr)&&e[s(1369)](s(1657)+"d",typeof localStorage))return new Xx(a,n);throw new Error(e[s(579)])}class ep{constructor(){let n=t;if(n(1754)===e[n(1250)])this[n(650)+n(750)+"Id"]=null,this[n(650)+"l"]=36e5,this[n(1224)]=Jd("qos","message_id");else{let s=n(1081)+_0x3532d3+(n(1663)+", max re"+n(1495)+"ached");this._debug(s),this["_dispatc"+n(1207)+n(968)](_0x318b6f(e[n(1368)],{message:s,code:_0x2ae21b[n(993)+n(1843)+"R"]}));return}}async[t(650)+t(1773)](){let n=t,s={vjXnO:function(d,f){return e[H(1024)](d,f)},XDmmm:function(d,f){return e.FPvdh(d,f)},JPrxm:function(d,f){return e[H(1558)](d,f)},FLLHc:function(d,f){return e[H(1785)](d,f)},qNbPj:e[n(610)],xMBJt:e.YZUkC};if(e[n(1341)]!==e.COJyp)clearInterval(this[n(650)+"lTimeoutId"]),this[n(650)+n(750)+"Id"]=e[n(585)](setInterval,()=>{this["flushExp"+n(1105)]()},this[n(650)+"l"]);else{let d=_0x28f1f1.split(/\./)[n(785)](w=>_0x50c0bf(w)),f=[];return f[0]=IvtuTI[n(740)](_0x166c86,IvtuTI[n(851)](d[0],d[1])),f[1]=IvtuTI.JPrxm(_0x5067ce,IvtuTI[n(1641)](d[2],d[3])),[n(1264),IvtuTI[n(694)],IvtuTI[n(694)],n(1264),"0000",IvtuTI[n(1852)],f[0],f[1]][n(724)]("")}}async[t(791)](){let n=t,s={hTnwO:"sent",vbhnX:function(d,f){return e[H(1092)](d,f)},HvxiG:e[n(1061)]};await this[n(1224)].openDB()[n(1491)](()=>{let d=n,f={MWUOB:s[d(942)]};s[d(1458)](d(614),s[d(1513)])?(this._ws&&this[d(862)][d(1573)](_0x287017),this[d(1142)](f[d(556)],_0x68b6a9)):this[d(650)+d(1773)]()})}async[t(696)+t(1105)](){let n=t;(await this._qosDB?.[n(1481)]()||[])[n(638)](({timestamp:f})=>f<Date[n(930)]()).forEach(f=>{let g=n,w={qWpek:e[g(1357)]};if(e.URJTz(e[g(1223)],g(1066)))this[g(1224)]?.[g(1635)](f[g(1321)+"id"]);else return{frameType:_0x23bc6f,headers:[{key:g(1335)+"ile_name",value:w[g(1410)]}],payload:void 0}})}async[t(1635)](n){let s=t;return this[s(1224)]?.[s(1635)](n)}async[t(941)](n,s){let d=t;return this[d(1224)]?.[d(941)]({message_id:n,timestamp:s})}async get(n){return this._qosDB?.get(n)}async closeDB(){let n=t;e.XEOOA(e[n(1452)],e[n(1300)])?(e.IjYHG(clearInterval,this[n(650)+n(750)+"Id"]),await this[n(1224)]?.closeDB()):(this["_miniNav"+n(960)+n(1604)]=_0x10e4da,_0x442000?this[n(691)+n(437)]():this[n(691)+"ffLine"]())}get isReady(){let n=t;return this[n(1224)]?.[n(1397)]}}function oa(a){let n=t,s=!!this[n(965)][n(720)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1709)](tn,a[n(1128)][n(1136)],e[n(704)],"2"),f=d&&e[n(1475)](tn,a[n(1128)][n(1136)],e[n(1753)],"1"),g=d&&e.WfhIs(tn,a[n(1128)][n(1136)],n(820)+n(1813)+"k","1"),w=g?e[n(664)](Zn,a[n(1128)][n(1136)],e[n(770)])?.[n(584)](",")[n(638)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:g,ackMsgIds:w}}async function Vd(){let a=t;return this[a(1679)+"ger"]||(this[a(1679)+"ger"]=new ep),this["_QoSMana"+a(350)][a(1397)]||await this._QoSManager[a(791)](),this[a(1679)+"ger"]}async function tp(a,n){let s=t,{enableAutoAck:d}=this[s(965)],f=tn(a[s(1128)][s(1136)],"need_ack","1"),g=e[s(1475)](tn,a.message[s(1136)],s(1400),"1"),w=oa[s(1525)](this,a);if(e[s(415)](d,f)){let{SeqID:b,LogID:x,service:A,LogIDNew:O,method:z}=a[s(1128)];this[s(926)]({SeqID:b,LogID:x,LogIDNew:O,service:A,method:z,headers:[{key:e[s(1273)],value:"1"},{key:e[s(1103)],value:e.xYYUA(O,"")},{key:e.DFsME,value:"0"}]})}g&&!w[s(808)]&&this[s(1184)+"hAckMessageEvent"](a),e.BuaRz(n)}async function np(a,n){let s=t;this[s(1142)](e[s(1734)],a[s(1128)]),n()}async function rp(a,n){let s=t,d=Xt(await $d(a.data));try{if(d[s(1206)]instanceof Uint8Array){let f=e[s(722)](this._options[s(1627)+s(382)],Object)?{force:!!this._options[s(1627)+s(382)][s(1769)],encoding:this[s(965)][s(1627)+"ncoding"].encoding?this[s(965)].payloadEncoding.encoding[s(1336)](/\s/g,"").toLowerCase():""}:{force:!1,encoding:this[s(965)][s(1627)+s(382)]?this._options["payloadE"+s(382)][s(1336)](/\s/g,"")[s(1575)+"ase"]():""},g=d[s(1627)+"ncoding"]?d[s(1627)+s(382)][s(1336)](/\s/g,"")[s(1575)+"ase"]():"",w=e[s(722)](this[s(965)].payloadType,Object)?{force:!!this[s(965)][s(842)+"ype"][s(1769)],type:this[s(965)]["payloadT"+s(987)][s(1271)]?this._options["payloadT"+s(987)][s(1271)][s(1336)](/\s/g,"")[s(1575)+s(660)]():""}:{force:!1,type:this[s(965)][s(842)+s(987)]?this[s(965)]["payloadT"+s(987)][s(1336)](/\s/g,"")[s(1575)+"ase"]():""},b=d[s(842)+"ype"]?d[s(842)+"ype"][s(1336)](/\s/g,"")["toLowerC"+s(660)]():"",x=w[s(1769)]?w[s(1271)]:b||w.type,A=f[s(1769)]?f[s(1074)]:g||f.encoding,O=[e[s(594)],"applicat"+s(1051),s(1218)+s(1051)+";charset"+s(840),e[s(803)]],z=[s(1229)+"e",e[s(1016)]];this[s(965)]["enableTr"+s(543)+s(1503)+"ad"]&&O.includes(x)&&(!A||z[s(462)](A))?d[s(906)+s(966)]=e.CyyWg(Kd,d.payload,0,d.payload[s(1227)+"th"]):d[s(906)+s(966)]=""}else d[s(906)+"oad"]=""}catch(f){d[s(906)+"oad"]="",console[s(757)](f)}a[s(1128)]=d,e[s(939)](n)}function ip(a,n,s){let d=t,f={lzEPx:function(A,O){return e[H(360)](A,O)},UdykM:function(A,O){return e[H(1461)](A,O)},LYziq:function(A,O){return e[H(1075)](A,O)},WKfsF:function(A,O){return A(O)},SNNOi:function(A,O){return e.MjRDU(A,O)},fMczi:function(A,O){return e.dDkJy(A,O)},lApOB:function(A,O){return e[H(1040)](A,O)}},g=e[d(1391)](s,8192),w=g>>>1,b=null,x=g;return function(A){let O=d;if(f.lzEPx(A,1)||f[O(471)](A,w))return a(A);f.UdykM(f[O(1295)](x,A),g)&&(b=f[O(1582)](a,g),x=0);let z=n.call(b,x,x+=A);return f[O(1687)](7,x)&&(x=f[O(843)](f[O(830)](7,x),1)),z}}let sp=4294967295;function op(a,n,s){let d=t;return RangeError(e[d(684)](e[d(429)](e[d(1632)](e[d(1512)]("index ou"+d(813)+d(1112),a),e[d(1282)]),e[d(1675)](n,1))+e[d(474)],s))}function ap(a,n,s){let d=t,f={lkRSk:e.KCvfV};if(e[d(895)](e[d(954)],e[d(1536)]))return _0x4e31f4||(_0x2ae75c=_0x1f9b3c[d(1240)]().then(_0x534bfd[d(1052)](_0x3eb83f,cGUdnk[d(856)]))),_0x474436;{if(s>sp)throw new Error("integer "+d(1100)+"e");let g=3;for(;g>=0;){let w=e[d(1122)](255,s);ca(w,a,e[d(522)](n,g)),s>>>=8,g--}return e[d(1785)](n,4)}}function cp(a,n){let s=t;if(e.znzGX(e[s(949)],s(541)))_0x2d4d39(_0x127b3d,18),_0x1891da(_0x1507c1,_0x4b78db);else{let d=0,f=n,g=e[s(1785)](n,4);for(;f<g;){let{value:w,offset:b}=e[s(1339)](aa,a,f);f=b,d=e[s(1286)](d,8)>>>0,d+=w}return{value:d,offset:g}}}function dp(a,n,s){let d=t;return a?e[d(619)](a.length,40)?e[d(1236)](e.WfhIs(ia,a,n,s),s):n[d(463)+"e"]?e[d(1839)](n[d(463)+"e"](a,s),s):n[d(893)]?e.YmHCx(n.write(a,s),s):e.nkpTy(ia,a,n,s)+s:s}function lp(a,n){let s=t,d=new ae(e[s(1775)](e.jVBlY(e[s(838)](e[s(1320)](a[e.keYWh(n,4)],24),e[s(1521)](a[e[s(1214)](n,5)],16)),e[s(1608)](a[n+6],8)),a[e.CyGjy(n,7)]),e.ifSBb(e[s(368)](e[s(379)](a[e[s(602)](n,0)],24)|e[s(869)](a[e.hoYyQ(n,1)],16),e[s(1208)](a[e[s(1744)](n,2)],8)),a[e.PJWPO(n,3)]),!0);return n+=8,{value:d,offset:e[s(1144)](n,8)}}function up(a,n,s){let d=t;if(e[d(1833)]==="yzscE"){let f=a[d(505)],g=a.high;return n[s]=e[d(636)](g,24),n[e[d(901)](s,1)]=e.YWAHh(e[d(935)](g,16),255),n[e.dDkJy(s,2)]=e[d(1415)](e[d(886)](g,8),255),n[s+3]=e[d(774)](255,g),n[e.DPzIE(s,4)]=e[d(636)](f,24),n[e.DQUeq(s,5)]=e[d(910)](e[d(608)](f,16),255),n[e[d(811)](s,6)]=e[d(835)](e[d(1560)](f,8),255),n[e.YmHCx(s,7)]=e[d(596)](255,f),s+=8,s}else{let f={HGMXV:function(w,b,x){return e.YTQdm(w,b,x)},WsWNe:d(1304)},g=_0x40146f[d(1053)].slice(_0x1f9526[d(347)+"et"],e.VYenR(_0x514606[d(1227)+"th"],_0x43f27f[d(347)+"et"]));this._socket&&this[d(1257)][d(1573)]({data:g,fail:w=>{let b=d;this[b(815)]("error",f[b(517)](_0x54217b,f[b(431)],{message:this[b(1110)+b(408)+b(1219)](w)}))}})}}function aa(a,n){let s=t;return a.readUInt8?{value:a.readUInt8(n),offset:e[s(1551)](n,1)}:{value:255&a[n],offset:e[s(1186)](n,1)}}function ca(a,n,s){let d=t;return n[d(528)+"t8"]?n[d(528)+"t8"](a,s):n[s]=e[d(1598)](255,a),e[d(821)](s,1)}let fp=function(a){return new Uint8Array(a)},hp=e.PBLSD(e[t(916)],typeof Buffer)?Buffer[t(1564)+t(852)]:e[t(538)](ip,fp,Uint8Array.prototype[t(1216)]);(()=>{let a=t,n={NzwxM:e[a(447)],kdViw:function(s,d){return s>>>d},wUgvU:function(s,d){return e[a(1446)](s,d)},ZtvzJ:function(s,d){return e[a(980)](s,d)},XvSdn:function(s,d){return s&d},oXqaL:function(s,d){return e.fjhMP(s,d)},Qccae:function(s,d){return s&d},uCahW:function(s,d){return e.ZtzBQ(s,d)},cZyeO:function(s,d){return s+d},KbqdI:function(s,d){return e[a(1281)](s,d)},JJTwT:function(s,d){return s<<d},tKBvN:function(s,d){return e[a(1040)](s,d)},tuRwF:function(s,d){return e[a(387)](s,d)},Fujlu:function(s,d){return e.uaiVH(s,d)},yGeXr:function(s,d){return e.bjiZu(s,d)},sEsaH:function(s,d){return e.zlNRw(s,d)},UHsGi:function(s,d){return e[a(1008)](s,d)},uNNpX:function(s,d){return e[a(880)](s,d)},nhQzZ:function(s,d){return e[a(1014)](s,d)},BBAzL:function(s,d){return e[a(368)](s,d)},wwOxO:function(s,d){return e.TBEoD(s,d)},gikzc:function(s,d){return e.zcTUA(s,d)},KavYm:function(s,d){return e.MQDxc(s,d)},omHNk:function(s,d){return e.VJpgH(s,d)},cydCt:function(s,d){return e.xgTcl(s,d)},Cajar:function(s,d){return e[a(1570)](s,d)},GfEsF:function(s,d){return s>d},BFZVt:e.ARxGw,YGLDD:e[a(428)],gKKVy:function(s,d,f,g){return s(d,f,g)}};if(e[a(1165)](e.hsypt,e[a(599)]))_0x23ebd4&&_0x5c8e4b["addEvent"+a(1469)](MMwggj[a(1540)],()=>_0x12c814()),_0x3b94b6&&_0x2f47c7[a(510)+a(1469)](a(868)+"hange",()=>_0x53e47e());else{let s=4294967295;return function(d,f,g=!0){let w=a;if(s=n[w(386)](127&d[f],0),d[f++]<128)return{value:g?s:0|s,offset:f};if(s=n.kdViw(s|n[w(1106)](n[w(1607)](127,d[f]),7),0),n[w(1270)](d[f++],128))return{value:g?s:n[w(1611)](0,s),offset:f};if(s=n[w(386)](s|n[w(1547)](n.wUgvU(127,d[f]),14),0),n[w(1665)](d[f++],128))return{value:g?s:n.BBAzL(0,s),offset:f};if(s=n.wwOxO(n[w(1291)](s,n.KavYm(n.Qccae(127,d[f]),21)),0),n[w(1270)](d[f++],128))return{value:g?s:n[w(837)](0,s),offset:f};if(s=n[w(950)](s|n[w(1472)](n[w(1607)](15,d[f]),28),0),n[w(1786)](d[f++],128))return{value:g?s:0|s,offset:f};if(n[w(1082)](f+=5,d.length))if(n[w(1674)]===n[w(1511)]){_0x40796f[w(362)](_0x54c94d)||(_0x142330=_0x50b91b[w(532)+"er"](_0x179b16));let b=MMwggj[w(814)](this[w(1376)],16),x=MMwggj[w(1094)](65535,this[w(1376)]),A=MMwggj.ZtvzJ(this[w(505)],16),O=MMwggj.XvSdn(65535,this[w(505)]),z=MMwggj[w(814)](_0x4db00e[w(1376)],16),G=MMwggj[w(1723)](65535,_0x47d13f[w(1376)]),K=MMwggj[w(814)](_0x57874b[w(505)],16),he=MMwggj[w(755)](65535,_0x32fb5b.low),Ee=0,be=0,Ie=0,Ye=0;return Ye+=MMwggj[w(1807)](O,he),Ie+=MMwggj.kdViw(Ye,16),Ye&=65535,Ie+=MMwggj[w(767)](A,K),be+=MMwggj[w(1468)](Ie,16),Ie&=65535,be+=MMwggj[w(767)](x,G),Ee+=MMwggj[w(814)](be,16),be&=65535,Ee+=MMwggj.KbqdI(b,z),Ee&=65535,_0xbf0761[w(1432)](MMwggj[w(1680)](Ie,16)|Ye,MMwggj[w(1563)](MMwggj[w(1547)](Ee,16),be),this[w(558)])}else throw f=d.length,n[w(548)](op,f,10,d[w(414)]);return{value:g?s:0|s,offset:f}}}})();let xp=16,da=32;function pp(a){let n=t,s={eQlBP:n(1128)},d=0,f={};for(let g=0;e[n(1623)](g,a[n(414)]);g++)e.Ljucs(e.bddWz,e[n(1765)])?(this.emit(s[n(1296)],_0x30dfb1),this.onmessage&&this[n(778)+"e"](_0x51b5a3)):(f[a[g].cursor_name]=e[n(1108)](Wd,a[g][n(1695)+n(1026)]),d+=e[n(367)](14,f[a[g][n(1695)+n(1026)]]));return[d,f]}function Yd(a,n,s){let d=t,f={LatDy:function(A,O){return e[H(992)](A,O)},sFtqj:e[d(937)],QAows:d(490),WIxpP:e.ELQDt,ivbUy:"service-"+d(1310),Zhqxx:e.wQrjw,gxHLt:e[d(349)],DSHWO:function(A,O,z,G){return e.nkpTy(A,O,z,G)},nxTRT:e.EcuUH,twedg:function(A,O,z,G){return e[d(1101)](A,O,z,G)}},[g,w]=e.ZBoyp(pp,a),b=e[d(742)](hp,g),x=0;return a[d(903)](A=>{let O=d;if(f[O(439)](f[O(854)],f[O(896)])){let z=("3|4|6|7|"+O(1114)+O(659))[O(584)]("|"),G=0;for(;;){switch(z[G++]){case"0":console[O(757)](f[O(936)],x);continue;case"1":console[O(757)](f.ivbUy,x);continue;case"2":console.log(O(1782),x);continue;case"3":console[O(757)](f[O(692)],A,A[O(1373)]);continue;case"4":x=ca(0,b,x);continue;case"5":x=ca(w[A[O(1695)+O(1026)]],b,x);continue;case"6":console[O(757)](f[O(859)],x);continue;case"7":x=f.DSHWO(ap,b,x,A[O(1373)]||0);continue;case"8":console[O(757)](f[O(686)],x);continue;case"9":x=f.DSHWO(up,ae[O(532)+"er"](A[O(457)]||n),b,x);continue;case"10":x=f[O(1431)](dp,A[O(1695)+O(1026)],b,x);continue}break}}else _0x34d969.body[O(656)+O(1020)](_0x3b42b1)}),{frameType:da,headers:[{key:d(1335)+d(703),value:s}],payload:b}}function gp(a){let n=t;if(e.zCyVp(e[n(1269)],e[n(1269)])){let s=0,d=[];for(;s<a[n(1227)+"th"];){let{offset:f}=e[n(444)](aa,a,s);s=f;let g={cursor_name:"",cursor:0,service:0},{value:w,offset:b}=e[n(1658)](cp,a,s);g[n(1373)]=w,s=b;let{value:x,offset:A}=e[n(1774)](aa,a,s);s=A,g[n(1695)+n(1026)]=e.CyyWg(Kd,a,s,e.pXrNp(s,x)),s+=x;let{value:O,offset:z}=e[n(1102)](lp,a,s);g[n(457)]=O.toNumber(),s=z,d.push(g)}return d}else e[n(1028)](_0x1b130e,_0x35793e,this[n(489)+n(571)+"e"](_0x34c97b))}function mp(){let a=t;return{frameType:da,headers:[{key:e.oaBXu,value:e[a(1357)]}],payload:void 0}}class wp{constructor(n,s,d){let f=t;this[f(911)+f(1404)]=n,this["_cursorF"+f(737)]=s,this[f(828)+f(1546)]=d,this[f(1224)]=e[f(739)](Jd,this[f(911)+"ameSpace"],e[f(751)])}async[t(791)](){let n=t;await this._qosDB[n(791)]()}async[t(365)+"rs"](){let n=t;if(!this._qosDB[n(1397)])return;let s=this[n(828)+"Strategy"],d=await this[n(1224)][n(1481)]();switch(console[n(757)](e[n(1004)],d),s){case e[n(540)]:return d&&d.length?Yd(d,0,this[n(1788)+n(737)]):void 0;case e[n(1776)]:return;case e[n(459)]:return d&&d[n(414)]?e[n(1644)](Yd,d,0,this[n(1788)+n(737)]):mp()}}async[t(941)](n,s,d){let f=t;return console[f(757)](e[f(807)],n,s,d),this._qosDB[f(941)]({cursor_name:n,cursor:s,service:d})}async[t(1796)+"rs"](n){let s=t;if(e[s(918)](e[s(1378)],e[s(783)]))_0x28e0d0=_0x2694e7[e[s(598)](e[s(782)](_0x594045,_0x59aef2),1)],_0x262a02=_0x5a9c6e[_0x321c1b+_0x3ee008+2],e[s(371)](e[s(1502)](_0x46b052,_0x576e6f<<8),49344)!==32896?_0x3219e5+=_0x4811f4:(_0x576b2e=e[s(1345)](e.vqkFu(e[s(555)](15,_0x461958),12),e[s(662)](e[s(1836)](63,_0x4db8ff),6))|e[s(1779)](63,_0x3da228),e[s(1003)](_0x5c0008,2048)||e[s(507)](_0x3cca3a,55296)&&e[s(582)](_0x1b418f,57343)?_0x4e61be+=_0x53d6b4:(_0x53fd83+=e[s(1068)](_0x481f9b,_0x4b1b93),_0x2ce867+=2));else{let d=e[s(1138)](gp,n);for(let f of d)console[s(757)](s(1130)+"r",d),await this[s(1224)][s(941)](f)}}async[t(633)](n){let s=t;return(await this[s(1224)][s(633)](n))?.[s(457)]}async[t(420)](){let n=t;await this._qosDB[n(420)]()}[t(1416)+t(509)+t(1457)](n){let s=t;this["_cursorF"+s(737)]=n}get isReady(){return this[t(1224)].isReady}}let _p=e.LjhhO;async function Zd(a){let n=t;if(!this[n(965)][n(720)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(965)],g=a||_p;try{return this[n(1156)+"anager"]?a&&this[n(1156)+n(853)][n(1416)+n(509)+n(1457)](a):this[n(1156)+n(853)]=new wp(d+"_"+s+"_"+g,g,f),this[n(1156)+"anager"][n(1397)]||await this[n(1156)+n(853)][n(791)](),this[n(1156)+"anager"]}catch{return null}}async function yp(a,n){let s=t,d=e[s(675)](tn,a[s(1128)].headers,e[s(1837)],"-1"),f=tn(a[s(1128)].headers,s(1400),"1"),g=e[s(710)](Zn,a[s(1128)][s(1136)],e[s(714)]),w=e[s(1656)](Number,Zn(a[s(1128)].headers,e.BghyF))||0,b=oa[s(1525)](this,a),x=e[s(1644)](tn,a[s(1128)].headers,e[s(389)],"2"),A=e[s(710)](Zn,a[s(1128)].headers,e[s(1383)]),O=e.UtKre(Number,Zn(a[s(1128)][s(1136)],e[s(933)]));if(b[s(808)])return n();let z=b[s(1146)+s(1471)]?await Vd[s(1525)](this):null;if(e.Yaqez(a[s(1128)][s(1373)],0)&&f&&!d||a[s(1128)][s(1373)]>0){if(g&&b["isQoSMes"+s(1471)]&&z){if(e[s(523)](e[s(1058)],e.sTLIz))return!!!await z[s(633)](g)&&(this[s(1184)+s(591)+s(1499)](a),await z[s(941)](g,e[s(429)](Date[s(930)](),w))),e[s(390)](n);if(!this["_navigat"+s(1035)]()||this[s(653)+"osed"])return;this[s(413)+s(1538)]?.[s(1645)+s(1211)+"fig"](),this[s(1411)+s(1032)]?.[s(606)+"nter"](),this[s(862)]?this["_disconn"+s(486)](1001,s(1638)+"ay, try "+s(1422)+"ting ser"+s(1486),!0):this[s(1592)]()}if(x){let G=await Zd[s(1525)](this);if(!G)return e.BtQNA!==e[s(1248)]?(this[s(1184)+s(591)+s(1499)](a),e[s(418)](n)):_0xae379b||(_0x20128e=[_0x128be4.prototype.advance,_0x29b02b[s(497)+"e"][s(446)],_0x12a726.prototype["continue"+s(1073)+"ey"]]);let K=await G[s(633)](A)??-1;if(e.TxkSH(K,O))this["_dispatc"+s(591)+s(1499)](a),G[s(941)](A,O,a[s(1128)][s(1373)]);else throw new Error(s(629)+s(1756)+s(1630)+O+(s(434)+"than loc"+s(634)+"r ")+K);return e.BuaRz(n)}return this[s(1184)+s(591)+s(1499)](a),n()}}async function Ep(a,n){let s=t,d=oa[s(1525)](this,a);if(!d[s(1146)+"sage"])return e[s(1510)](n);let f=await Vd.call(this);if(d[s(419)+s(1059)+s(1219)]&&d[s(749)+"s"].length)for(let g of d.ackMsgIds)await f[s(1635)](g);e[s(418)](n)}async function bp(a,n){let s=t,d=e[s(1352)](a.message[s(1437)+"e"],xp),f=e[s(1840)](a.message[s(1437)+"e"],da);if(e[s(1722)](!d,!f))return n();let g=Zn(a[s(1128)][s(1136)],s(1335)+s(703));if(!g)return e[s(1111)](n);let w=await Zd[s(1525)](this,g);if(!w)return e[s(1127)](n);if(d){let b=await w[s(365)+"rs"](),x={frameType:b?.[s(1437)+"e"],SeqID:ae[s(532)+"er"](this[s(1425)]++),LogID:ae[s(532)+"er"](this[s(965)][s(1442)+s(1389)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[s(1206)]},A=T(x);this._ws&&this[s(862)][s(998)+"te"]&&this[s(862)][s(1573)](A)}if(f){let b=a[s(1128)][s(1206)];b&&w[s(1796)+"rs"](b)}}let vp=async function(a,n){let s=t;this[s(763)]=!1,e[s(827)](clearTimeout,this[s(1592)+s(1055)+s(1548)]),e[s(1487)](n)},Sp=async function(a,n){let s=t;if(!this[s(862)]||e[s(1239)](this[s(862)][s(998)+"te"],this[s(1060)]))return e[s(586)](n);let{pingInterval:d}=this[s(965)];this[s(413)+"tManager"]?.["resetEnd"+s(1211)+s(1629)]();for(let g=0;e[s(1141)](g,this[s(828)+s(1375)][s(414)]);g++){let w=this[s(828)+s(1375)][g];if(this[s(862)][s(998)+"te"]===this[s(1060)]&&w!==null)this[s(862)]&&this[s(862)].send(w),this[s(828)+s(1375)][g]=null;else break}this["_message"+s(1375)]=this[s(828)+s(1375)][s(638)](g=>!!g),this[s(1188)+s(1492)+"Id"]=e[s(743)](setTimeout,()=>this[s(734)](),d),this[s(1184)+s(1509)+"nt"](a),this[s(1209)+"er"]&&this[s(862)]&&(this[s(862)][s(1485)+"pe"]=this[s(1460)+s(987)]);let f=this[s(413)+s(1538)]?.["getCurre"+s(986)+"nt"]();this[s(1142)](s(1571)+f+s(1476)),e[s(1421)](n)},Ip=async function(a,n){let s=t,d=this[s(413)+s(1538)]?.[s(726)+s(986)+"nt"]();this[s(1142)](s(1571)+d),e[s(390)](n)};class Ap extends ra{constructor(n){let s=t,d={ZdDxi:function(b,x,A){return e[H(969)](b,x,A)},SQxGG:e[s(1701)],oMsrg:function(b){return e[s(1204)](b)},BhTHx:e[s(690)],EpCKD:e[s(587)],kvaTW:e[s(919)],DgNxs:s(633),TxFWZ:e[s(478)],KgpdC:e[s(1274)],RZcoR:function(b,x){return e[s(1036)](b,x)},agFXy:function(b,x){return e[s(1222)](b,x)},wHOGB:"always",wejzD:"auto",JVqqQ:function(b,x){return e[s(624)](b,x)},ZRXwk:s(1315),HVyRv:e.BGUgM,wORPQ:e.JLwiI,bHUpV:s(1304),dFORX:function(b,x){return e[s(1222)](b,x)},hziou:function(b,x){return e[s(895)](b,x)},MFSIZ:function(b,x){return e[s(1497)](b,x)},CsUkB:function(b,x){return b===x},pQbIK:e[s(666)],vNvwI:function(b,x,A){return e[s(1316)](b,x,A)},PIrQG:function(b,x){return e[s(1681)](b,x)},lvJcx:function(b,x,A){return b(x,A)},KYOqF:s(1834),SKbBX:function(b,x,A){return b(x,A)},RqTcw:e.NbEsp,KDBgd:function(b,x){return e.oLOOh(b,x)},yjdBO:function(b,x,A){return e[s(441)](b,x,A)},BcCLz:function(b,x){return e[s(1198)](b,x)}};super(),this[s(882)+"igatorOn"+s(1604)]=!0,this[s(1209)+"er"]=Yn,this[s(907)]=Hx,this[s(1015)+"T"]=In,this._isMiniWX=Hr,this[s(1643)+"r"]=jr,this[s(828)+"Queue"]=[],this[s(413)+s(1538)]=null,this["_readyCl"+s(1466)]=!1,this[s(1460)+"ype"]=e[s(1655)],this[s(1592)+"Lock"]=!1,this[s(1592)+"ionTimeo"+s(1548)]=null,this[s(1285)+s(1838)+s(366)]=null,this._pingPongTimeoutId=null,this[s(1425)]=0,this._isInit=!1,this._url="",this[s(1679)+s(350)]=null,this[s(1156)+s(853)]=null,this[s(1411)+s(1032)]=null,this[s(867)+"ls"]=e[s(819)],this[s(1853)]=3,this.CONNECTING=0,this[s(1060)]=1,this[s(745)]=2,this[s(631)]=b=>{let x=s;try{Gd(this,b,[vp,Sp,Ip])}catch(A){let O=d[x(1242)](at,x(1304),{message:A[x(1128)],code:en[x(402)+"OR"],error:A});this[x(1184)+"hErrorEv"+x(968)](O)}},this[s(1817)+"ge"]=async b=>{let x=s,A={LHtlh:d.SQxGG,IbuMH:function(G){return d.oMsrg(G)},hHUId:d[x(1482)],Kxrxn:d[x(1340)],VFPOj:d[x(1685)],lrTFl:d[x(1612)],NAnpq:x(1481),JcQJa:d.TxFWZ,LpuIa:d[x(1735)]},{pingInterval:O,pingFrequency:z}=this[x(965)];if(d.RZcoR("hi",b.data)&&d.agFXy(d[x(1418)],z)||d[x(1317)](d[x(1180)],z))if(d[x(780)](x(1315),d.ZRXwk)){let G=A.LHtlh[x(584)]("|"),K=0;for(;;){switch(G[K++]){case"0":_0x460deb(he=>({...he,get:(Ee,be,Ie)=>_0x584b93(Ee,be)||he[x(633)](Ee,be,Ie),has:(Ee,be)=>!!_0x4f75e5(Ee,be)||he[x(1596)](Ee,be)}));continue;case"1":_0x15a114();continue;case"2":_0x5302b7=new _0x3eeaf6;continue;case"3":WthzeS[x(953)](_0x621d9d);continue;case"4":_0x1d7d14=[WthzeS[x(1185)],WthzeS.Kxrxn,x(1276),WthzeS[x(1331)]];continue;case"5":_0x1dce78=[WthzeS.lrTFl,x(1793),WthzeS[x(1835)],WthzeS[x(881)],WthzeS[x(982)]];continue}break}}else this[x(647)+x(1708)](),this[x(815)](d.HVyRv,d.wORPQ),this[x(1188)+x(1492)+"Id"]=setTimeout(this[x(734)][x(1052)](this),O);if(b.data!=="hi")try{Gd(this,b,[rp,tp,Ep,bp,yp,np])}catch(G){let K=at(d[x(1305)],{message:G[x(1128)],code:en[x(518)+x(568)],error:G});this[x(1184)+x(1207)+x(968)](K)}},this[s(427)]=b=>{let x=s;if(d[x(723)](d[x(822)],d[x(822)])){let A=this[x(413)+"tManager"]?.[x(658)+x(1319)+"es"](),O=this[x(413)+x(1538)]?.[x(726)+"ntEndpoint"]();if(A&&!b.message){let z="connect "+O+(x(1717)+x(1688)+x(655)+"ed");this[x(1184)+x(1207)+x(968)](d.vNvwI(at,d.bHUpV,{message:z,code:en["MAX_RETR"+x(1843)+"R"],error:b}));return}this._ws&&d[x(1763)](this._ws[x(998)+"te"],this[x(1060)])&&this[x(1408)+x(486)](),this[x(1184)+x(1207)+x(968)](at(x(1304),{message:b[x(1128)],code:en.NATIVE_ERROR,error:b}))}else return JWkkkc[x(1544)](-1,this[x(505)])&&JWkkkc[x(1846)](-1,this[x(1376)])?_0x1b5c81[x(1432)](0,0,this[x(558)]):JWkkkc.RZcoR(-1,this.low)?_0x202cfd[x(1432)](0,this[x(1376)]+1,this[x(558)]):_0x4c8e62[x(1432)](JWkkkc[x(1856)](this[x(505)],1),this[x(1376)],this[x(558)])},this[s(545)]=async b=>{let x=s;this["_clearTi"+x(1157)](),this[x(647)+x(1708)](),this[x(1637)+x(786)+"rs"](),this[x(862)]=null,this._connectLock=!1;let A=this["_endpoin"+x(1538)]?.[x(658)+x(1319)+"es"]();if(!A&&this[x(996)+x(1035)]()&&!this[x(653)+x(1466)]){let O=this[x(413)+x(1538)]?.["getCurre"+x(986)+"nt"](),z=this[x(965)][x(1422)+x(353)+x(1302)](b.code,b[x(1205)]);this[x(1184)+x(1029)+"ent"](d[x(391)](xt,d[x(604)],{code:1006,reason:b.reason||x(1605)+"ng faile"+x(1268)+x(1527)+x(1155)+x(1761)+O,willReconnect:z})),z&&this[x(1592)]();return}if(d[x(780)](1e3,b[x(777)])&&this[x(653)+x(1466)]){this[x(1184)+"hCloseEv"+x(968)](d[x(908)](xt,d[x(604)],{code:1e3,reason:d[x(775)]})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+"sCounter"]?.[x(606)+x(407)]();return}if(b[x(777)]!==1e3&&A){let O=this[x(413)+x(1538)]?.getCurrentEndpoint(),z=b[x(1205)];z||(z=await d[x(425)](Vx,this[x(1697)])),z="connecti"+x(1197)+x(706)+z+(x(520)+x(1725))+O+(x(1541)+x(1495)+x(1506)),this[x(1184)+x(1029)+x(968)](d.yjdBO(xt,x(1834),{code:b[x(777)],reason:z}));let G=x(1081)+O+(x(1717)+"ax retri"+x(655)+"ed");this[x(1184)+x(1207)+x(968)](d[x(697)](at,d[x(1305)],{message:G,code:en["MAX_RETR"+x(1843)+"R"]})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+"nter"]();return}if(d[x(1583)](1e3,b.code)&&!b[x(1205)]){let O=this[x(413)+x(1538)]?.["getCurre"+x(986)+"nt"]();this[x(1184)+x(1029)+"ent"](d[x(391)](xt,d[x(604)],{code:b[x(777)],reason:x(1605)+"ng faile"+x(1268)+"wn reason, hostn"+x(1761)+O})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+x(407)]();return}this[x(1184)+x(1029)+x(968)](b),this[x(413)+"tManager"]?.["resetEndpointCon"+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+"nter"]()},this.onclose=null,this[s(1712)]=null,this.onmessage=null,this[s(682)]=null,this[s(1132)+"econnect"]=null,this[s(395)+s(1770)]=null,this[s(1477)+"mediatel"+s(1660)+"ct"]=null,this["_handleO"+s(437)]=this[s(691)+s(437)][s(1052)](this),this[s(691)+s(1740)]=this[s(691)+s(1740)][s(1052)](this),this[s(635)+s(1084)]=this["_handleP"+s(1084)][s(1052)](this),this[s(635)+s(593)]=this["_handleP"+s(593)][s(1052)](this),this[s(965)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength: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(378),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(459)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:g}=n,w=Array[s(1467)](f)?f:e.HQmyD(e[s(803)],typeof f)?[f]:[];if(!w||w[s(414)]===0)throw new Error(s(667)+s(639)+s(794));if(!e[s(1661)](Wx,g))throw new Error(e.TOTOf);Object.assign(this[s(965)],n),this[s(413)+"tManager"]=new jd(w,this._options[s(1805)+"es"]),this[s(1411)+s(1032)]=new Jx(this[s(965)][s(760)+s(975)]),this[s(965)][s(816)+s(1398)]&&(this[s(763)]=!0,this._connect()),this[s(965)]["listenNe"+s(484)+"nged"]&&(this._isMiniTT||this[s(561)+"X"]?this[s(1841)+s(1183)+s(620)]():this[s(1209)+"er"]&&this[s(1139)+"balEvent"+s(1469)]())}[t(691)+"nLine"](){let n=t;this[n(965)][n(1586)+n(1385)+n(1445)]||this[n(653)+n(1466)]||this[n(1220)+n(535)]()}["_handleO"+t(1740)](){let n=t,s={RSWFB:"open",SIBxd:function(d,f,g){return e[H(364)](d,f,g)}};if(e[n(1036)](e[n(1443)],e[n(1443)])){this[n(361)+n(1642)+"t"]();let d=e[n(1189)](na,e[n(1140)],{message:e[n(1403)]});this[n(1477)+n(931)+n(1660)+"ct"]&&this["onStopIm"+n(931)+n(1660)+"ct"](d)}else this[n(815)](NOaFJy.RSWFB,NOaFJy[n(354)](_0x520df5,NOaFJy[n(1562)],{..._0x10cf1a,data:_0x1eddf4.errMsg||""}))}[t(1139)+t(1424)+"Listener"](){let n=t;this[n(1209)+"er"]&&window[n(510)+n(1469)](e[n(1822)],this[n(691)+"nLine"]),this[n(1209)+"er"]&&window[n(510)+n(1469)](e[n(1508)],this["_handleO"+n(1740)]),this[n(1209)+"er"]&&window["addEvent"+n(1469)](e[n(621)],this[n(635)+n(1084)]),this[n(1209)+"er"]&&window["addEvent"+n(1469)](e[n(458)],this[n(635)+"ageShow"])}["_dropGlo"+t(1424)+"Listener"](){let n=t;this[n(1209)+"er"]&&window["removeEv"+n(1262)+n(1231)](e.XXeqB,this[n(691)+n(437)]),this._isBrowser&&window["removeEv"+n(1262)+"ner"](e[n(1508)],this[n(691)+n(1740)]),this[n(1209)+"er"]&&window["removeEv"+n(1262)+n(1231)](e[n(621)],this[n(635)+n(1084)]),this[n(1209)+"er"]&&window[n(1699)+"entListe"+n(1231)](e[n(458)],this[n(635)+"ageShow"])}[t(635)+t(1084)](n){let s=t;!n[s(1819)+"d"]&&(this._isBrowser&&window[s(1699)+s(1262)+s(1231)](e.NmNoN,this[s(635)+"ageHide"]),this._isBrowser&&window[s(1699)+s(1262)+"ner"](e.xDcxY,this[s(635)+s(593)]),this[s(1834)]()),this[s(1209)+"er"]&&window["removeEv"+s(1262)+s(1231)](e[s(1822)],this[s(691)+s(437)]),this._isBrowser&&window[s(1699)+"entListe"+s(1231)](s(1182),this[s(691)+"ffLine"])}[t(635)+"ageShow"](n){let s=t;if(n[s(1819)+"d"])if(e.kxInc(e[s(1096)],e[s(1096)]))this[s(996)+s(1035)]()&&(!this[s(862)]||e[s(688)](this[s(862)][s(998)+"te"],this[s(1060)])||e[s(451)](this[s(862)][s(998)+"te"],this[s(1010)+"NG"]))&&this[s(691)+s(437)](),this[s(1209)+"er"]&&window[s(510)+s(1469)]("online",this[s(691)+s(437)]),this._isBrowser&&window["addEvent"+s(1469)](e[s(1508)],this[s(691)+s(1740)]);else{let d="0|3|4|2|1"[s(584)]("|"),f=0;for(;;){switch(d[f++]){case"0":if(_0x5f0bb4)return!0;continue;case"1":return!1;case"2":if((_0x4c0b23||_0x30bffd)&&e[s(1615)](s(1657)+"d",typeof _0x264bae)&&_0xeead56)return!0;continue;case"3":if(_0x5f11e0&&_0x44b013[s(1354)+s(1585)])return!0;continue;case"4":if(_0x5a1ddf&&_0x1ca1f6[s(1354)+s(1585)])return!0;continue}break}}}async[t(1358)+t(1450)](n){let s=t;if(e.fFPse!==e[s(700)]){let d=this._endpointManager?.[s(726)+"ntEndpoint"](),f=this[s(965)]["reconnectInterce"+s(1302)](_0x4ddf09[s(777)],_0x439d63[s(1205)]);this[s(1184)+s(1029)+s(968)](e[s(915)](_0x10c673,e[s(447)],{code:1006,reason:_0x3acefb[s(1205)]||s(1605)+s(1197)+s(1268)+s(1527)+s(1155)+s(1761)+d,willReconnect:f})),f&&this[s(1592)]();return}else{let{fpID:d,deviceID:f,bddID:g,ttwID:w,accessKey:b,aID:x,customParams:A={},enableAutoAck:O,enableQoS:z,QoSLevel:G,env:K}=this[s(965)],he,Ee,be;this[s(1209)+"er"]||this[s(561)+"X"]||this._isMiniTT?(he=location&&e.TGeGq(e.tMeGm,location[s(1145)])?e.XYmXL:s(741),Ee=n[s(1336)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),be=/^wss(.*:\/\/)/[s(687)](n)?n:""+he+Ee):(he=s(1766),Ee=n[s(1336)](/(^http)((?:[s]*:\/\/))/,""),be=/(^ws)((?:[s]*:\/\/))/[s(687)](Ee)?Ee:""+he+Ee);let Ie=g?e[s(1228)]:w?e[s(1313)]:e[s(1729)],Ye=g||w||f;if(e[s(580)](!Ye,!Ie))throw new Error(e[s(999)]);let Tp=s(1588)==typeof A?await e.fsUdl(A):A,Rp=K?e[s(385)]($x,K.xUseEnv,K.xTTEnv):{},la=Object.assign({device_platform:e[s(1147)],version_code:e[s(959)],access_key:b,fpid:d,aid:x,[Ie]:Ye,xsack:O?1:0,xaack:O?1:0,xsqos:z?1:0,qos_level:z?G:void 0,qos_sdk_version:2,...Rp},Tp),Cp=Object.keys(la)[s(468)]((ua,fa)=>la[fa]!==void 0?""+ua+(ua?"&":"?")+fa+"="+la[fa]:ua,"");return be+"/ws/v2"+Cp}}async _connect(){let n=t;if(!(this["_connect"+n(1537)]||this[n(653)+n(1466)])){this._connectLock=!0;try{let s=this["_endpoin"+n(1538)]?.[n(824)+n(1258)+"ointReac"+n(1493)+n(1683)](),{timeoutInterval:d}=this[n(965)];if(s){let g=this[n(413)+"tManager"]?.["getCurre"+n(986)+"nt"](),w=this[n(413)+"tManager"]?.[n(400)+"ackupEnd"+n(1678)+n(1253)+n(1749)](),b=this[n(413)+n(1538)]?.["getCurre"+n(986)+n(530)+n(1720)]();if(w){let x=n(1081)+g+(n(1663)+n(1541)+n(1495)+n(705)+"ill use "+n(1832)+n(1427))+w+(n(611)+"y"),A=e[n(915)](at,e[n(1368)],{message:x,code:en[n(993)+n(1843)+"R"]});this[n(1142)](x),this[n(1184)+n(1207)+n(968)](A),this[n(1697)]=await this["_generat"+n(1450)](w),this[n(1142)]("connect "+w+" "+b+n(1809)),this[n(1637)+"sListeners"]()}else if(e[n(460)](n(1366),e.MTCoz)){let x="connect "+g+(" timeout"+n(1541)+n(1495)+n(1506));this[n(1142)](x),this[n(1184)+n(1207)+n(968)](e[n(799)](at,e.TYaio,{message:x,code:en["MAX_RETR"+n(1843)+"R"]}));return}else{if(_0x19a475[n(414)]!==4){let x=_0x5a0030.substring(0,4-_0x2716e8[n(414)]),A=x[n(1714)](_0x41fd55);_0x4031a7[n(738)](A)}else _0x1fcbcb.push(_0x2921eb);_0x363be7&&(_0x426c33+=1),_0x56dec0+=1,_0x566897=!1}}else{let g=this[n(413)+n(1538)]?.["getCurre"+n(986)+n(1578)+"ateCount"](),w=this[n(413)+"tManager"]?.[n(726)+"ntEndpoi"+n(530)+n(1720)]();this._url=await this[n(1358)+n(1450)](e[n(1201)](g,"")),this[n(1142)]("connect "+g+" "+w+" times"),this[n(1637)+n(786)+"rs"]()}if(this[n(763)])this[n(763)]=!1;else if(n(1668)===e.mlUnQ)this[n(1015)+"T"]||this[n(561)+"X"]?this[n(1841)+n(1183)+n(620)]():this._isBrowser&&this[n(1139)+n(1424)+n(1469)]();else{let g=na(e[n(1140)],{message:e[n(1617)]});this[n(1132)+n(535)]&&this["onStartR"+n(535)](g)}let f=this[n(413)+n(1538)]?.[n(726)+n(986)+n(530)+"ount"]()||0;e[n(1453)](f,1)&&await this._wait(f-1),this[n(1142)]("connecti"+n(1711)+this._url+(n(1640)+n(1246))+this[n(867)+"ls"]),this[n(862)]=e[n(1131)](Gx,{url:this[n(1697)],protocols:[this[n(867)+"ls"]],headers:this[n(965)][n(773)+n(1243)+"s"][n(1489)+n(1306)]},this[n(965)].ws),(this[n(1209)+"er"]||this[n(1643)+"r"])&&this[n(862)]&&(this[n(862)].binaryType=this[n(1460)+n(987)]),this[n(875)+n(1161)](),this["_connect"+n(1055)+n(1548)]=e[n(672)](setTimeout,this._onTimeout.bind(this),d)}catch(s){throw this["_connect"+n(1537)]=!1,s}}}["_clearTi"+t(1157)](){let n=t;e[n(850)](clearTimeout,this[n(1592)+n(1055)+n(1548)]),this[n(1592)+n(1055)+n(1548)]=null}[t(647)+t(1708)](){let n=t;clearTimeout(this[n(1188)+n(1492)+"Id"]),e[n(1707)](clearTimeout,this[n(1285)+"ctTimeou"+n(366)]),this[n(1188)+n(1492)+"Id"]=null,this[n(1285)+n(1838)+n(366)]=null}[t(1142)](...n){let s=t;this[s(965)][s(1083)]&&console[s(757)][s(898)](console,[e[s(440)],...n])}[t(489)+"rvalValue"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:g}=this[s(965)],w=e[s(1362)](d,Math[s(1048)](g,e[s(1600)](n,1)));return e[s(612)](w,f)?f:w}[t(734)](){let n=t;if(this._ws&&e.Zqikc(this[n(862)][n(998)+"te"],this[n(1010)+"NG"])){this[n(647)+n(1708)](),this[n(1188)+n(1492)+"Id"]=e[n(1530)](setTimeout,this._ping[n(1052)](this),this._options[n(1394)+n(1784)]);return}if(!this._ws||e[n(1730)](this[n(862)][n(998)+"te"],this[n(1060)]))return void this[n(1220)+n(535)]();this[n(862)]&&this[n(862)][n(1573)]("hi"),this[n(1285)+n(1838)+n(366)]=setTimeout(this[n(1220)+n(535)+n(1705)].bind(this),this[n(965)][n(1662)+"outInter"+n(1550)])}[t(1220)+t(535)+t(1705)](){let n=t;this[n(1411)+n(1032)]?.[n(1625)](),this.emit(e[n(601)],e[n(1395)]),this[n(1411)+n(1032)]?.[n(658)+"chMaxCount"]()?this._handleReconnect():this._ping()}[t(996)+t(1035)](){let n=t;return this._isMiniTT||this[n(561)+"X"]?this["_miniNav"+n(960)+n(1604)]:(this[n(1209)+"er"]||this._isWorker)&&this[n(965)]["listenNe"+n(484)+n(1557)]?navigator.onLine:!0}[t(1220)+t(535)](){let n=t;!this["_navigat"+n(1035)]()||this[n(653)+"osed"]||(this[n(413)+n(1538)]?.["resetEnd"+n(1211)+n(1629)](),this[n(1411)+n(1032)]?.["resetCou"+n(407)](),this[n(862)]?this[n(1408)+"ect"](1001,"going aw"+n(1504)+"reconnec"+n(1011)+n(1486),!0):this._connect())}[t(1841)+t(1183)+t(620)](){let n=t;e[n(1681)]("fKxkO",n(715))?this[n(1788)+n(737)]=_0x52bdec:this[n(1015)+"T"]?tt[n(1382)+n(1275)+"hange"](({isConnected:s})=>{let d=n;this[d(882)+d(960)+"line"]=s,s?this[d(691)+d(437)]():this[d(691)+d(1740)]()}):this._isMiniWX&&wx[n(1382)+n(1275)+n(1086)](({isConnected:s})=>{let d=n;this[d(882)+"igatorOnline"]=s,s?this[d(691)+d(437)]():this[d(691)+d(1740)]()})}[t(1049)](n){let s=t,d={DIqEQ:function(f,g){return e.ZDCUY(f,g)},dgfyk:function(f,g,w,b){return e[H(675)](f,g,w,b)},ZKNcL:function(f,g){return e[H(1327)](f,g)}};if(e[s(1438)](s(607),e[s(448)])){let f=EgZRES[s(1787)](255,_0x103a19);EgZRES[s(1603)](_0x1c706d,f,_0x495a7e,EgZRES[s(1791)](_0x2eeed3,_0x375e72)),_0x18fb27>>>=8,_0xf58df8--}else return new Promise(f=>{let g=s;setTimeout(f,this[g(489)+g(571)+"e"](n))})}[t(1408)+t(486)](n=1e3,s="",d=!1){let f=t;this[f(862)]&&this[f(361)+f(1642)+"t"](n,s,d)}_onTimeout(){let n=t,s=this[n(413)+"tManager"]?.[n(726)+n(986)+"nt"]();this._debug(n(1081)+s+n(1663)),this[n(1408)+"ect"](1001,e[n(569)],!0)}[t(926)](n){let s=t,d=e[s(426)](zt,n);this[s(862)]&&e[s(460)](this[s(862)][s(998)+"te"],this[s(1060)])&&(this._ws&&this[s(862)][s(1573)](d),this[s(1142)]("send_ack",n))}[t(1637)+"sListeners"](){let n=t,s=e[n(1667)].split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(862)]["removeEv"+n(1262)+n(1231)](e.TYaio,this[n(427)]);continue;case"1":this[n(862)][n(1699)+n(1262)+"ner"](e.gjZRl,this[n(545)]);continue;case"2":this[n(862)]["removeEv"+n(1262)+"ner"](e.Txkxl,this[n(1817)+"ge"]);continue;case"3":this[n(862)][n(1699)+n(1262)+n(1231)](e[n(1143)],this[n(631)]);continue;case"4":if(!this._ws)return;continue}break}}[t(875)+t(1161)](){let n=t;if(e[n(1079)](e[n(454)],"pIVzA")){let s=(n(943)+"2")[n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this._ws)return;continue;case"1":this._ws[n(510)+"Listener"](e[n(1143)],this[n(631)]);continue;case"2":this[n(862)][n(510)+"Listener"](e[n(1368)],this[n(427)]);continue;case"3":this[n(862)]["addEvent"+n(1469)](e[n(447)],this._onClose);continue;case"4":this[n(862)][n(510)+n(1469)](e[n(348)],this[n(1817)+"ge"]);continue}break}}else return this[n(1224)]?.[n(633)](_0x352a54)}[t(717)+t(1620)](n=1e3,s=""){let d=t,f={wzbHY:function(g,w){return g(w)},Sdmpn:function(g,w,b){return e[H(972)](g,w,b)}};try{e[d(1434)]===e[d(1434)]?this[d(862)]&&this[d(862)][d(1834)](n,s):(FNPTTD[d(1619)](_0xb38999,this._intervalTimeoutId),this["_interva"+d(750)+"Id"]=FNPTTD.Sdmpn(_0x315f2e,()=>{this.flushExpired()},this[d(650)+"l"]))}catch{}}[t(361)+t(1642)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(647)+f(1708)](),this[f(526)+f(1157)](),this[f(1637)+"sListeners"](),this[f(717)+"nceClose"](1e3,s),this[f(1592)+f(1537)]=!1,d&&this[f(996)+f(1035)]()&&!this[f(653)+"osed"]){if(this[f(413)+"tManager"]?.[f(658)+"chMaxTries"]()){if(e[f(1748)](f(1580),e[f(764)]))return this[f(1224)].isReady;{let w=this[f(413)+f(1538)]?.getCurrentEndpoint();this[f(1184)+f(1029)+f(968)](e.Isbrl(xt,e[f(447)],{code:1006,reason:"connect "+w+(" timeout"+f(1541)+f(1495)+f(1506)),wasClean:!0}))}}else{let w=this[f(965)][f(1422)+f(353)+f(1302)](n,s);this[f(1184)+"hCloseEv"+f(968)](xt(e[f(447)],{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this[f(1592)]()}return}this[f(996)+"orOnline"]()||this[f(653)+f(1466)]?this[f(1184)+f(1029)+f(968)](e[f(1244)](xt,e[f(447)],{code:n,reason:e[f(396)]})):this[f(1184)+"hCloseEv"+f(968)](e[f(538)](xt,e[f(447)],{code:1006,reason:e[f(744)]})),this[f(862)]=null,this[f(413)+"tManager"]?.[f(1645)+f(1211)+f(1629)](),this[f(1411)+f(1032)]?.["resetCou"+f(407)]()}[t(1184)+"hOpenEvent"](n){let s=t,d={WRGKv:function(f,g){return e.IFESq(f,g)},NSEAt:function(f,g){return e[H(1369)](f,g)},xuimX:e[s(916)],VSJZS:function(f,g){return e.zbZXi(f,g)},Gttuy:e[s(579)]};if(e[s(1346)]===e[s(1346)])this[s(815)](e[s(1143)],n),this.onopen&&this[s(682)](n);else{if(RgkAOa[s(885)](_0x50e6d3,_0x3c9d45))return new _0x3cd124(_0x4d0b85,_0x2b18ed);if((_0x2d0cfb||_0xf2dc0b)&&RgkAOa[s(1742)](RgkAOa[s(453)],typeof _0xd26d05))return new _0xcc7c63(_0x190328,_0x1c6719);if(RgkAOa[s(1283)](_0x49eb2c,_0x147c73)&&RgkAOa[s(1742)](RgkAOa[s(453)],typeof _0x5a4efe))return new _0x498e10(_0x5de71c,_0x746ac1);throw new _0x4e1c84(RgkAOa[s(506)])}}[t(1184)+t(591)+t(1499)](n){let s=t;this[s(815)](e[s(348)],n),this[s(778)+"e"]&&this[s(778)+"e"](n)}[t(1184)+t(562)+t(817)](n){let s=t,d={TVmQx:function(f,g,w,b){return e.zBQuj(f,g,w,b)},aDcBn:function(f,g){return e[H(821)](f,g)},VrsKE:function(f,g){return e[H(1126)](f,g)},NcxRE:function(f,g,w,b){return e[H(1783)](f,g,w,b)}};if(e.Tzwdf(e[s(1496)],e.KRVHO))this.emit(e[s(1064)],n),this[s(395)+"eAck"]&&this[s(395)+s(1770)](n);else return _0x43aaa4?_0x19db54.length<40?PKffle[s(871)](_0x569557,_0x1aab95,_0x10c89a,_0x15c59b)+_0x46b5fe:_0x6388a1[s(463)+"e"]?PKffle[s(1001)](_0x21474d[s(463)+"e"](_0x59bd16,_0x4fe653),_0x2c72ed):_0x3bdb1d.write?PKffle.VrsKE(_0x4067fe.write(_0x34a149,_0x31e26f),_0x361b11):PKffle[s(1001)](PKffle[s(1297)](_0x270b71,_0x164ac8,_0x5108aa,_0x57f624),_0x5063ef):_0x46d32f}[t(1184)+t(1207)+"ent"](n){let s=t;this[s(815)](e[s(1368)],n),this[s(1712)]&&this.onerror(n)}[t(1184)+t(1029)+t(968)](n){let s=t;this.emit(e[s(447)],n),this[s(729)]&&this[s(729)](n)}get[t(1485)+"pe"](){let n=t;return this[n(862)]?this[n(862)][n(1485)+"pe"]:this[n(1460)+"ype"]}set[t(1485)+"pe"](n){let s=t;e[s(1118)]===e.mluUr?(this[s(1460)+s(987)]=n,this[s(862)]&&(this[s(862)][s(1485)+"pe"]=n)):(_0x3b16c7=_0x4d3ffa[s(1714)](_0x5528f1),_0x2ccb86=_0xa59803.concat(_0x416ead[_0x361f59]))}get[t(1037)+"nt"](){let n=t;return this["_endpoin"+n(1538)]?.[n(726)+n(986)+"ntTriesC"+n(1720)]()||0}get[t(1210)+t(508)](){let n=t,s=this[n(828)+n(1375)].reduce((d,f)=>(d+=f&&f[n(1227)+"th"]||0,d),0);return e[n(519)](s,this[n(862)]?this[n(862)].bufferedAmount:0)}get[t(1733)+"ns"](){let n=t;return this[n(862)]?this[n(862)][n(1733)+"ns"]:""}get[t(1145)](){let n=t;if(e[n(624)]("IpTAD",e[n(588)]))_0x5682c2=_0x30a9ed[n(1117)+"At"](_0x4213be),e.TpbmG(_0x1d85b0,128)?_0x46cb1f+=1:_0x1300b2<2048?_0x590801+=2:e[n(430)](e[n(1372)](64512,_0x1ec808),55296)&&e[n(430)](e[n(487)](64512,_0x1c4589[n(1117)+"At"](e[n(1535)](_0xab6356,1))),56320)?(++_0x340a45,_0x6d6da7+=4):_0x245b68+=3;else return this[n(862)]?this[n(862)][n(1145)]:""}get[t(998)+"te"](){let n=t;if(e[n(1652)](e[n(1831)],e[n(944)])){let s=e[n(1007)](_0x504990,_0x30a706,_0x113868[n(836)]),d=_0x239851[n(899)],f=_0x566019[n(899)];for(let g=0,w=_0x3a276c[n(836)];g<w;g++)d[e.PcxEh(g,s)]=f[g]}else return this._ws?this[n(862)][n(998)+"te"]:this[n(965)].automaticOpen?this[n(1010)+"NG"]:this[n(1853)]}get url(){let n=t;return this[n(862)]?this[n(862)].url:this[n(1697)]}close(n=1e3,s){let d=t,f=e[d(970)][d(584)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(544)+"balEventListener"]();continue;case"1":if(this[d(862)][d(998)+"te"]===this[d(1853)]||e[d(895)](this[d(862)][d(998)+"te"],this[d(745)]))return void this[d(1142)](e[d(383)]);continue;case"2":this["_QoSMana"+d(350)]?.closeDB();continue;case"3":this[d(526)+d(1157)]();continue;case"4":this[d(361)+d(1642)+"t"](n,s);continue;case"5":if(!this[d(862)])return void this[d(1142)](e[d(1192)]);continue;case"6":this[d(653)+d(1466)]=!0;continue;case"7":this._clearPingTimer();continue}break}}async send(n,s){let d=t;if(e[d(470)](null,n))throw new Error(e[d(1390)]);e[d(1031)](e[d(1153)],typeof n)&&(n=JSON[d(531)+"y"](n)),e.QSYit(e[d(803)],typeof n)&&!e[d(1288)](n,ArrayBuffer)&&!(n.buffer&&e[d(685)](n.buffer,ArrayBuffer))&&(n=JSON[d(531)+"y"](n));let f=await $d(n),g=e[d(551)](Kx,n),{method:w=0,service:b=this[d(965)][d(1373)],logID:x=this[d(965)][d(1442)+d(1389)](),headers:A=this[d(965)][d(1136)],payloadEncoding:O=this[d(965)][d(1627)+d(382)],payloadType:z=this[d(965)][d(842)+d(987)],logIDNew:G=this._options[d(533)+d(771)]["enableAutoGenera"+d(1721)+"ew"]?e.yJero(i,this._options["logIDNew"+d(771)][d(495)]):""}=e[d(1847)](s,{});if(!b)throw new Error(e.YaWya);let K={SeqID:ae[d(532)+"er"](this._seqId++),LogID:ae[d(532)+"er"](x),service:b,method:w,headers:A,payloadEncoding:e[d(685)](O,Object)?O[d(1074)]?O[d(1074)]:"":O,payloadType:e[d(873)](z,Object)?z[d(1271)]?z[d(1271)]:g:z||g,payload:f,LogIDNew:G},he=e.yvhhC(zt,K);if(this[d(862)]&&e[d(1177)](this[d(862)][d(998)+"te"],this.OPEN))this[d(862)]&&this._ws[d(1573)](he),this._debug(d(1311),K);else if(e[d(1124)](this._messageQueue[d(414)],this._options[d(1624)+d(473)+"ength"]))if(e[d(417)]("NZwqJ",e.IhGFs))this._messageQueue[d(738)](he),this[d(1142)](e[d(1350)],K);else return this._ws?this[d(862)].protocol:"";else this[d(828)+d(1375)][d(1823)](),this._messageQueue[d(738)](he);return{seqID:this[d(1425)],logID:x,logIDNew:G}}async[t(1422)+"t"](n){let s=t,{url:d}=e[s(889)](n,{}),f=Array.isArray(d)?d:e.HkfWs(e[s(803)],typeof d)?[d]:[];n&&Object[s(1217)](this[s(965)],n),f&&f[s(414)]?this._endpointManager=new jd(f,this[s(965)][s(1805)+"es"]):this[s(413)+s(1538)]?.[s(1645)+s(1211)+s(1629)](),this[s(1411)+"sCounter"]?.[s(606)+s(407)](this[s(965)]["pingLoss"+s(975)]),this["_readyCl"+s(1466)]=!1,this._ws&&e[s(1459)](this[s(862)][s(998)+"te"],this[s(1853)])?this[s(1408)+s(486)](1e3,e[s(1599)],!0):(this._isInit=!0,this[s(1592)]())}async[t(1426)](){let n=t;if(!this["_connect"+n(1537)])if(e[n(1200)](e[n(1420)],e[n(1420)])){e.hjjLf(_0x3b9aad,_0x332979,42);let s=e[n(1690)](_0x525f79);_0x4a8691(_0x3be897,s),e[n(963)](_0x1c3630,_0x249b11,s.limit),e[n(708)](_0x527426,_0x32038a,s),_0xb61c35(s)}else{let s=e[n(377)][n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(763)]=!0;continue;case"1":this._readyClosed=!1;continue;case"2":this[n(413)+"tManager"]?.[n(1645)+"pointCon"+n(1629)]();continue;case"3":this[n(1592)]();continue;case"4":this[n(1411)+n(1032)]?.[n(606)+n(407)]();continue}break}}}["addEvent"+t(1469)](n,s){this.on(n,s)}dispatchEvent(n){let s=t,{type:d}=n;this[s(815)](d,n)}["removeEv"+t(1262)+t(1231)](n,s){this.off(n,s)}[t(404)](){let n=t,s={mjXyo:function(d,f){return d(f)},OamGT:e[n(758)],SOKjt:n(847)+n(539)+"s",uwStJ:e[n(601)],sluMH:function(d,f){return e[n(1656)](d,f)},pnmje:n(1179)};return new Promise((d,f)=>{let g=n,w={Lxqvl:function(b,x){return b(x)},hWYNl:e.JLwiI,jymRw:e[g(499)],RdVaw:"ping_onc"+g(398)+"t"};if(e.KeOWc(e[g(1260)],g(1191)))w.Lxqvl(_0x33ae7b,w[g(1676)]),this[g(1671)](w[g(1483)],_0x5d7808),this[g(1671)](w.RdVaw,_0x5215c7);else{this[g(647)+g(1708)](),this[g(1188)+g(1492)+"Id"]=setTimeout(this[g(734)][g(1052)](this),this[g(965)][g(1394)+"rval"]);let b=()=>{let A=g;s[A(352)](d,s[A(1738)]),this[A(1671)](s.SOKjt,b),this[A(1671)](s[A(1044)],x)},x=()=>{let A=g;s[A(480)](f,s[A(1162)]),this.off(s.SOKjt,b),this[A(1671)](s[A(1044)],x)};this.on(e.BGUgM,b),this.on(e.FnXlA,x),this._ping()}})}}})(),ke[L(637)+L(1129)]=De[L(637)+L(1129)],ke[L(834)+L(1377)]=De[L(834)+"rorEvent"],ke[L(445)+"e"]=De[L(445)+"e"],ke[L(1499)]=De[L(1499)],ke.FWS=De[L(595)],ke[L(527)+L(597)+L(1280)]=De["Frontier"+L(597)+"vent"],ke[L(597)+L(1280)]=De["MessageE"+L(1280)],ke[L(952)+"t"]=De[L(952)+"t"],ke[L(861)+"tEvent"]=De[L(861)+L(565)],ke[L(481)+L(1129)]=De[L(481)+L(1129)],ke[L(753)+"rorEvent"]=De["createEr"+L(1377)],ke["createMe"+L(979)+"nt"]=De[L(1116)+"ssageEvent"],ke[L(673)+L(1267)]=De[L(673)+L(1267)],ke["createRe"+L(1614)+"vent"]=De[L(1669)+L(1614)+L(1280)],ke[L(1194)+L(1409)]=De[L(1194)+L(1409)],ke[L(1478)+L(1026)]=De.encodeFrame;for(mo in De)[L(637)+L(1129),L(834)+L(1377),L(445)+"e",L(1499),L(595),L(527)+L(597)+L(1280),L(597)+"vent","OpenEvent",L(861)+L(565),"createCloseEvent",L(753)+L(1377),L(1116)+"ssageEvent",L(673)+"enEvent",L(1669)+L(1614)+L(1280),L(1194)+L(1409),"encodeFrame"][L(1087)](mo)===-1&&(ke[mo]=De[mo]);var mo;Object[L(1529)+L(1021)](ke,"__esModule",{value:!0})});var $t=ie((N3,K0)=>{"use strict";var G0=["nodebuffer","arraybuffer","fragments"],W0=typeof Blob<"u";W0&&G0.push("blob");K0.exports={BINARY_TYPES:G0,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:W0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var zi=ie((L3,So)=>{"use strict";var{EMPTY_BUFFER:CE}=$t(),Qc=Buffer[Symbol.species];function DE(t,e){if(t.length===0)return CE;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Qc(r.buffer,r.byteOffset,i):r}function $0(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function J0(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function kE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ed(t){if(ed.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Qc(t):ArrayBuffer.isView(t)?e=new Qc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ed.readOnly=!1),e}So.exports={concat:DE,mask:$0,toArrayBuffer:kE,toBuffer:ed,unmask:J0};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ce("bufferutil");So.exports.mask=function(e,r,i,o,c){c<48?$0(e,r,i,o,c):t.mask(e,r,i,o,c)},So.exports.unmask=function(e,r){e.length<32?J0(e,r):t.unmask(e,r)}}catch{}});var Z0=ie((M3,Y0)=>{"use strict";var V0=Symbol("kDone"),td=Symbol("kRun"),nd=class{constructor(e){this[V0]=()=>{this.pending--,this[td]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[td]()}[td](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[V0])}}};Y0.exports=nd});var Dr=ie((B3,th)=>{"use strict";var Fi=ce("zlib"),X0=zi(),OE=Z0(),{kStatusCode:Q0}=$t(),PE=Buffer[Symbol.species],NE=Buffer.from([0,0,255,255]),Ao=Symbol("permessage-deflate"),Jt=Symbol("total-length"),Rr=Symbol("callback"),bn=Symbol("buffers"),Cr=Symbol("error"),Io,rd=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Io){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Io=new OE(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){Io.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Io.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Fi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Ao]=this,this._inflate[Jt]=0,this._inflate[bn]=[],this._inflate.on("error",ME),this._inflate.on("data",eh)}this._inflate[Rr]=i,this._inflate.write(e),r&&this._inflate.write(NE),this._inflate.flush(()=>{let c=this._inflate[Cr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=X0.concat(this._inflate[bn],this._inflate[Jt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Jt]=0,this._inflate[bn]=[],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"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Fi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Jt]=0,this._deflate[bn]=[],this._deflate.on("data",LE)}this._deflate[Rr]=i,this._deflate.write(e),this._deflate.flush(Fi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=X0.concat(this._deflate[bn],this._deflate[Jt]);r&&(c=new PE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Rr]=null,this._deflate[Jt]=0,this._deflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};th.exports=rd;function LE(t){this[bn].push(t),this[Jt]+=t.length}function eh(t){if(this[Jt]+=t.length,this[Ao]._maxPayload<1||this[Jt]<=this[Ao]._maxPayload){this[bn].push(t);return}this[Cr]=new RangeError("Max payload size exceeded"),this[Cr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Cr][Q0]=1009,this.removeListener("data",eh),this.reset()}function ME(t){if(this[Ao]._inflate=null,this[Cr]){this[Rr](this[Cr]);return}t[Q0]=1007,this[Rr](t)}});var kr=ie((z3,To)=>{"use strict";var{isUtf8:nh}=ce("buffer"),{hasBlob:BE}=$t(),zE=[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 FE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function id(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function UE(t){return BE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}To.exports={isBlob:UE,isValidStatusCode:FE,isValidUTF8:id,tokenChars:zE};if(nh)To.exports.isValidUTF8=function(t){return t.length<24?id(t):nh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ce("utf-8-validate");To.exports.isValidUTF8=function(e){return e.length<32?id(e):t(e)}}catch{}});var dd=ie((F3,dh)=>{"use strict";var{Writable:qE}=ce("stream"),rh=Dr(),{BINARY_TYPES:HE,EMPTY_BUFFER:ih,kStatusCode:jE,kWebSocket:GE}=$t(),{concat:sd,toArrayBuffer:WE,unmask:KE}=zi(),{isValidStatusCode:$E,isValidUTF8:sh}=kr(),Ro=Buffer[Symbol.species],ut=0,oh=1,ah=2,ch=3,od=4,ad=5,Co=6,cd=class extends qE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||HE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[GE]=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=ut}_write(e,r,i){if(this._opcode===8&&this._state==ut)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 Ro(i.buffer,i.byteOffset+e,i.length-e),new Ro(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 Ro(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 ut:this.getInfo(e);break;case oh:this.getPayloadLength16(e);break;case ah:this.getPayloadLength64(e);break;case ch:this.getMask();break;case od:this.getData(e);break;case ad:case Co: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[rh.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=oh:this._payloadLength===127?this._state=ah: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=ch:this._state=od}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=od}getData(e){let r=ih;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&&KE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ad,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rh.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===ut&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ut;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=sd(i,r):this._binaryType==="arraybuffer"?o=WE(sd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit("message",o,!0),this._state=ut,this.startLoop(e)}))}else{let o=sd(i,r);if(!this._skipUTF8Validation&&!sh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ad||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit("message",o,!1),this._state=ut,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ih),this.end();else{let i=e.readUInt16BE(0);if(!$E(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Ro(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!sh(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=ut;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ut,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[jE]=o,l}};dh.exports=cd});var fd=ie((q3,fh)=>{"use strict";var{Duplex:U3}=ce("stream"),{randomFillSync:JE}=ce("crypto"),lh=Dr(),{EMPTY_BUFFER:VE,kWebSocket:YE,NOOP:ZE}=$t(),{isBlob:Or,isValidStatusCode:XE}=kr(),{mask:uh,toBuffer:Hn}=zi(),ft=Symbol("kByteLength"),QE=Buffer.alloc(4),Do=8*1024,jn,Pr=Do,vt=0,eb=1,tb=2,ld=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=vt,this.onerror=ZE,this[YE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||QE,r.generateMask?r.generateMask(i):(Pr===Do&&(jn===void 0&&(jn=Buffer.alloc(Do)),JE(jn,0,Do),Pr=0),i[0]=jn[Pr++],i[1]=jn[Pr++],i[2]=jn[Pr++],i[3]=jn[Pr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ft]!==void 0?u=r[ft]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let h=u;u>=65536?(c+=8,h=127):u>125&&(c+=2,h=126);let p=Buffer.allocUnsafe(o?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=h,h===126?p.writeUInt16BE(u,2):h===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(uh(e,i,p,c,u),[p]):(uh(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=VE;else{if(typeof e!="number"||!XE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ft]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==vt?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):Or(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.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};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?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):Or(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.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};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[lh.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Or(e)?(u=e.size,h=!1):(e=Hn(e),u=e.length,h=Hn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[ft]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==vt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ft],this._state=tb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(ud,this,u,o);return}this._bufferedBytes-=i[ft];let l=Hn(c);r?this.dispatch(l,r,i,o):(this._state=vt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(nb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[lh.extensionName];this._bufferedBytes+=i[ft],this._state=eb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");ud(this,h,o);return}this._bufferedBytes-=i[ft],this._state=vt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===vt&&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)}};fh.exports=ld;function ud(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function nb(t,e,r){ud(t,e,r),t.onerror(e)}});var Eh=ie((H3,yh)=>{"use strict";var{kForOnEventAttribute:Ui,kListener:hd}=$t(),hh=Symbol("kCode"),xh=Symbol("kData"),ph=Symbol("kError"),gh=Symbol("kMessage"),mh=Symbol("kReason"),Nr=Symbol("kTarget"),wh=Symbol("kType"),_h=Symbol("kWasClean"),Vt=class{constructor(e){this[Nr]=null,this[wh]=e}get target(){return this[Nr]}get type(){return this[wh]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var Gn=class extends Vt{constructor(e,r={}){super(e),this[hh]=r.code===void 0?0:r.code,this[mh]=r.reason===void 0?"":r.reason,this[_h]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[hh]}get reason(){return this[mh]}get wasClean(){return this[_h]}};Object.defineProperty(Gn.prototype,"code",{enumerable:!0});Object.defineProperty(Gn.prototype,"reason",{enumerable:!0});Object.defineProperty(Gn.prototype,"wasClean",{enumerable:!0});var Lr=class extends Vt{constructor(e,r={}){super(e),this[ph]=r.error===void 0?null:r.error,this[gh]=r.message===void 0?"":r.message}get error(){return this[ph]}get message(){return this[gh]}};Object.defineProperty(Lr.prototype,"error",{enumerable:!0});Object.defineProperty(Lr.prototype,"message",{enumerable:!0});var qi=class extends Vt{constructor(e,r={}){super(e),this[xh]=r.data===void 0?null:r.data}get data(){return this[xh]}};Object.defineProperty(qi.prototype,"data",{enumerable:!0});var rb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ui]&&o[hd]===e&&!o[Ui])return;let i;if(t==="message")i=function(c,l){let u=new qi("message",{data:l?c:c.toString()});u[Nr]=this,ko(e,this,u)};else if(t==="close")i=function(c,l){let u=new Gn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Nr]=this,ko(e,this,u)};else if(t==="error")i=function(c){let l=new Lr("error",{error:c,message:c.message});l[Nr]=this,ko(e,this,l)};else if(t==="open")i=function(){let c=new Vt("open");c[Nr]=this,ko(e,this,c)};else return;i[Ui]=!!r[Ui],i[hd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[hd]===e&&!r[Ui]){this.removeListener(t,r);break}}};yh.exports={CloseEvent:Gn,ErrorEvent:Lr,Event:Vt,EventTarget:rb,MessageEvent:qi};function ko(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Oo=ie((j3,bh)=>{"use strict";var{tokenChars:Hi}=kr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ib(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,p=-1,m=-1,E=0;for(;E<t.length;E++)if(p=t.charCodeAt(E),l===void 0)if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(E!==0&&(p===32||p===9))m===-1&&h!==-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(h,m);p===44?(Bt(e,_,r),r=Object.create(null)):l=_,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(p===32||p===9)m===-1&&h!==-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Bt(r,t.slice(h,m),!0),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),h=m=-1}else if(p===61&&h!==-1&&m===-1)u=t.slice(h,E),h=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(Hi[p]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);h===-1?h=E:i||(i=!0),o=!1}else if(c)if(Hi[p]===1)h===-1&&(h=E);else if(p===34&&h!==-1)c=!1,m=E;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(p===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(h!==-1&&(p===32||p===9))m===-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(h,m);i&&(_=_.replace(/\\/g,""),i=!1),Bt(r,u,_),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),u=void 0,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(h===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let T=t.slice(h,m);return l===void 0?Bt(e,T,r):(u===void 0?Bt(r,T,!0):i?Bt(r,u,T.replace(/\\/g,"")):Bt(r,u,T),Bt(e,l,r)),e}function sb(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(", ")}bh.exports={format:sb,parse:ib}});var Mo=ie((K3,Nh)=>{"use strict";var ob=ce("events"),ab=ce("https"),cb=ce("http"),Ih=ce("net"),db=ce("tls"),{randomBytes:lb,createHash:ub}=ce("crypto"),{Duplex:G3,Readable:W3}=ce("stream"),{URL:xd}=ce("url"),vn=Dr(),fb=dd(),hb=fd(),{isBlob:xb}=kr(),{BINARY_TYPES:vh,CLOSE_TIMEOUT:pb,EMPTY_BUFFER:Po,GUID:gb,kForOnEventAttribute:pd,kListener:mb,kStatusCode:wb,kWebSocket:He,NOOP:Ah}=$t(),{EventTarget:{addEventListener:_b,removeEventListener:yb}}=Eh(),{format:Eb,parse:bb}=Oo(),{toBuffer:vb}=zi(),Th=Symbol("kAborted"),gd=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],Sb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pe=class t extends ob{constructor(e,r,i){super(),this._binaryType=vh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Po,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Rh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vh.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 fb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new hb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[He]=this,c[He]=this,e[He]=this,o.on("conclude",Tb),o.on("drain",Rb),o.on("error",Cb),o.on("message",Db),o.on("ping",kb),o.on("pong",Ob),c.onerror=Pb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",kh),e.on("data",Lo),e.on("end",Oh),e.on("error",Ph),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){ot(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())}),Dh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Po,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Po,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Po,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(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:Yt.indexOf("CONNECTING")});Object.defineProperty(pe.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(pe,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(pe.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(pe,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(pe.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(pe,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(pe.prototype,"CLOSED",{enumerable:!0,value:Yt.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[pd])return e[mb];return null},set(e){for(let r of this.listeners(t))if(r[pd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[pd]:!0})}})});pe.prototype.addEventListener=_b;pe.prototype.removeEventListener=yb;Nh.exports=pe;function Rh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:pb,protocolVersion:gd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!gd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${gd.join(", ")})`);let c;if(e instanceof xd)c=e;else try{c=new xd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",u=c.protocol==="ws+unix:",h;if(c.protocol!=="ws:"&&!l&&!u?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?h="The URL's pathname is empty":c.hash&&(h="The URL contains a fragment identifier"),h){let I=new SyntaxError(h);if(t._redirects===0)throw I;No(t,I);return}let p=l?443:80,m=lb(16).toString("base64"),E=l?ab.request:cb.request,T=new Set,_;if(o.createConnection=o.createConnection||(l?Ab:Ib),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Eb({[vn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Sb.test(I)||T.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.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=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,C]of Object.entries(I))i.headers[S.toLowerCase()]=C}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&&!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=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{ot(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Th]||(v=t._req=null,No(t,I))}),v.on("response",I=>{let S=I.headers.location,C=I.statusCode;if(S&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){ot(t,v,"Maximum redirects exceeded");return}v.abort();let N;try{N=new xd(S,e)}catch{let D=new SyntaxError(`Invalid URL: ${S}`);No(t,D);return}Rh(t,N,r,i)}else t.emit("unexpected-response",v,I)||ot(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,C)=>{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"){ot(t,S,"Invalid Upgrade header");return}let y=ub("sha1").update(m+gb).digest("base64");if(I.headers["sec-websocket-accept"]!==y){ot(t,S,"Invalid Sec-WebSocket-Accept header");return}let D=I.headers["sec-websocket-protocol"],k;if(D!==void 0?T.size?T.has(D)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":T.size&&(k="Server sent no subprotocol"),k){ot(t,S,k);return}D&&(t._protocol=D);let M=I.headers["sec-websocket-extensions"];if(M!==void 0){if(!_){ot(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=bb(M)}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(B);if(J.length!==1||J[0]!==vn.extensionName){ot(t,S,"Server indicated an extension that was not requested");return}try{_.accept(B[vn.extensionName])}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=_}t.setSocket(S,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function No(t,e){t._readyState=pe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ib(t){return t.path=t.socketPath,Ih.connect(t)}function Ab(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ih.isIP(t.host)?"":t.host),db.connect(t)}function ot(t,e,r){t._readyState=pe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[Th]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(No,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function md(t,e,r){if(e){let i=xb(e)?e.size:vb(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 Tb(t,e){let r=this[He];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[He]!==void 0&&(r._socket.removeListener("data",Lo),process.nextTick(Ch,r._socket),t===1005?r.close():r.close(t,e))}function Rb(){let t=this[He];t.isPaused||t._socket.resume()}function Cb(t){let e=this[He];e._socket[He]!==void 0&&(e._socket.removeListener("data",Lo),process.nextTick(Ch,e._socket),e.close(t[wb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Sh(){this[He].emitClose()}function Db(t,e){this[He].emit("message",t,e)}function kb(t){let e=this[He];e._autoPong&&e.pong(t,!this._isServer,Ah),e.emit("ping",t)}function Ob(t){this[He].emit("pong",t)}function Ch(t){t.resume()}function Pb(t){let e=this[He];e.readyState!==pe.CLOSED&&(e.readyState===pe.OPEN&&(e._readyState=pe.CLOSING,Dh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Dh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function kh(){let t=this[He];if(this.removeListener("close",kh),this.removeListener("data",Lo),this.removeListener("end",Oh),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[He]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Sh),t._receiver.on("finish",Sh))}function Lo(t){this[He]._receiver.write(t)||this.pause()}function Oh(){let t=this[He];t._readyState=pe.CLOSING,t._receiver.end(),this.end()}function Ph(){let t=this[He];this.removeListener("error",Ph),this.on("error",Ah),t&&(t._readyState=pe.CLOSING,this.destroy())}});var zh=ie((J3,Bh)=>{"use strict";var $3=Mo(),{Duplex:Nb}=ce("stream");function Lh(t){t.emit("close")}function Lb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Mh(t){this.removeListener("error",Mh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Mb(t,e){let r=!0,i=new Nb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Lh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(Lh,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",Lb),i.on("error",Mh),i}Bh.exports=Mb});var wd=ie((V3,Fh)=>{"use strict";var{tokenChars:Bb}=kr();function zb(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&&Bb[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Fh.exports={parse:zb}});var Kh=ie((Z3,Wh)=>{"use strict";var Fb=ce("events"),Bo=ce("http"),{Duplex:Y3}=ce("stream"),{createHash:Ub}=ce("crypto"),Uh=Oo(),Wn=Dr(),qb=wd(),Hb=Mo(),{CLOSE_TIMEOUT:jb,GUID:Gb,kWebSocket:Wb}=$t(),Kb=/^[+/0-9A-Za-z]{22}==$/,qh=0,Hh=1,Gh=2,_d=class extends Fb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:jb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Hb,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Bo.createServer((i,o)=>{let c=Bo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=$b(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=qh}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===Gh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ji,this);return}if(e&&this.once("close",e),this._state!==Hh)if(this._state=Hh,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(ji,this):process.nextTick(ji,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{ji(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",jh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Kb.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Gi(r,400);return}let h=e.headers["sec-websocket-protocol"],p=new Set;if(h!==void 0)try{p=qb.parse(h)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let T=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=Uh.parse(m);_[Wn.extensionName]&&(T.accept(_[Wn.extensionName]),E[Wn.extensionName]=T)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let T={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(T,(_,v,I,S)=>{if(!_)return Gi(r,v||401,I,S);this.completeUpgrade(E,c,p,e,r,i,o)});return}if(!this.options.verifyClient(T))return Gi(r,401)}this.completeUpgrade(E,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[Wb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>qh)return Gi(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ub("sha1").update(r+Gb).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(p.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[Wn.extensionName]){let E=e[Wn.extensionName].params,T=Uh.format({[Wn.extensionName]:[E]});p.push(`Sec-WebSocket-Extensions: ${T}`),m._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",jh),m.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ji,this)})),u(m,o)}};Wh.exports=_d;function $b(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 ji(t){t._state=Gh,t.emit("close")}function jh(){this.destroy()}function Gi(t,e,r,i){r=r||Bo.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} ${Bo.STATUS_CODES[e]}\r
|
|
17
17
|
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else
|
|
21
|
-
<string>${
|
|
20
|
+
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else Gi(r,i,o,c)}});import{existsSync as mv,openSync as wv}from"node:fs";import{mkdir as _v}from"node:fs/promises";import{dirname as yv}from"node:path";import{fileURLToPath as Ev}from"node:url";function vv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function vd(t=Z()){return mv(t.libEntry)?t.libEntry:Ev(new URL("../index.ts",import.meta.url))}async function ox(t={}){let e=t.paths??Z(),r=t.entryOverride??vd(e),i=vv(e,process.env.COZE_BRIDGE_LOG_MODE);await _v(yv(i),{recursive:!0});let o=wv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=lt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[$i]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return bv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var bv,$i,jo=Ze(()=>{"use strict";yn();te();Ne();bv=U("spawn-daemon"),$i="COZE_BRIDGE_DAEMON"});import{spawn as uS}from"node:child_process";import{mkdir as fS,unlink as hS,writeFile as xS}from"node:fs/promises";import{dirname as pS,join as gS}from"node:path";function Fr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function mS(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Fr(r)}</key>
|
|
21
|
+
<string>${Fr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function wS(t,e){return new Promise((r,i)=>{let o=uS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var zr,Vi,Yo,Dd,Sx=Ze(()=>{"use strict";te();zr=U("supervisor.launchd"),Vi="ai.coze.bridge",Yo=wS,Dd={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>
|
|
@@ -31,8 +31,8 @@ ${e}
|
|
|
31
31
|
<string>${Vi}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Fr(t.nodeBin)}</string>
|
|
35
|
+
<string>${Fr(t.entry)}</string>
|
|
36
36
|
<string>--daemon</string>
|
|
37
37
|
</array>
|
|
38
38
|
<key>RunAtLoad</key>
|
|
@@ -42,13 +42,13 @@ ${e}
|
|
|
42
42
|
<key>ThrottleInterval</key>
|
|
43
43
|
<integer>10</integer>
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Fr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Fr(t.logFile)}</string>${mS(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function Qo(t,e){return new Promise((r,i)=>{let o=
|
|
50
|
+
`},configPath(t){return gS(t.homeDir,"Library","LaunchAgents",`${Vi}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await fS(pS(i),{recursive:!0}),await xS(i,this.renderConfig(t),"utf8"),zr.info("plist written",{plistPath:i,activate:r}),!r)return;await Yo("launchctl",["unload","-w",i]).catch(c=>zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await Yo("launchctl",["load","-w",i]),zr.info("launchd job loaded",{label:Vi});let o=process.getuid?.()??0;await Yo("launchctl",["kickstart","-k",`gui/${o}/${Vi}`]),zr.info("launchd job kickstarted",{label:Vi,uid:o})},async uninstall(t){let e=this.configPath(t);await Yo("launchctl",["unload","-w",e]).catch(r=>zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await hS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),zr.info("launchd job removed",{plistPath:e})}}});import{spawn as _S}from"node:child_process";import{mkdir as yS,unlink as ES,writeFile as bS}from"node:fs/promises";import{dirname as vS,join as Ix}from"node:path";function Xo(t,e){return t.isRoot?e:["--user",...e]}function IS(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function Qo(t,e){return new Promise((r,i)=>{let o=_S(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Zo,Ur,SS,kd,Ax=Ze(()=>{"use strict";te();Zo=U("supervisor.systemd"),Ur="coze-bridge.service",SS="/etc/systemd/system";kd={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
|
+
${IS(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Ix(SS,Ur):Ix(t.homeDir,".config","systemd","user",Ur)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await yS(vS(i),{recursive:!0}),await bS(i,this.renderConfig(t),"utf8"),Zo.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await Qo("systemctl",Xo(t,["daemon-reload"])),await Qo("systemctl",Xo(t,r?["enable","--now",Ur]:["enable",Ur])),Zo.info("systemd unit enabled",{unitName:Ur,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await Qo("systemctl",Xo(t,["disable","--now",Ur])).catch(r=>Zo.warn("systemctl disable failed (ignored)",{err:String(r)})),await ES(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Qo("systemctl",Xo(t,["daemon-reload"])).catch(()=>{}),Zo.info("systemd unit removed",{unitPath:e})}}});import{spawn as AS}from"node:child_process";import{join as TS}from"node:path";function Tx(t,e){return new Promise((r,i)=>{let o=AS(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Od,ea,Pd,Rx=Ze(()=>{"use strict";te();Od=U("supervisor.taskscheduler"),ea="CozeBridge",Pd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,43 +86,43 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return Tv(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Th("schtasks",["/Create","/SC","ONLOGON","/TN",ea,"/TR",r,"/RU",t.userName,"/F"]),Pd.info("task scheduler entry created",{task:ea,logFile:t.logFile})},async uninstall(t){await Th("schtasks",["/Delete","/TN",ea,"/F"]).catch(e=>Pd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Pd.info("task scheduler entry removed",{task:ea})}}});var Dh={};ha(Dh,{buildContext:()=>Ov,getSupervisor:()=>Rv,launchdSupervisor:()=>Rd,systemdSupervisor:()=>kd,taskSchedulerSupervisor:()=>Od});import{homedir as Cv,userInfo as Dv}from"node:os";function Rv(t=process.platform){switch(t){case"darwin":return Rd;case"linux":return kd;case"win32":return Od;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function Pv(){let t={};for(let e of kv){let r=process.env[e];r&&(t[e]=r)}return t}function Ov(){let t=ee();return{nodeBin:process.execPath,entry:vd(t),logFile:t.logFile,homeDir:Cv(),userName:Dv().username,isRoot:process.getuid?.()===0,env:Pv()}}var kv,Rh=Ze(()=>{"use strict";Le();Ho();Sh();Ah();Ch();kv=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ie();nn();var dl=j("acp-installer-warmup"),ng=["claude-code","codex"];async function ll(t={}){let e=t.ensure??er,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);dl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&dl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();ie();import{readdir as hg}from"node:fs/promises";import{mkdir as gl,writeFile as ml}from"node:fs/promises";import{join as ba}from"node:path";var xg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await gl(t,{recursive:!0});let i=xg[e],o=ba(t,i);return await ml(o,r??"","utf8"),o}async function wl(t){let e=ba(t,".claude");await gl(e,{recursive:!0});let r=ba(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await ml(r,i,"utf8"),r}var nt=j("agent-detail-sync"),pg=6e4,gg=5*6e4,as=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await hg(r)}catch(o){nt.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}nt.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await je(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){nt.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){nt.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),nt.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){nt.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){nt.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await je(e,this.opts.paths);if(!i){nt.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){nt.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){nt.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&&nt.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){nt.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),nt.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 N0=It(Zl(),1);import{lstat as Mc,mkdir as Bc,readFile as k0,readdir as Hw,rm as jw,stat as Ww,writeFile as Fc}from"node:fs/promises";import{dirname as Kw,join as Pt,normalize as $w,relative as qc,resolve as zc,sep as P0}from"node:path";import{Readable as O0}from"node:stream";import{pipeline as L0}from"node:stream/promises";import Fg from"events";import et from"fs";import{EventEmitter as yc}from"node:events";import Of from"node:stream";import{StringDecoder as zg}from"node:string_decoder";import Mf from"node:path";import pr from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import tc from"assert";import{Buffer as Bn}from"buffer";import*as nf from"zlib";import cm from"zlib";import{posix as cr}from"node:path";import{basename as Nm}from"node:path";import zs from"fs";import Dt from"fs";import lf from"path";import{win32 as Km}from"node:path";import mf from"path";import Zf from"node:fs";import dw from"node:assert";import{randomBytes as Xf}from"node:crypto";import se from"node:fs";import Me from"node:path";import Qf from"fs";import Js from"node:fs";import gi from"node:path";import st from"node:fs";import gw from"node:fs/promises";import Gs from"node:path";import{join as l0}from"node:path";import it from"node:fs";import x0 from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},Xl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Of||qg(t)||Gg(t)),qg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.pipe=="function"&&t.pipe!==Of.Writable.prototype.pipe,Gg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),us=Symbol("emittingEnd"),Qr=Symbol("emittedError"),xs=Symbol("closed"),Ql=Symbol("read"),hs=Symbol("flush"),ef=Symbol("flushChunk"),pt=Symbol("encoding"),ar=Symbol("decoder"),Fe=Symbol("flowing"),ei=Symbol("paused"),ur=Symbol("resume"),ze=Symbol("buffer"),Ve=Symbol("pipes"),Ue=Symbol("bufferLength"),Ta=Symbol("bufferPush"),ps=Symbol("bufferShift"),$e=Symbol("objectMode"),Te=Symbol("destroyed"),Ca=Symbol("error"),Da=Symbol("emitData"),tf=Symbol("emitEnd"),Ra=Symbol("emitEnd2"),At=Symbol("async"),ka=Symbol("abort"),gs=Symbol("aborted"),ti=Symbol("signal"),Cn=Symbol("dataListeners"),rt=Symbol("discarded"),ni=t=>Promise.resolve().then(t),Hg=t=>t(),jg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Lf=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()}},$g=class extends Lf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Jg=t=>!!t.objectMode,Vg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends yc{[Fe]=!1;[ei]=!1;[Ve]=[];[ze]=[];[$e];[pt];[At];[ar];[Ut]=!1;[on]=!1;[us]=!1;[xs]=!1;[Qr]=null;[Ue]=0;[Te]=!1;[ti];[gs]=!1;[Cn]=0;[rt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Jg(e)?(this[$e]=!0,this[pt]=null):Vg(e)?(this[pt]=e.encoding,this[$e]=!1):(this[$e]=!1,this[pt]=null),this[At]=!!e.async,this[ar]=this[pt]?new zg(this[pt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ze]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ve]});let{signal:r}=e;r&&(this[ti]=r,r.aborted?this[ka]():r.addEventListener("abort",()=>this[ka]()))}get bufferLength(){return this[Ue]}get encoding(){return this[pt]}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[$e]}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}[ka](){this[gs]=!0,this.emit("abort",this[ti]?.reason),this.destroy(this[ti]?.reason)}get aborted(){return this[gs]}set aborted(t){}write(t,e,r){if(this[gs])return!1;if(this[Ut])throw new Error("write after end");if(this[Te])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]?ni:Hg;if(!this[$e]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[$e]?(this[Fe]&&this[Ue]!==0&&this[hs](!0),this[Fe]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe]):t.length?(typeof t=="string"&&!(e===this[pt]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[pt]&&(t=this[ar].write(t)),this[Fe]&&this[Ue]!==0&&this[hs](!0),this[Fe]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[Fe])}read(t){if(this[Te])return null;if(this[rt]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[qt](),null;this[$e]&&(t=null),this[ze].length>1&&!this[$e]&&(this[ze]=[this[pt]?this[ze].join(""):Buffer.concat(this[ze],this[Ue])]);let e=this[Ql](t||null,this[ze][0]);return this[qt](),e}[Ql](t,e){if(this[$e])this[ps]();else{let r=e;t===r.length||t===null?this[ps]():typeof r=="string"?(this[ze][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[ze][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[ze].length&&!this[Ut]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ut]=!0,this.writable=!1,(this[Fe]||!this[ei])&&this[qt](),this}[ur](){this[Te]||(!this[Cn]&&!this[Ve].length&&(this[rt]=!0),this[ei]=!1,this[Fe]=!0,this.emit("resume"),this[ze].length?this[hs]():this[Ut]?this[qt]():this.emit("drain"))}resume(){return this[ur]()}pause(){this[Fe]=!1,this[ei]=!0,this[rt]=!1}get destroyed(){return this[Te]}get flowing(){return this[Fe]}get paused(){return this[ei]}[Ta](t){this[$e]?this[Ue]+=1:this[Ue]+=t.length,this[ze].push(t)}[ps](){return this[$e]?this[Ue]-=1:this[Ue]-=this[ze][0].length,this[ze].shift()}[hs](t=!1){do;while(this[ef](this[ps]())&&this[ze].length);!t&&!this[ze].length&&!this[Ut]&&this.emit("drain")}[ef](t){return this.emit("data",t),this[Fe]}pipe(t,e){if(this[Te])return t;this[rt]=!1;let r=this[on];return e=e||{},t===Xl.stdout||t===Xl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ve].push(e.proxyErrors?new $g(this,t,e):new Lf(this,t,e)),this[At]?ni(()=>this[ur]()):this[ur]()),t}unpipe(t){let e=this[Ve].find(r=>r.dest===t);e&&(this[Ve].length===1?(this[Fe]&&this[Cn]===0&&(this[Fe]=!1),this[Ve]=[]):this[Ve].splice(this[Ve].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[rt]=!1,this[Cn]++,!this[Ve].length&&!this[Fe]&&this[ur]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(jg(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Qr]){let i=e;this[At]?ni(()=>i.call(this,this[Qr])):i.call(this,this[Qr])}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[rt]&&!this[Ve].length&&(this[Fe]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[rt]&&!this[Ve].length&&(this[Fe]=!1)),e}get emittedEnd(){return this[on]}[qt](){!this[us]&&!this[on]&&!this[Te]&&this[ze].length===0&&this[Ut]&&(this[us]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[xs]&&this.emit("close"),this[us]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Te&&this[Te])return!1;if(t==="data")return!this[$e]&&!r?!1:this[At]?(ni(()=>this[Da](r)),!0):this[Da](r);if(t==="end")return this[tf]();if(t==="close"){if(this[xs]=!0,!this[on]&&!this[Te])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Qr]=r,super.emit(Ca,r);let o=!this[ti]||this.listeners("error").length?super.emit("error",r):!1;return this[qt](),o}else if(t==="resume"){let o=super.emit("resume");return this[qt](),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[qt](),i}[Da](t){for(let r of this[Ve])r.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[qt](),e}[tf](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(ni(()=>this[Ra]()),!0):this[Ra]())}[Ra](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[Ve])r.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Ve])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[$e]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[$e]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[$e])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[pt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Te,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return e();let i,o,c=p=>{this.off("data",l),this.off("end",f),this.off(Te,x),e(),o(p)},l=p=>{this.off("error",c),this.off("end",f),this.off(Te,x),this.pause(),i({value:p,done:!!this[Ut]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Te,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,b)=>{o=b,i=p,this.once(Te,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[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ca,e),this.off(Te,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Ca,e),this.once(Te,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Te])return t?this.emit("error",t):this.emit(Te),this;this[Te]=!0,this[rt]=!0,this[ze].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[xs]&&e.close(),t?this.emit("error",t):this.emit(Te),this}static get isStream(){return Ug}},Yg=et.writev,gn=Symbol("_autoClose"),_t=Symbol("_close"),ri=Symbol("_ended"),de=Symbol("_fd"),Pa=Symbol("_finished"),Wt=Symbol("_flags"),Oa=Symbol("_flush"),Qa=Symbol("_handleChunk"),ec=Symbol("_makeBuf"),hi=Symbol("_mode"),ms=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),La=Symbol("_onread"),xr=Symbol("_onwrite"),mn=Symbol("_open"),wt=Symbol("_path"),fn=Symbol("_pos"),Tt=Symbol("_queue"),hr=Symbol("_read"),Na=Symbol("_readSize"),jt=Symbol("_reading"),ii=Symbol("_remain"),Ma=Symbol("_size"),Ts=Symbol("_write"),Dn=Symbol("_writing"),Cs=Symbol("_defaultFlag"),Mn=Symbol("_errored"),bc=class extends Un{[Mn]=!1;[de];[wt];[Na];[jt]=!1;[Ma];[ii];[gn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Mn]=!1,this[de]=typeof e.fd=="number"?e.fd:void 0,this[wt]=t,this[Na]=e.readSize||16*1024*1024,this[jt]=!1,this[Ma]=typeof e.size=="number"?e.size:1/0,this[ii]=this[Ma],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[de]=="number"?this[hr]():this[mn]()}get fd(){return this[de]}get path(){return this[wt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){et.open(this[wt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[de]=e,this.emit("open",e),this[hr]())}[ec](){return Buffer.allocUnsafe(Math.min(this[Na],this[ii]))}[hr](){if(!this[jt]){this[jt]=!0;let t=this[ec]();if(t.length===0)return process.nextTick(()=>this[La](null,0,t));et.read(this[de],t,0,t.length,null,(e,r,i)=>this[La](e,r,i))}}[La](t,e,r){this[jt]=!1,t?this[mr](t):this[Qa](e,r)&&this[hr]()}[_t](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[jt]=!0,this[_t](),this.emit("error",t)}[Qa](t,e){let r=!1;return this[ii]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ii]<=0)&&(r=!1,this[_t](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[de]=="number"&&this[hr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Zg=class extends bc{[mn](){let t=!0;try{this[wr](null,et.openSync(this[wt],"r")),t=!1}finally{t&&this[_t]()}}[hr](){let t=!0;try{if(!this[jt]){this[jt]=!0;do{let e=this[ec](),r=e.length===0?0:et.readSync(this[de],e,0,e.length,null);if(!this[Qa](r,e))break}while(!0);this[jt]=!1}t=!1}finally{t&&this[_t]()}}[_t](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.closeSync(t),this.emit("close")}}},Hs=class extends Fg{readable=!1;writable=!0;[Mn]=!1;[Dn]=!1;[ri]=!1;[Tt]=[];[ms]=!1;[wt];[hi];[gn];[de];[Cs];[Wt];[Pa]=!1;[fn];constructor(t,e){e=e||{},super(e),this[wt]=t,this[de]=typeof e.fd=="number"?e.fd:void 0,this[hi]=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[Cs]=e.flags===void 0,this[Wt]=e.flags===void 0?r:e.flags,this[de]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[de]}get path(){return this[wt]}[mr](t){this[_t](),this[Dn]=!0,this.emit("error",t)}[mn](){et.open(this[wt],this[Wt],this[hi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Cs]&&this[Wt]==="r+"&&t&&t.code==="ENOENT"?(this[Wt]="w",this[mn]()):t?this[mr](t):(this[de]=e,this.emit("open",e),this[Dn]||this[Oa]())}end(t,e){return t&&this.write(t,e),this[ri]=!0,!this[Dn]&&!this[Tt].length&&typeof this[de]=="number"&&this[xr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ri]?(this.emit("error",new Error("write() after end()")),!1):this[de]===void 0||this[Dn]||this[Tt].length?(this[Tt].push(t),this[ms]=!0,!1):(this[Dn]=!0,this[Ts](t),!0)}[Ts](t){et.write(this[de],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[Tt].length?this[Oa]():(this[Dn]=!1,this[ri]&&!this[Pa]?(this[Pa]=!0,this[_t](),this.emit("finish")):this[ms]&&(this[ms]=!1,this.emit("drain"))))}[Oa](){if(this[Tt].length===0)this[ri]&&this[xr](null,0);else if(this[Tt].length===1)this[Ts](this[Tt].pop());else{let t=this[Tt];this[Tt]=[],Yg(this[de],t,this[fn],(e,r)=>this[xr](e,r))}}[_t](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Nf=class extends Hs{[mn](){let t;if(this[Cs]&&this[Wt]==="r+")try{t=et.openSync(this[wt],this[Wt],this[hi])}catch(e){if(e?.code==="ENOENT")return this[Wt]="w",this[mn]();throw e}else t=et.openSync(this[wt],this[Wt],this[hi]);this[wr](null,t)}[_t](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.closeSync(t),this.emit("close")}}[Ts](t){let e=!0;try{this[xr](null,et.writeSync(this[de],t,0,t.length,this[fn])),e=!1}finally{if(e)try{this[_t]()}catch{}}}},em=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"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,Ec=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},vi=(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=Ec(c);if(o?.(x,l),tm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(nm(x)){let p=e(x,l);return f?p.then(()=>f(),f):p}else if(rm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(im(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}),dm=cm.constants||{ZLIB_VERNUM:4736},kt=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},dm)),lm=Bn.concat,rf=Object.getOwnPropertyDescriptor(Bn,"concat"),fm=t=>t,Ba=rf?.writable===!0||rf?.set!==void 0?t=>{Bn.concat=t?fm:lm}:t=>{},Fn=Symbol("_superWrite"),ws=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Fa=Symbol("flushFlag"),vc=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 nf[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new nf[e](t)}catch(r){throw new ws(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ws(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return tc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[Fa]: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;tc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ba(!0);let l;try{let x=typeof t[Fa]=="number"?t[Fa]:this.#r;l=this.#t._processChunk(t,x),Ba(!1)}catch(x){Ba(!1),this.#o(new ws(x,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ws(x,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];f=this[Fn](Bn.from(x));for(let p=1;p<l.length;p++)f=this[Fn](l[p])}else f=this[Fn](Bn.from(l));return r&&r(),f}},Bf=class extends vc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||kt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||kt.Z_FINISH,t.fullFlushFlag=kt.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(kt.Z_SYNC_FLUSH),tc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},um=class extends Bf{#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)}},xm=class extends Bf{constructor(t){super(t,"Unzip")}},Ff=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||kt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=kt.BROTLI_OPERATION_FLUSH,super(t,e)}},hm=class extends Ff{constructor(t){super(t,"BrotliCompress")}},pm=class extends Ff{constructor(t){super(t,"BrotliDecompress")}},zf=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.ZSTD_e_continue,t.finishFlush=t.finishFlush||kt.ZSTD_e_end,t.fullFlushFlag=kt.ZSTD_e_flush,super(t,e)}},gm=class extends zf{constructor(t){super(t,"ZstdCompress")}},mm=class extends zf{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(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]=Uf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=qf(o))}},bm=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?Em(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},Em=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Uf(c):c===0?l=c:(i=!0,l=qf(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=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},Uf=t=>(255^t)&255,qf=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>Sc,isCode:()=>Ds,isName:()=>Im,name:()=>js});var Ds=t=>js.has(t),Im=t=>Sc.has(t),js=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Sc=new Map(Array.from(js).map(t=>[t[1],t[0]])),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??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??za(t,e+136,12),this.cksum=un(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Rn(t,e+156,1);if(Ds(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??un(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??un(t,e+337,8)??0,t[e+475]!==0){let l=Rn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Rn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??za(t,e+476,12),this.ctime=r?.ctime??i?.ctime??za(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=Am(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=Ua(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=Ua(t,e+476,12,this.atime)||this.needPax,this.needPax=Ua(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let 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(Sc.get(t));if(Ds(e)||e==="Unsupported")this.#e=e;else if(Ds(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Am=(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.*/,""),za=(t,e,r)=>Tm(un(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),un=(t,e,r)=>Number(t[e])&128?bm(t.subarray(e,e+r)):Dm(t,e,r),Cm=t=>isNaN(t)?void 0:t,Dm=(t,e,r)=>Cm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Rm={12:8589934591,8:2097151},xn=(t,e,r,i)=>i===void 0?!1:i>Rm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Pm(i,r),e,r,"ascii"),Pm=(t,e)=>Om(Math.floor(t).toString(8),e),Om=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ua=(t,e,r,i)=>i===void 0?!1:xn(t,e,r,i.getTime()/1e3),Lm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Lm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Fs=class Gf{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/"+Nm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new
|
|
91
|
-
`).reduce(Fm,Object.create(null)),Fm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Q=zm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Hf=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=Q(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Q(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,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=Q(t.path)),t.linkpath&&(t.linkpath=Q(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ws=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Um=1024*1024,nc=Buffer.from([31,139]),rc=Buffer.from([40,181,47,253]),qm=Math.max(nc.length,rc.length),ct=Symbol("state"),Pn=Symbol("writeEntry"),Gt=Symbol("readEntry"),qa=Symbol("nextEntry"),sf=Symbol("processEntry"),Ct=Symbol("extendedHeader"),si=Symbol("globalExtendedHeader"),an=Symbol("meta"),of=Symbol("emitMeta"),pe=Symbol("buffer"),Ht=Symbol("queue"),cn=Symbol("ended"),Ga=Symbol("emittedEnd"),On=Symbol("emit"),Re=Symbol("unzip"),_s=Symbol("consumeChunk"),ys=Symbol("consumeChunkSub"),Ha=Symbol("consumeBody"),af=Symbol("consumeMeta"),cf=Symbol("consumeHeader"),oi=Symbol("consuming"),ja=Symbol("bufferConcat"),bs=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),Es=Symbol("onDone"),Ln=Symbol("sawValidEntry"),vs=Symbol("sawNullBlock"),Ss=Symbol("sawEOF"),df=Symbol("closeStream"),Gm=()=>!0,Ei=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ht]=[];[pe];[Gt];[Pn];[ct]="begin";[an]="";[Ct];[si];[cn]=!1;[Re];[dn]=!1;[Ln];[vs]=!1;[Ss]=!1;[dr]=!1;[oi]=!1;[Ga]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Es,()=>{(this[ct]==="begin"||this[Ln]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Es,t.ondone):this.on(Es,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:Gm;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[df]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ws(this,t,e,r)}[cf](t,e){this[Ln]===void 0&&(this[Ln]=!1);let r;try{r=new zn(t,e,this[Ct],this[si])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[vs]?(this[Ss]=!0,this[ct]==="begin"&&(this[ct]="header"),this[On]("eof")):(this[vs]=!0,this[On]("nullBlock"));else if(this[vs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[Pn]=new Hf(r,this[Ct],this[si]);if(!this[Ln])if(o.remain){let c=()=>{o.invalid||(this[Ln]=!0)};o.on("end",c)}else this[Ln]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[On]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[ct]="meta"):(this[Ct]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[On]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[Gt]?this[Ht].push(o):(this[Ht].push(o),this[qa]())))}}}[df](){queueMicrotask(()=>this.emit("close"))}[sf](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[qa]()),e=!1);return e}[qa](){do;while(this[sf](this[Ht].shift()));if(this[Ht].length===0){let t=this[Gt];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ha](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[ct]="header",this[Pn]=void 0,r.end()),o.length}[af](t,e){let r=this[Pn],i=this[Ha](t,e);return!this[Pn]&&r&&this[of](r),i}[On](t,e,r){this[Ht].length===0&&!this[Gt]?this.emit(t,e,r):this[Ht].push([t,e,r])}[of](t){switch(this[On]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Ct]=Fs.parse(this[an],this[Ct],!1);break;case"GlobalExtendedHeader":this[si]=Fs.parse(this[an],this[si],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Ct]??Object.create(null);this[Ct]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Ct]||Object.create(null);this[Ct]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Re]===void 0||this.brotli===void 0&&this[Re]===!1)&&t){if(this[pe]&&(t=Buffer.concat([this[pe],t]),this[pe]=void 0),t.length<qm)return this[pe]=t,r?.(),!0;for(let l=0;this[Re]===void 0&&l<nc.length;l++)t[l]!==nc[l]&&(this[Re]=!1);let o=!1;if(this[Re]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<rc.length;l++)if(t[l]!==rc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Re]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[pe]=t,r?.(),!0;else try{new zn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Re]===void 0||this[Re]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Re]=this[Re]===void 0?new xm({}):o?new mm({}):new pm({}),this[Re].on("data",x=>this[_s](x)),this[Re].on("error",x=>this.abort(x)),this[Re].on("end",()=>{this[cn]=!0,this[_s]()}),this[dr]=!0;let f=!!this[Re][l?"end":"write"](t);return this[dr]=!1,r?.(),f}}this[dr]=!0,this[Re]?this[Re].write(t):this[_s](t),this[dr]=!1;let i=this[Ht].length>0?!1:this[Gt]?this[Gt].flowing:!0;return!i&&this[Ht].length===0&&this[Gt]?.once("drain",()=>this.emit("drain")),r?.(),i}[ja](t){t&&!this[dn]&&(this[pe]=this[pe]?Buffer.concat([this[pe],t]):t)}[bs](){if(this[cn]&&!this[Ga]&&!this[dn]&&!this[oi]){this[Ga]=!0;let t=this[Pn];if(t&&t.blockRemain){let e=this[pe]?this[pe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[pe]&&t.write(this[pe]),t.end()}this[On](Es)}}[_s](t){if(this[oi]&&t)this[ja](t);else if(!t&&!this[pe])this[bs]();else if(t){if(this[oi]=!0,this[pe]){this[ja](t);let e=this[pe];this[pe]=void 0,this[ys](e)}else this[ys](t);for(;this[pe]&&this[pe]?.length>=512&&!this[dn]&&!this[Ss];){let e=this[pe];this[pe]=void 0,this[ys](e)}this[oi]=!1}(!this[pe]||this[cn])&&this[bs]()}[ys](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ss];)switch(this[ct]){case"begin":case"header":this[cf](t,e),e+=512;break;case"ignore":case"body":e+=this[Ha](t,e);break;case"meta":e+=this[af](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[pe]=this[pe]?Buffer.concat([t.subarray(e),this[pe]]):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[Re]?(t&&this[Re].write(t),this[Re].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[bs]())),this}},pi=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)},Hm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},jf=(t,e)=>{let r=new Map(e.map(c=>[pi(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||Qg(c).root||".",x;if(c===f)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(Xg(c),f)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(pi(c)):c=>o(pi(c))},jm=t=>{let e=new Ei(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{}}},Wm=(t,e)=>{let r=new Ei(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 p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},_r=vi(jm,Wm,t=>new Ei(t),t=>new Ei(t),(t,e)=>{e?.length&&jf(t,e),t.noResume||Hm(t)}),Wf=(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:$m,parse:ff}=Km,Ic=t=>{let e="",r=ff(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=ff(t)}return[e,t]},Ks=["|","<",">","?",":"],Ac=Ks.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Jm=new Map(Ks.map((t,e)=>[t,Ac[e]])),Vm=new Map(Ac.map((t,e)=>[t,Ks[e]])),uf=t=>Ks.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),Ym=t=>Ac.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),Kf=(t,e)=>e?(t=Q(t).replace(/^\.(\/|$)/,""),pi(e)+"/"+t):Q(t),Zm=16*1024*1024,xf=Symbol("process"),hf=Symbol("file"),pf=Symbol("directory"),ic=Symbol("symlink"),gf=Symbol("hardlink"),ai=Symbol("header"),Rs=Symbol("read"),sc=Symbol("lstat"),ks=Symbol("onlstat"),oc=Symbol("onread"),ac=Symbol("onreadlink"),cc=Symbol("openfile"),dc=Symbol("onopenfile"),hn=Symbol("close"),Us=Symbol("mode"),lc=Symbol("awaitDrain"),Wa=Symbol("ondrain"),Rt=Symbol("prefix"),$f=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=Ec(e);super(),this.path=Q(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Zm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Q(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Q(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Ic(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Ym(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Q(r.absolute||lf.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[ks](o):this[sc]()}warn(t,e,r={}){return Ws(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[sc](){Dt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ks](e)})}[ks](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[xf]()}[xf](){switch(this.type){case"File":return this[hf]();case"Directory":return this[pf]();case"SymbolicLink":return this[ic]();default:return this.end()}}[Us](t){return Wf(t,this.type==="Directory",this.portable)}[Rt](t){return Kf(t,this.prefix)}[ai](){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[Us](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Fs({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)}[pf](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ai](),this.end()}[ic](){Dt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ac](e)})}[ac](t){this.linkpath=Q(t),this[ai](),this.end()}[gf](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Q(lf.relative(this.cwd,t)),this.stat.size=0,this[ai](),this.end()}[hf](){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[gf](e);this.linkCache.set(t,this.absolute)}if(this[ai](),this.stat.size===0)return this.end();this[cc]()}[cc](){Dt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[dc](e)})}[dc](t){if(this.fd=t,this.#e)return this[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[Rs]()}[Rs](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Dt.read(t,e,r,i,o,(c,l)=>{if(c)return this[hn](()=>this.emit("error",c));this[oc](l)})}[hn](t=()=>{}){this.fd!==void 0&&Dt.close(this.fd,t)}[oc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[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[Wa]():this[lc](()=>this[Wa]())}[lc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Wa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[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[Rs]()}},Xm=class extends $f{sync=!0;[sc](){this[ks](Dt.lstatSync(this.absolute))}[ic](){this[ac](Dt.readlinkSync(this.absolute))}[cc](){this[dc](Dt.openSync(this.absolute,"r"))}[Rs](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Dt.readSync(e,r,i,o,c);this[oc](l),t=!1}finally{if(t)try{this[hn](()=>{})}catch{}}}[lc](t){t()}[hn](t=()=>{}){this.fd!==void 0&&Dt.closeSync(this.fd),t()}},Qm=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 Ws(this,t,e,r)}constructor(t,e={}){let r=Ec(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Q(t.path),this.mode=t.mode!==void 0?this[Us](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Q(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=Ic(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 Fs({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 Kf(t,this.prefix)}[Us](t){return Wf(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}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=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++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(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=nw(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 nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Tc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Tc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Tc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Tc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},wf=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},_f=Buffer.alloc(1024),Ps=Symbol("onStat"),ci=Symbol("ended"),gt=Symbol("queue"),di=Symbol("queue"),ln=Symbol("current"),Nn=Symbol("process"),li=Symbol("processing"),Is=Symbol("processJob"),mt=Symbol("jobs"),Ka=Symbol("jobDone"),Os=Symbol("addFSEntry"),yf=Symbol("addTarEntry"),fc=Symbol("stat"),uc=Symbol("readdir"),Ls=Symbol("onreaddir"),Ns=Symbol("pipe"),bf=Symbol("entry"),$a=Symbol("entryOpt"),Ms=Symbol("writeEntryClass"),Jf=Symbol("write"),Ja=Symbol("ondrain"),$s=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ms];onWriteEntry;[gt];[di]=new Map;[mt]=0;[li]=!1;[ci]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Q(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ms]=$f,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new um(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new hm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[gt]=new tw,this[mt]=0,this.jobs=Number(t.jobs)||4,this[li]=!1,this[ci]=!1}[Jf](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[ci]=!0,this[Nn](),r&&r(),this}write(t){if(this[ci])throw new Error("write after end");return t instanceof Hf?this[yf](t):this[Os](t),this.flowing}[yf](t){let e=Q(mf.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new wf(t.path,e);r.entry=new Qm(t,this[$a](r)),r.entry.on("end",()=>this[Ka](r)),this[mt]+=1,this[gt].push(r)}this[Nn]()}[Os](t){let e=Q(mf.resolve(this.cwd,t));this[gt].push(new wf(t,e)),this[Nn]()}[fc](t){t.pending=!0,this[mt]+=1;let e=this.follow?"stat":"lstat";zs[e](t.absolute,(r,i)=>{t.pending=!1,this[mt]-=1,r?this.emit("error",r):this[Ps](t,i)})}[Ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Is](t);else{let r=`${e.dev}:${e.ino}`,i=this[di].get(r);i?i.push(t):this[di].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Nn]()}[uc](t){t.pending=!0,this[mt]+=1,zs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[mt]-=1,e)return this.emit("error",e);this[Ls](t,r)})}[Ls](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Nn]()}[Nn](){if(!this[li]){this[li]=!0;for(let t=this[gt].head;t&&this[mt]<this.jobs;t=t.next)if(this[Is](t.value),t.value.ignore){let e=t.next;this[gt].removeNode(t),t.next=e}this[li]=!1,this[ci]&&this[gt].length===0&&this[mt]===0&&(this.zip?this.zip.end(_f):(super.write(_f),super.end()))}}get[ln](){return this[gt]&&this[gt].head&&this[gt].head.value}[Ka](t){this[gt].shift(),this[mt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[di].get(r);if(i){this[di].delete(r);for(let o of i)o.pending=!1,this[Is](o)}}this[Nn]()}[Is](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[Ns](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ps](t,e):this[fc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ls](t,e):this[uc](t),!t.readdir)return}if(t.entry=this[bf](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Ns](t)}}}[$a](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[bf](t){this[mt]+=1;try{return new this[Ms](t.path,this[$a](t)).on("end",()=>this[Ka](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Ns](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Os](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ws(this,t,e,r)}},Cc=class extends $s{sync=!0;constructor(t){super(t),this[Ms]=Xm}pause(){}resume(){}[fc](t){let e=this.follow?"statSync":"lstatSync";this[Ps](t,zs[e](t.absolute))}[uc](t){this[Ls](t,zs.readdirSync(t.absolute))}[Ns](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Os](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[Jf](i)})}},sw=(t,e)=>{let r=new Cc(t),i=new Nf(t.file,{mode:t.mode||438});r.pipe(i),Vf(r,e)},ow=(t,e)=>{let r=new $s(t),i=new Hs(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 Yf(r,e).catch(c=>r.emit("error",c)),o},Vf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:Mf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Yf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:Mf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new Cc(t);return Vf(r,e),r},cw=(t,e)=>{let r=new $s(t);return Yf(r,e).catch(i=>r.emit("error",i)),r},p2=vi(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,e0=lw==="win32",{O_CREAT:t0,O_NOFOLLOW:Ef,O_TRUNC:n0,O_WRONLY:r0}=Qf.constants,i0=Number(process.env.__FAKE_FS_O_FILENAME__)||Qf.constants.UV_FS_O_FILEMAP||0,fw=e0&&!!i0,uw=512*1024,xw=i0|n0|t0|r0,vf=!e0&&typeof Ef=="number"?Ef|n0|t0|r0:null,s0=vf!==null?()=>vf:fw?t=>t<uw?xw:"w":()=>"w",xc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},qs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},hw=(t,e,r,i,o)=>{if(e.isDirectory())o0(gi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=gi.resolve(t,e.name);qs(l,r,i,o)});else{let c=gi.resolve(t,e.name);qs(c,r,i,o)}},o0=(t,e,r,i)=>{Js.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return qs(t,e,r,i);let l=c.length,f=null,x=p=>{if(!f){if(p)return i(f=p);if(--l===0)return qs(t,e,r,i)}};for(let p of c)hw(t,p,e,r,x)})},pw=(t,e,r,i)=>{e.isDirectory()&&a0(gi.resolve(t,e.name),r,i),xc(gi.resolve(t,e.name),r,i)},a0=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return xc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return xc(t,e,r)},c0=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Vs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new c0(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=Q(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,f=e.gid,x=typeof l=="number"&&typeof f=="number"&&(l!==e.processUid||f!==e.processGid),p=e.preserve,b=e.unlink,_=Q(e.cwd),A=(v,I)=>{v?r(v):I&&x?o0(I,l,f,S=>A(S)):c?st.chmod(t,o,r):r()};if(t===_)return mw(t,A);if(p)return gw.mkdir(t,{mode:o,recursive:!0}).then(v=>A(null,v??void 0),A);let w=Q(Gs.relative(_,t)).split("/");hc(_,w,o,b,_,void 0,A)},hc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),x=Q(Gs.resolve(t+"/"+f));st.mkdir(x,r,d0(x,e,r,i,o,c,l))},d0=(t,e,r,i,o,c,l)=>f=>{f?st.lstat(t,(x,p)=>{if(x)x.path=x.path&&Q(x.path),l(x);else if(p.isDirectory())hc(t,e,r,i,o,c,l);else if(i)st.unlink(t,b=>{if(b)return l(b);st.mkdir(t,r,d0(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Vs(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,hc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new c0(t,r??"ENOTDIR")}},yw=(t,e)=>{t=Q(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,p=e.unlink,b=Q(e.cwd),_=v=>{v&&f&&a0(v,c,l),o&&st.chmodSync(t,i)};if(t===b)return _w(b),_();if(x)return _(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=Q(Gs.relative(b,t)).split("/"),w;for(let v=A.shift(),I=b;v&&(I+="/"+v);v=A.shift()){I=Q(Gs.resolve(I));try{st.mkdirSync(I,i),w=w||I}catch{let S=st.lstatSync(I);if(S.isDirectory())continue;if(p){st.unlinkSync(I),st.mkdirSync(I,i),w=w||I;continue}else if(S.isSymbolicLink())return new Vs(I,I+"/"+A.join("/"))}}return _(w)},Va=Object.create(null),Sf=1e4,lr=new Set,bw=t=>{lr.has(t)?lr.delete(t):Va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=Va[t],r=lr.size-Sf;if(r>Sf/10){for(let i of lr)if(lr.delete(i),delete Va[i],--r<=0)break}return e},Ew=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=Ew==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=l0(i,r)),e.push(r||"/"),e},[]),Iw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>pi(l0(bw(i))));let r=new Set(t.map(i=>Sw(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}},Aw=()=>process.umask(),If=Symbol("onEntry"),pc=Symbol("checkFs"),Af=Symbol("checkFs2"),gc=Symbol("isReusable"),dt=Symbol("makeFs"),mc=Symbol("file"),wc=Symbol("directory"),Bs=Symbol("link"),Tf=Symbol("symlink"),Cf=Symbol("hardlink"),xi=Symbol("ensureNoSymlink"),Df=Symbol("unsupported"),Rf=Symbol("checkPath"),Ya=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),qe=Symbol("onError"),As=Symbol("pending"),kf=Symbol("pend"),fr=Symbol("unpend"),Za=Symbol("ended"),Xa=Symbol("maybeClose"),_c=Symbol("skip"),mi=Symbol("doChown"),wi=Symbol("uid"),_i=Symbol("gid"),yi=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,bi=Tw==="win32",Cw=1024,Dw=(t,e)=>{if(!bi)return se.unlink(t,e);let r=t+".DELETE."+Xf(16).toString("hex");se.rename(t,r,i=>{if(i)return e(i);se.unlink(r,e)})},Rw=t=>{if(!bi)return se.unlinkSync(t);let e=t+".DELETE."+Xf(16).toString("hex");se.renameSync(t,e),se.unlinkSync(e)},Pf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Dc=class extends Ei{[Za]=!1;[yi]=!1;[As]=0;reservations=new Iw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Za]=!0,this[Xa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Cw,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=Q(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Aw():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[If](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Xa](){this[Za]&&this[As]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ya](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Ic(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||bi&&/^[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=Me.posix.dirname(t.path),x=Me.posix.normalize(Me.posix.join(f,l.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Rf](t){let e=Q(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Q(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ya](t,"path")||!this[Ya](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Q(Me.resolve(t.path)):Q(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Q(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+uf(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+uf(t.path.slice(o.length))}return!0}[If](t){if(!this[Rf](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[pc](t);default:return this[Df](t)}}[qe](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){ww(Q(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[mi](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}[wi](t){return Pf(this.uid,t.uid,this.processUid)}[_i](t){return Pf(this.gid,t.gid,this.processGid)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Hs(String(t.absolute),{flags:s0(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&se.close(i.fd,()=>{}),i.write=()=>!0,this[qe](f,t),e()});let o=1,c=f=>{if(f){i.fd&&se.close(i.fd,()=>{}),this[qe](f,t),e();return}--o===0&&i.fd!==void 0&&se.close(i.fd,x=>{x?this[qe](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 p=t.atime||new Date,b=t.mtime;se.futimes(x,p,b,_=>_?se.utimes(f,p,b,A=>c(A&&_)):c())}if(typeof x=="number"&&this[mi](t)){o++;let p=this[wi](t),b=this[_i](t);typeof p=="number"&&typeof b=="number"&&se.fchown(x,p,b,_=>_?se.chown(f,p,b,A=>c(A&&_)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[qe](f,t),e()}),t.pipe(l)),l.pipe(i)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[qe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[fr](),t.resume())};t.mtime&&!this.noMtime&&(o++,se.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[mi](t)&&(o++,se.chown(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)),c)),c()})}[Df](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Tf](t,e){let r=Q(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[xi](t,this.cwd,r,()=>this[Bs](t,String(t.linkpath),"symlink",e),i=>{this[qe](i,t),e()})}[Cf](t,e){let r=Q(Me.resolve(this.cwd,String(t.linkpath))),i=Q(String(t.linkpath)).split("/");this[xi](t,this.cwd,i,()=>this[Bs](t,r,"link",e),o=>{this[qe](o,t),e()})}[xi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);se.lstat(l,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new Vs(l,Me.resolve(l,r.join("/"))));this[xi](t,l,r,i,o)})}[kf](){this[As]++}[fr](){this[As]--,this[Xa]()}[_c](t){this[fr](),t.resume()}[gc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!bi}[pc](t){this[kf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Af](t,r))}[Af](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[qe](l,t),r();return}this[yi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Q(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,f=>{if(f){this[qe](f,t),r();return}c()})}c()},c=()=>{se.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[_c](t),r();return}if(l||this[gc](t,f))return this[dt](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,p=b=>this[dt](b??null,t,r);return x?se.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return se.rmdir(String(t.absolute),x=>this[dt](x??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);Dw(String(t.absolute),x=>this[dt](x??null,t,r))})};this[yi]?o():i()}[dt](t,e,r){if(t){this[qe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[mc](e,r);case"Link":return this[Cf](e,r);case"SymbolicLink":return this[Tf](e,r);case"Directory":case"GNUDumpDir":return this[wc](e,r)}}[Bs](t,e,r,i){se[r](e,String(t.absolute),o=>{o?this[qe](o,t):(this[fr](),t.resume()),i()})}},fi=t=>{try{return[null,t()]}catch(e){return[e,null]}},f0=class extends Dc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[pc](t){if(!this[yi]){let o=this[pn](this.cwd,this.dmode);if(o)return this[qe](o,t);this[yi]=!0}if(t.absolute!==this.cwd){let o=Q(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[qe](c,t)}}let[e,r]=fi(()=>se.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[_c](t);if(e||this[gc](t,r))return this[dt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?fi(()=>{se.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=fi(()=>se.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:fi(()=>Rw(String(t.absolute)));this[dt](i,t)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{se.closeSync(o)}catch(x){f=x}(l||f)&&this[qe](l||f,t),e()},o;try{o=se.openSync(String(t.absolute),s0(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[qe](l,t)),t.pipe(c)),c.on("data",l=>{try{se.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{se.futimesSync(o,f,x)}catch(p){try{se.utimesSync(String(t.absolute),f,x)}catch{l=p}}}if(this[mi](t)){let f=this[wi](t),x=this[_i](t);try{se.fchownSync(o,Number(f),Number(x))}catch(p){try{se.chownSync(String(t.absolute),Number(f),Number(x))}catch{l=l||p}}}i(l)})}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[qe](i,t),e();return}if(t.mtime&&!this.noMtime)try{se.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[mi](t))try{se.chownSync(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)))}catch{}e(),t.resume()}[pn](t,e){try{return yw(Q(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[xi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Me.resolve(c,l);let[f,x]=fi(()=>se.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new Vs(c,Me.resolve(e,r.join("/"))))}i()}[Bs](t,e,r,i){let o=`${r}Sync`;try{se[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[qe](c,t)}}},kw=t=>{let e=new f0(t),r=t.file,i=Zf.statSync(r),o=t.maxReadSize||16*1024*1024;new Zg(r,{readSize:o,size:i.size}).pipe(e)},Pw=(t,e)=>{let r=new Dc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Zf.stat(o,(f,x)=>{if(f)l(f);else{let p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},u0=vi(kw,Pw,t=>new f0(t),t=>new Dc(t),(t,e)=>{e?.length&&jf(t,e)}),Ow=(t,e)=>{let r=new Cc(t),i=!0,o,c;try{try{o=it.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=it.openSync(t.file,"w+");else throw x}let l=it.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let b=0,_=0;b<512;b+=_){if(_=it.readSync(o,f,b,f.length-b,c+b),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!_)break e}let x=new zn(f);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Lw(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},Lw=(t,e,r,i,o)=>{let c=new Nf(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Nw=(t,e)=>{e=Array.from(e);let r=new $s(t),i=(o,c,l)=>{let f=(A,w)=>{A?it.close(o,v=>l(A)):l(null,w)},x=0;if(c===0)return f(null,0);let p=0,b=Buffer.alloc(512),_=(A,w)=>{if(A||w===void 0)return f(A);if(p+=w,p<512&&w)return it.read(o,b,p,b.length-p,x+p,_);if(x===0&&b[0]===31&&b[1]===139)return f(new Error("cannot append to compressed archives"));if(p<512)return f(null,x);let v=new zn(b);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),p=0,it.read(o,b,0,512,x,_)};it.read(o,b,0,512,x,_)};return new Promise((o,c)=>{r.on("error",c);let l="r+",f=(x,p)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,f);if(x||!p)return c(x);it.fstat(p,(b,_)=>{if(b)return it.close(p,()=>c(b));i(p,_.size,(A,w)=>{if(A)return c(A);let v=new Hs(t.file,{fd:p,start:w});r.pipe(v),v.on("error",c),v.on("close",o),Bw(r,e)})})};it.open(t.file,l,f)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:x0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:x0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},ui=vi(Ow,Nw,()=>{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")}),R2=vi(ui.syncFile,ui.asyncFile,ui.syncNoFile,ui.asyncNoFile,(t,e=[])=>{ui.validate?.(t,e),Fw(t)}),Fw=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 yt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Si(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function h0(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Rc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function p0(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();ie();Le();Je();function Kt(t,e){if(Si(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ys(t){return t.startsWith("http://")||t.startsWith("https://")}function Zs(t){return t.endsWith("/")?t.slice(0,-1):t}Je();ie();var Xs="1008033",g0="1289";var m0="pbbp2",w0="https://www.coze.cn",_0="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",qw="wss://frontier.coze.cn";function Qs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function y0(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??qw}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 Ai(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ii=j("handshake");async function kc(t){let e=Qs(t.endpoint),r=t.timeoutMs??1e4,i=`${Zs(e)}${_0}?aid=${encodeURIComponent(Xs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...br(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ii.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let v=await f.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${v.slice(0,200)}`)}let b=await f.json();if(b.code!==void 0&&b.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${b.code} msg=${b.msg??"-"} logid=${x}`);let _=b.data??{},A=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,w=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!A||!w){let v=JSON.stringify(b).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ii.info("handshake ok",{remoteDeviceId:w,logid:x,traceId:p}),{accessKey:A,deviceId:w}}catch(f){if(f instanceof T)throw Ii.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw Ii.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:f});let x=f.cause;throw Ii.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 Pc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",bt="auto",b0=2e5;function E0(t){return{model:Oc(t.model)??bt,...t.modelToken?{modelToken:t.modelToken}:{}}}function v0(t){return!t||t===bt}var Gw=new Set(["auto","\u81EA\u52A8"]);function Oc(t){let e=t?.trim();if(e)return Gw.has(e.toLowerCase())?bt:e}function S0(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Pc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||bt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else v0(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function I0(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||bt}"`):v0(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Pc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??b0;e.push("-c",`model_context_window=${r}`)}return e}function A0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Lc(t,e){let{ttEnv:r,usePpe:i}=Ai(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function T0(t,e,r){if(!t.modelToken)return{};let i=Lc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
-
`)}}function Nc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function C0(t,e,r){if(!t.modelToken)return null;let i=t.model||bt,o=Lc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Pc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??b0,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function D0(t,e,r){if(!t.modelToken)return[];let i=Lc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Be=j("agent-handlers"),R0=5*1024*1024,Jw=1,Vw=6,Yw=new Set(["node_modules",".git",".coze","dist","build",".next"]),eo=class{constructor(e){this.opts=e}opts;async listSkills(e){Kt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let f of c){let x=Pt(o,f.relPath,"SKILL.md");await Ww(x).then(b=>b.isFile()).catch(()=>!1)&&l.push(t_(f))}return{skills:l}}async addSkills(e){Kt(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,p)=>[x.skillId,p])),f=[];for(let x of o){let p=await Gc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Hc(c,l,p),f.push(x)}return await ss(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Kt(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=Pt(i.workspace,f.relPath);await jw(x,{recursive:!0,force:!0}),Be.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await ss(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Be.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,Be.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(p=>Be.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Be.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await je(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Be.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Be.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),Be.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 je(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Be.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}):(Be.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Kt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Oc(e.model)??bt,i=await je(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),Be.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Be.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Be.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Be.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Kt(e._meta,yt.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,yt.RESET),await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Be.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(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 Zr(e,o)}async clearPersistedAcpSessionIds(e){let r=await je(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(Kt(e._meta,yt.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Be.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Be.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Be.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Kt(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 Mc(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 Yr(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=u_(e.depth);return f.isDirectory()?{tree:await f_(o,l,c,x)}:{tree:[{name:x_(c),path:B0(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Kt(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 Mc(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 Yr(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>R0)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${R0})`);let l=await k0(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 je(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=zc(e,r||"."),o=qc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${P0}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return je(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 Zw(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 Xw(t){return t==="claude-code"?Pt(".claude","skills"):Pt(".agents","skills")}var Qw=3e4,e_=50*1024*1024,Er=3e4;async function Gc(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=Zw(o.skillName),x=Xw(i),p=Pt(x,f),b=Pt(r,p);if(await Bc(b,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");Ti(A.length),await Fc(Pt(b,"SKILL.md"),A,"utf8")}else{let A=await n_(o.downloadUrl);i_(A)?await c_(A,b):s_(A)?await o_(A,b):await Fc(Pt(b,"SKILL.md"),A.toString("utf8"),"utf8")}let _={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Be.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),_}function Hc(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 t_(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 n_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ti(e);let r=r_(t);return Ti(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await k0(e);return Ti(r.length),r}if(Ys(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);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 Ti(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 Ti(t){if(t>e_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(t){return t.length>=2&&t[0]===31&&t[1]===139}function 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 Uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new N0.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||Uc(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(p=>p===".."))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=a_(i),c=zc(e);for(let l of i){if(Uc(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=zc(e,f),p=qc(c,x);if(p.startsWith("..")||p==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await Bc(x,{recursive:!0});continue}await Bc(Kw(x),{recursive:!0});let b;try{b=l.getData()}catch(_){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${_.message}`,{cause:_})}await Fc(x,b)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||Uc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=u0({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 L0(O0.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`))},Er);try{await L0(O0.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 l_=5e3;async function f_(t,e,r,i){return M0(t,e,r,i,{count:0})}async function M0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Hw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(Yw.has(f.name)||f.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Pt(e,f.name),p=$w(Pt(r,f.name)),b=null;try{b=await Mc(x)}catch{continue}if(b.isSymbolicLink())continue;o.count++;let _={name:f.name,path:B0(qc(t,x)),isDir:b.isDirectory(),size:b.size,modifiedAt:Math.floor(b.mtimeMs)};b.isDirectory()&&i>1&&(_.children=await M0(t,x,p,i-1,o)),l.push(_)}return l.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),l}function u_(t){return!t||t<=0?Jw:Math.min(t,Vw)}function x_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function B0(t){return t.split(P0).join("/")}ie();import{readFileSync as UI}from"node:fs";import{dirname as GI,join as HI}from"node:path";import{fileURLToPath as WI}from"node:url";var vr="0.1.96-beta.1";var wn=j("agent-health-reporter"),h_=1e4,Ci=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??h_}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=p_(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 p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as ay,mkdir as lo,rm as cy,stat as dy,writeFile as ly}from"node:fs/promises";import{homedir as fy}from"node:os";import{join as iu}from"node:path";nn();import{spawnSync as P_}from"node:child_process";import{existsSync as O_}from"node:fs";import{release as L_}from"node:os";import{basename as N_,isAbsolute as M_}from"node:path";function Di(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ir(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}Je();var to=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ne={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function F0(t){return"method"in t&&"id"in t&&t.id!==void 0}function z0(t){return"method"in t&&!("id"in t)}function no(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:ne.AGENT_NOT_FOUND,AGENT_BUSY:ne.AGENT_BUSY,AGENT_DISCONNECTED:ne.AGENT_DISCONNECTED,AGENT_TIMEOUT:ne.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ne.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ne.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ne.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ne.INTERNAL_ERROR,BRIDGE_INTERNAL:ne.INTERNAL_ERROR,IPC_AUTH_FAILED:ne.INTERNAL_ERROR,IPC_BAD_REQUEST:ne.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ne.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ne.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ne.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ne.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ne.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ne.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ne.FILE_TOO_LARGE,UNSUPPORTED_MIME:ne.UNSUPPORTED_MIME,UPLOAD_FAILED:ne.UPLOAD_FAILED,UPSTREAM_NOT_READY:ne.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ne.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ne.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ne.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ne.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ri(t.message)}:typeof t=="string"?Ri(t):typeof t=="object"?__(t):t}var w_=[[/\/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 Ri(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ri(i):e[r]=i;return e}function ki(t){if(t instanceof T){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:g_[t.code]??ne.INTERNAL_ERROR,message:Ri(t.message),data:r}}return{code:ne.INTERNAL_ERROR,message:Ri(t instanceof Error?t.message:String(t))}}function U0(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 G0(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 j0={"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"},nA=Object.fromEntries(Object.entries(j0).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ar=class{seq=0;next(e,r){this.seq+=1;let i=j0[e]??b_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>H0(r?.[x]??"")),f=E_(l).join(":");f&&c.push(f)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>H0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function b_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function H0(t){return t.replace(/[:_\s]+/g,"-")}function E_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Vr();import{readFileSync as v_}from"node:fs";var S_=384;async function jc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:S_})}function Wc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function W0(t,e,r={},i=o=>o){return{...i({...t,...Wc(e)}),...r}}yn();Zi();Je();ie();Le();var k_=[{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_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\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_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"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (claude ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes)\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 V0(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=zt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),F_=200,z_=40,U_=zt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),q_=zt("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),G_=zt("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Y0=500;function H_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Y0?t:`${e.slice(0,Y0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Z0(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),P_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function X0(t){try{return O_(t)}catch{return}}function j_(t,e){return{platform:process.platform,osRelease:L_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?X0(e.command):void 0,cwd:e.cwd,cwdExists:X0(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${N_(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 ro({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ar;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=W0(process.env,this.opts.agentEnvFile??ee().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=lt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>F_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(this.buildExitError(o,c));for(let f of this.exitHandlers)f(o,c)}),i.on("error",o=>{let c=o,l=j_(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",W_(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()));Z0(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Z0(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=U_,i=q_,o=G_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ir(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_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=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),f=Di(l,e,r),x=(()=>{if(typeof r!="object"||r===null)return;let _=r.sessionId;return typeof _=="string"?_:void 0})(),p=i>0&&Number.isFinite(i),b=o>0&&Number.isFinite(o);return new Promise((_,A)=>{let w={resolve:_,reject:A,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(p){let S=()=>{w.timer=setTimeout(()=>{let C=Date.now()-v;if(this.inflightAgentRequests.size>0&&C<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:C,approvalMaxMs:c,...x?{sessionId:x}:{}}),S();return}this.pending.delete(l),w.firstUpdateTimer&&clearTimeout(w.firstUpdateTimer);let L=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:L,...x?{sessionId:x}:{}}),A(L?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=b?()=>{w.firstUpdateTimer&&clearTimeout(w.firstUpdateTimer),w.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),I?.();return}w.timer&&clearTimeout(w.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),A(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;w.onFirstUpdate=b?()=>{w.firstUpdateTimer&&clearTimeout(w.firstUpdateTimer),w.firstUpdateTimer=null,w.onFirstUpdate=null}:null,this.pending.set(l,w),I?.();try{this.writeFrame(f)}catch(S){w.timer&&clearTimeout(w.timer),w.firstUpdateTimer&&clearTimeout(w.firstUpdateTimer),this.pending.delete(l),A(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(G0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(no(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(U0(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:H_(e.result)}),r.resolve(e.result));return}if(z0(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(F0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_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,ki(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}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(z_).join(`
|
|
95
|
-
`),o=V0(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.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var io=class extends Ot{framework="claude-code";constructor(e){let{command:r,args:i}=Jr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return K_(e)}};nn();import{mkdtempSync as $_,rmSync as J_}from"node:fs";import{tmpdir as V_}from"node:os";import{join as Y_}from"node:path";var so=class extends Ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Jr("codex",e.command,i),l=e.isolateCodexHome?$_(Y_(V_(),"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{J_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Z_=3e4,Tr=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.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Z_))}get acpSessionName(){return this.sessionName}};Je();ie();Le();function Kc(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 oo=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new 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)Pi(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 Pi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();ie();import{constants as Q0}from"node:fs";import{access as X_}from"node:fs/promises";import{delimiter as Q_,join as ey}from"node:path";var Et=j("framework-detector"),eu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ty=[".exe",".cmd",".bat",".ps1"],qn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??lt,access:e.access??X_}}async detect(e){let r=eu[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,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(eu).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(Q_).filter(Boolean),i=this.env.platform==="win32"?["",...ty]:[""];for(let o of r)for(let c of i){let l=ey(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Q0.F_OK:Q0.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(l=>l?.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 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){Et.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&&(ry(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",p=>{o+=p.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",p=>f({code:p,stdout:o}))}catch{f(null)}})}},ny=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ry(t){return t.replace(ny,"")}import{homedir as iy}from"node:os";import{join as sy}from"node:path";yn();Je();Vr();ie();async function ru(){let t=sy(iy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var tu=j("openclaw.config"),oy=[0,5e3,5e3],nu="models.providers.",ao="agents.defaults.models",co=class{command;env;retryDelaysMs;queue=new bn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??oy}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,tu.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=lt(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){tu.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",`${nu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${nu}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ao}[${e}]`,()=>this.runCli(["config","set",ao,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ao}[${e}]`,`${ao}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var me=j("agent-manager"),uy=(t,e,r,i,o,c,l,f,x)=>{switch(t){case"claude-code":{let p={...o?{...S0(o),...T0(o,l,f)}:{},...x??{},IS_SANDBOX:"1"};return new io({cwd:r,env:p,agentId:i})}case"codex":{let b=[...o?[...I0(o),...D0(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],_={...o?A0(o):{},...x??{}},A=!!o;return new so({cwd:r,agentId:i,...b.length>0?{extraArgs:b}:{},...Object.keys(_).length>0?{env:_}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tr({command:e,cwd:r,agentId:i,...c?{sessionName:Kc(c)}:{}})}};function $c(t){return t==="claude-code"||t==="codex"}function xy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(hy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return TS(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 Tx("schtasks",["/Create","/SC","ONLOGON","/TN",ea,"/TR",r,"/RU",t.userName,"/F"]),Od.info("task scheduler entry created",{task:ea,logFile:t.logFile})},async uninstall(t){await Tx("schtasks",["/Delete","/TN",ea,"/F"]).catch(e=>Od.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Od.info("task scheduler entry removed",{task:ea})}}});var Cx={};xa(Cx,{buildContext:()=>PS,getSupervisor:()=>DS,launchdSupervisor:()=>Dd,systemdSupervisor:()=>kd,taskSchedulerSupervisor:()=>Pd});import{homedir as RS,userInfo as CS}from"node:os";function DS(t=process.platform){switch(t){case"darwin":return Dd;case"linux":return kd;case"win32":return Pd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function OS(){let t={};for(let e of kS){let r=process.env[e];r&&(t[e]=r)}return t}function PS(){let t=Z();return{nodeBin:process.execPath,entry:vd(t),logFile:t.logFile,homeDir:RS(),userName:CS().username,isRoot:process.getuid?.()===0,env:OS()}}var kS,Dx=Ze(()=>{"use strict";Ne();jo();Sx();Ax();Rx();kS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();nn();var dl=U("acp-installer-warmup"),ng=["claude-code","codex"];async function ll(t={}){let e=t.ensure??er,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);dl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&dl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();te();import{readdir as xg}from"node:fs/promises";import{mkdir as gl,writeFile as ml}from"node:fs/promises";import{join as Ea}from"node:path";var hg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await gl(t,{recursive:!0});let i=hg[e],o=Ea(t,i);return await ml(o,r??"","utf8"),o}async function wl(t){let e=Ea(t,".claude");await gl(e,{recursive:!0});let r=Ea(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await ml(r,i,"utf8"),r}var nt=U("agent-detail-sync"),pg=6e4,gg=5*6e4,as=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await xg(r)}catch(o){nt.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}nt.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ge(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){nt.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){nt.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),nt.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){nt.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){nt.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ge(e,this.opts.paths);if(!i){nt.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){nt.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let h=this.retryQueue.get(e),p=h?Math.min(h.currentDelay*2,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){nt.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&&nt.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){nt.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),nt.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 Lf=It(Zl(),1);import{lstat as Mc,mkdir as Bc,readFile as kf,readdir as jw,rm as Gw,stat as Ww,writeFile as zc}from"node:fs/promises";import{dirname as Kw,join as Ot,normalize as $w,relative as qc,resolve as Fc,sep as Of}from"node:path";import{Readable as Pf}from"node:stream";import{pipeline as Nf}from"node:stream/promises";import zg from"events";import et from"fs";import{EventEmitter as yc}from"node:events";import Ou from"node:stream";import{StringDecoder as Fg}from"node:string_decoder";import Lu from"node:path";import pr from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import tc from"assert";import{Buffer as Bn}from"buffer";import*as nu from"zlib";import cm from"zlib";import{posix as cr}from"node:path";import{basename as Lm}from"node:path";import Fs from"fs";import Ct from"fs";import du from"path";import{win32 as Km}from"node:path";import gu from"path";import Yu from"node:fs";import dw from"node:assert";import{randomBytes as Zu}from"node:crypto";import ne from"node:fs";import Me from"node:path";import Xu from"fs";import Js from"node:fs";import gi from"node:path";import st from"node:fs";import gw from"node:fs/promises";import Hs from"node:path";import{join as lf}from"node:path";import it from"node:fs";import hf from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},Xl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Ou||qg(t)||Hg(t)),qg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.pipe=="function"&&t.pipe!==Ou.Writable.prototype.pipe,Hg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),fs=Symbol("emittingEnd"),Qr=Symbol("emittedError"),hs=Symbol("closed"),Ql=Symbol("read"),xs=Symbol("flush"),eu=Symbol("flushChunk"),pt=Symbol("encoding"),ar=Symbol("decoder"),ze=Symbol("flowing"),ei=Symbol("paused"),fr=Symbol("resume"),Fe=Symbol("buffer"),Je=Symbol("pipes"),Ue=Symbol("bufferLength"),Ta=Symbol("bufferPush"),ps=Symbol("bufferShift"),Ke=Symbol("objectMode"),Ae=Symbol("destroyed"),Ra=Symbol("error"),Ca=Symbol("emitData"),tu=Symbol("emitEnd"),Da=Symbol("emitEnd2"),At=Symbol("async"),ka=Symbol("abort"),gs=Symbol("aborted"),ti=Symbol("signal"),Rn=Symbol("dataListeners"),rt=Symbol("discarded"),ni=t=>Promise.resolve().then(t),jg=t=>t(),Gg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Pu=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()}},$g=class extends Pu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Jg=t=>!!t.objectMode,Vg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends yc{[ze]=!1;[ei]=!1;[Je]=[];[Fe]=[];[Ke];[pt];[At];[ar];[Ut]=!1;[on]=!1;[fs]=!1;[hs]=!1;[Qr]=null;[Ue]=0;[Ae]=!1;[ti];[gs]=!1;[Rn]=0;[rt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Jg(e)?(this[Ke]=!0,this[pt]=null):Vg(e)?(this[pt]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[pt]=null),this[At]=!!e.async,this[ar]=this[pt]?new Fg(this[pt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Fe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Je]});let{signal:r}=e;r&&(this[ti]=r,r.aborted?this[ka]():r.addEventListener("abort",()=>this[ka]()))}get bufferLength(){return this[Ue]}get encoding(){return this[pt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[At]}set async(t){this[At]=this[At]||!!t}[ka](){this[gs]=!0,this.emit("abort",this[ti]?.reason),this.destroy(this[ti]?.reason)}get aborted(){return this[gs]}set aborted(t){}write(t,e,r){if(this[gs])return!1;if(this[Ut])throw new Error("write after end");if(this[Ae])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]?ni:jg;if(!this[Ke]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ke]?(this[ze]&&this[Ue]!==0&&this[xs](!0),this[ze]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):t.length?(typeof t=="string"&&!(e===this[pt]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[pt]&&(t=this[ar].write(t)),this[ze]&&this[Ue]!==0&&this[xs](!0),this[ze]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze])}read(t){if(this[Ae])return null;if(this[rt]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[qt](),null;this[Ke]&&(t=null),this[Fe].length>1&&!this[Ke]&&(this[Fe]=[this[pt]?this[Fe].join(""):Buffer.concat(this[Fe],this[Ue])]);let e=this[Ql](t||null,this[Fe][0]);return this[qt](),e}[Ql](t,e){if(this[Ke])this[ps]();else{let r=e;t===r.length||t===null?this[ps]():typeof r=="string"?(this[Fe][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[Fe][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[Fe].length&&!this[Ut]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ut]=!0,this.writable=!1,(this[ze]||!this[ei])&&this[qt](),this}[fr](){this[Ae]||(!this[Rn]&&!this[Je].length&&(this[rt]=!0),this[ei]=!1,this[ze]=!0,this.emit("resume"),this[Fe].length?this[xs]():this[Ut]?this[qt]():this.emit("drain"))}resume(){return this[fr]()}pause(){this[ze]=!1,this[ei]=!0,this[rt]=!1}get destroyed(){return this[Ae]}get flowing(){return this[ze]}get paused(){return this[ei]}[Ta](t){this[Ke]?this[Ue]+=1:this[Ue]+=t.length,this[Fe].push(t)}[ps](){return this[Ke]?this[Ue]-=1:this[Ue]-=this[Fe][0].length,this[Fe].shift()}[xs](t=!1){do;while(this[eu](this[ps]())&&this[Fe].length);!t&&!this[Fe].length&&!this[Ut]&&this.emit("drain")}[eu](t){return this.emit("data",t),this[ze]}pipe(t,e){if(this[Ae])return t;this[rt]=!1;let r=this[on];return e=e||{},t===Xl.stdout||t===Xl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Je].push(e.proxyErrors?new $g(this,t,e):new Pu(this,t,e)),this[At]?ni(()=>this[fr]()):this[fr]()),t}unpipe(t){let e=this[Je].find(r=>r.dest===t);e&&(this[Je].length===1?(this[ze]&&this[Rn]===0&&(this[ze]=!1),this[Je]=[]):this[Je].splice(this[Je].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[rt]=!1,this[Rn]++,!this[Je].length&&!this[ze]&&this[fr]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(Gg(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Qr]){let i=e;this[At]?ni(()=>i.call(this,this[Qr])):i.call(this,this[Qr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Rn]=this.listeners("data").length,this[Rn]===0&&!this[rt]&&!this[Je].length&&(this[ze]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Rn]=0,!this[rt]&&!this[Je].length&&(this[ze]=!1)),e}get emittedEnd(){return this[on]}[qt](){!this[fs]&&!this[on]&&!this[Ae]&&this[Fe].length===0&&this[Ut]&&(this[fs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[hs]&&this.emit("close"),this[fs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ae&&this[Ae])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[At]?(ni(()=>this[Ca](r)),!0):this[Ca](r);if(t==="end")return this[tu]();if(t==="close"){if(this[hs]=!0,!this[on]&&!this[Ae])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Qr]=r,super.emit(Ra,r);let o=!this[ti]||this.listeners("error").length?super.emit("error",r):!1;return this[qt](),o}else if(t==="resume"){let o=super.emit("resume");return this[qt](),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[qt](),i}[Ca](t){for(let r of this[Je])r.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[qt](),e}[tu](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(ni(()=>this[Da]()),!0):this[Da]())}[Da](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[Je])r.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Je])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ke]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ke]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ke])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[pt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ae,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(Ae,h),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(Ae,h),this.pause(),i({value:p,done:!!this[Ut]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ae,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((p,m)=>{o=m,i=p,this.once(Ae,h),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ra,e),this.off(Ae,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(Ra,e),this.once(Ae,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ae])return t?this.emit("error",t):this.emit(Ae),this;this[Ae]=!0,this[rt]=!0,this[Fe].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[hs]&&e.close(),t?this.emit("error",t):this.emit(Ae),this}static get isStream(){return Ug}},Yg=et.writev,gn=Symbol("_autoClose"),_t=Symbol("_close"),ri=Symbol("_ended"),oe=Symbol("_fd"),Oa=Symbol("_finished"),Wt=Symbol("_flags"),Pa=Symbol("_flush"),Qa=Symbol("_handleChunk"),ec=Symbol("_makeBuf"),xi=Symbol("_mode"),ms=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Na=Symbol("_onread"),hr=Symbol("_onwrite"),mn=Symbol("_open"),wt=Symbol("_path"),un=Symbol("_pos"),Tt=Symbol("_queue"),xr=Symbol("_read"),La=Symbol("_readSize"),Gt=Symbol("_reading"),ii=Symbol("_remain"),Ma=Symbol("_size"),Ts=Symbol("_write"),Cn=Symbol("_writing"),Rs=Symbol("_defaultFlag"),Mn=Symbol("_errored"),Ec=class extends Un{[Mn]=!1;[oe];[wt];[La];[Gt]=!1;[Ma];[ii];[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[oe]=typeof e.fd=="number"?e.fd:void 0,this[wt]=t,this[La]=e.readSize||16*1024*1024,this[Gt]=!1,this[Ma]=typeof e.size=="number"?e.size:1/0,this[ii]=this[Ma],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[oe]=="number"?this[xr]():this[mn]()}get fd(){return this[oe]}get path(){return this[wt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){et.open(this[wt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[oe]=e,this.emit("open",e),this[xr]())}[ec](){return Buffer.allocUnsafe(Math.min(this[La],this[ii]))}[xr](){if(!this[Gt]){this[Gt]=!0;let t=this[ec]();if(t.length===0)return process.nextTick(()=>this[Na](null,0,t));et.read(this[oe],t,0,t.length,null,(e,r,i)=>this[Na](e,r,i))}}[Na](t,e,r){this[Gt]=!1,t?this[mr](t):this[Qa](e,r)&&this[xr]()}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[Gt]=!0,this[_t](),this.emit("error",t)}[Qa](t,e){let r=!1;return this[ii]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ii]<=0)&&(r=!1,this[_t](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[oe]=="number"&&this[xr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Zg=class extends Ec{[mn](){let t=!0;try{this[wr](null,et.openSync(this[wt],"r")),t=!1}finally{t&&this[_t]()}}[xr](){let t=!0;try{if(!this[Gt]){this[Gt]=!0;do{let e=this[ec](),r=e.length===0?0:et.readSync(this[oe],e,0,e.length,null);if(!this[Qa](r,e))break}while(!0);this[Gt]=!1}t=!1}finally{t&&this[_t]()}}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.closeSync(t),this.emit("close")}}},js=class extends zg{readable=!1;writable=!0;[Mn]=!1;[Cn]=!1;[ri]=!1;[Tt]=[];[ms]=!1;[wt];[xi];[gn];[oe];[Rs];[Wt];[Oa]=!1;[un];constructor(t,e){e=e||{},super(e),this[wt]=t,this[oe]=typeof e.fd=="number"?e.fd:void 0,this[xi]=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[Rs]=e.flags===void 0,this[Wt]=e.flags===void 0?r:e.flags,this[oe]===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[oe]}get path(){return this[wt]}[mr](t){this[_t](),this[Cn]=!0,this.emit("error",t)}[mn](){et.open(this[wt],this[Wt],this[xi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Rs]&&this[Wt]==="r+"&&t&&t.code==="ENOENT"?(this[Wt]="w",this[mn]()):t?this[mr](t):(this[oe]=e,this.emit("open",e),this[Cn]||this[Pa]())}end(t,e){return t&&this.write(t,e),this[ri]=!0,!this[Cn]&&!this[Tt].length&&typeof this[oe]=="number"&&this[hr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ri]?(this.emit("error",new Error("write() after end()")),!1):this[oe]===void 0||this[Cn]||this[Tt].length?(this[Tt].push(t),this[ms]=!0,!1):(this[Cn]=!0,this[Ts](t),!0)}[Ts](t){et.write(this[oe],t,0,t.length,this[un],(e,r)=>this[hr](e,r))}[hr](t,e){t?this[mr](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[Tt].length?this[Pa]():(this[Cn]=!1,this[ri]&&!this[Oa]?(this[Oa]=!0,this[_t](),this.emit("finish")):this[ms]&&(this[ms]=!1,this.emit("drain"))))}[Pa](){if(this[Tt].length===0)this[ri]&&this[hr](null,0);else if(this[Tt].length===1)this[Ts](this[Tt].pop());else{let t=this[Tt];this[Tt]=[],Yg(this[oe],t,this[un],(e,r)=>this[hr](e,r))}}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Nu=class extends js{[mn](){let t;if(this[Rs]&&this[Wt]==="r+")try{t=et.openSync(this[wt],this[Wt],this[xi])}catch(e){if(e?.code==="ENOENT")return this[Wt]="w",this[mn]();throw e}else t=et.openSync(this[wt],this[Wt],this[xi]);this[wr](null,t)}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.closeSync(t),this.emit("close")}}[Ts](t){let e=!0;try{this[hr](null,et.writeSync(this[oe],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[_t]()}catch{}}}},em=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"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,bc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},vi=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let h=bc(c);if(o?.(h,l),tm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(nm(h)){let p=e(h,l);return u?p.then(()=>u(),u):p}else if(rm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(im(h)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(h,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),dm=cm.constants||{ZLIB_VERNUM:4736},kt=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},dm)),lm=Bn.concat,ru=Object.getOwnPropertyDescriptor(Bn,"concat"),um=t=>t,Ba=ru?.writable===!0||ru?.set!==void 0?t=>{Bn.concat=t?um:lm}:t=>{},zn=Symbol("_superWrite"),ws=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},za=Symbol("flushFlag"),vc=class extends 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 nu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new nu[e](t)}catch(r){throw new ws(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ws(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return tc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[za]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[zn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;tc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ba(!0);let l;try{let h=typeof t[za]=="number"?t[za]:this.#r;l=this.#t._processChunk(t,h),Ba(!1)}catch(h){Ba(!1),this.#o(new ws(h,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",h=>this.#o(new ws(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[zn](Bn.from(h));for(let p=1;p<l.length;p++)u=this[zn](l[p])}else u=this[zn](Bn.from(l));return r&&r(),u}},Mu=class extends vc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||kt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||kt.Z_FINISH,t.fullFlushFlag=kt.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(kt.Z_SYNC_FLUSH),tc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},fm=class extends Mu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[zn](t){return this.#e?(this.#e=!1,t[9]=255,super[zn](t)):super[zn](t)}},hm=class extends Mu{constructor(t){super(t,"Unzip")}},Bu=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||kt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=kt.BROTLI_OPERATION_FLUSH,super(t,e)}},xm=class extends Bu{constructor(t){super(t,"BrotliCompress")}},pm=class extends Bu{constructor(t){super(t,"BrotliDecompress")}},zu=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.ZSTD_e_continue,t.finishFlush=t.finishFlush||kt.ZSTD_e_end,t.fullFlushFlag=kt.ZSTD_e_flush,super(t,e)}},gm=class extends zu{constructor(t){super(t,"ZstdCompress")}},mm=class extends zu{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(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]=Fu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Uu(o))}},Em=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?bm(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},bm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Fu(c):c===0?l=c:(i=!0,l=Uu(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=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},Fu=t=>(255^t)&255,Uu=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>Sc,isCode:()=>Cs,isName:()=>Im,name:()=>Gs});var Cs=t=>Gs.has(t),Im=t=>Sc.has(t),Gs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Sc=new Map(Array.from(Gs).map(t=>[t[1],t[0]])),Fn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??fn(t,e+100,8),this.uid=r?.uid??i?.uid??fn(t,e+108,8),this.gid=r?.gid??i?.gid??fn(t,e+116,8),this.size=r?.size??i?.size??fn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Fa(t,e+136,12),this.cksum=fn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(Cs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??fn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??fn(t,e+337,8)??0,t[e+475]!==0){let l=Dn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Dn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Fa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Fa(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Am(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=hn(t,e+100,8,this.mode)||this.needPax,this.needPax=hn(t,e+108,8,this.uid)||this.needPax,this.needPax=hn(t,e+116,8,this.gid)||this.needPax,this.needPax=hn(t,e+124,12,this.size)||this.needPax,this.needPax=Ua(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=hn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=hn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(t,e+345,130,c)||this.needPax,this.needPax=Ua(t,e+476,12,this.atime)||this.needPax,this.needPax=Ua(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,hn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Gs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Sc.get(t));if(Cs(e)||e==="Unsupported")this.#e=e;else if(Cs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Am=(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.*/,""),Fa=(t,e,r)=>Tm(fn(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?Em(t.subarray(e,e+r)):Cm(t,e,r),Rm=t=>isNaN(t)?void 0:t,Cm=(t,e,r)=>Rm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Dm={12:8589934591,8:2097151},hn=(t,e,r,i)=>i===void 0?!1:i>Dm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Om(i,r),e,r,"ascii"),Om=(t,e)=>Pm(Math.floor(t).toString(8),e),Pm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ua=(t,e,r,i)=>i===void 0?!1:hn(t,e,r,i.getTime()/1e3),Nm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Nm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),zs=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 Fn({path:("PaxHeader/"+Lm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new qu(Mm(Bm(e),r),i)}},Mm=(t,e)=>e?Object.assign({},e,t):t,Bm=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(zm,Object.create(null)),zm=(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},Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=Fm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Hu=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=Y(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?Y(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=Y(t.path)),t.linkpath&&(t.linkpath=Y(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ws=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Um=1024*1024,nc=Buffer.from([31,139]),rc=Buffer.from([40,181,47,253]),qm=Math.max(nc.length,rc.length),ct=Symbol("state"),On=Symbol("writeEntry"),Ht=Symbol("readEntry"),qa=Symbol("nextEntry"),iu=Symbol("processEntry"),Rt=Symbol("extendedHeader"),si=Symbol("globalExtendedHeader"),an=Symbol("meta"),su=Symbol("emitMeta"),ue=Symbol("buffer"),jt=Symbol("queue"),cn=Symbol("ended"),Ha=Symbol("emittedEnd"),Pn=Symbol("emit"),Ce=Symbol("unzip"),_s=Symbol("consumeChunk"),ys=Symbol("consumeChunkSub"),ja=Symbol("consumeBody"),ou=Symbol("consumeMeta"),au=Symbol("consumeHeader"),oi=Symbol("consuming"),Ga=Symbol("bufferConcat"),Es=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),bs=Symbol("onDone"),Nn=Symbol("sawValidEntry"),vs=Symbol("sawNullBlock"),Ss=Symbol("sawEOF"),cu=Symbol("closeStream"),Hm=()=>!0,bi=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[jt]=[];[ue];[Ht];[On];[ct]="begin";[an]="";[Rt];[si];[cn]=!1;[Ce];[dn]=!1;[Nn];[vs]=!1;[Ss]=!1;[dr]=!1;[oi]=!1;[Ha]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(bs,()=>{(this[ct]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(bs,t.ondone):this.on(bs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:Hm;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[cu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ws(this,t,e,r)}[au](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new Fn(t,e,this[Rt],this[si])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[vs]?(this[Ss]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Pn]("eof")):(this[vs]=!0,this[Pn]("nullBlock"));else if(this[vs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[On]=new Hu(r,this[Rt],this[si]);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[ct]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[ct]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Pn]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[Ht]?this[jt].push(o):(this[jt].push(o),this[qa]())))}}}[cu](){queueMicrotask(()=>this.emit("close"))}[iu](t){let e=!0;if(!t)this[Ht]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ht]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[qa]()),e=!1);return e}[qa](){do;while(this[iu](this[jt].shift()));if(this[jt].length===0){let t=this[Ht];!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[ct]="header",this[On]=void 0,r.end()),o.length}[ou](t,e){let r=this[On],i=this[ja](t,e);return!this[On]&&r&&this[su](r),i}[Pn](t,e,r){this[jt].length===0&&!this[Ht]?this.emit(t,e,r):this[jt].push([t,e,r])}[su](t){switch(this[Pn]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=zs.parse(this[an],this[Rt],!1);break;case"GlobalExtendedHeader":this[si]=zs.parse(this[an],this[si],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[ue]&&(t=Buffer.concat([this[ue],t]),this[ue]=void 0),t.length<qm)return this[ue]=t,r?.(),!0;for(let l=0;this[Ce]===void 0&&l<nc.length;l++)t[l]!==nc[l]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<rc.length;l++)if(t[l]!==rc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[ue]=t,r?.(),!0;else try{new Fn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Ce]=this[Ce]===void 0?new hm({}):o?new mm({}):new pm({}),this[Ce].on("data",h=>this[_s](h)),this[Ce].on("error",h=>this.abort(h)),this[Ce].on("end",()=>{this[cn]=!0,this[_s]()}),this[dr]=!0;let u=!!this[Ce][l?"end":"write"](t);return this[dr]=!1,r?.(),u}}this[dr]=!0,this[Ce]?this[Ce].write(t):this[_s](t),this[dr]=!1;let i=this[jt].length>0?!1:this[Ht]?this[Ht].flowing:!0;return!i&&this[jt].length===0&&this[Ht]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ga](t){t&&!this[dn]&&(this[ue]=this[ue]?Buffer.concat([this[ue],t]):t)}[Es](){if(this[cn]&&!this[Ha]&&!this[dn]&&!this[oi]){this[Ha]=!0;let t=this[On];if(t&&t.blockRemain){let e=this[ue]?this[ue].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ue]&&t.write(this[ue]),t.end()}this[Pn](bs)}}[_s](t){if(this[oi]&&t)this[Ga](t);else if(!t&&!this[ue])this[Es]();else if(t){if(this[oi]=!0,this[ue]){this[Ga](t);let e=this[ue];this[ue]=void 0,this[ys](e)}else this[ys](t);for(;this[ue]&&this[ue]?.length>=512&&!this[dn]&&!this[Ss];){let e=this[ue];this[ue]=void 0,this[ys](e)}this[oi]=!1}(!this[ue]||this[cn])&&this[Es]()}[ys](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ss];)switch(this[ct]){case"begin":case"header":this[au](t,e),e+=512;break;case"ignore":case"body":e+=this[ja](t,e);break;case"meta":e+=this[ou](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[ue]=this[ue]?Buffer.concat([t.subarray(e),this[ue]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[dn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Es]())),this}},pi=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)},jm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},ju=(t,e)=>{let r=new Map(e.map(c=>[pi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Qg(c).root||".",h;if(c===u)h=!1;else{let p=r.get(c);h=p!==void 0?p:o(Xg(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(pi(c)):c=>o(pi(c))},Gm=t=>{let e=new bi(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=pr.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let h=pr.readSync(i,u,0,c,l);if(h===0)break;l+=h,e.write(u.subarray(0,h))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},Wm=(t,e)=>{let r=new bi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ec(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},_r=vi(Gm,Wm,t=>new bi(t),t=>new bi(t),(t,e)=>{e?.length&&ju(t,e),t.noResume||jm(t)}),Gu=(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:$m,parse:lu}=Km,Ic=t=>{let e="",r=lu(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=lu(t)}return[e,t]},Ks=["|","<",">","?",":"],Ac=Ks.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Jm=new Map(Ks.map((t,e)=>[t,Ac[e]])),Vm=new Map(Ac.map((t,e)=>[t,Ks[e]])),uu=t=>Ks.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),Ym=t=>Ac.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),Wu=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),pi(e)+"/"+t):Y(t),Zm=16*1024*1024,fu=Symbol("process"),hu=Symbol("file"),xu=Symbol("directory"),ic=Symbol("symlink"),pu=Symbol("hardlink"),ai=Symbol("header"),Ds=Symbol("read"),sc=Symbol("lstat"),ks=Symbol("onlstat"),oc=Symbol("onread"),ac=Symbol("onreadlink"),cc=Symbol("openfile"),dc=Symbol("onopenfile"),xn=Symbol("close"),Us=Symbol("mode"),lc=Symbol("awaitDrain"),Wa=Symbol("ondrain"),Dt=Symbol("prefix"),Ku=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=bc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Zm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Y(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Y(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Ic(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Ym(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||du.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[ks](o):this[sc]()}warn(t,e,r={}){return Ws(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[sc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ks](e)})}[ks](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[fu]()}[fu](){switch(this.type){case"File":return this[hu]();case"Directory":return this[xu]();case"SymbolicLink":return this[ic]();default:return this.end()}}[Us](t){return Gu(t,this.type==="Directory",this.portable)}[Dt](t){return Wu(t,this.prefix)}[ai](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Fn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this[Us](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new zs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[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)}[xu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ai](),this.end()}[ic](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ac](e)})}[ac](t){this.linkpath=Y(t),this[ai](),this.end()}[pu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(du.relative(this.cwd,t)),this.stat.size=0,this[ai](),this.end()}[hu](){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[pu](e);this.linkCache.set(t,this.absolute)}if(this[ai](),this.stat.size===0)return this.end();this[cc]()}[cc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[dc](e)})}[dc](t){if(this.fd=t,this.#e)return this[xn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ds]()}[Ds](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,l)=>{if(c)return this[xn](()=>this.emit("error",c));this[oc](l)})}[xn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[oc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Wa]():this[lc](()=>this[Wa]())}[lc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Wa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[xn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ds]()}},Xm=class extends Ku{sync=!0;[sc](){this[ks](Ct.lstatSync(this.absolute))}[ic](){this[ac](Ct.readlinkSync(this.absolute))}[cc](){this[dc](Ct.openSync(this.absolute,"r"))}[Ds](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Ct.readSync(e,r,i,o,c);this[oc](l),t=!1}finally{if(t)try{this[xn](()=>{})}catch{}}}[lc](t){t()}[xn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},Qm=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 Ws(this,t,e,r)}constructor(t,e={}){let r=bc(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=Y(t.path),this.mode=t.mode!==void 0?this[Us](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Ic(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Fn({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 zs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[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 Wu(t,this.prefix)}[Us](t){return Gu(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}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=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++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(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=nw(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 nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Tc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Tc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Tc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Tc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},mu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},wu=Buffer.alloc(1024),Os=Symbol("onStat"),ci=Symbol("ended"),gt=Symbol("queue"),di=Symbol("queue"),ln=Symbol("current"),Ln=Symbol("process"),li=Symbol("processing"),Is=Symbol("processJob"),mt=Symbol("jobs"),Ka=Symbol("jobDone"),Ps=Symbol("addFSEntry"),_u=Symbol("addTarEntry"),uc=Symbol("stat"),fc=Symbol("readdir"),Ns=Symbol("onreaddir"),Ls=Symbol("pipe"),yu=Symbol("entry"),$a=Symbol("entryOpt"),Ms=Symbol("writeEntryClass"),$u=Symbol("write"),Ja=Symbol("ondrain"),$s=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ms];onWriteEntry;[gt];[di]=new Map;[mt]=0;[li]=!1;[ci]=!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=Y(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ms]=Ku,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 fm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new xm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[gt]=new tw,this[mt]=0,this.jobs=Number(t.jobs)||4,this[li]=!1,this[ci]=!1}[$u](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[ci]=!0,this[Ln](),r&&r(),this}write(t){if(this[ci])throw new Error("write after end");return t instanceof Hu?this[_u](t):this[Ps](t),this.flowing}[_u](t){let e=Y(gu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new mu(t.path,e);r.entry=new Qm(t,this[$a](r)),r.entry.on("end",()=>this[Ka](r)),this[mt]+=1,this[gt].push(r)}this[Ln]()}[Ps](t){let e=Y(gu.resolve(this.cwd,t));this[gt].push(new mu(t,e)),this[Ln]()}[uc](t){t.pending=!0,this[mt]+=1;let e=this.follow?"stat":"lstat";Fs[e](t.absolute,(r,i)=>{t.pending=!1,this[mt]-=1,r?this.emit("error",r):this[Os](t,i)})}[Os](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Is](t);else{let r=`${e.dev}:${e.ino}`,i=this[di].get(r);i?i.push(t):this[di].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[fc](t){t.pending=!0,this[mt]+=1,Fs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[mt]-=1,e)return this.emit("error",e);this[Ns](t,r)})}[Ns](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[li]){this[li]=!0;for(let t=this[gt].head;t&&this[mt]<this.jobs;t=t.next)if(this[Is](t.value),t.value.ignore){let e=t.next;this[gt].removeNode(t),t.next=e}this[li]=!1,this[ci]&&this[gt].length===0&&this[mt]===0&&(this.zip?this.zip.end(wu):(super.write(wu),super.end()))}}get[ln](){return this[gt]&&this[gt].head&&this[gt].head.value}[Ka](t){this[gt].shift(),this[mt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[di].get(r);if(i){this[di].delete(r);for(let o of i)o.pending=!1,this[Is](o)}}this[Ln]()}[Is](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[Ls](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Os](t,e):this[uc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ns](t,e):this[fc](t),!t.readdir)return}if(t.entry=this[yu](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Ls](t)}}}[$a](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[yu](t){this[mt]+=1;try{return new this[Ms](t.path,this[$a](t)).on("end",()=>this[Ka](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Ls](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ps](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ws(this,t,e,r)}},Rc=class extends $s{sync=!0;constructor(t){super(t),this[Ms]=Xm}pause(){}resume(){}[uc](t){let e=this.follow?"statSync":"lstatSync";this[Os](t,Fs[e](t.absolute))}[fc](t){this[Ns](t,Fs.readdirSync(t.absolute))}[Ls](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ps](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[$u](i)})}},sw=(t,e)=>{let r=new Rc(t),i=new Nu(t.file,{mode:t.mode||438});r.pipe(i),Ju(r,e)},ow=(t,e)=>{let r=new $s(t),i=new js(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 Vu(r,e).catch(c=>r.emit("error",c)),o},Ju=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:Lu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Vu=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:Lu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new Rc(t);return Ju(r,e),r},cw=(t,e)=>{let r=new $s(t);return Vu(r,e).catch(i=>r.emit("error",i)),r},p2=vi(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,Qu=lw==="win32",{O_CREAT:ef,O_NOFOLLOW:Eu,O_TRUNC:tf,O_WRONLY:nf}=Xu.constants,rf=Number(process.env.__FAKE_FS_O_FILENAME__)||Xu.constants.UV_FS_O_FILEMAP||0,uw=Qu&&!!rf,fw=512*1024,hw=rf|tf|ef|nf,bu=!Qu&&typeof Eu=="number"?Eu|tf|ef|nf:null,sf=bu!==null?()=>bu:uw?t=>t<fw?hw:"w":()=>"w",hc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},qs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},xw=(t,e,r,i,o)=>{if(e.isDirectory())of(gi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=gi.resolve(t,e.name);qs(l,r,i,o)});else{let c=gi.resolve(t,e.name);qs(c,r,i,o)}},of=(t,e,r,i)=>{Js.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return qs(t,e,r,i);let l=c.length,u=null,h=p=>{if(!u){if(p)return i(u=p);if(--l===0)return qs(t,e,r,i)}};for(let p of c)xw(t,p,e,r,h)})},pw=(t,e,r,i)=>{e.isDirectory()&&af(gi.resolve(t,e.name),r,i),hc(gi.resolve(t,e.name),r,i)},af=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return hc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return hc(t,e,r)},cf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Vs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new cf(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,h=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,m=e.unlink,E=Y(e.cwd),T=(v,I)=>{v?r(v):I&&h?of(I,l,u,S=>T(S)):c?st.chmod(t,o,r):r()};if(t===E)return mw(t,T);if(p)return gw.mkdir(t,{mode:o,recursive:!0}).then(v=>T(null,v??void 0),T);let _=Y(Hs.relative(E,t)).split("/");xc(E,_,o,m,E,void 0,T)},xc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=Y(Hs.resolve(t+"/"+u));st.mkdir(h,r,df(h,e,r,i,o,c,l))},df=(t,e,r,i,o,c,l)=>u=>{u?st.lstat(t,(h,p)=>{if(h)h.path=h.path&&Y(h.path),l(h);else if(p.isDirectory())xc(t,e,r,i,o,c,l);else if(i)st.unlink(t,m=>{if(m)return l(m);st.mkdir(t,r,df(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Vs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,xc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new cf(t,r??"ENOTDIR")}},yw=(t,e)=>{t=Y(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),h=e.preserve,p=e.unlink,m=Y(e.cwd),E=v=>{v&&u&&af(v,c,l),o&&st.chmodSync(t,i)};if(t===m)return _w(m),E();if(h)return E(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let T=Y(Hs.relative(m,t)).split("/"),_;for(let v=T.shift(),I=m;v&&(I+="/"+v);v=T.shift()){I=Y(Hs.resolve(I));try{st.mkdirSync(I,i),_=_||I}catch{let S=st.lstatSync(I);if(S.isDirectory())continue;if(p){st.unlinkSync(I),st.mkdirSync(I,i),_=_||I;continue}else if(S.isSymbolicLink())return new Vs(I,I+"/"+T.join("/"))}}return E(_)},Va=Object.create(null),vu=1e4,lr=new Set,Ew=t=>{lr.has(t)?lr.delete(t):Va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=Va[t],r=lr.size-vu;if(r>vu/10){for(let i of lr)if(lr.delete(i),delete Va[i],--r<=0)break}return e},bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=bw==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=lf(i,r)),e.push(r||"/"),e},[]),Iw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>pi(lf(Ew(i))));let r=new Set(t.map(i=>Sw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let h of u)o.add(h)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Aw=()=>process.umask(),Su=Symbol("onEntry"),pc=Symbol("checkFs"),Iu=Symbol("checkFs2"),gc=Symbol("isReusable"),dt=Symbol("makeFs"),mc=Symbol("file"),wc=Symbol("directory"),Bs=Symbol("link"),Au=Symbol("symlink"),Tu=Symbol("hardlink"),hi=Symbol("ensureNoSymlink"),Ru=Symbol("unsupported"),Cu=Symbol("checkPath"),Ya=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),qe=Symbol("onError"),As=Symbol("pending"),Du=Symbol("pend"),ur=Symbol("unpend"),Za=Symbol("ended"),Xa=Symbol("maybeClose"),_c=Symbol("skip"),mi=Symbol("doChown"),wi=Symbol("uid"),_i=Symbol("gid"),yi=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ei=Tw==="win32",Rw=1024,Cw=(t,e)=>{if(!Ei)return ne.unlink(t,e);let r=t+".DELETE."+Zu(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},Dw=t=>{if(!Ei)return ne.unlinkSync(t);let e=t+".DELETE."+Zu(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},ku=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Cc=class extends bi{[Za]=!1;[yi]=!1;[As]=0;reservations=new Iw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Za]=!0,this[Xa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Rw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ei,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Aw():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[Su](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Xa](){this[Za]&&this[As]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ya](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Ic(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ei&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Me.posix.dirname(t.path),h=Me.posix.normalize(Me.posix.join(u,l.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Cu](t){let e=Y(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Y(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ya](t,"path")||!this[Ya](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Y(Me.resolve(t.path)):Y(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Y(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+uu(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+uu(t.path.slice(o.length))}return!0}[Su](t){if(!this[Cu](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[pc](t);default:return this[Ru](t)}}[qe](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){ww(Y(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)}[mi](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}[wi](t){return ku(this.uid,t.uid,this.processUid)}[_i](t){return ku(this.gid,t.gid,this.processGid)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new js(String(t.absolute),{flags:sf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[qe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ne.close(i.fd,()=>{}),this[qe](u,t),e();return}--o===0&&i.fd!==void 0&&ne.close(i.fd,h=>{h?this[qe](h,t):this[ur](),e()})};i.on("finish",()=>{let u=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,m=t.mtime;ne.futimes(h,p,m,E=>E?ne.utimes(u,p,m,T=>c(T&&E)):c())}if(typeof h=="number"&&this[mi](t)){o++;let p=this[wi](t),m=this[_i](t);typeof p=="number"&&typeof m=="number"&&ne.fchown(h,p,m,E=>E?ne.chown(u,p,m,T=>c(T&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[qe](u,t),e()}),t.pipe(l)),l.pipe(i)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[qe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[ur](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[mi](t)&&(o++,ne.chown(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)),c)),c()})}[Ru](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Au](t,e){let r=Y(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[hi](t,this.cwd,r,()=>this[Bs](t,String(t.linkpath),"symlink",e),i=>{this[qe](i,t),e()})}[Tu](t,e){let r=Y(Me.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[hi](t,this.cwd,i,()=>this[Bs](t,r,"link",e),o=>{this[qe](o,t),e()})}[hi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);ne.lstat(l,(u,h)=>{if(u)return i();if(h?.isSymbolicLink())return o(new Vs(l,Me.resolve(l,r.join("/"))));this[hi](t,l,r,i,o)})}[Du](){this[As]++}[ur](){this[As]--,this[Xa]()}[_c](t){this[ur](),t.resume()}[gc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ei}[pc](t){this[Du]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Iu](t,r))}[Iu](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[qe](l,t),r();return}this[yi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,u=>{if(u){this[qe](u,t),r();return}c()})}c()},c=()=>{ne.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[_c](t),r();return}if(l||this[gc](t,u))return this[dt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=m=>this[dt](m??null,t,r);return h?ne.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ne.rmdir(String(t.absolute),h=>this[dt](h??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);Cw(String(t.absolute),h=>this[dt](h??null,t,r))})};this[yi]?o():i()}[dt](t,e,r){if(t){this[qe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[mc](e,r);case"Link":return this[Tu](e,r);case"SymbolicLink":return this[Au](e,r);case"Directory":case"GNUDumpDir":return this[wc](e,r)}}[Bs](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[qe](o,t):(this[ur](),t.resume()),i()})}},ui=t=>{try{return[null,t()]}catch(e){return[e,null]}},uf=class extends Cc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[pc](t){if(!this[yi]){let o=this[pn](this.cwd,this.dmode);if(o)return this[qe](o,t);this[yi]=!0}if(t.absolute!==this.cwd){let o=Y(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[qe](c,t)}}let[e,r]=ui(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[_c](t);if(e||this[gc](t,r))return this[dt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?ui(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=ui(()=>ne.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:ui(()=>Dw(String(t.absolute)));this[dt](i,t)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ne.closeSync(o)}catch(h){u=h}(l||u)&&this[qe](l||u,t),e()},o;try{o=ne.openSync(String(t.absolute),sf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[qe](l,t)),t.pipe(c)),c.on("data",l=>{try{ne.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,h=t.mtime;try{ne.futimesSync(o,u,h)}catch(p){try{ne.utimesSync(String(t.absolute),u,h)}catch{l=p}}}if(this[mi](t)){let u=this[wi](t),h=this[_i](t);try{ne.fchownSync(o,Number(u),Number(h))}catch(p){try{ne.chownSync(String(t.absolute),Number(u),Number(h))}catch{l=l||p}}}i(l)})}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[qe](i,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[mi](t))try{ne.chownSync(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)))}catch{}e(),t.resume()}[pn](t,e){try{return yw(Y(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 l of r){c=Me.resolve(c,l);let[u,h]=ui(()=>ne.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new Vs(c,Me.resolve(e,r.join("/"))))}i()}[Bs](t,e,r,i){let o=`${r}Sync`;try{ne[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[qe](c,t)}}},kw=t=>{let e=new uf(t),r=t.file,i=Yu.statSync(r),o=t.maxReadSize||16*1024*1024;new Zg(r,{readSize:o,size:i.size}).pipe(e)},Ow=(t,e)=>{let r=new Cc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Yu.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ec(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},ff=vi(kw,Ow,t=>new uf(t),t=>new Cc(t),(t,e)=>{e?.length&&ju(t,e)}),Pw=(t,e)=>{let r=new Rc(t),i=!0,o,c;try{try{o=it.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=it.openSync(t.file,"w+");else throw h}let l=it.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=it.readSync(o,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let h=new Fn(u);if(!h.cksumValid)break;let p=512*Math.ceil((h.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,Nw(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},Nw=(t,e,r,i,o)=>{let c=new Nu(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Lw=(t,e)=>{e=Array.from(e);let r=new $s(t),i=(o,c,l)=>{let u=(T,_)=>{T?it.close(o,v=>l(T)):l(null,_)},h=0;if(c===0)return u(null,0);let p=0,m=Buffer.alloc(512),E=(T,_)=>{if(T||_===void 0)return u(T);if(p+=_,p<512&&_)return it.read(o,m,p,m.length-p,h+p,E);if(h===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,h);let v=new Fn(m);if(!v.cksumValid)return u(null,h);let I=512*Math.ceil((v.size??0)/512);if(h+I+512>c||(h+=I+512,h>=c))return u(null,h);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,it.read(o,m,0,512,h,E)};it.read(o,m,0,512,h,E)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(h,p)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,u);if(h||!p)return c(h);it.fstat(p,(m,E)=>{if(m)return it.close(p,()=>c(m));i(p,E.size,(T,_)=>{if(T)return c(T);let v=new js(t.file,{fd:p,start:_});r.pipe(v),v.on("error",c),v.on("close",o),Bw(r,e)})})};it.open(t.file,l,u)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},fi=vi(Pw,Lw,()=>{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")}),D2=vi(fi.syncFile,fi.asyncFile,fi.syncNoFile,fi.asyncNoFile,(t,e=[])=>{fi.validate?.(t,e),zw(t)}),zw=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 yt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Si(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function xf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Dc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function pf(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}$e();te();Ne();$e();function Kt(t,e){if(Si(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ys(t){return t.startsWith("http://")||t.startsWith("https://")}function Zs(t){return t.endsWith("/")?t.slice(0,-1):t}$e();te();var Xs="1008033",gf="1289";var mf="pbbp2",wf="https://www.coze.cn",_f="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",qw="wss://frontier.coze.cn";function Qs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function yf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??qw}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 Ai(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ii=U("handshake");async function kc(t){let e=Qs(t.endpoint),r=t.timeoutMs??1e4,i=`${Zs(e)}${_f}?aid=${encodeURIComponent(Xs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Er(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ii.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${v.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${h}`);let E=m.data??{},T=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!T||!_){let v=JSON.stringify(m).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${v}`)}return Ii.info("handshake ok",{remoteDeviceId:_,logid:h,traceId:p}),{accessKey:T,deviceId:_}}catch(u){if(u instanceof R)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 R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw Ii.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:h?.code,syscall:h?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Oc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto",Ef=2e5;function bf(t){return{model:Pc(t.model)??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function vf(t){return!t||t===Et}var Hw=new Set(["auto","\u81EA\u52A8"]);function Pc(t){let e=t?.trim();if(e)return Hw.has(e.toLowerCase())?Et:e}function Sf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Oc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||Et;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else vf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function If(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||Et}"`):vf(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Oc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Ef;e.push("-c",`model_context_window=${r}`)}return e}function Af(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Nc(t,e){let{ttEnv:r,usePpe:i}=Ai(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Tf(t,e,r){if(!t.modelToken)return{};let i=Nc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function Lc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Rf(t,e,r){if(!t.modelToken)return null;let i=t.model||Et,o=Nc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Oc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Ef,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Cf(t,e,r){if(!t.modelToken)return[];let i=Nc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Be=U("agent-handlers"),Df=5*1024*1024,Jw=1,Vw=6,Yw=new Set(["node_modules",".git",".coze","dist","build",".next"]),eo=class{constructor(e){this.opts=e}opts;async listSkills(e){Kt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=Ot(o,u.relPath,"SKILL.md");await Ww(h).then(m=>m.isFile()).catch(()=>!1)&&l.push(t_(u))}return{skills:l}}async addSkills(e){Kt(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((h,p)=>[h.skillId,p])),u=[];for(let h of o){let p=await Hc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});jc(c,l,p),u.push(h)}return await ss(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Kt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let h=Ot(i.workspace,u.relPath);await Gw(h,{recursive:!0,force:!0}),Be.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ss(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Be.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let h=c.downstream;c.downstream=void 0,Be.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(p=>Be.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Be.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ge(r);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Be.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Be.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),Be.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ge(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Be.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}):(Be.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Kt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Pc(e.model)??Et,i=await Ge(e.agentId);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),Be.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Be.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Be.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let h=o.sessions.get(l);h?.downstream&&(await h.downstream.stop(`switchModel: ${r}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(c),Be.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(Kt(e._meta,yt.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,yt.RESET),await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Be.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(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 Zr(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ge(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(Kt(e._meta,yt.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Be.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Be.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Be.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Kt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Mc(l).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Yr(l,o))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=f_(e.depth);return u.isDirectory()?{tree:await u_(o,l,c,h)}:{tree:[{name:h_(c),path:Bf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Kt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Mc(o).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Yr(o,i))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Df)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Df})`);let l=await kf(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ge(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Fc(e,r||"."),o=qc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Of}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ge(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function Zw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Xw(t){return t==="claude-code"?Ot(".claude","skills"):Ot(".agents","skills")}var Qw=3e4,e_=50*1024*1024,br=3e4;async function Hc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new R("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new R("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=Zw(o.skillName),h=Xw(i),p=Ot(h,u),m=Ot(r,p);if(await Bc(m,{recursive:!0}),c){let T=Buffer.from(o.content,"utf8");Ti(T.length),await zc(Ot(m,"SKILL.md"),T,"utf8")}else{let T=await n_(o.downloadUrl);i_(T)?await c_(T,m):s_(T)?await o_(T,m):await zc(Ot(m,"SKILL.md"),T.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Be.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),E}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 t_(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 n_(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ti(e);let r=r_(t);return Ti(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await kf(e);return Ti(r.length),r}if(Ys(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new R("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ti(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ti(t){if(t>e_)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(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 Uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new Lf.default(t),i=r.getEntries()}catch(l){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Uc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=a_(i),c=Fc(e);for(let l of i){if(Uc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=Fc(e,u),p=qc(c,h);if(p.startsWith("..")||p==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Bc(h,{recursive:!0});continue}await Bc(Kw(h),{recursive:!0});let m;try{m=l.getData()}catch(E){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await zc(h,m)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||Uc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=ff({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`))},br);try{await Nf(Pf.from(t),r)}catch(c){throw c instanceof R?c:i?new R("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`))},br);try{await Nf(Pf.from(t),r)}catch(c){throw i?new R("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var l_=5e3;async function u_(t,e,r,i){return Mf(t,e,r,i,{count:0})}async function Mf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await jw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(Yw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Ot(e,u.name),p=$w(Ot(r,u.name)),m=null;try{m=await Mc(h)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let E={name:u.name,path:Bf(qc(t,h)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(E.children=await Mf(t,h,p,i-1,o)),l.push(E)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function f_(t){return!t||t<=0?Jw:Math.min(t,Vw)}function h_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Bf(t){return t.split(Of).join("/")}te();import{readFileSync as UI}from"node:fs";import{dirname as HI,join as jI}from"node:path";import{fileURLToPath as WI}from"node:url";var vr="0.1.96-beta.2";var wn=U("agent-health-reporter"),x_=1e4,Ri=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??x_}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 u=p_(l);if(!u)continue;let h={agentId:l.agentId,status:u};l.patToken&&(h.patToken=l.patToken),l.accountId&&(h.accountId=l.accountId),r.push(h)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){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 p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as ay,mkdir as lo,rm as cy,stat as dy,writeFile as ly}from"node:fs/promises";import{homedir as uy}from"node:os";import{join as i0}from"node:path";nn();import{spawnSync as O_}from"node:child_process";import{existsSync as P_}from"node:fs";import{release as N_}from"node:os";import{basename as L_,isAbsolute as M_}from"node:path";function Ci(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ir(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}$e();var to=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function zf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Ff(t){return"method"in t&&!("id"in t)}function no(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Q.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Q.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Q.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Di(t.message)}:typeof t=="string"?Di(t):typeof t=="object"?__(t):t}var w_=[[/\/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 Di(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Di(i):e[r]=i;return e}function ki(t){if(t instanceof R){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:g_[t.code]??Q.INTERNAL_ERROR,message:Di(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Di(t instanceof Error?t.message:String(t))}}function Uf(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...u}=e;c=u}return new R(r,o,{retriable:e?.retriable??!1,cause:c})}function Hf(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var qf=10*1024*1024,ro=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(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 Gf={"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"},nA=Object.fromEntries(Object.entries(Gf).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ar=class{seq=0;next(e,r){this.seq+=1;let i=Gf[e]??E_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>jf(r?.[h]??"")),u=b_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>jf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function E_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function jf(t){return t.replace(/[:_\s]+/g,"-")}function b_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Vr();import{readFileSync as v_}from"node:fs";var S_=384;async function Gc(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:S_})}function Wc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Wf(t,e,r={},i=o=>o){return{...i({...t,...Wc(e)}),...r}}yn();Zi();$e();te();Ne();var k_=[{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_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\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_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"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (claude ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes)\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 Vf(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=Ft("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),z_=200,F_=40,U_=Ft("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),q_=Ft("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),H_=Ft("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Yf=500;function j_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Yf?t:`${e.slice(0,Yf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Zf(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),O_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function Xf(t){try{return P_(t)}catch{return}}function G_(t,e){return{platform:process.platform,osRelease:N_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?Xf(e.command):void 0,cwd:e.cwd,cwdExists:Xf(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${L_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=U(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new ro({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ar;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Wf(process.env,this.opts.agentEnvFile??Z().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=lt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>z_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=G_(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 R("AGENT_SPAWN_FAILED",W_(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()));Zf(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Zf(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=U_,i=q_,o=H_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ir(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_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=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),u=Ci(l,e,r),h=(()=>{if(typeof r!="object"||r===null)return;let E=r.sessionId;return typeof E=="string"?E:void 0})(),p=i>0&&Number.isFinite(i),m=o>0&&Number.isFinite(o);return new Promise((E,T)=>{let _={resolve:E,reject:T,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(p){let S=()=>{_.timer=setTimeout(()=>{let C=Date.now()-v;if(this.inflightAgentRequests.size>0&&C<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:C,approvalMaxMs:c,...h?{sessionId:h}:{}}),S();return}this.pending.delete(l),_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer);let N=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:N,...h?{sessionId:h}:{}}),T(N?new R("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=m?()=>{_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),_.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...h?{sessionId:h}:{}}),I?.();return}_.timer&&clearTimeout(_.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...h?{sessionId:h}:{}}),T(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;_.onFirstUpdate=m?()=>{_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),_.firstUpdateTimer=null,_.onFirstUpdate=null}:null,this.pending.set(l,_),I?.();try{this.writeFrame(u)}catch(S){_.timer&&clearTimeout(_.timer),_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),this.pending.delete(l),T(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Hf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(no(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(Uf(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:j_(e.result)}),r.resolve(e.result));return}if(Ff(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(zf(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_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,ki(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new R("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(F_).join(`
|
|
95
|
+
`),o=Vf(this.framework,i);return o?new R(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new R("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var io=class extends 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 K_(e)}};nn();import{mkdtempSync as $_,rmSync as J_}from"node:fs";import{tmpdir as V_}from"node:os";import{join as Y_}from"node:path";var so=class extends Pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Jr("codex",e.command,i),l=e.isolateCodexHome?$_(Y_(V_(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,h={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(h),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{J_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Z_=3e4,Tr=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.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Z_))}get acpSessionName(){return this.sessionName}};$e();te();Ne();function Kc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();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 oo=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new 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)Oi(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 Oi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();te();import{constants as Qf}from"node:fs";import{access as X_}from"node:fs/promises";import{delimiter as Q_,join as ey}from"node:path";var bt=U("framework-detector"),e0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ty=[".exe",".cmd",".bat",".ps1"],qn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??lt,access:e.access??X_}}async detect(e){let r=e0[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)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(e0).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(Q_).filter(Boolean),i=this.env.platform==="win32"?["",...ty]:[""];for(let o of r)for(let c of i){let l=ey(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Qf.F_OK:Qf.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&&(ry(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),u(null)},15e3),h.stdout?.on("data",p=>{o+=p.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",p=>u({code:p,stdout:o}))}catch{u(null)}})}},ny=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ry(t){return t.replace(ny,"")}import{homedir as iy}from"node:os";import{join as sy}from"node:path";yn();$e();Vr();te();async function r0(){let t=sy(iy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var t0=U("openclaw.config"),oy=[0,5e3,5e3],n0="models.providers.",ao="agents.defaults.models",co=class{command;env;retryDelaysMs;queue=new En;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??oy}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,t0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=lt(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){t0.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",`${n0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${n0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ao}[${e}]`,()=>this.runCli(["config","set",ao,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ao}[${e}]`,`${ao}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var xe=U("agent-manager"),fy=(t,e,r,i,o,c,l,u,h)=>{switch(t){case"claude-code":{let p={...o?{...Sf(o),...Tf(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new io({cwd:r,env:p,agentId:i})}case"codex":{let m=[...o?[...If(o),...Cf(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...o?Af(o):{},...h??{}},T=!!o;return new so({cwd:r,agentId:i,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...T?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tr({command:e,cwd:r,agentId:i,...c?{sessionName:Kc(c)}:{}})}};function $c(t){return t==="claude-code"||t==="codex"}function hy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(xy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
96
96
|
`)}
|
|
97
|
-
`}function
|
|
98
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var py={path:"",version:"cloud-deployed"},su="openclaw_gateway_unavailable",gy="openclaw_default_agent_missing";function ou(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var my={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},wy=6e4,fo=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??uy,this.createTimeoutMs=e.createTimeoutMs??wy,this.detectorFactory=e.detectorFactory??(()=>new qn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new co({command:r})),this.openclawConfigDir=e.openclawConfigDir??iu(fy(),".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=>{me.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=iu(e,".env");if(await dy(r).then(c=>c.isFile()).catch(()=>!1)){me.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await lo(e,{recursive:!0});let o=xy({...process.env,...Wc(this.paths.agentEnvFile)});if(await ly(r,o,"utf8"),process.platform!=="win32")try{await ay(r,384)}catch(c){me.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}me.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),me.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=Si(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")me.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>me.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){me.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await je(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Qe(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){me.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await je(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Qe(S,this.paths))}return me.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=Xe(e.agentId,this.paths),f=Si(e._meta),x=e.framework==="openclaw"&&f==="local",p;x&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let b=p??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),_=e.workspace??b??l.workspace,A=new AbortController,w=setTimeout(()=>A.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&$c(e.framework)&&await er(e.framework,A.signal);let S=()=>{if(A.signal.aborted)throw A.signal.reason instanceof Error?A.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await lo(l.root,{recursive:!0}),await lo(_,{recursive:!0}),await lo(l.logs,{recursive:!0}),S(),x||await rr(_,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await wl(_),S();let C=await je(e.agentId,this.paths).catch(()=>null),L=E0({model:e.model??C?.model}),y=h0(e._meta)??C?.accountId,D=e.patToken??C?.patToken,R=f==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new oo({agentId:e.agentId,framework:e.framework,workspace:_,model:L.model??bt,deployType:f,...y?{accountId:y}:{},...D?{patToken:D}:{},...R?{modelInfo:R}:{}}),v.status="ok",C?.sessions){for(let[X,re]of Object.entries(C.sessions))v.sessions.set(X,{acpSessionId:re.acpSessionId,modelToken:re.modelToken,tokenGeneratedAt:re.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let Z=Object.keys(C.sessions).length;Z>0&&me.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:Z})}this.registry.register(v),I=!0;let M={agentId:e.agentId,framework:e.framework,workspace:_,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:L.model};f==="cloud"&&(M.deployType="cloud"),y&&(M.accountId=y),D&&(M.patToken=D),R&&(M.modelInfo=R),C?.skills&&(M.skills=C.skills),C?.agentName&&(M.agentName=C.agentName),C?.description&&(M.description=C.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,_)):me.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let Z=[...M.skills??[]],X=new Map(Z.map((Se,ge)=>[Se.skillId,ge])),re=await Promise.allSettled(B.map(Se=>Gc({agentId:e.agentId,workspace:_,framework:e.framework,skill:Se}))),te=0;for(let[Se,ge]of re.entries()){let O=B[Se];O&&(ge.status==="fulfilled"?(Hc(Z,X,ge.value),te++):me.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(ge.reason)}))}te>0&&(M.skills=Z,me.info("initialSkills installed",{agentId:e.agentId,installed:te,requested:B.length}))}return await Qe(M,this.paths),me.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:_,framework:e.framework}}catch(S){throw me.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 cy(l.root,{recursive:!0,force:!0}).catch(C=>me.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof T?S:new T("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&$c(e.framework))f=py;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);$c(e.framework)&&!ns(e.framework)&&(me.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,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:f.path}):p=this.factory(e.framework,f.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(my),p}catch(b){let _=p instanceof Ot?p.getStderrTail():[];throw _.length>0&&me.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:b instanceof T?b.code:"unknown",recentStderr:_}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,f.path,b)}}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",ou(o),{cause:{reason:su}})}catch(o){me.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};me.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 me.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:gy}})}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",ou(r),{cause:{reason:su}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,x=Kc(o);if(r.deployType==="local"){let A=await this.ensureOpenclawDefaultAgent();return new Tr({command:f,cwd:A.workspace,agentId:A.id,sessionName:x})}let p=await ru(),b=i?C0(i,c,l):null,_;if(b){let A=Nc(o),v=b.models[0]?.id??bt,I=`${A}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(A,b),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}_=I}return new Tr({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Nc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(f){l=!1,me.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){l=!1,me.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as fu}from"node:crypto";import{promises as Ay}from"node:fs";import{basename as uu}from"node:path";Je();ie();import{promises as yy}from"node:fs";import{basename as by}from"node:path";var au=j("file-upload"),Ey="/api/coze_claw/file/agent_upload",vy=6e4;async function cu(t,e={}){let i=`${Zs(Qs(e.handshakeBase))}${Ey}`,o=e.timeoutMs??vy,c=await yy.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,p=setTimeout(()=>x.abort(),o);au.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let b=await fetch(i,{method:"POST",headers:f,body:l,signal:x.signal}),_=b.headers.get("x-tt-logid")??"";if(!b.ok){let v=await b.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${b.status} logid=${_}: ${v.slice(0,200)}`)}let A=await b.json();if(A.code!==void 0&&A.code!==0)throw new T("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${_}`);let w=A.data?.file?.file_url;if(!w)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(A).slice(0,200)}`);return au.info("file upload ok",{uri:w,logid:_}),{uri:w}}catch(b){throw b instanceof T?b:b.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${by(t.path)}`):new T("UPLOAD_FAILED",String(b),{cause:b})}finally{clearTimeout(p)}}Je();ie();import{extname as Sy}from"node:path";var Iy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function du(t){let e=Sy(t).toLowerCase();return Iy[e]??"application/octet-stream"}Le();var uo=j("agent-send"),lu=50*1024*1024;function xu(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 hu(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(p){f=p,x<2&&(uo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(b=>setTimeout(b,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function pu(t,e){let{session:r,runtime:i}=xu(e.core,t.agentId,t.sessionId);if(!await Yr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ay.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>lu)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${lu}`);let c=await du(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??uu(t.path),f;try{f=await cu({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw uo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof T?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:fu(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:l,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await hu(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),uo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function gu(t,e){let{session:r,runtime:i}=xu(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??uu(t.path),c={sessionUpdate:"group_file",messageId:fu(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await hu(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),uo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function mu(t,e){let 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();ie();var Lt=j("coze-cli-installer"),wu="@coze/cli@latest",Ty="coze",_u="0.1.8",Cy=5e3,Dy=5e3,Ry=9e4,yu=1e4,Oi=null,xo=!1;async function Jc(t,e={}){if(xo)return;if(Oi)return Oi;let r=e.exec??J0;return Oi=(async()=>{try{let i=await ky(Ty,r),o=!1;if(i){let l=await Py(r);if(l===void 0)Lt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(mu(l,_u))Lt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:_u}),o=!0;else{Lt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),xo=!0;return}}let c=o?"upgrade-only":"full";Lt.info("coze-cli install start",{package:wu,mode:c});try{await r("npm",["i","-g","--prefer-online",wu],{timeout:Ry,maxBuffer:10*1024*1024}),Lt.info("coze-cli install ok")}catch(l){Lt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){xo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:yu}),Lt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Lt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:yu}),Lt.info("coze auth login ok")}catch(l){Lt.warn("coze auth login failed",{err:String(l)});return}xo=!0}finally{Oi=null}})(),Oi}async function ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Cy});return ya(i)}catch{return}}async function Py(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Dy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Vr();Le();var Oy=10*6e4;function bu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Oy:e}function ho(t){return tr(t??ee().configFile)}function Li(t,e){return nr(e??ee().configFile,t)}import{randomBytes as Qy}from"node:crypto";Zi();Je();ie();import{createReadStream as Ly}from"node:fs";import{mkdir as Ny,readFile as My,realpath as By,stat as Fy,writeFile as zy}from"node:fs/promises";import{basename as Uy,dirname as Vc,isAbsolute as qy,join as Gy,relative as Hy,resolve as Eu,sep as jy}from"node:path";import{createInterface as Wy}from"node:readline";var Su=j("fs-rpc"),Ni=zt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Iu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ni)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ni} bytes`);let i=await Tu(t.path,e);return await Ny(Vc(i),{recursive:!0}),await zy(i,t.content,"utf8"),Su.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Au(t,e){let r=await Tu(t.path,e),i=await Fy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ni&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ni} bytes`);let c;if(o&&i.size>Ni)c=await Ky(r,t.line??1,t.limit);else{let l=await My(r,"utf8");if(o){let f=l.split(`
|
|
99
|
-
`),
|
|
100
|
-
`)}else c=l}return
|
|
101
|
-
`)}async function Tu(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([vu(Eu(e)),vu(Eu(t))]),o=Hy(r,i);if($y(o,jy,qy(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function $y(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function vu(t){let e=[],r=t;for(;r!==Vc(r);)try{let i=await By(r);return e.length?Gy(i,...e.reverse()):i}catch{e.push(Uy(r)),r=Vc(r)}return t}ie();var Cu=j("prompt-multimodal"),Du=10*1024*1024,Jy=15e3,Vy=6;async function Ru(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 Yy(l))}}let o=Array.from({length:Math.min(Vy,t.length)},()=>i());return await Promise.all(o),e}function ku(t){return t.some(e=>e.type==="image")}async function Yy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ys(e.uri))return t;try{let{buf:r,contentType:i}=await Xy(e.uri),o=e.mimeType||Zy(i)||"application/octet-stream";return Cu.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 Cu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Zy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Xy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Jy);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Du)throw new Error(`image too large: ${o.byteLength} bytes (max ${Du})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();Je();ie();var Y=j("core"),eb=3e4,tb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",rb="\u5BA1\u6279\u5DF2\u8D85\u65F6",ib=3e4,po=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ar;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=bu(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),Y.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Y.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}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),Y.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){Y.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)&&Y.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)=>{Y.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Pi(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){Y.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:ne.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>Y.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ne.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){Y.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ne.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(no(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&tb.test(i)?this.currentCozeEnv=i:i&&Y.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,ne.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):Y.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ir(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ir(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ir(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ne.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):Y.warn("drop unknown notification",{method:e.method})}catch(o){Y.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,ki(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 p=r._meta?.cozeTriggerMsgId,b=Rc(r._meta);return Y.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,nb,p,b)}}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{Y.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}=p0(i);switch(r){case"session/new":{let c=sb();return Y.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return Y.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 p=Rc(i._meta);if(p?e.activeGroupIds.set(f.acpSessionId,p):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&ku(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let b=await Ru(c.prompt);try{let _=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:b});return f.lastActiveAt=Date.now(),_}catch(_){if(_ instanceof T&&_.code==="AGENT_APPROVAL_TIMEOUT"){let A=f.pendingPermission;A&&(A.downstream.respondAgentRequest(A.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(A.upstreamId),f.pendingPermission=void 0);let w=f.acpSessionId,v=w?e.activeTriggers.get(w):void 0,I=w?e.activeGroupIds.get(w):void 0;return Y.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,rb,v,I)}throw _}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let _=f.downstream;_&&(f.downstream=void 0,Y.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),_.stop("reload-after-turn").catch(A=>Y.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(A)})))}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&&(Y.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(yt.GEN_MODEL_TOKEN,i,ib);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(Pi(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(p){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(Y.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),Y.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){Y.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let b=await x.sessionNew({cwd:e.workspace});i.acpSessionId=b.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Pi(i),this.isRuntimeBusy(e,i)){Y.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)){Y.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}Y.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=>Y.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=>Y.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){Y.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){Y.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(ab(r)){Y.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(p=>Y.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}Y.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:ne.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 Iu(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Au(c,o);r.respondAgentRequest(i.id,l)}}catch(o){Y.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,ki(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,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let b=f?e.activeGroupIds.get(f):void 0;b&&(p.cozeGroupId=b);let _=f?this.reverseSessionId(e,f):void 0,A=_?e.sessions.get(_):void 0;A&&(A.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let w={...c,..._?{sessionId:_}:{},_meta:p};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:f,cloudSessionId:_,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Di(o,"session/request_permission",w)).catch(v=>{this.pendingUpstream.delete(o),Y.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:ne.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?(Y.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"&&ob(e.result,o),Y.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new to(e.error)):i.value.resolve(e.result);return}Y.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 Y.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=eb){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(Di(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Zr(e.agentId,r,this.paths)}catch(r){Y.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 sb(){return Qy(16).toString("hex")}function ob(t,e){if(!t||typeof t!="object"){Y.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){Y.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){Y.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")&&Y.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function ab(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}ie();Le();import{randomBytes as cb}from"node:crypto";import{chmod as db,mkdir as lb,writeFile as Pu}from"node:fs/promises";import{createServer as fb}from"node:http";import{dirname as ub}from"node:path";var xb=1e6,Yc=j("ipc"),go=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??ee()}async start(){this.token=cb(32).toString("hex");let e=fb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Yc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await lb(ub(this.paths.portFile),{recursive:!0}),await Pu(this.paths.portFile,String(this.port),"utf8"),await Pu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await db(this.paths.tokenFile,384)}catch(e){Yc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Mi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Mi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await hb(e)}catch(f){Mi(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);Mi(r,200,f??{ok:!0})}catch(f){Yc.error("IPC handler failed",{key:o,err:String(f)}),Mi(r,500,{error:f instanceof Error?f.message:String(f)})}}};function Mi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function hb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>xb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var th=It(Hu(),1);var J1=It(zx(),1),V1=It(Po(),1),Y1=It(Rr(),1),Z1=It(dd(),1),X1=It(ud(),1),Q1=It(wd(),1),Jx=It(Mo(),1),eE=It($x(),1);var Vx=Jx.default;Je();ie();var Pe=j("upstream.frontier"),Zx="application/json",Xx="none",nE=15e3;function rE(t){class e extends Vx{constructor(i){super(i,m0,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Pe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(nl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Pe.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Pe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Wi=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){Pe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:w0,...br(this.opts.ppeOverride)},r=rE(e),i=y0(this.opts.urlOverride),o={url:i,ws:r,fpID:g0,aID:Xs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Zx,force:!0},payloadEncoding:{encoding:Xx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new th.FWS(o),l=!1,f=null,x,p,b=new Promise((w,v)=>{x=w,p=v}),_=w=>{l||(l=!0,f&&(clearTimeout(f),f=null),w?p(w):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let w=this.openCount===1;Pe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:w,openCount:this.openCount}),w&&_();for(let v of this.connectHandlers)Promise.resolve(v({initial:w})).catch(I=>Pe.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=w=>{this.opened=!1,Pe.info("frontier closed",{code:w.code,reason:w.reason,willReconnect:w.willReconnect})},c.onerror=w=>{Pe.warn("frontier error",{code:w.code,msg:w.message}),_(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${w.code} msg=${w.message??""}`))},c.onmessage=w=>this.handleMessage(w),this.fws=c;let A=this.opts.openTimeoutMs??nE;f=setTimeout(()=>{_(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await b}catch(w){try{c.close(1e3,"open failed")}catch(v){Pe.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,w}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Pe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Pe.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?(Pe.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;Qx(c)||Pe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Zx,payloadEncoding:Xx})}catch(f){throw Pe.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){Pe.debug("drop non-adapter frontier frame",{service:r});return}let i=oE(e);if(!i){Pe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Pe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Pe.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Qx(c)||Pe.info("frontier frame in",{logid:sE(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:iE(i)}),Promise.resolve(this.handler(o)).catch(l=>Pe.warn("frontier frame handler threw",{err:String(l)}))}};function Qx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var eh=2e3;function iE(t){return t.length<=eh?t:`${t.slice(0,eh)}...<truncated, total ${t.length} chars>`}function sE(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function oE(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ie();var yd=j("upstream.switchable"),Fo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;yd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw yd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>yd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ie();var bd=j("upstream"),Mr=class{handler=null;async start(){bd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){bd.info("NoopUpstream stopped",{reason:e})}async send(e){bd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Je();ie();ie();Le();import{promises as Ed}from"node:fs";import{dirname as aE}from"node:path";var cE=j("pat-token-store");async function zo(t=ee()){try{let r=(await Ed.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&cE.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ki(t,e=ee()){if(!t)throw new Error("writePatToken: empty patToken");await Ed.mkdir(aE(e.patTokenFile),{recursive:!0}),await Ed.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Le();Le();import{promises as Uo}from"node:fs";import{join as dE}from"node:path";function lE(t,e){return`#!/bin/sh
|
|
97
|
+
`}function xy(t){if(t.includes(`
|
|
98
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var py={path:"",version:"cloud-deployed"},s0="openclaw_gateway_unavailable",gy="openclaw_default_agent_missing";function o0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var my={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},wy=6e4,uo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fy,this.createTimeoutMs=e.createTimeoutMs??wy,this.detectorFactory=e.detectorFactory??(()=>new qn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new co({command:r})),this.openclawConfigDir=e.openclawConfigDir??i0(uy(),".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 R("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=i0(e,".env");if(await dy(r).then(c=>c.isFile()).catch(()=>!1)){xe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await lo(e,{recursive:!0});let o=hy({...process.env,...Wc(this.paths.agentEnvFile)});if(await ly(r,o,"utf8"),process.platform!=="win32")try{await ay(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 R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let i=Si(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new R("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 Ge(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Qe(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 Ge(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Qe(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 R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=Xe(e.agentId,this.paths),u=Si(e._meta),h=e.framework==="openclaw"&&u==="local",p;h&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let m=p??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),E=e.workspace??m??l.workspace,T=new AbortController,_=setTimeout(()=>T.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&$c(e.framework)&&await er(e.framework,T.signal);let S=()=>{if(T.signal.aborted)throw T.signal.reason instanceof Error?T.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await lo(l.root,{recursive:!0}),await lo(E,{recursive:!0}),await lo(l.logs,{recursive:!0}),S(),h||await rr(E,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await wl(E),S();let C=await Ge(e.agentId,this.paths).catch(()=>null),N=bf({model:e.model??C?.model}),y=xf(e._meta)??C?.accountId,D=e.patToken??C?.patToken,k=u==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new oo({agentId:e.agentId,framework:e.framework,workspace:E,model:N.model??Et,deployType:u,...y?{accountId:y}:{},...D?{patToken:D}:{},...k?{modelInfo:k}:{}}),v.status="ok",C?.sessions){for(let[V,ee]of Object.entries(C.sessions))v.sessions.set(V,{acpSessionId:ee.acpSessionId,modelToken:ee.modelToken,tokenGeneratedAt:ee.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let J=Object.keys(C.sessions).length;J>0&&xe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:J})}this.registry.register(v),I=!0;let M={agentId:e.agentId,framework:e.framework,workspace:E,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:N.model};u==="cloud"&&(M.deployType="cloud"),y&&(M.accountId=y),D&&(M.patToken=D),k&&(M.modelInfo=k),C?.skills&&(M.skills=C.skills),C?.agentName&&(M.agentName=C.agentName),C?.description&&(M.description=C.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,E)):xe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let J=[...M.skills??[]],V=new Map(J.map((ye,fe)=>[ye.skillId,fe])),ee=await Promise.allSettled(B.map(ye=>Hc({agentId:e.agentId,workspace:E,framework:e.framework,skill:ye}))),X=0;for(let[ye,fe]of ee.entries()){let P=B[ye];P&&(fe.status==="fulfilled"?(jc(J,V,fe.value),X++):xe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:P.skillId,skillName:P.skillName,err:String(fe.reason)}))}X>0&&(M.skills=J,xe.info("initialSkills installed",{agentId:e.agentId,installed:X,requested:B.length}))}return await Qe(M,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:E,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 cy(l.root,{recursive:!0,force:!0}).catch(C=>xe.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof R?S:new R("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&$c(e.framework))u=py;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);$c(e.framework)&&!ns(e.framework)&&(xe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(my),p}catch(m){let E=p instanceof Pt?p.getStderrTail():[];throw E.length>0&&xe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof R?m.code:"unknown",recentStderr:E}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,m)}}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 R("AGENT_ENV_NOT_READY",o0(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 R?new R(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new R("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 R("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:gy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new R("AGENT_ENV_NOT_READY",o0(r),{cause:{reason:s0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=Kc(o);if(r.deployType==="local"){let T=await this.ensureOpenclawDefaultAgent();return new Tr({command:u,cwd:T.workspace,agentId:T.id,sessionName:h})}let p=await r0(),m=i?Rf(i,c,l):null,E;if(m){let T=Lc(o),v=m.models[0]?.id??Et,I=`${T}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(T,m),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}E=I}return new Tr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...p?{gatewayToken:p}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Lc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,xe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,xe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as u0}from"node:crypto";import{promises as Ay}from"node:fs";import{basename as f0}from"node:path";$e();te();import{promises as yy}from"node:fs";import{basename as Ey}from"node:path";var a0=U("file-upload"),by="/api/coze_claw/file/agent_upload",vy=6e4;async function c0(t,e={}){let i=`${Zs(Qs(e.handshakeBase))}${by}`,o=e.timeoutMs??vy,c=await yy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Er(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,p=setTimeout(()=>h.abort(),o);a0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:u,body:l,signal:h.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let v=await m.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${v.slice(0,200)}`)}let T=await m.json();if(T.code!==void 0&&T.code!==0)throw new R("UPLOAD_FAILED",`upload code=${T.code} msg=${T.msg??"-"} logid=${E}`);let _=T.data?.file?.file_url;if(!_)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(T).slice(0,200)}`);return a0.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof R?m:m.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Ey(t.path)}`):new R("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(p)}}$e();te();import{extname as Sy}from"node:path";var Iy={".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 d0(t){let e=Sy(t).toLowerCase();return Iy[e]??"application/octet-stream"}Ne();var fo=U("agent-send"),l0=50*1024*1024;function h0(t,e,r){let i=t.get(e);if(!i)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function x0(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,h<2&&(fo.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(p)}),await new Promise(m=>setTimeout(m,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function p0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!await Yr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ay.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>l0)throw new R("FILE_TOO_LARGE",`${o.size} bytes > limit ${l0}`);let c=await d0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??f0(t.path),u;try{u=await c0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw fo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof R?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let h={sessionUpdate:"agent_file",messageId:u0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),fo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function g0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??f0(t.path),c={sessionUpdate:"group_file",messageId:u0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),fo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function 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 l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}nn();yn();te();var Nt=U("coze-cli-installer"),w0="@coze/cli@latest",Ty="coze",_0="0.1.8",Ry=5e3,Cy=5e3,Dy=9e4,y0=1e4,Pi=null,ho=!1;async function Jc(t,e={}){if(ho)return;if(Pi)return Pi;let r=e.exec??Jf;return Pi=(async()=>{try{let i=await ky(Ty,r),o=!1;if(i){let l=await Oy(r);if(l===void 0)Nt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(m0(l,_0))Nt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:_0}),o=!0;else{Nt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),ho=!0;return}}let c=o?"upgrade-only":"full";Nt.info("coze-cli install start",{package:w0,mode:c});try{await r("npm",["i","-g","--prefer-online",w0],{timeout:Dy,maxBuffer:10*1024*1024}),Nt.info("coze-cli install ok")}catch(l){Nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){ho=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:y0}),Nt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Nt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:y0}),Nt.info("coze auth login ok")}catch(l){Nt.warn("coze auth login failed",{err:String(l)});return}ho=!0}finally{Pi=null}})(),Pi}async function ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Ry});return ya(i)}catch{return}}async function Oy(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Cy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Vr();Ne();var Py=10*6e4;function E0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Py:e}function xo(t){return tr(t??Z().configFile)}function Ni(t,e){return nr(e??Z().configFile,t)}import{randomBytes as Qy}from"node:crypto";Zi();$e();te();import{createReadStream as Ny}from"node:fs";import{mkdir as Ly,readFile as My,realpath as By,stat as zy,writeFile as Fy}from"node:fs/promises";import{basename as Uy,dirname as Vc,isAbsolute as qy,join as Hy,relative as jy,resolve as b0,sep as Gy}from"node:path";import{createInterface as Wy}from"node:readline";var S0=U("fs-rpc"),Li=Ft("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function I0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Li)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Li} bytes`);let i=await T0(t.path,e);return await Ly(Vc(i),{recursive:!0}),await Fy(i,t.content,"utf8"),S0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function A0(t,e){let r=await T0(t.path,e),i=await zy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Li&&!o)throw new R("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Li} bytes`);let c;if(o&&i.size>Li)c=await Ky(r,t.line??1,t.limit);else{let l=await My(r,"utf8");if(o){let u=l.split(`
|
|
99
|
+
`),h=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?h+t.limit:void 0;c=u.slice(h,p).join(`
|
|
100
|
+
`)}else c=l}return S0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Ky(t,e,r){let i=Wy({input:Ny(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],u=0;try{for await(let h of i)if(u>=o&&u<c&&l.push(h),u++,u>=c)break}finally{i.close()}return l.join(`
|
|
101
|
+
`)}async function T0(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([v0(b0(e)),v0(b0(t))]),o=jy(r,i);if($y(o,Gy,qy(o)))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function $y(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function v0(t){let e=[],r=t;for(;r!==Vc(r);)try{let i=await By(r);return e.length?Hy(i,...e.reverse()):i}catch{e.push(Uy(r)),r=Vc(r)}return t}te();var R0=U("prompt-multimodal"),C0=10*1024*1024,Jy=15e3,Vy=6;async function D0(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 Yy(l))}}let o=Array.from({length:Math.min(Vy,t.length)},()=>i());return await Promise.all(o),e}function k0(t){return t.some(e=>e.type==="image")}async function Yy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ys(e.uri))return t;try{let{buf:r,contentType:i}=await Xy(e.uri),o=e.mimeType||Zy(i)||"application/octet-stream";return R0.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 R0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Zy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Xy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Jy);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>C0)throw new Error(`image too large: ${o.byteLength} bytes (max ${C0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();$e();te();var $=U("core"),eE=3e4,tE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",rE="\u5BA1\u6279\u5DF2\u8D85\u65F6",iE=3e4,po=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ar;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=E0(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Oi(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:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>$.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new R("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(no(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&tE.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ir(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ir(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ir(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,ki(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new R("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new R("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let h=o.sessions.get(c);if(h?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,m=Dc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,h,c,nE,p,m)}}let l=Date.now(),u=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,h}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=pf(i);switch(r){case"session/new":{let c=sE();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(u.acpSessionId,h):e.activeTriggers.delete(u.acpSessionId);let p=Dc(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&k0(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await D0(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:m});return u.lastActiveAt=Date.now(),E}catch(E){if(E instanceof R&&E.code==="AGENT_APPROVAL_TIMEOUT"){let T=u.pendingPermission;T&&(T.downstream.respondAgentRequest(T.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(T.upstreamId),u.pendingPermission=void 0);let _=u.acpSessionId,v=_?e.activeTriggers.get(_):void 0,I=_?e.activeGroupIds.get(_):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,rE,v,I)}throw E}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let E=u.downstream;E&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(T=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(T)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(yt.GEN_MODEL_TOKEN,i,iE);if(!o?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof R&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new R("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Oi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new R("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let m=await h.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await h.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Oi(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(h=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(h)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(aE(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(p=>$.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await I0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await A0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,ki(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,h=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};h&&(p.cozeTriggerMsgId=h);let m=u?e.activeGroupIds.get(u):void 0;m&&(p.cozeGroupId=m);let E=u?this.reverseSessionId(e,u):void 0,T=E?e.sessions.get(E):void 0;T&&(T.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...E?{sessionId:E}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ci(o,"session/request_permission",_)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&oE(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new to(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=eE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Ci(o,e,r)).catch(h=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Zr(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 sE(){return Qy(16).toString("hex")}function oE(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function aE(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}te();Ne();import{randomBytes as cE}from"node:crypto";import{chmod as dE,mkdir as lE,writeFile as O0}from"node:fs/promises";import{createServer as uE}from"node:http";import{dirname as fE}from"node:path";var hE=1e6,Yc=U("ipc"),go=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??Z()}async start(){this.token=cE(32).toString("hex");let e=uE((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Yc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await lE(fE(this.paths.portFile),{recursive:!0}),await O0(this.paths.portFile,String(this.port),"utf8"),await O0(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await dE(this.paths.tokenFile,384)}catch(e){Yc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Mi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Mi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await xE(e)}catch(u){Mi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Mi(r,200,u??{ok:!0})}catch(u){Yc.error("IPC handler failed",{key:o,err:String(u)}),Mi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Mi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function xE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>hE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ex=It(j0(),1);var Jb=It(zh(),1),Vb=It(Oo(),1),Yb=It(Dr(),1),Zb=It(dd(),1),Xb=It(fd(),1),Qb=It(wd(),1),$h=It(Mo(),1),ev=It(Kh(),1);var Jh=$h.default;$e();te();var Oe=U("upstream.frontier"),Yh="application/json",Zh="none",nv=15e3;function rv(t){class e extends Jh{constructor(i){super(i,mf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Oe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(nl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Oe.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Oe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Wi=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){Oe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:wf,...Er(this.opts.ppeOverride)},r=rv(e),i=yf(this.opts.urlOverride),o={url:i,ws:r,fpID:gf,aID:Xs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Yh,force:!0},payloadEncoding:{encoding:Zh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ex.FWS(o),l=!1,u=null,h,p,m=new Promise((_,v)=>{h=_,p=v}),E=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?p(_):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Oe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:_})).catch(I=>Oe.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,Oe.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Oe.warn("frontier error",{code:_.code,msg:_.message}),E(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let T=this.opts.openTimeoutMs??nv;u=setTimeout(()=>{E(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${T}ms (handshake or upgrade slow)`))},T),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(v){Oe.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Oe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Oe.warn("frontier send refused: upstream not started",{method:i}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Oe.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Xh(c)||Oe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Yh,payloadEncoding:Zh})}catch(u){throw Oe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Oe.debug("drop non-adapter frontier frame",{service:r});return}let i=ov(e);if(!i){Oe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Oe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Oe.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Xh(c)||Oe.info("frontier frame in",{logid:sv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:iv(i)}),Promise.resolve(this.handler(o)).catch(l=>Oe.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 Qh=2e3;function iv(t){return t.length<=Qh?t:`${t.slice(0,Qh)}...<truncated, total ${t.length} chars>`}function sv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function ov(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}te();var yd=U("upstream.switchable"),zo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;yd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw yd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>yd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};te();var Ed=U("upstream"),Mr=class{handler=null;async start(){Ed.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ed.info("NoopUpstream stopped",{reason:e})}async send(e){Ed.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)}};$e();te();te();Ne();import{promises as bd}from"node:fs";import{dirname as av}from"node:path";var cv=U("pat-token-store");async function Fo(t=Z()){try{let r=(await bd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&cv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ki(t,e=Z()){if(!t)throw new Error("writePatToken: empty patToken");await bd.mkdir(av(e.patTokenFile),{recursive:!0}),await bd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Ne();Ne();import{promises as Uo}from"node:fs";import{join as dv}from"node:path";function lv(t,e){return`#!/bin/sh
|
|
102
102
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
103
|
-
`}function
|
|
103
|
+
`}function uv(t,e){return`@echo off\r
|
|
104
104
|
"${e}" "${t}" %*\r
|
|
105
|
-
`}async function nh(t,e=ee()){let r=e.binDir;await Uo.mkdir(r,{recursive:!0});let i=dE(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?fE(t,o):lE(t,o);return await Uo.readFile(i,"utf8").catch(()=>null)===c||(await Uo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Uo.chmod(i,493)),r}ie();Le();import{execSync as rh}from"node:child_process";import{readFileSync as ih,unlinkSync as uE}from"node:fs";import{mkdir as xE,readFile as sh,unlink as oh,writeFile as hE}from"node:fs/promises";import{dirname as pE}from"node:path";function qo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var gE=j("single-instance"),Go=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??ee().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(gE.warn("removing stale pid file",{stalePid:e}),await oh(this.pidFile).catch(()=>{})),await xE(pE(this.pidFile),{recursive:!0}),await hE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await sh(this.pidFile,"utf8")).trim()===String(process.pid)&&await oh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await sh(this.pidFile,"utf8"),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 qo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=ih(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=rh(`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=rh(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{ih(this.pidFile,"utf8").trim()===String(process.pid)&&uE(this.pidFile)}catch{}})}};Ho();ie();var $n=j("daemon.upstream-watchdog"),SE=12e4,IE=9e5,AE=3e4;function Sd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var jo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",SE),this.hardMs=e.hardMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",IE),this.intervalMs=e.intervalMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",AE),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var J=j("daemon"),TE="coze-bridge-daemon";async function dh(){let t=ee();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&el({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>Xe(O,t).logs,listAgentIds:()=>rs(t)});let e=new Go({processTitle:TE}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await ho(),o=i??{};ts({pid:process.pid}),J.info(i?"loaded bridge config":"initialized bridge config");try{let O=new qn;o.frameworksCache=await O.detectAll(),J.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){J.warn("framework detection failed",{err:String(O)})}await Li(o);let c=new Fo(new Mr),l=null,f=new po({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,K,V,oe)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,K,V,oe)}});await DE(t,f);let x=new fo({paths:t,config:o,registry:f});l=x;let p,b,_=null,A={},w,v=null,I=null,S=null,C=new bn;function L(O,K){return C.enqueue(()=>D(O,K))}function y(){I||(I=new jo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?L(S,{force:!0}):void 0,onFatal:O=>{if(process.env[$i]==="1"){J.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}J.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),I.start()}async function D(O,K){let V=O,oe=V?.privatecode;if(!oe)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ye=Ai(V.env),xe=V.handshake_url,he=V.frontier_url,St=ch(V.env,xe,he);if(S=V,!K?.force&&p===oe&&b===St){let _e=await CE(t);return f.agents.size===0&&_e?(J.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ko(t,x).catch(Ce=>J.warn("connect-noop auto-revive error (ignored)",{err:String(Ce)}))):J.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let xt=!!p&&p!==oe,Xt=b!==void 0&&b!==St,Ft=xt||Xt,Qt=await kc({privatecode:oe,...xe?{endpoint:xe}:{},ppeOverride:Ye});if(Ft){J.warn("connect config switched, resetting agents",{pcChanged:xt,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(oe)});for(let _e of[...f.agents.values()])await _e.dispose("connect config switch").catch(()=>{}),f.agents.delete(_e.agentId);f.disconnectedAgents.size>0&&(J.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Mr,"connect switch").catch(()=>{})}_=Qt.deviceId,ts({deviceId:_,pid:process.pid}),Jc({patToken:oe,env:V.env}).catch(_e=>J.warn("coze-cli setup error (ignored)",{err:String(_e)}));let qr=new Wi({handshake:Qt,privatecode:oe,...he?{urlOverride:he}:{},ppeOverride:Ye,getPatTokenForAgent:_e=>f.agents.get(_e)?.patToken});return await c.swap(qr,"connect"),p=oe,b=St,A=Ye,w=xe,V.mock_scenario!==void 0&&(f.setMockScenario(V.mock_scenario),J.info("mock scenario set",{scenario:V.mock_scenario})),v||(v=new Ci({core:f,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(_e=>J.warn("detailSync.retryPending failed (ignored)",{err:String(_e)})),onAuthFailures:Z})),v.start(),y(),Ft&&Ko(t,x).catch(_e=>J.warn("post-connect-switch auto-revive error (ignored)",{err:String(_e)})),Ki(oe,t).catch(_e=>J.warn("writePatToken after /connect failed (ignored)",{err:String(_e)})),J.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async O=>x.createAgent(O.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let R={},M=new eo({agents:f.agents,disposeAndMarkDisconnected:async(O,K)=>{let V=f.agents.get(O);if(V){await x.cleanupOpenclawSessionProviders(V).catch(Ye=>J.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Ye)}));let oe=!0;try{await V.dispose(`disconnect: ${K}`)}catch(Ye){oe=!1,J.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Ye)}),V.status="error"}oe&&(V.status="disconnected",f.unregister(O),f.disconnectedAgents.add(O))}else f.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!R.ref)throw new Error("agent-detail-sync not initialized yet");await R.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,K)=>{await x.openclawRepair(O,K)},isRuntimePendingPermission:O=>f.hasPendingPermissionFor(O)});f.registerExtension("_agent/listSkills",O=>M.listSkills(O.params)),f.registerExtension("_agent/addSkills",O=>M.addSkills(O.params)),f.registerExtension("_agent/removeSkills",O=>M.removeSkills(O.params)),f.registerExtension("_agent/getFileTree",O=>M.getFileTree(O.params)),f.registerExtension("_agent/getFileContent",O=>M.getFileContent(O.params)),f.registerExtension("_agent/update",O=>M.updateAgent(O.params)),f.registerExtension("_agent/disconnect",O=>M.disconnectAgent(O.params)),f.registerExtension("_agent/switchModel",O=>M.switchModel(O.params)),f.registerExtension("_agent/reset",O=>M.resetAgent(O.params)),f.registerExtension("_agent/repair",O=>M.repairAgent(O.params));let B=new as({paths:t,handlers:M,sendDetail:O=>f.sendRequest("_agent/detail",O)});R.ref=B;let Z=async O=>{await Promise.allSettled(O.map(async K=>{try{await M.disconnectAgent({agentId:K.agentId,reason:`auth_failure: code=${K.code} ${K.message}`}),J.info("agent disconnected due to auth failure from heartbeat response",{agentId:K.agentId,code:K.code,message:K.message})}catch(V){J.warn("disconnect during authFailure handling failed (ignored)",{agentId:K.agentId,err:String(V)})}}))};c.onConnect(({initial:O})=>{J.info("frontier upstream connected, triggering detail sync",{initial:O}),B.syncAll(O?"initial-connect":"reconnect").catch(K=>J.warn("detail sync top-level error (ignored)",{err:String(K)}))});let X=new go({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[$i]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let K=O,V=K?.privatecode,oe=K?.pairing_code;if(!V||!oe)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ye=Ai(K.env),xe=K.handshake_url,he=K.frontier_url,St=ch(K.env,xe,he),xt=!!p&&p!==V,Xt=b!==void 0&&b!==St,Ft=xt||Xt,Qt=await kc({privatecode:V,...xe?{endpoint:xe}:{},ppeOverride:Ye});if(Ft){J.warn("pair config switched, resetting agents",{pcChanged:xt,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(V),previousEnvKey:b??"",nextEnvKey:St});for(let Ce of[...f.agents.values()])await Ce.dispose("pair config switch").catch(()=>{}),f.agents.delete(Ce.agentId);f.disconnectedAgents.size>0&&(J.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Mr,"pair switch").catch(()=>{})}_=Qt.deviceId,ts({deviceId:_,pid:process.pid}),Jc({patToken:V,env:K.env}).catch(Ce=>J.warn("coze-cli setup error (ignored)",{err:String(Ce)}));let qr=new Wi({handshake:Qt,privatecode:V,...he?{urlOverride:he}:{},ppeOverride:Ye,getPatTokenForAgent:Ce=>f.agents.get(Ce)?.patToken});await c.swap(qr,"pair");try{let Ce=new qn;o.frameworksCache=await Ce.detectAll(),await Li(o),J.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ce){J.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ce)})}let _e=Object.keys(o.frameworksCache??{});try{let Ce=await f.sendRequest("_agent/pair",{pairCode:oe,patToken:V,frameworks:_e,_meta:{cozeDeviceId:_}});J.info("_agent/pair ok",{pairResult:Ce}),p=V,b=St,A=Ye,w=xe,K.mock_scenario!==void 0&&(f.setMockScenario(K.mock_scenario),J.info("mock scenario set",{scenario:K.mock_scenario})),Ki(V,t).catch(Oe=>J.warn("writePatToken after /pair failed (ignored)",{err:String(Oe)})),v||(v=new Ci({core:f,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(Oe=>J.warn("detailSync.retryPending failed (ignored)",{err:String(Oe)})),onAuthFailures:Z})),v.start(),y(),Ft&&Ko(t,x).catch(Oe=>J.warn("post-pair-switch auto-revive error (ignored)",{err:String(Oe)}));let Jn;return K.agent_id&&(Jn=await RE(K.agent_id,t,x,Oe=>f.sendRequest("_agent/detail",Oe),V).catch(Oe=>(J.error("--agent-id ensureAgent failed",{agentId:K.agent_id,err:String(Oe)}),{ok:!1,agentId:K.agent_id??"",note:String(Oe)}))),{ok:!0,note:"paired with cloud",...Jn?{agent:Jn}:{}}}catch(Ce){return J.error("_agent/pair failed",{err:String(Ce)}),{ok:!1,note:`pair failed: ${String(Ce)}`}}}},{method:"POST",path:"/connect",handler:O=>L(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let K=O;return{ok:!0,result:await x.createAgent(K)}}},{method:"POST",path:"/agent/send",handler:async O=>{let K=O;if(!K?.agentId||!K?.sessionId||!K?.kind||!K?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let V=K;return await(V.groupFile?gu:pu)(V,{core:f,patToken:p,handshakeBase:w,ppeOverride:A})}catch(V){if(V instanceof T)return{ok:!1,code:V.code,message:V.message};throw V}}},{method:"POST",path:"/reload",handler:async O=>{let K=O?.agent_id,V=await f.reloadAgents(K);return J.info("IPC /reload: recycled agent subprocesses",{agentId:K??"(all)",recycled:V}),{ok:!0,recycled:V}}},{method:"POST",path:"/shutdown",handler:async()=>(J.info("IPC /shutdown received"),setImmediate(()=>{ge.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:re,token:te}=await X.start();try{await nh(t.libEntry,t)}catch(O){J.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await f.start(),Ko(t,x).catch(O=>J.warn("auto-revive top-level error (ignored)",{err:String(O)})),ll().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(nn(),cl));for(let K of["claude-code","codex"]){let V=await O(K);V&&J.info("acp wrapper version",{framework:K,version:V})}}).catch(O=>J.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let Se=null,ge={port:re,token:te,core:f,ipc:X,shutdown(O){return Se||(J.info("daemon shutdown",{reason:O}),Se=(async()=>{v?.stop(),I?.stop(),await f.stop(O),await X.stop(),await e.release()})(),Se)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{ge.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{J.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{J.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
-
`)}catch{}process.exit(1)}),
|
|
107
|
-
`;await Jo(
|
|
108
|
-
`).filter(l=>l.length>0).filter(l=>
|
|
109
|
-
`)}async function
|
|
110
|
-
`),1;for(let p of
|
|
111
|
-
`);return 0}let o=t.date??An(new Date),c=
|
|
105
|
+
`}async function tx(t,e=Z()){let r=e.binDir;await Uo.mkdir(r,{recursive:!0});let i=dv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?uv(t,o):lv(t,o);return await Uo.readFile(i,"utf8").catch(()=>null)===c||(await Uo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Uo.chmod(i,493)),r}te();Ne();import{execSync as nx}from"node:child_process";import{readFileSync as rx,unlinkSync as fv}from"node:fs";import{mkdir as hv,readFile as ix,unlink as sx,writeFile as xv}from"node:fs/promises";import{dirname as pv}from"node:path";function qo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var gv=U("single-instance"),Ho=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Z().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&&(gv.warn("removing stale pid file",{stalePid:e}),await sx(this.pidFile).catch(()=>{})),await hv(pv(this.pidFile),{recursive:!0}),await xv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await ix(this.pidFile,"utf8")).trim()===String(process.pid)&&await sx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await ix(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 qo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=rx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=nx(`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=nx(`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{rx(this.pidFile,"utf8").trim()===String(process.pid)&&fv(this.pidFile)}catch{}})}};jo();te();var $n=U("daemon.upstream-watchdog"),Sv=12e4,Iv=9e5,Av=3e4;function Sd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Go=class{constructor(e){this.opts=e;this.softMs=e.softMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Sv),this.hardMs=e.hardMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Iv),this.intervalMs=e.intervalMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Av),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=U("daemon"),Tv="coze-bridge-daemon";async function cx(){let t=Z();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&el({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:P=>Xe(P,t).logs,listAgentIds:()=>rs(t)});let e=new Ho({processTitle:Tv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await xo(),o=i??{};ts({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");try{let P=new qn;o.frameworksCache=await P.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){j.warn("framework detection failed",{err:String(P)})}await Ni(o);let c=new zo(new Mr),l=null,u=new po({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(P,q,W,re)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,q,W,re)}});await Cv(t,u);let h=new uo({paths:t,config:o,registry:u});l=h;let p,m,E=null,T={},_,v=null,I=null,S=null,C=new En;function N(P,q){return C.enqueue(()=>D(P,q))}function y(){I||(I=new Go({isConnected:()=>c.isConnected(),forceReconnect:()=>S?N(S,{force:!0}):void 0,onFatal:P=>{if(process.env[$i]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:P});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:P}),process.exit(1)}})),I.start()}async function D(P,q){let W=P,re=W?.privatecode;if(!re)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Ai(W.env),de=W.handshake_url,le=W.frontier_url,St=ax(W.env,de,le);if(S=W,!q?.force&&p===re&&m===St){let ge=await Rv(t);return u.agents.size===0&&ge?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ko(t,h).catch(Te=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Te)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ht=!!p&&p!==re,Xt=m!==void 0&&m!==St,zt=ht||Xt,Qt=await kc({privatecode:re,...de?{endpoint:de}:{},ppeOverride:Ve});if(zt){j.warn("connect config switched, resetting agents",{pcChanged:ht,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(re)});for(let ge of[...u.agents.values()])await ge.dispose("connect config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"connect switch").catch(()=>{})}E=Qt.deviceId,ts({deviceId:E,pid:process.pid}),Jc({patToken:re,env:W.env}).catch(ge=>j.warn("coze-cli setup error (ignored)",{err:String(ge)}));let qr=new Wi({handshake:Qt,privatecode:re,...le?{urlOverride:le}:{},ppeOverride:Ve,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});return await c.swap(qr,"connect"),p=re,m=St,T=Ve,_=de,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new Ri({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(ge=>j.warn("detailSync.retryPending failed (ignored)",{err:String(ge)})),onAuthFailures:J})),v.start(),y(),zt&&Ko(t,h).catch(ge=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(ge)})),Ki(re,t).catch(ge=>j.warn("writePatToken after /connect failed (ignored)",{err:String(ge)})),j.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async P=>h.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let k={},M=new eo({agents:u.agents,disposeAndMarkDisconnected:async(P,q)=>{let W=u.agents.get(P);if(W){await h.cleanupOpenclawSessionProviders(W).catch(Ve=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(Ve)}));let re=!0;try{await W.dispose(`disconnect: ${q}`)}catch(Ve){re=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(Ve)}),W.status="error"}re&&(W.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await h.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,q)=>{await h.openclawRepair(P,q)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>M.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>M.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>M.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>M.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>M.getFileContent(P.params)),u.registerExtension("_agent/update",P=>M.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>M.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>M.switchModel(P.params)),u.registerExtension("_agent/reset",P=>M.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>M.repairAgent(P.params));let B=new as({paths:t,handlers:M,sendDetail:P=>u.sendRequest("_agent/detail",P)});k.ref=B;let J=async P=>{await Promise.allSettled(P.map(async q=>{try{await M.disconnectAgent({agentId:q.agentId,reason:`auth_failure: code=${q.code} ${q.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:q.agentId,code:q.code,message:q.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:q.agentId,err:String(W)})}}))};c.onConnect(({initial:P})=>{j.info("frontier upstream connected, triggering detail sync",{initial:P}),B.syncAll(P?"initial-connect":"reconnect").catch(q=>j.warn("detail sync top-level error (ignored)",{err:String(q)}))});let V=new go({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[$i]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let q=P,W=q?.privatecode,re=q?.pairing_code;if(!W||!re)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Ai(q.env),de=q.handshake_url,le=q.frontier_url,St=ax(q.env,de,le),ht=!!p&&p!==W,Xt=m!==void 0&&m!==St,zt=ht||Xt,Qt=await kc({privatecode:W,...de?{endpoint:de}:{},ppeOverride:Ve});if(zt){j.warn("pair config switched, resetting agents",{pcChanged:ht,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(W),previousEnvKey:m??"",nextEnvKey:St});for(let Te of[...u.agents.values()])await Te.dispose("pair config switch").catch(()=>{}),u.agents.delete(Te.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"pair switch").catch(()=>{})}E=Qt.deviceId,ts({deviceId:E,pid:process.pid}),Jc({patToken:W,env:q.env}).catch(Te=>j.warn("coze-cli setup error (ignored)",{err:String(Te)}));let qr=new Wi({handshake:Qt,privatecode:W,...le?{urlOverride:le}:{},ppeOverride:Ve,getPatTokenForAgent:Te=>u.agents.get(Te)?.patToken});await c.swap(qr,"pair");try{let Te=new qn;o.frameworksCache=await Te.detectAll(),await Ni(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Te){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Te)})}let ge=Object.keys(o.frameworksCache??{});try{let Te=await u.sendRequest("_agent/pair",{pairCode:re,patToken:W,frameworks:ge,_meta:{cozeDeviceId:E}});j.info("_agent/pair ok",{pairResult:Te}),p=W,m=St,T=Ve,_=de,q.mock_scenario!==void 0&&(u.setMockScenario(q.mock_scenario),j.info("mock scenario set",{scenario:q.mock_scenario})),Ki(W,t).catch(Pe=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),v||(v=new Ri({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(Pe=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:J})),v.start(),y(),zt&&Ko(t,h).catch(Pe=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let Jn;return q.agent_id&&(Jn=await Dv(q.agent_id,t,h,Pe=>u.sendRequest("_agent/detail",Pe),W).catch(Pe=>(j.error("--agent-id ensureAgent failed",{agentId:q.agent_id,err:String(Pe)}),{ok:!1,agentId:q.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...Jn?{agent:Jn}:{}}}catch(Te){return j.error("_agent/pair failed",{err:String(Te)}),{ok:!1,note:`pair failed: ${String(Te)}`}}}},{method:"POST",path:"/connect",handler:P=>N(P)},{method:"POST",path:"/_agent/create",handler:async P=>{let q=P;return{ok:!0,result:await h.createAgent(q)}}},{method:"POST",path:"/agent/send",handler:async P=>{let q=P;if(!q?.agentId||!q?.sessionId||!q?.kind||!q?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=q;return await(W.groupFile?g0:p0)(W,{core:u,patToken:p,handshakeBase:_,ppeOverride:T})}catch(W){if(W instanceof R)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async P=>{let q=P?.agent_id,W=await u.reloadAgents(q);return j.info("IPC /reload: recycled agent subprocesses",{agentId:q??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{fe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await V.start();try{await tx(t.libEntry,t)}catch(P){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await u.start(),Ko(t,h).catch(P=>j.warn("auto-revive top-level error (ignored)",{err:String(P)})),ll().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(nn(),cl));for(let q of["claude-code","codex"]){let W=await P(q);W&&j.info("acp wrapper version",{framework:q,version:W})}}).catch(P=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let ye=null,fe={port:ee,token:X,core:u,ipc:V,shutdown(P){return ye||(j.info("daemon shutdown",{reason:P}),ye=(async()=>{v?.stop(),I?.stop(),await u.stop(P),await V.stop(),await e.release()})(),ye)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{fe.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{j.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name});try{process.stderr.write(`FATAL uncaughtException: ${P.stack??P.message}
|
|
106
|
+
`)}catch{}process.exit(1)}),j.info("daemon ready",{port:ee,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),kv({cliSpawned:process.env[$i]==="1",readPatToken:()=>Fo(t),connect:N}).catch(P=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(P)})),fe}async function Rv(t){return rs(t).length>0}function Wo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function ax(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Cv(t,e){let r=rs(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),os));for(let c of r){await o(c,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Dv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),os)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let m={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(h);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Ko(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(),os));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let h;try{h=await o(u,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:h.framework});let p=Ov(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...p?{_meta:p}:{}},{revive:!0}),c+=1}catch(p){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:h.framework,err:String(p)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function kv(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Ov(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();Ne();import{readFile as dx}from"node:fs/promises";var Zt=class{paths;constructor(e){this.paths=e??Z()}async probe(e=1e3){let r=await $o(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:Nv(i)}}}async request(e){let r=await $o(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),h=await u.text();return{status:u.status,body:Pv(h)}}finally{clearTimeout(l)}}};async function $o(t){try{let[e,r]=await Promise.all([dx(t.portFile,"utf8"),dx(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 Pv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Nv(t){return t instanceof Error?t.message:String(t)}yn();te();Ne();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}nn();import{chmod as Lv,copyFile as lx,mkdir as fx,readFile as Jo,rename as ux,rm as Id,stat as hx,writeFile as Mv}from"node:fs/promises";import{homedir as hC}from"node:os";import{dirname as Bv,join as Br,resolve as Ad,sep as Ji}from"node:path";import{fileURLToPath as zv}from"node:url";yn();te();Ne();var Td=U("dist-install");function Fv(t){let e=zv(t),r=Bv(e),i=`${Ji}src${Ji}`;if(r.includes(i)||r.endsWith(`${Ji}src${Ji}cli`))return null;let o=Ad(r,"index.js"),c=Ad(r,"..","package.json");return{dist:o,pkgJson:c}}async function Cd(t={}){let e=t.paths??Z(),r=Fv(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let T=JSON.parse(await Jo(o,"utf8"));c=T.version??"unknown",l=T.dependencies??{}}catch(T){return Td.warn("cannot read source package.json,skip dist install",{err:String(T)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(T)}`}}let u=$r.map(T=>`${T}@${l[T]??"latest"}`),h=await xo(e.configFile)??{},p=h.libVersion,m=await Jo(e.libEntry).then(()=>!0).catch(()=>!1),E=p===c;if(E&&m&&await Rd(e))return{kind:"already-current",libVersion:c};if(!E||!m){await fx(e.libDir,{recursive:!0}),await lx(i,e.libEntry),await lx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let T=Ad(e.libDir,"package.json"),_=`${JSON.stringify({type:"module"},null,2)}
|
|
107
|
+
`;await Jo(T,"utf8").catch(()=>null)!==_&&await Mv(T,_)}return(!E||!await Rd(e))&&await(t.installWrappers??Uv)(e,u),h.libVersion=c,await Ni(h,e.configFile),Td.info("dist installed",{libEntry:e.libEntry,fromVersion:p,toVersion:c}),E&&m?{kind:"already-current",libVersion:c}:p?{kind:"version-changed",fromVersion:p,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Rd(t){for(let e of $r){let r=Br(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await hx(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function Uv(t,e){await jv(t.installLock,async()=>{if(await Rd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Ji}.staging-${process.pid}-${r}`,o=Br(i,"node_modules"),c=Br(t.libDir,"node_modules");try{await fx(i,{recursive:!0}),await qv(e,i),await Hv(o);let l=`${c}.trash-${r}`;await ux(c,l).catch(()=>{}),await ux(o,c),await Id(l,{recursive:!0,force:!0}).catch(()=>{}),Td.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Id(i,{recursive:!0,force:!0}).catch(()=>{})}})}function qv(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=lt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",h=>{l.length<8192&&(l+=h.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",h=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(h)}`))}),c.once("close",h=>{clearTimeout(u),h===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${h}: ${l.trim().slice(0,2e3)}`))})})}async function Hv(t){for(let e of $r){let r=Br(t,...e.split("/")),i=JSON.parse(await Jo(Br(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=Br(t,".bin",o),l=await hx(c);process.platform!=="win32"&&!(l.mode&73)&&await Lv(c,l.mode|73).catch(()=>{})}}async function jv(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 Id(t,{force:!0}).catch(()=>{})}}ga();te();Ne();import{closeSync as px,fstatSync as gx,openSync as mx,readFileSync as Gv,readSync as Wv,readdirSync as Kv,statSync as $v}from"node:fs";import{join as Vo}from"node:path";var Jv=new Set(["debug","info","warn","error"]);function _x(t){let e=t,r=Sn(e,"--agent-id");e=r.rest;let i=Sn(e,"--date");e=i.rest;let o=Sn(e,"-n","--lines");e=o.rest;let c=Sn(e,"--level");e=c.rest;let l=Sn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),h=Number.isInteger(u)&&u>=0?u:200,p=c.value&&Jv.has(c.value)?c.value:void 0,m={lines:h,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(m.agentId=r.value),i.value&&(m.date=i.value),p&&(m.level=p),l.value&&(m.grep=l.value),m}function Vv(t,e){return t.agentId?Vo(Xe(t.agentId,e).logs,Xn("agent",t.date)):Vo(e.bridgeLogsDir,Xn("bridge",t.date))}function Yv(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function Zv(t,e){let r;try{r=Kv(t)}catch{return[]}let i=[];for(let o of r){let c=pa(o,e);if(!c)continue;let l=0;try{l=$v(Vo(t,o)).size}catch{}i.push({file:Vo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function yx(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"&&!rl(r,e.level))return!1}return!0}var xx={debug:"90",info:"36",warn:"33",error:"31"},Xv=new Set(["ts","level","module","msg"]);function Qv(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Ex(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=Qv(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&xx[o]&&(c=`\x1B[${xx[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",h=Object.entries(r).filter(([p])=>!Xv.has(p)).map(([p,m])=>` ${p}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${l} ${u}${h}`}function eS(t,e,r){let c=Gv(t,"utf8").split(`
|
|
108
|
+
`).filter(l=>l.length>0).filter(l=>yx(l,{level:e.level,grep:e.grep}));for(let l of Yv(c,e.lines))process.stdout.write(`${Ex(l,{raw:e.raw,color:r})}
|
|
109
|
+
`)}async function bx(t,e){let r=e.paths??Z(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Xe(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",h=Zv(l,u);if(h.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
110
|
+
`),1;for(let p of h)process.stdout.write(`${p.date} ${(p.size/1024).toFixed(1)}KB ${p.file}
|
|
111
|
+
`);return 0}let o=t.date??An(new Date),c=Vv({agentId:t.agentId,date:o},r);try{eS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
112
112
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
113
113
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
114
|
-
`),1}return t.follow&&await
|
|
115
|
-
`);o=
|
|
116
|
-
`)}await new Promise(
|
|
114
|
+
`),1}return t.follow&&await rS(c,t,i),0}var tS=500;function nS(t){try{let e=mx(t,"r");try{return gx(e).size}finally{px(e)}}catch{return 0}}async function rS(t,e,r){let i=nS(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let h=mx(t,"r");try{let p=gx(h).size;if(p>i){let m=Buffer.allocUnsafe(p-i),E=Wv(h,m,0,m.length,i);u=m.subarray(0,E).toString("utf8"),i+=E}}finally{px(h)}}catch{}if(u){let h=(o+u).split(`
|
|
115
|
+
`);o=h.pop()??"";for(let p of h)p.length>0&&yx(p,{level:e.level,grep:e.grep})&&process.stdout.write(`${Ex(p,{raw:e.raw,color:r})}
|
|
116
|
+
`)}await new Promise(h=>setTimeout(h,tS))}}finally{process.off("SIGINT",l)}}import{basename as iS,resolve as sS}from"node:path";Ne();var oS=9e4,aS={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 cS(t){return aS[t]??1}async function vx(t,e={}){let r=e.paths??Z();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
117
117
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
118
118
|
`),3;let i=await $o(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
119
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
119
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:sS(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 dS(i,"/agent/send",o,oS)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
120
120
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
121
|
-
`),
|
|
122
|
-
`);else{let l=t.name??
|
|
123
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${
|
|
124
|
-
`)}return 0}async function
|
|
125
|
-
`)}function
|
|
121
|
+
`),cS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
122
|
+
`);else{let l=t.name??iS(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${u})
|
|
123
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${lS(c.bytes)})
|
|
124
|
+
`)}return 0}async function dS(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),u=await l.text(),h=u?JSON.parse(u):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function lS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Ox=U("cli");function je(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function ta(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
125
|
+
`)}function NS(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:C}=je(e.slice(1),"--agent-id");return C?{mode:"reload",agentId:C}:{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 LS(e.slice(1));if(e[0]==="log")return{mode:"log",..._x(e.slice(1))};if(e[0]==="connect")return MS(e.slice(1));if(e.includes("--status"))return ta("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ta("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ta("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ta("--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}=je(r,"--pat-token");r=o;let{value:c,rest:l}=je(r,"--pair-code");r=l;let{value:u,rest:h}=je(r,"--env");r=h;let{value:p,rest:m}=je(r,"--handshake-url");r=m;let{value:E,rest:T}=je(r,"--frontier-url");r=T;let{value:_,rest:v}=je(r,"--mock-scenario");r=v;let{value:I}=je(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return u&&(S.env=u),p&&(S.handshakeUrl=p),E&&(S.frontierUrl=E),_&&(S.mockScenario=_),I&&(S.agentId=I),S}function LS(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}=je(i,"--caption");i=c;let{value:l,rest:u}=je(i,"--name");i=u;let{value:h,rest:p}=je(i,"--agent-id");i=p;let{value:m,rest:E}=je(i,"--session-id");i=E;let{value:T,rest:_}=je(i,"--mime");i=_;let v=i.includes("--group-file");i=i.filter(C=>C!=="--group-file");let I=i.includes("--json"),S={mode:"send",kind:e,path:r,json:I};return o&&(S.caption=o),l&&(S.name=l),h&&(S.agentId=h),m&&(S.sessionId=m),v&&(S.groupFile=!0),T&&(S.mimeType=T),S}function MS(t){let e=t,{value:r,rest:i}=je(e,"--pat-token");e=i;let{value:o,rest:c}=je(e,"--env");e=c;let{value:l,rest:u}=je(e,"--handshake-url");e=u;let{value:h,rest:p}=je(e,"--frontier-url");e=p;let{value:m,rest:E}=je(e,"--mock-scenario");e=E;let T={mode:"connect"};return r&&(T.privatecode=r),o&&(T.env=o),l&&(T.handshakeUrl=l),h&&(T.frontierUrl=h),m&&(T.mockScenario=m),T}var BS=`
|
|
126
126
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
127
127
|
|
|
128
128
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -201,52 +201,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
201
201
|
|
|
202
202
|
Internal:
|
|
203
203
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
204
|
-
`.trimStart();async function
|
|
205
|
-
`),0;case"daemon":{try{await
|
|
206
|
-
`),1;if(i.kind==="stale")return await
|
|
204
|
+
`.trimStart();async function Px(t=process.argv,e={}){let r=NS(t);switch(r.mode){case"help":return process.stdout.write(BS),0;case"version":return process.stdout.write(`${vr}
|
|
205
|
+
`),0;case"daemon":{try{await cx()}catch(i){return Ox.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return zS(e);case"stop":return Lx(e);case"reload":return qS(r.agentId,e);case"log":return bx(r,e);case"update":return FS(e);case"purge":return HS(e);case"service-install":return jS(e);case"service-uninstall":return GS(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),WS(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),KS(r.privatecode,e,i)}case"send":return vx({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 Nx(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 zS(t){let e=t.paths??Z(),r=new Zt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
206
|
+
`),1;if(i.kind==="stale")return await Nx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
207
207
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
208
208
|
${JSON.stringify(o.body,null,2)}
|
|
209
|
-
`),0}async function
|
|
209
|
+
`),0}async function Lx(t){let e=t.paths??Z(),r=new Zt(e),i=await Yi(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
210
210
|
`)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
211
211
|
`:`coze-bridge: not running
|
|
212
|
-
`),0;if(c.kind==="stale")return await
|
|
212
|
+
`),0;if(c.kind==="stale")return await Nx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
213
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
214
214
|
`),0}catch(l){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
215
215
|
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
|
|
216
|
-
`),1)}}async function
|
|
217
|
-
`),e(1)})})}async function
|
|
216
|
+
`),1)}}async function FS(t){return await Lx(t),(t.spawnNpx??US)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function US(t){return new Promise(e=>{let r=lt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
217
|
+
`),e(1)})})}async function qS(t,e){let r=new Zt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
218
218
|
`),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
219
219
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
220
220
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
221
221
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
222
|
-
`),1}}async function Yi(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:
|
|
222
|
+
`),1}}async function Yi(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(l,u),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Dx(),Cx)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Mx(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??ox,o=t.waitTimeoutMs??15e3,c=t.sleep??JS,l=t.paths??Z(),u=await Yi(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let h=await kx(e,o,c);if(h.kind==="connected")return h;Wr(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(h){Wr(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(h)})}await u.uninstall().catch(()=>{}),await $S(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(h=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(h)}
|
|
223
223
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
224
|
-
`),await i({paths:t.paths}),
|
|
224
|
+
`),await i({paths:t.paths}),kx(e,o,c)}async function HS(t){let e=new Zt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
225
225
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
226
226
|
`)}await new Promise(l=>setTimeout(l,500))}let i=await Yi(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
227
227
|
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
228
|
-
`)}let o=t.paths??
|
|
228
|
+
`)}let o=t.paths??Z(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
229
229
|
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
230
230
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
231
|
-
`),0}async function
|
|
231
|
+
`),0}async function jS(t){let e=await Yi(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
232
232
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
233
233
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
234
|
-
`),1}}async function
|
|
234
|
+
`),1}}async function GS(t){let e=await Yi(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
235
235
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
236
|
-
`),1}}async function
|
|
237
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
238
|
-
`)}let
|
|
239
|
-
`),1;let
|
|
236
|
+
`),1}}async function WS(t,e,r,i={},o){let c=new Zt(r.paths),l=r.paths??Z();if(await Gc(l).catch(p=>Wr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(p)})),!r.skipDistInstall){let p=await Cd({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
237
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
238
|
+
`)}let u=await Mx(r,c);if(u.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
239
|
+
`),1;let h={privatecode:t,pairing_code:e};i.env&&(h.env=i.env),i.handshakeUrl&&(h.handshake_url=i.handshakeUrl),i.frontierUrl&&(h.frontier_url=i.frontierUrl),i.mockScenario&&(h.mock_scenario=i.mockScenario),o&&(h.agent_id=o);try{let p=await c.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let m=p.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
|
|
240
240
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
241
241
|
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
|
|
242
242
|
`),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
245
|
-
`)}let l=await
|
|
246
|
-
`),1;let
|
|
247
|
-
`),await Ki(o,i).catch(p=>
|
|
248
|
-
`),1)}catch(
|
|
249
|
-
`),1}}async function
|
|
243
|
+
`),1}}async function KS(t,e,r={}){let i=e.paths??Z(),o=t??await Fo(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 Zt(e.paths);if(await Gc(i).catch(h=>Wr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!e.skipDistInstall){let h=await Cd({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
244
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(m=>setTimeout(m,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
245
|
+
`)}let l=await Mx(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
246
|
+
`),1;let u={privatecode:o};r.env&&(u.env=r.env),r.handshakeUrl&&(u.handshake_url=r.handshakeUrl),r.frontierUrl&&(u.frontier_url=r.frontierUrl),r.mockScenario&&(u.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:u,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
|
|
247
|
+
`),await Ki(o,i).catch(p=>Ox.warn("writePatToken after connect failed (ignored)",{err:String(p)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
|
|
248
|
+
`),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
|
|
249
|
+
`),1}}async function kx(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 $S(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!qo(u))return;await e(i)}}function JS(t){return new Promise(e=>setTimeout(e,t))}te();function VS(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 Bx(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=VS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
|
|
250
250
|
`),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
251
|
-
|
|
251
|
+
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
252
|
+
npx -y coze-bridge@latest stop
|
|
253
|
+
npx -y coze-bridge@latest connect
|
|
254
|
+
|
|
255
|
+
`)}Bx();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&tl("warn");Px(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
252
256
|
`),process.exit(1)});
|