coze-bridge 0.2.0-alpha.7 → 0.2.0-alpha.8
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 +85 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,34 +5,34 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
8
|
+
var rg=Object.create;var wa=Object.defineProperty;var ig=Object.getOwnPropertyDescriptor;var sg=Object.getOwnPropertyNames;var og=Object.getPrototypeOf,ag=Object.prototype.hasOwnProperty;var le=(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 Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var oe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_a=(t,e)=>{for(var r in e)wa(t,r,{get:e[r],enumerable:!0})},cg=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of sg(e))!ag.call(t,o)&&o!==r&&wa(t,o,{get:()=>e[o],enumerable:!(i=ig(e,o))||i.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?rg(og(t)):{},cg(e||!t||!t.__esModule?wa(r,"default",{value:t,enumerable:!0}):r,t));function He(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Qn=Ye(()=>{"use strict"});import{createWriteStream as dg,mkdirSync as lg,readdirSync as ug,unlinkSync as fg}from"node:fs";import{join as ul}from"node:path";function Tn(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function er(t,e){return`${t}-${e}.log`}function ya(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function hg(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 ns(t,e,r,i){let o;try{o=ug(t)}catch{return}for(let c of o){let l=ya(c,e);if(l&&hg(l,r,i))try{fg(ul(t,c))}catch{}}}var Vr,Ea=Ye(()=>{"use strict";Vr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>Tn(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{lg(this.dir,{recursive:!0});let r=dg(ul(this.dir,er(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await Al(o,i,{encoding:"utf8",mode:r.mode}):await Al(o,i,"utf8"),await Il(o,t),r?.mode!==void 0&&await Rg(t,r.mode)}catch(c){await Il(o,o).catch(()=>{});let{rm:d}=await import("node:fs/promises");throw await d(o,{force:!0}).catch(()=>{}),c}}var ti=Ye(()=>{"use strict"});import{promises as Tl,readdirSync as Og}from"node:fs";import{homedir as Lg}from"node:os";import{sep as Ng,join as Ie,resolve as Cl}from"node:path";function X(t){let e=t??Lg(),r=Ie(e,".coze"),i=Ie(r,"bridge"),o=Ie(i,"lib"),c=Ie(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ie(o,"index.js"),binDir:Ie(i,"bin"),pidFile:Ie(i,"bridge.pid"),portFile:Ie(i,"bridge.port"),tokenFile:Ie(i,"bridge.token"),patTokenFile:Ie(i,"pat-token"),agentEnvFile:Ie(i,"agent-env.json"),logFile:Ie(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ie(c,"daemon-stdio.log"),installLock:Ie(i,"install.lock"),configFile:Ie(i,"config.json"),agentsRoot:Ie(r,"agents")}}function Xe(t,e=X()){let r=Ie(e.agentsRoot,t);return{root:r,config:Ie(r,"config.json"),workspace:Ie(r,"workspace"),logs:Ie(r,"logs")}}function ls(t=X()){try{return Og(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ni(t,e){let r=await Tl.realpath(Cl(t)).catch(()=>null);if(!r)return!1;let i=await Tl.realpath(Cl(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+Ng)}var ke=Ye(()=>{"use strict"});var xs={};Ea(xs,{AGENT_CONFIG_FILE_MODE:()=>us,enforceAgentConfigMode:()=>Fg,loadAgentConfig:()=>Ne,persistAgentSessions:()=>ri,persistAgentSkills:()=>fs,saveAgentConfig:()=>Qe});import{chmod as Mg,stat as Bg}from"node:fs/promises";function Ne(t,e){return or(Xe(t,e).config)}function Qe(t,e){return ar(Xe(t.agentId,e).config,t,{mode:us})}async function Fg(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await Bg(r);if(!i.isFile())return;let o=i.mode&511;o!==us&&(await Mg(r,us),Rl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Rl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ri(t,e,r){let i=await Ne(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function fs(t,e,r){let i=await Ne(t,r);i&&(i.skills=e,await Qe(i,r))}var Rl,us,an=Ye(()=>{"use strict";ti();te();ke();Rl=G("agent-config"),us=384});var ka=oe((R2,Pl)=>{Pl.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 ps=oe(Ll=>{var Ol={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 qg(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(Ol))Ll[t]=qg(Ol[t])});var zl=oe((D2,Fl)=>{var Wg=le("fs"),De=le("path"),Nl=ka(),Kg=ps(),$g=typeof process=="object"&&process.platform==="win32",Ml=t=>typeof t=="object"&&t!==null,Bl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function ye(t){this.sep=De.sep,this.fs=Wg,Ml(t)&&Ml(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Fl.exports=ye;ye.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var d;try{d=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(d&&d.isFile())throw Kg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ye.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var d=De.dirname(t);o.fs.existsSync(d)||o.makeDir(d);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};ye.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!r)return o(!1);c.fs.stat(t,function(u,x){if(d&&x.isDirectory())return o(!1);var p=De.dirname(t);c.fs.exists(p,function(g){g||c.makeDir(p),c.fs.open(t,"w",438,function(_,S){_?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)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ye.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let d=[];return e.fs.readdirSync(i).forEach(function(u){let x=De.join(i,u),p=e.fs.statSync(x);(!o||o.test(x))&&d.push(De.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(d=d.concat(r(x,o,c)))}),d}return r(t,void 0,!0)};ye.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let d=c.length;if(!d)return e(null,i);c.forEach(function(u){u=De.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(i.push(De.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(g,_){if(g)return e(g);i=i.concat(_),--d||e(null,i)}):--d||e(null,i))})})})};ye.prototype.getAttributes=function(){};ye.prototype.setAttributes=function(){};ye.crc32update=function(t,e){return Bl[(t^e)&255]^t>>>8};ye.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ye.crc32update(r,t[i++]);return~r>>>0};ye.methodToString=function(t){switch(t){case Nl.STORED:return"STORED ("+t+")";case Nl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ye.canonical=function(t){if(!t)return"";let e=De.posix.normalize("/"+t.split("\\").join("/"));return De.join(".",e)};ye.zipnamefix=function(t){if(!t)return"";let e=De.posix.normalize("/"+t.split("\\").join("/"));return De.posix.join(".",e)};ye.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ye.sanitize=function(t,e){t=De.resolve(De.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=De.normalize(De.join(t,r.slice(i,o).join(De.sep)));if(c.indexOf(t)===0)return c}return De.normalize(De.join(t,De.basename(e)))};ye.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ye.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ye.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};ye.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};ye.isWin=$g;ye.crcTable=Bl});var Gl=oe((P2,Ul)=>{var Vg=le("path");Ul.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=Vg.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 jl=oe((O2,Hl)=>{Hl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var lr=oe((L2,dr)=>{dr.exports=zl();dr.exports.Constants=ka();dr.exports.Errors=ps();dr.exports.FileAttr=Gl();dr.exports.decoder=jl()});var Wl=oe((N2,ql)=>{var cn=lr(),z=cn.Constants;ql.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,d=0,u=0,x=0,p=0,g=0,_=0,S=0,w=0,v=0;t|=cn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},T=y=>Math.max(0,y)>>>0,R=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=cn.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&z.FLG_EFS)>0},set flags_efs(y){y?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(y){y?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(y){switch(y){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=y},get time(){return cn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=cn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=T(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=T(y)},get compressedSize(){return d},set compressedSize(y){d=T(y)},get size(){return u},set size(y){u=T(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 g},set commentLength(y){g=y},get diskNumStart(){return _},set diskNumStart(y){_=T(y)},get inAttr(){return S},set inAttr(y){S=T(y)},get attr(){return w},set attr(y){w=T(y)},get fileAttr(){return(w||0)>>16&4095},get offset(){return v},set offset(y){v=T(y)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+x+p+g},get realDataOffset(){return v+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var k=y.slice(v,v+z.LOCHDR);if(k.readUInt32LE(0)!==z.LOCSIG)throw cn.Errors.INVALID_LOC();I.version=k.readUInt16LE(z.LOCVER),I.flags=k.readUInt16LE(z.LOCFLG),I.flags_desc=(I.flags&z.FLG_DESC)>0,I.method=k.readUInt16LE(z.LOCHOW),I.time=k.readUInt32LE(z.LOCTIM),I.crc=k.readUInt32LE(z.LOCCRC),I.compressedSize=k.readUInt32LE(z.LOCSIZ),I.size=k.readUInt32LE(z.LOCLEN),I.fnameLen=k.readUInt16LE(z.LOCNAM),I.extraLen=k.readUInt16LE(z.LOCEXT);let O=v+z.LOCHDR+I.fnameLen,F=O+I.extraLen;return y.slice(O,F)},loadFromBinary:function(y){if(y.length!==z.CENHDR||y.readUInt32LE(0)!==z.CENSIG)throw cn.Errors.INVALID_CEN();t=y.readUInt16LE(z.CENVEM),e=y.readUInt16LE(z.CENVER),r=y.readUInt16LE(z.CENFLG),i=y.readUInt16LE(z.CENHOW),o=y.readUInt32LE(z.CENTIM),c=y.readUInt32LE(z.CENCRC),d=y.readUInt32LE(z.CENSIZ),u=y.readUInt32LE(z.CENLEN),x=y.readUInt16LE(z.CENNAM),p=y.readUInt16LE(z.CENEXT),g=y.readUInt16LE(z.CENCOM),_=y.readUInt16LE(z.CENDSK),S=y.readUInt16LE(z.CENATT),w=y.readUInt32LE(z.CENATX),v=y.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(z.LOCHDR);return y.writeUInt32LE(z.LOCSIG,0),y.writeUInt16LE(e,z.LOCVER),y.writeUInt16LE(r,z.LOCFLG),y.writeUInt16LE(i,z.LOCHOW),y.writeUInt32LE(o,z.LOCTIM),y.writeUInt32LE(c,z.LOCCRC),y.writeUInt32LE(d,z.LOCSIZ),y.writeUInt32LE(u,z.LOCLEN),y.writeUInt16LE(x,z.LOCNAM),y.writeUInt16LE(I.extraLen,z.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(z.CENHDR+x+p+g);return y.writeUInt32LE(z.CENSIG,0),y.writeUInt16LE(t,z.CENVEM),y.writeUInt16LE(e,z.CENVER),y.writeUInt16LE(r,z.CENFLG),y.writeUInt16LE(i,z.CENHOW),y.writeUInt32LE(o,z.CENTIM),y.writeUInt32LE(c,z.CENCRC),y.writeUInt32LE(d,z.CENSIZ),y.writeUInt32LE(u,z.CENLEN),y.writeUInt16LE(x,z.CENNAM),y.writeUInt16LE(p,z.CENEXT),y.writeUInt16LE(g,z.CENCOM),y.writeUInt16LE(_,z.CENDSK),y.writeUInt16LE(S,z.CENATT),y.writeUInt32LE(w,z.CENATX),y.writeUInt32LE(v,z.CENOFF),y},toJSON:function(){let y=function(k){return k+" bytes"};return{made:t,version:e,flags:r,method:cn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(d),size:y(u),fileNameLength:y(x),extraLength:y(p),commentLength:y(g),diskNumStart:_,inAttr:S,attr:w,offset:v,centralHeaderSize:y(z.CENHDR+x+p+g)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var $l=oe((M2,Kl)=>{var ur=lr(),me=ur.Constants;Kl.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 ur.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=ur.readBigUInt64LE(c,me.ZIP64SUB),e=ur.readBigUInt64LE(c,me.ZIP64TOT),r=ur.readBigUInt64LE(c,me.ZIP64SIZE),i=ur.readBigUInt64LE(c,me.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(me.ENDHDR+o);return c.writeUInt32LE(me.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,me.ENDSUB),c.writeUInt16LE(e,me.ENDTOT),c.writeUInt32LE(r,me.ENDSIZ),c.writeUInt32LE(i,me.ENDOFF),c.writeUInt16LE(o,me.ENDCOM),c.fill(" ",me.ENDHDR),c},toJSON:function(){let c=function(d,u){let x=d.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Pa=oe(Da=>{Da.EntryHeader=Wl();Da.MainHeader=$l()});var Jl=oe((F2,Vl)=>{Vl.exports=function(t){var e=le("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],d=0;o.on("data",function(u){c.push(u),d+=u.length}),o.on("end",function(){var u=Buffer.alloc(d),x=0;u.fill(0);for(var p=0;p<c.length;p++){var g=c[p];g.copy(u,x),x+=g.length}i&&i(u)}),o.end(t)}}}});var Yl=oe((z2,Zl)=>{var Jg=+(process.versions?process.versions.node:"").split(".")[0]||0;Zl.exports=function(t,e){var r=le("zlib");let i=Jg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),d=[],u=0;c.on("data",function(x){d.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var g=0;g<d.length;g++){var _=d[g];_.copy(x,p),p+=_.length}o&&o(x)}),c.end(t)}}}});var nu=oe((U2,tu)=>{"use strict";var{randomFillSync:Xl}=le("crypto"),Zg=ps(),Yg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),eu=(t,e)=>Math.imul(t,e)>>>0,Ql=(t,e)=>Yg[(t^e)&255]^t>>>8,ii=()=>typeof Xl=="function"?Xl(Buffer.alloc(12)):ii.node();ii.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 gs={genSalt:ii};function ms(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])}ms.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ql(e[0],t),e[1]+=e[0]&255,e[1]=eu(e[1],134775813)+1,e[2]=Ql(e[2],e[1]>>>24),t};ms.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return eu(t,t^1)>>8&255};function Xg(t){let e=new ms(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 Qg(t){let e=new ms(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let d=e.next();i[o++]=c^d,e.updateKeys(c)}return i}}function em(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Xg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Zg.WRONG_PASSWORD();return i(t.slice(12))}function tm(t){Buffer.isBuffer(t)&&t.length>=12?gs.genSalt=function(){return t.slice(0,12)}:t==="node"?gs.genSalt=ii.node:gs.genSalt=ii}function nm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Qg(r),c=gs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return o(c,d),o(t,d,12)}tu.exports={decrypt:em,encrypt:nm,_salter:tm}});var ru=oe(ws=>{ws.Deflater=Jl();ws.Inflater=Yl();ws.ZipCrypto=nu()});var La=oe((H2,iu)=>{var ae=lr(),rm=Pa(),Ee=ae.Constants,Oa=ru();iu.exports=function(t,e){var r=new rm.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let g=t,_=typeof g.decoder=="object"?g.decoder:ae.decoder;p=_.hasOwnProperty("efs")?_.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function w(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ae.crc32(y)!==r.localHeader.crc)return!1}else{let k={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Ee.LOCSIG||e.readUInt32LE(O)==Ee.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Ee.EXTSIG)k.crc=e.readUInt32LE(O+Ee.EXTCRC),k.compressedSize=e.readUInt32LE(O+Ee.EXTSIZ),k.size=e.readUInt32LE(O+Ee.EXTLEN);else if(e.readUInt16LE(O+12)===19280)k.crc=e.readUInt32LE(O+Ee.EXTCRC-4),k.compressedSize=e.readUInt32LE(O+Ee.EXTSIZ-4),k.size=e.readUInt32LE(O+Ee.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(k.compressedSize!==r.compressedSize||k.size!==r.size||k.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(y)!==k.crc)return!1}return!0}function v(y,k,O){if(typeof k>"u"&&typeof y=="string"&&(O=y,y=void 0),c)return y&&k&&k(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=S();if(F.length===0)return y&&k&&k(F),F;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw ae.Errors.INVALID_PASS_PARAM();F=Oa.ZipCrypto.decrypt(F,r,O)}var N=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(F.copy(N),w(N))return y&&k&&k(N),N;throw y&&k&&k(N,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var J=new Oa.Inflater(F,r.size);if(y)J.inflateAsync(function(K){K.copy(K,0),k&&(w(K)?k(K):k(K,ae.Errors.BAD_CRC()))});else{if(J.inflate(N).copy(N,0),!w(N))throw ae.Errors.BAD_CRC(`"${_.decode(i)}"`);return N}break;default:throw y&&k&&k(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function I(y,k){if((!d||!d.length)&&Buffer.isBuffer(e))return y&&k&&k(S()),S();if(d.length&&!c){var O;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(d.length),d.copy(O),y&&k&&k(O),O;default:case ae.Constants.DEFLATED:var F=new Oa.Deflater(d);if(y)F.deflateAsync(function(J){O=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(O),k&&k(O)});else{var N=F.deflate();return r.compressedSize=N.length,N}F=null;break}}else if(y&&k)k(Buffer.alloc(0));else return Buffer.alloc(0)}function T(y,k){return ae.readBigUInt64LE(y,k)}function R(y){try{for(var k=0,O,F,N;k+4<y.length;)O=y.readUInt16LE(k),k+=2,F=y.readUInt16LE(k),k+=2,N=y.slice(k,k+F),k+=F,Ee.ID_ZIP64===O&&P(N)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var k,O,F,N;y.length>=Ee.EF_ZIP64_SCOMP&&(k=T(y,Ee.EF_ZIP64_SUNCOMP),r.size===Ee.EF_ZIP64_OR_32&&(r.size=k)),y.length>=Ee.EF_ZIP64_RHO&&(O=T(y,Ee.EF_ZIP64_SCOMP),r.compressedSize===Ee.EF_ZIP64_OR_32&&(r.compressedSize=O)),y.length>=Ee.EF_ZIP64_DSN&&(F=T(y,Ee.EF_ZIP64_RHO),r.offset===Ee.EF_ZIP64_OR_32&&(r.offset=F)),y.length>=Ee.EF_ZIP64_DSN+4&&(N=y.readUInt32LE(Ee.EF_ZIP64_DSN),r.diskNumStart===Ee.EF_ZIP64_OR_16&&(r.diskNumStart=N))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(y){i=ae.toBuffer(y,_.encode);var k=i[i.length-1];c=k===47||k===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,R(y)},get comment(){return _.decode(o)},set comment(y){if(o=ae.toBuffer(y,_.encode),r.commentLength=o.length,o.length>65535)throw ae.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){d=ae.toBuffer(y,ae.decoder.encode),!c&&d.length?(r.size=d.length,r.method=ae.Constants.DEFLATED,r.crc=ae.crc32(y),r.changed=!0):r.method=ae.Constants.STORED},getData:function(y){return r.changed?d:v(!1,null,y)},getDataAsync:function(y,k){r.changed?y(d):v(!0,y,k)},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(),k=ae.Constants.CENHDR;return i.copy(y,k),k+=i.length,u.copy(y,k),k+=r.extraLength,o.copy(y,k),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let k=r.localHeaderToBinary(),O=Buffer.alloc(k.length+i.length+r.extraLocalLength);return k.copy(O,y),y+=k.length,i.copy(O,y),y+=i.length,x.copy(O,y),y+=x.length,O},toJSON:function(){let y=function(k){return"<"+(k&&k.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var au=oe((j2,ou)=>{var su=La(),im=Pa(),He=lr();ou.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new im.MainHeader,d=!1,u=null;let x=new Set,p=e,{noSort:g,decoder:_}=p;t?v(p.readEntries):d=!0;function S(){let T=new Set;for(let R of Object.keys(i)){let P=R.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let k=P.slice(0,y+1).join("/")+"/";T.add(k)}}for(let R of T)if(!(R in i)){let P=new su(p);P.entryName=R,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function w(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/He.Constants.CENHDR)throw He.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var T=c.offset,R=0;R<r.length;R++){var P=T,y=new su(p,t);y.header=t.slice(P,P+=He.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),T+=y.header.centralHeaderSize,r[R]=y,i[y.entryName]=y}x.clear(),S()}function v(T){var R=t.length-He.Constants.ENDHDR,P=Math.max(0,R-65535),y=P,k=t.length,O=-1,F=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),R;R>=y;R--)if(t[R]===80){if(t.readUInt32LE(R)===He.Constants.ENDSIG){O=R,F=R,k=R+He.Constants.ENDHDR,y=R-He.Constants.END64HDR;continue}if(t.readUInt32LE(R)===He.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(R)===He.Constants.ZIP64SIG){O=R,k=R+He.readBigUInt64LE(t,R+He.Constants.ZIP64SIZE)+He.Constants.ZIP64LEAD;break}}if(O==-1)throw He.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,k)),c.commentLength&&(o=t.slice(F+He.Constants.ENDHDR)),T&&w()}function I(){r.length>1&&!g&&r.sort((T,R)=>T.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return d||w(),r.filter(T=>!x.has(T))},get comment(){return _.decode(o)},set comment(T){o=He.toBuffer(T,_.encode),c.commentLength=o.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(T){this.entries.forEach(T)},getEntry:function(T){return d||w(),i[T]||null},setEntry:function(T){d||w(),r.push(T),i[T.entryName]=T,c.totalEntries=r.length},deleteFile:function(T,R=!0){d||w();let P=i[T];this.getEntryChildren(P,R).map(k=>k.entryName).forEach(this.deleteEntry)},deleteEntry:function(T){d||w();let R=i[T],P=r.indexOf(R);P>=0&&(r.splice(P,1),delete i[T],c.totalEntries=r.length)},getEntryChildren:function(T,R=!0){if(d||w(),typeof T=="object")if(T.isDirectory&&R){let P=[],y=T.entryName;for(let k of r)k.entryName.startsWith(y)&&P.push(k);return P}else return[T];return[]},getChildCount:function(T){if(T&&T.isDirectory){let R=this.getEntryChildren(T);return R.includes(T)?R.length-1:R.length}return 0},compressToBuffer:function(){d||w(),I();let T=[],R=[],P=0,y=0;c.size=0,c.offset=0;let k=0;for(let N of this.entries){let J=N.getCompressedData();N.header.offset=y;let K=N.packLocalHeader(),ee=K.length+J.length;y+=ee,T.push(K),T.push(J);let Z=N.packCentralHeader();R.push(Z),c.size+=Z.length,P+=ee+Z.length,k++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=k,y=0;let O=Buffer.alloc(P);for(let N of T)N.copy(O,y),y+=N.length;for(let N of R)N.copy(O,y),y+=N.length;let F=c.toBinary();return o&&o.copy(F,He.Constants.ENDHDR),F.copy(O,y),t=O,d=!1,O},toAsyncBuffer:function(T,R,P,y){try{d||w(),I();let k=[],O=[],F=0,N=0,J=0;c.size=0,c.offset=0;let K=function(ee){if(ee.length>0){let Z=ee.shift(),re=Z.entryName+Z.extra.toString();P&&P(re),Z.getCompressedDataAsync(function(se){y&&y(re),Z.header.offset=N;let L=Z.packLocalHeader(),H=L.length+se.length;N+=H,k.push(L),k.push(se);let W=Z.packCentralHeader();O.push(W),c.size+=W.length,F+=H+W.length,J++,K(ee)})}else{F+=c.mainHeaderSize,c.offset=N,c.totalEntries=J,N=0;let Z=Buffer.alloc(F);k.forEach(function(se){se.copy(Z,N),N+=se.length}),O.forEach(function(se){se.copy(Z,N),N+=se.length});let re=c.toBinary();o&&o.copy(re,He.Constants.ENDHDR),re.copy(Z,N),t=Z,d=!1,T(Z)}};K(Array.from(this.entries))}catch(k){R(k)}}}}});var lu=oe((q2,du)=>{var _e=lr(),we=le("path"),sm=La(),om=au(),Dn=(...t)=>_e.findLast(t,e=>typeof e=="boolean"),cu=(...t)=>_e.findLast(t,e=>typeof e=="string"),am=(...t)=>_e.findLast(t,e=>typeof e=="function"),cm={noSort:!1,readEntries:!1,method:_e.Constants.NONE,fs:null};du.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),cm);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 om(r,i),{canonical:d,sanitize:u,zipnamefix:x}=_e;function p(w){if(w&&c){var v;if(typeof w=="string"&&(v=c.getEntry(we.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 g(w){let{join:v,normalize:I,sep:T}=we.posix;return v(we.isAbsolute(w)?"/":".",I(T+w.split("\\").join(T)+T))}function _(w){return w instanceof RegExp?(function(v){return function(I){return v.test(I)}})(w):typeof w!="function"?()=>!0:w}let S=(w,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",we.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 T=I.getData();if(T&&T.length)return T.toString(v||"utf8")}return""},readAsTextAsync:function(w,v,I){var T=p(w);T?T.getDataAsync(function(R,P){if(P){v(R,P);return}R&&R.length?v(R.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,T){if(o.fs.existsSync(w)){v=v?g(v):"";let R=we.win32.basename(we.win32.normalize(w));v+=I||R;let P=o.fs.statSync(w),y=P.isFile()?o.fs.readFileSync(w):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,y,T,P)}else throw _e.Errors.FILE_NOT_FOUND(w)},addLocalFileAsync:function(w,v){w=typeof w=="object"?w:{localPath:w};let I=we.resolve(w.localPath),{comment:T}=w,{zipPath:R,zipName:P}=w,y=this;o.fs.stat(I,function(k,O){if(k)return v(k,!1);R=R?g(R):"";let F=we.win32.basename(we.win32.normalize(I));if(R+=P||F,O.isFile())o.fs.readFile(I,function(N,J){return N?v(N,!1):(y.addFile(R,J,T,O),setImmediate(v,void 0,!0))});else if(O.isDirectory())return R+=o.sep,y.addFile(R,Buffer.alloc(0),T,O),setImmediate(v,void 0,!0)})},addLocalFolder:function(w,v,I){if(I=_(I),v=v?g(v):"",w=we.normalize(w),o.fs.existsSync(w)){let T=o.findFiles(w),R=this;if(T.length)for(let P of T){let y=we.join(v,S(w,P));I(y)&&R.addLocalFile(P,we.dirname(y))}}else throw _e.Errors.FILE_NOT_FOUND(w)},addLocalFolderAsync:function(w,v,I,T){T=_(T),I=I?g(I):"",w=we.normalize(w);var R=this;o.fs.open(w,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,_e.Errors.FILE_NOT_FOUND(w));else if(P)v(void 0,P);else{var y=o.findFiles(w),k=-1,O=function(){if(k+=1,k<y.length){var F=y[k],N=S(w,F).split("\\").join("/");N=N.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),T(N)?o.fs.stat(F,function(J,K){J&&v(void 0,J),K.isFile()?o.fs.readFile(F,function(ee,Z){ee?v(void 0,ee):(R.addFile(I+N,Z,"",K),O())}):(R.addFile(I+N+"/",Buffer.alloc(0),"",K),O())}):process.nextTick(()=>{O()})}else v(!0,void 0)};O()}})},addLocalFolderAsync2:function(w,v){let I=this;w=typeof w=="object"?w:{localPath:w},localPath=we.resolve(g(w.localPath));let{zipPath:T,filter:R,namefix:P}=w;R instanceof RegExp?R=(function(O){return function(F){return O.test(F)}})(R):typeof R!="function"&&(R=function(){return!0}),T=T?g(T):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let y=O=>we.join(T,P(S(localPath,O))),k=O=>we.win32.basename(we.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?v(void 0,_e.Errors.FILE_NOT_FOUND(localPath)):O?v(void 0,O):o.findFilesAsync(localPath,function(F,N){if(F)return v(F);N=N.filter(J=>R(y(J))),N.length||v(void 0,!1),setImmediate(N.reverse().reduce(function(J,K){return function(ee,Z){if(ee||Z===!1)return setImmediate(J,ee,!1);I.addLocalFileAsync({localPath:K,zipPath:we.dirname(y(K)),zipName:k(K)},J)}},v))})})},addLocalFolderPromise:function(w,v){return new Promise((I,T)=>{this.addLocalFolderAsync2(Object.assign({localPath:w},v),(R,P)=>{R&&T(R),P&&I(this)})})},addFile:function(w,v,I,T){w=x(w);let R=p(w),P=R!=null;P||(R=new sm(i),R.entryName=w),R.comment=I||"";let y=typeof T=="object"&&T instanceof o.fs.Stats;y&&(R.header.time=T.mtime);var k=R.isDirectory?16:0;let O=R.isDirectory?16384:32768;return y?O|=4095&T.mode:typeof T=="number"?O|=4095&T:O|=R.isDirectory?493:420,k=(k|O<<16)>>>0,R.attr=k,R.setData(v),P||c.setEntry(R),R},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,T,R,P){T=Dn(!1,T),R=Dn(!1,R),I=Dn(!0,I),P=cu(R,P);var y=p(w);if(!y)throw _e.Errors.NO_ENTRY();var k=d(y.entryName),O=u(v,P&&!y.isDirectory?P:I?k:we.basename(k));if(y.isDirectory){var F=c.getEntryChildren(y);return F.forEach(function(K){if(K.isDirectory)return;var ee=K.getData();if(!ee)throw _e.Errors.CANT_EXTRACT_FILE();var Z=d(K.entryName),re=u(v,I?Z:we.basename(Z));let se=R?K.header.fileAttr:void 0;o.writeFileTo(re,ee,T,se)}),!0}var N=y.getData(c.password);if(!N)throw _e.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!T)throw _e.Errors.CANT_OVERRIDE();let J=R?w.header.fileAttr:void 0;return o.writeFileTo(O,N,T,J),!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,T){if(I=Dn(!1,I),T=cu(I,T),v=Dn(!1,v),!c)throw _e.Errors.NO_ZIP();c.entries.forEach(function(R){var P=u(w,d(R.entryName));if(R.isDirectory){o.makeDir(P);return}var y=R.getData(T);if(!y)throw _e.Errors.CANT_EXTRACT_FILE();let k=I?R.header.fileAttr:void 0;o.writeFileTo(P,y,v,k);try{o.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw _e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(w,v,I,T){if(T=am(v,I,T),I=Dn(!1,I),v=Dn(!1,v),!T)return new Promise((O,F)=>{this.extractAllToAsync(w,v,I,function(N){N?F(N):O(this)})});if(!c){T(_e.Errors.NO_ZIP());return}w=we.resolve(w);let R=O=>u(w,we.normalize(d(O.entryName))),P=(O,F)=>new Error(O+': "'+F+'"'),y=[],k=[];c.entries.forEach(O=>{O.isDirectory?y.push(O):k.push(O)});for(let O of y){let F=R(O),N=I?O.header.fileAttr:void 0;try{o.makeDir(F),N&&o.fs.chmodSync(F,N),o.fs.utimesSync(F,O.header.time,O.header.time)}catch{T(P("Unable to create folder",F))}}k.reverse().reduce(function(O,F){return function(N){if(N)O(N);else{let J=we.normalize(d(F.entryName)),K=u(w,J);F.getDataAsync(function(ee,Z){if(Z)O(Z);else if(!ee)O(_e.Errors.CANT_EXTRACT_FILE());else{let re=I?F.header.fileAttr:void 0;o.writeFileToAsync(K,ee,v,re,function(se){se||O(P("Unable to write file",K)),o.fs.utimes(K,F.header.time,F.header.time,function(L){L?O(P("Unable to set times",K)):O()})})}})}}},T)()},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 T=o.writeFileTo(w,I,!0);typeof v=="function"&&v(T?null:new Error("failed"),"")}}},writeZipPromise:function(w,v){let{overwrite:I,perm:T}=Object.assign({overwrite:!0},v);return new Promise((R,P)=>{!w&&i.filename&&(w=i.filename),w||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let k=O=>O?R(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(w,y,I,T,k)},P)})},toBufferPromise:function(){return new Promise((w,v)=>{c.toAsyncBuffer(w,v)})},toBuffer:function(w,v,I,T){return typeof w=="function"?(c.toAsyncBuffer(w,v,I,T),null):c.compressToBuffer()}}}});import{execFile as h_,spawn as p_,spawnSync as cA}from"node:child_process";import{promisify as g_}from"node:util";function w_(t){if(process.platform!=="win32")return!1;if(kf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(kf,"").toLowerCase();return m_.has(r)}function Df(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return w_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function nt(t,e=[],r={}){return p_(t,e,Df(t,r))}function Pf(t,e=[],r={}){return __(t,e,Df(t,r))}var m_,kf,__,Vt=Ye(()=>{"use strict";m_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),kf=/\.(cmd|bat|ps1)$/i;__=g_(h_)});var Zt=oe((zR,ax)=>{"use strict";var sx=["nodebuffer","arraybuffer","fragments"],ox=typeof Blob<"u";ox&&sx.push("blob");ax.exports={BINARY_TYPES:sx,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ox,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Wi=oe((UR,Io)=>{"use strict";var{EMPTY_BUFFER:tb}=Zt(),ad=Buffer[Symbol.species];function nb(t,e){if(t.length===0)return tb;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new ad(r.buffer,r.byteOffset,i):r}function cx(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function dx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function rb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function cd(t){if(cd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new ad(t):ArrayBuffer.isView(t)?e=new ad(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),cd.readOnly=!1),e}Io.exports={concat:nb,mask:cx,toArrayBuffer:rb,toBuffer:cd,unmask:dx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");Io.exports.mask=function(e,r,i,o,c){c<48?cx(e,r,i,o,c):t.mask(e,r,i,o,c)},Io.exports.unmask=function(e,r){e.length<32?dx(e,r):t.unmask(e,r)}}catch{}});var fx=oe((GR,ux)=>{"use strict";var lx=Symbol("kDone"),dd=Symbol("kRun"),ld=class{constructor(e){this[lx]=()=>{this.pending--,this[dd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[dd]()}[dd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[lx])}}};ux.exports=ld});var Br=oe((HR,gx)=>{"use strict";var Ki=le("zlib"),xx=Wi(),ib=fx(),{kStatusCode:hx}=Zt(),sb=Buffer[Symbol.species],ob=Buffer.from([0,0,255,255]),To=Symbol("permessage-deflate"),Yt=Symbol("total-length"),Nr=Symbol("callback"),An=Symbol("buffers"),Mr=Symbol("error"),Ao,ud=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,!Ao){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ao=new ib(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[Nr];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){Ao.add(o=>{this._decompress(e,r,(c,d)=>{o(),i(c,d)})})}compress(e,r,i){Ao.add(o=>{this._compress(e,r,(c,d)=>{o(),i(c,d)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Ki.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Ki.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[To]=this,this._inflate[Yt]=0,this._inflate[An]=[],this._inflate.on("error",cb),this._inflate.on("data",px)}this._inflate[Nr]=i,this._inflate.write(e),r&&this._inflate.write(ob),this._inflate.flush(()=>{let c=this._inflate[Mr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=xx.concat(this._inflate[An],this._inflate[Yt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Yt]=0,this._inflate[An]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,d)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Ki.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Ki.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[Yt]=0,this._deflate[An]=[],this._deflate.on("data",ab)}this._deflate[Nr]=i,this._deflate.write(e),this._deflate.flush(Ki.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=xx.concat(this._deflate[An],this._deflate[Yt]);r&&(c=new sb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Nr]=null,this._deflate[Yt]=0,this._deflate[An]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};gx.exports=ud;function ab(t){this[An].push(t),this[Yt]+=t.length}function px(t){if(this[Yt]+=t.length,this[To]._maxPayload<1||this[Yt]<=this[To]._maxPayload){this[An].push(t);return}this[Mr]=new RangeError("Max payload size exceeded"),this[Mr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Mr][hx]=1009,this.removeListener("data",px),this.reset()}function cb(t){if(this[To]._inflate=null,this[Mr]){this[Nr](this[Mr]);return}t[hx]=1007,this[Nr](t)}});var Fr=oe((jR,Co)=>{"use strict";var{isUtf8:mx}=le("buffer"),{hasBlob:db}=Zt(),lb=[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 ub(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function fd(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 fb(t){return db&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Co.exports={isBlob:fb,isValidStatusCode:ub,isValidUTF8:fd,tokenChars:lb};if(mx)Co.exports.isValidUTF8=function(t){return t.length<24?fd(t):mx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Co.exports.isValidUTF8=function(e){return e.length<32?fd(e):t(e)}}catch{}});var md=oe((qR,Ix)=>{"use strict";var{Writable:xb}=le("stream"),_x=Br(),{BINARY_TYPES:hb,EMPTY_BUFFER:yx,kStatusCode:pb,kWebSocket:gb}=Zt(),{concat:xd,toArrayBuffer:mb,unmask:wb}=Wi(),{isValidStatusCode:_b,isValidUTF8:Ex}=Fr(),Ro=Buffer[Symbol.species],lt=0,bx=1,vx=2,Sx=3,hd=4,pd=5,ko=6,gd=class extends xb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||hb[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[gb]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}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 lt:this.getInfo(e);break;case bx:this.getPayloadLength16(e);break;case vx:this.getPayloadLength64(e);break;case Sx:this.getMask();break;case hd:this.getData(e);break;case pd:case ko: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[_x.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=bx:this._payloadLength===127?this._state=vx:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Sx:this._state=hd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=hd}getData(e){let r=yx;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&&wb(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=pd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[_x.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let d=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=xd(i,r):this._binaryType==="arraybuffer"?o=mb(xd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=xd(i,r);if(!this._skipUTF8Validation&&!Ex(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===pd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit("message",o,!1),this._state=lt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,yx),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 Ro(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ex(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=lt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=lt):(this._state=ko,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=lt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let d=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[pb]=o,d}};Ix.exports=gd});var yd=oe((KR,Cx)=>{"use strict";var{Duplex:WR}=le("stream"),{randomFillSync:yb}=le("crypto"),{types:{isUint8Array:Eb}}=le("util"),Ax=Br(),{EMPTY_BUFFER:bb,kWebSocket:vb,NOOP:Sb}=Zt(),{isBlob:zr,isValidStatusCode:Ib}=Fr(),{mask:Tx,toBuffer:Kn}=Wi(),ut=Symbol("kByteLength"),Ab=Buffer.alloc(4),Do=8*1024,$n,Ur=Do,St=0,Tb=1,Cb=2,wd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=St,this.onerror=Sb,this[vb]=void 0}static frame(e,r){let i,o=!1,c=2,d=!1;r.mask&&(i=r.maskBuffer||Ab,r.generateMask?r.generateMask(i):(Ur===Do&&($n===void 0&&($n=Buffer.alloc(Do)),yb($n,0,Do),Ur=0),i[0]=$n[Ur++],i[1]=$n[Ur++],i[2]=$n[Ur++],i[3]=$n[Ur++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[ut]!==void 0?u=r[ut]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!d);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(o?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(u,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],d?[p,e]:o?(Tx(e,i,p,c,u),[p]):(Tx(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=bb;else{if(typeof e!="number"||!Ib(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");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(Eb(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let d={[ut]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==St?this.enqueue([this.dispatch,c,!1,d,o]):this.sendFrame(t.frame(c,d),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):zr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};zr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==St?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):zr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};zr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==St?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}send(e,r,i){let o=this._extensions[Ax.extensionName],c=r.binary?2:1,d=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):zr(e)?(u=e.size,x=!1):(e=Kn(e),u=e.length,x=Kn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=o._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[ut]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:d};zr(e)?this._state!==St?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==St?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=Cb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(_d,this,u,o);return}this._bufferedBytes-=i[ut];let d=Kn(c);r?this.dispatch(d,r,i,o):(this._state=St,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(Rb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ax.extensionName];this._bufferedBytes+=i[ut],this._state=Tb,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");_d(this,x,o);return}this._bufferedBytes-=i[ut],this._state=St,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===St&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][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)}};Cx.exports=wd;function _d(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function Rb(t,e,r){_d(t,e,r),t.onerror(e)}});var Bx=oe(($R,Mx)=>{"use strict";var{kForOnEventAttribute:$i,kListener:Ed}=Zt(),Rx=Symbol("kCode"),kx=Symbol("kData"),Dx=Symbol("kError"),Px=Symbol("kMessage"),Ox=Symbol("kReason"),Gr=Symbol("kTarget"),Lx=Symbol("kType"),Nx=Symbol("kWasClean"),Xt=class{constructor(e){this[Gr]=null,this[Lx]=e}get target(){return this[Gr]}get type(){return this[Lx]}};Object.defineProperty(Xt.prototype,"target",{enumerable:!0});Object.defineProperty(Xt.prototype,"type",{enumerable:!0});var Vn=class extends Xt{constructor(e,r={}){super(e),this[Rx]=r.code===void 0?0:r.code,this[Ox]=r.reason===void 0?"":r.reason,this[Nx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Rx]}get reason(){return this[Ox]}get wasClean(){return this[Nx]}};Object.defineProperty(Vn.prototype,"code",{enumerable:!0});Object.defineProperty(Vn.prototype,"reason",{enumerable:!0});Object.defineProperty(Vn.prototype,"wasClean",{enumerable:!0});var Hr=class extends Xt{constructor(e,r={}){super(e),this[Dx]=r.error===void 0?null:r.error,this[Px]=r.message===void 0?"":r.message}get error(){return this[Dx]}get message(){return this[Px]}};Object.defineProperty(Hr.prototype,"error",{enumerable:!0});Object.defineProperty(Hr.prototype,"message",{enumerable:!0});var Vi=class extends Xt{constructor(e,r={}){super(e),this[kx]=r.data===void 0?null:r.data}get data(){return this[kx]}};Object.defineProperty(Vi.prototype,"data",{enumerable:!0});var kb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[$i]&&o[Ed]===e&&!o[$i])return;let i;if(t==="message")i=function(c,d){let u=new Vi("message",{data:d?c:c.toString()});u[Gr]=this,Po(e,this,u)};else if(t==="close")i=function(c,d){let u=new Vn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Gr]=this,Po(e,this,u)};else if(t==="error")i=function(c){let d=new Hr("error",{error:c,message:c.message});d[Gr]=this,Po(e,this,d)};else if(t==="open")i=function(){let c=new Xt("open");c[Gr]=this,Po(e,this,c)};else return;i[$i]=!!r[$i],i[Ed]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Ed]===e&&!r[$i]){this.removeListener(t,r);break}}};Mx.exports={CloseEvent:Vn,ErrorEvent:Hr,Event:Xt,EventTarget:kb,MessageEvent:Vi};function Po(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Oo=oe((VR,Fx)=>{"use strict";var{tokenChars:Ji}=Fr();function Mt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Db(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,d,u,x=-1,p=-1,g=-1,_=0;for(;_<t.length;_++)if(p=t.charCodeAt(_),d===void 0)if(g===-1&&Ji[p]===1)x===-1&&(x=_);else if(_!==0&&(p===32||p===9))g===-1&&x!==-1&&(g=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let w=t.slice(x,g);p===44?(Mt(e,w,r),r=Object.create(null)):d=w,x=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(g===-1&&Ji[p]===1)x===-1&&(x=_);else if(p===32||p===9)g===-1&&x!==-1&&(g=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_),Mt(r,t.slice(x,g),!0),p===44&&(Mt(e,d,r),r=Object.create(null),d=void 0),x=g=-1}else if(p===61&&x!==-1&&g===-1)u=t.slice(x,_),x=g=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(Ji[p]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);x===-1?x=_:i||(i=!0),o=!1}else if(c)if(Ji[p]===1)x===-1&&(x=_);else if(p===34&&x!==-1)c=!1,g=_;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(g===-1&&Ji[p]===1)x===-1&&(x=_);else if(x!==-1&&(p===32||p===9))g===-1&&(g=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let w=t.slice(x,g);i&&(w=w.replace(/\\/g,""),i=!1),Mt(r,u,w),p===44&&(Mt(e,d,r),r=Object.create(null),d=void 0),u=void 0,x=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");g===-1&&(g=_);let S=t.slice(x,g);return d===void 0?Mt(e,S,r):(u===void 0?Mt(r,S,!0):i?Mt(r,u,S.replace(/\\/g,"")):Mt(r,u,S),Mt(e,d,r)),e}function Pb(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(d=>d===!0?o:`${o}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Fx.exports={format:Pb,parse:Db}});var Bo=oe((YR,Zx)=>{"use strict";var Ob=le("events"),Lb=le("https"),Nb=le("http"),Gx=le("net"),Mb=le("tls"),{randomBytes:Bb,createHash:Fb}=le("crypto"),{Duplex:JR,Readable:ZR}=le("stream"),{URL:bd}=le("url"),Tn=Br(),zb=md(),Ub=yd(),{isBlob:Gb}=Fr(),{BINARY_TYPES:zx,CLOSE_TIMEOUT:Hb,EMPTY_BUFFER:Lo,GUID:jb,kForOnEventAttribute:vd,kListener:qb,kStatusCode:Wb,kWebSocket:Ue,NOOP:Hx}=Zt(),{EventTarget:{addEventListener:Kb,removeEventListener:$b}}=Bx(),{format:Vb,parse:Jb}=Oo(),{toBuffer:Zb}=Wi(),jx=Symbol("kAborted"),Sd=[8,13],Qt=["CONNECTING","OPEN","CLOSING","CLOSED"],Yb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pe=class t extends Ob{constructor(e,r,i){super(),this._binaryType=zx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Lo,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),qx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){zx.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 zb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Ub(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ue]=this,c[Ue]=this,e[Ue]=this,o.on("conclude",e1),o.on("drain",t1),o.on("error",n1),o.on("message",r1),o.on("ping",i1),o.on("pong",s1),c.onerror=o1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",$x),e.on("data",Mo),e.on("end",Vx),e.on("error",Jx),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[Tn.extensionName]&&this._extensions[Tn.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){Id(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Lo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Id(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Lo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Id(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Tn.extensionName]||(o.compress=!1),this._sender.send(e||Lo,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:Qt.indexOf("CONNECTING")});Object.defineProperty(pe.prototype,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(pe,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(pe.prototype,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(pe,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(pe.prototype,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(pe,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});Object.defineProperty(pe.prototype,"CLOSED",{enumerable:!0,value:Qt.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[vd])return e[qb];return null},set(e){for(let r of this.listeners(t))if(r[vd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[vd]:!0})}})});pe.prototype.addEventListener=Kb;pe.prototype.removeEventListener=$b;Zx.exports=pe;function qx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Hb,protocolVersion:Sd[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Sd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Sd.join(", ")})`);let c;if(e instanceof bd)c=e;else try{c=new bd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!d&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;No(t,I);return}let p=d?443:80,g=Bb(16).toString("base64"),_=d?Lb.request:Nb.request,S=new Set,w;if(o.createConnection=o.createConnection||(d?Qb:Xb),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":g,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(w=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Vb({[Tn.extensionName]:w.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Yb.test(I)||S.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[T,R]of Object.entries(I))i.headers[T.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!d)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=_(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[jx]||(v=t._req=null,No(t,I))}),v.on("response",I=>{let T=I.headers.location,R=I.statusCode;if(T&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){ot(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new bd(T,e)}catch{let k=new SyntaxError(`Invalid URL: ${T}`);No(t,k);return}qx(t,P,r,i)}else t.emit("unexpected-response",v,I)||ot(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,T,R)=>{if(t.emit("upgrade",I),t.readyState!==pe.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){ot(t,T,"Invalid Upgrade header");return}let y=Fb("sha1").update(g+jb).digest("base64");if(I.headers["sec-websocket-accept"]!==y){ot(t,T,"Invalid Sec-WebSocket-Accept header");return}let k=I.headers["sec-websocket-protocol"],O;if(k!==void 0?S.size?S.has(k)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":S.size&&(O="Server sent no subprotocol"),O){ot(t,T,O);return}k&&(t._protocol=k);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!w){ot(t,T,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let N;try{N=Jb(F)}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(N);if(J.length!==1||J[0]!==Tn.extensionName){ot(t,T,"Server indicated an extension that was not requested");return}try{w.accept(N[Tn.extensionName])}catch{ot(t,T,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=w}t.setSocket(T,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,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 Xb(t){return t.path=t.socketPath,Gx.connect(t)}function Qb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Gx.isIP(t.host)?"":t.host),Mb.connect(t)}function ot(t,e,r){t._readyState=pe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[jx]=!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 Id(t,e,r){if(e){let i=Gb(e)?e.size:Zb(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Qt[t.readyState]})`);process.nextTick(r,i)}}function e1(t,e){let r=this[Ue];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ue]!==void 0&&(r._socket.removeListener("data",Mo),process.nextTick(Wx,r._socket),t===1005?r.close():r.close(t,e))}function t1(){let t=this[Ue];t.isPaused||t._socket.resume()}function n1(t){let e=this[Ue];e._socket[Ue]!==void 0&&(e._socket.removeListener("data",Mo),process.nextTick(Wx,e._socket),e.close(t[Wb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ux(){this[Ue].emitClose()}function r1(t,e){this[Ue].emit("message",t,e)}function i1(t){let e=this[Ue];e._autoPong&&e.pong(t,!this._isServer,Hx),e.emit("ping",t)}function s1(t){this[Ue].emit("pong",t)}function Wx(t){t.resume()}function o1(t){let e=this[Ue];e.readyState!==pe.CLOSED&&(e.readyState===pe.OPEN&&(e._readyState=pe.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 $x(){let t=this[Ue];if(this.removeListener("close",$x),this.removeListener("data",Mo),this.removeListener("end",Vx),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[Ue]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ux),t._receiver.on("finish",Ux))}function Mo(t){this[Ue]._receiver.write(t)||this.pause()}function Vx(){let t=this[Ue];t._readyState=pe.CLOSING,t._receiver.end(),this.end()}function Jx(){let t=this[Ue];this.removeListener("error",Jx),this.on("error",Hx),t&&(t._readyState=pe.CLOSING,this.destroy())}});var eh=oe((QR,Qx)=>{"use strict";var XR=Bo(),{Duplex:a1}=le("stream");function Yx(t){t.emit("close")}function c1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Xx(t){this.removeListener("error",Xx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function d1(t,e){let r=!0,i=new a1({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Yx,i);return}let d=!1;t.once("error",function(x){d=!0,c(x)}),t.once("close",function(){d||c(o),process.nextTick(Yx,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,d){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,d)});return}t.send(o,d)},i.on("end",c1),i.on("error",Xx),i}Qx.exports=d1});var Ad=oe((ek,th)=>{"use strict";var{tokenChars:l1}=Fr();function u1(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let d=t.charCodeAt(o);if(i===-1&&l1[d]===1)r===-1&&(r=o);else if(o!==0&&(d===32||d===9))i===-1&&r!==-1&&(i=o);else if(d===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}th.exports={parse:u1}});var ch=oe((nk,ah)=>{"use strict";var f1=le("events"),Fo=le("http"),{Duplex:tk}=le("stream"),{createHash:x1}=le("crypto"),nh=Oo(),Jn=Br(),h1=Ad(),p1=Bo(),{CLOSE_TIMEOUT:g1,GUID:m1,kWebSocket:w1}=Zt(),_1=/^[+/0-9A-Za-z]{22}==$/,rh=0,ih=1,oh=2,Td=class extends f1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:g1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:p1,...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=Fo.createServer((i,o)=>{let c=Fo.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=y1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,d)=>{this.handleUpgrade(o,c,d,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=rh}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===oh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Zi,this);return}if(e&&this.once("close",e),this._state!==ih)if(this._state=ih,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(Zi,this):process.nextTick(Zi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Zi(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",sh);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Zn(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){Zn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!_1.test(c)){Zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Zn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Yi(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=h1.parse(x)}catch{Zn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let g=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&g!==void 0){let S=new Jn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let w=nh.parse(g);w[Jn.extensionName]&&(S.accept(w[Jn.extensionName]),_[Jn.extensionName]=S)}catch{Zn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(w,v,I,T)=>{if(!w)return Yi(r,v||401,I,T);this.completeUpgrade(_,c,p,e,r,i,o)});return}if(!this.options.verifyClient(S))return Yi(r,401)}this.completeUpgrade(_,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,d,u){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>rh)return Yi(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${x1("sha1").update(r+m1).digest("base64")}`],g=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: ${_}`),g._protocol=_)}if(e[Jn.extensionName]){let _=e[Jn.extensionName].params,S=nh.format({[Jn.extensionName]:[_]});p.push(`Sec-WebSocket-Extensions: ${S}`),g._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&ns(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as xg,mkdirSync as pg}from"node:fs";import{join as gg}from"node:path";function hl(t){let e=t.retentionDays??_g,r=t.clock??(()=>Tn(new Date));is={bridgeSink:new Vr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Vr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();ns(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])ns(t.agentLogsDir(o),"agent",i,e)}function yg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function xl(t){ba=t}function pl(t){return tr[ba]<=tr[t]}function gl(t,e){let r=tr[t];return r===void 0?!0:r>=tr[e]}function ss(t){fl={...t}}function ml(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`${Tn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function St(t,e,r,i,o){try{let c=`${JSON.stringify({ts:ml(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;pg(t,{recursive:!0}),xg(gg(t,er("bridge",Tn(new Date))),c)}catch{}}function Eg(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function rs(t,e,r,i,o){if(tr[t]<tr[ba])return;let c=`${JSON.stringify({ts:ml(new Date),level:t,module:e,msg:r,...fl,...i})}
|
|
12
|
+
`;if(is){let l=Eg(o,i),u=l?yg(is,l):is.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?wg.write(c):mg.write(c)}function G(t,e){return{debug:(r,i)=>rs("debug",t,r,i,e),info:(r,i)=>rs("info",t,r,i,e),warn:(r,i)=>rs("warn",t,r,i,e),error:(r,i)=>rs("error",t,r,i,e),child:r=>G(`${t}.${r}`,e),forAgent:r=>G(t,r)}}var tr,ba,mg,wg,fl,_g,is,te=Ye(()=>{"use strict";Qn();Ea();tr={debug:10,info:20,warn:30,error:40},ba=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),mg=process.stdout,wg=process.stderr,fl={},_g=He("COZE_BRIDGE_LOG_RETENTION_DAYS",30),is=null});var T,We=Ye(()=>{"use strict";T=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var El={};_a(El,{ACP_WRAPPER_NPM_PACKAGES:()=>Zr,_resetAcpInstallerForTests:()=>Tg,_setBinaryPathCacheForTests:()=>Rg,buildAcpSpawn:()=>Yr,ensureAcpInstalled:()=>nr,getAcpBinaryPath:()=>os,pickWhichLine:()=>Ia,probeAcpVersion:()=>Ag,resolveAcpCommand:()=>yl});import{readFileSync as wl}from"node:fs";import{createRequire as bg}from"node:module";import{dirname as vg,resolve as Sg}from"node:path";function Ia(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function Ig(t){let e=_l.resolve(`${t.npmPackage}/package.json`),r=vg(e),i=JSON.parse(wl(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 Sg(r,o)}async function nr(t,e){let r=Sa[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Jr.get(t);if(i)return i;try{let o=Ig(r);return Jr.set(t,o),va.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw va.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new T("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
|
|
13
|
+
`),{cause:o})}}async function Ag(t){let e=Sa[t];if(e)try{let r=_l.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(wl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){va.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function os(t){return Jr.get(t)}function yl(t,e){if(e)return e;let r=os(t);if(!r)throw new T("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Yr(t,e,r){if(e)return{command:e,args:[...r]};let i=yl(t);return{command:process.execPath,args:[i,...r]}}function Tg(){Jr.clear()}function Rg(t,e){Jr.set(t,e)}var va,Sa,Zr,_l,Jr,nn=Ye(()=>{"use strict";We();te();va=G("agents.acp-installer"),Sa={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Zr=Object.values(Sa).filter(t=>t!==void 0).map(t=>t.npmPackage),_l=bg(import.meta.url),Jr=new Map});import{chmod as kg,mkdir as Dg,readFile as Pg,rename as Sl,writeFile as Il}from"node:fs/promises";import{dirname as Og}from"node:path";async function rr(t){try{let e=await Pg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function ir(t,e,r){await Dg(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 Il(o,i,{encoding:"utf8",mode:r.mode}):await Il(o,i,"utf8"),await Sl(o,t),r?.mode!==void 0&&await kg(t,r.mode)}catch(c){await Sl(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Xr=Ye(()=>{"use strict"});import{promises as Al,readdirSync as Lg}from"node:fs";import{homedir as Ng}from"node:os";import{sep as Mg,join as Ae,resolve as Tl}from"node:path";function X(t){let e=t??Ng(),r=Ae(e,".coze"),i=Ae(r,"bridge"),o=Ae(i,"lib"),c=Ae(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ae(o,"index.js"),binDir:Ae(i,"bin"),pidFile:Ae(i,"bridge.pid"),portFile:Ae(i,"bridge.port"),tokenFile:Ae(i,"bridge.token"),patTokenFile:Ae(i,"pat-token"),agentEnvFile:Ae(i,"agent-env.json"),logFile:Ae(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ae(c,"daemon-stdio.log"),installLock:Ae(i,"install.lock"),configFile:Ae(i,"config.json"),agentsRoot:Ae(r,"agents")}}function Xe(t,e=X()){let r=Ae(e.agentsRoot,t);return{root:r,config:Ae(r,"config.json"),workspace:Ae(r,"workspace"),logs:Ae(r,"logs")}}function as(t=X()){try{return Lg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Qr(t,e){let r=await Al.realpath(Tl(t)).catch(()=>null);if(!r)return!1;let i=await Al.realpath(Tl(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+Mg)}var De=Ye(()=>{"use strict"});var ls={};_a(ls,{AGENT_CONFIG_FILE_MODE:()=>cs,enforceAgentConfigMode:()=>zg,loadAgentConfig:()=>Ne,persistAgentSessions:()=>ei,persistAgentSkills:()=>ds,saveAgentConfig:()=>Qe});import{chmod as Bg,stat as Fg}from"node:fs/promises";function Ne(t,e){return rr(Xe(t,e).config)}function Qe(t,e){return ir(Xe(t.agentId,e).config,t,{mode:cs})}async function zg(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!==cs&&(await Bg(r,cs),Rl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Rl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ei(t,e,r){let i=await Ne(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function ds(t,e,r){let i=await Ne(t,r);i&&(i.skills=e,await Qe(i,r))}var Rl,cs,rn=Ye(()=>{"use strict";Xr();te();De();Rl=G("agent-config"),cs=384});var Ra=oe((k2,Dl)=>{Dl.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 fs=oe(Ol=>{var Pl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Wg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Pl))Ol[t]=Wg(Pl[t])});var Fl=oe((P2,Bl)=>{var Kg=le("fs"),Pe=le("path"),Ll=Ra(),$g=fs(),Vg=typeof process=="object"&&process.platform==="win32",Nl=t=>typeof t=="object"&&t!==null,Ml=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ee(t){this.sep=Pe.sep,this.fs=Kg,Nl(t)&&Nl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Bl.exports=Ee;Ee.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var 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)};Ee.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Pe.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};Ee.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,h){if(l&&h.isDirectory())return o(!1);var x=Pe.dirname(t);c.fs.exists(x,function(m){m||c.makeDir(x),c.fs.open(t,"w",438,function(E,S){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let h=Pe.join(i,u),x=e.fs.statSync(h);(!o||o.test(h))&&l.push(Pe.normalize(h)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};Ee.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Pe.join(t,u),r.fs.stat(u,function(h,x){if(h)return e(h);x&&(i.push(Pe.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(m,E){if(m)return e(m);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Ml[(t^e)&255]^t>>>8};Ee.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ee.crc32update(r,t[i++]);return~r>>>0};Ee.methodToString=function(t){switch(t){case Ll.STORED:return"STORED ("+t+")";case Ll.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.posix.join(".",e)};Ee.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ee.sanitize=function(t,e){t=Pe.resolve(Pe.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Pe.normalize(Pe.join(t,r.slice(i,o).join(Pe.sep)));if(c.indexOf(t)===0)return c}return Pe.normalize(Pe.join(t,Pe.basename(e)))};Ee.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ee.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ee.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Ee.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Ee.isWin=Vg;Ee.crcTable=Ml});var Ul=oe((O2,zl)=>{var Jg=le("path");zl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Jg.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 ql=oe((L2,Gl)=>{Gl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var ar=oe((N2,or)=>{or.exports=Fl();or.exports.Constants=Ra();or.exports.Errors=fs();or.exports.FileAttr=Ul();or.exports.decoder=ql()});var Hl=oe((M2,jl)=>{var sn=ar(),z=sn.Constants;jl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,x=0,m=0,E=0,S=0,_=0,b=0;t|=sn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,R=y=>Math.max(0,y)&65535,k=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&z.FLG_EFS)>0},set flags_efs(y){y?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(y){y?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(y){switch(y){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=y},get time(){return sn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=sn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return k(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return l},set compressedSize(y){l=A(y)},get size(){return u},set size(y){u=A(y)},get fileNameLength(){return h},set fileNameLength(y){h=y},get extraLength(){return x},set extraLength(y){x=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=A(y)},get inAttr(){return S},set inAttr(y){S=A(y)},get attr(){return _},set attr(y){_=A(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return b},set offset(y){b=A(y)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+h+x+m},get realDataOffset(){return b+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var C=y.slice(b,b+z.LOCHDR);if(C.readUInt32LE(0)!==z.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=C.readUInt16LE(z.LOCVER),I.flags=C.readUInt16LE(z.LOCFLG),I.flags_desc=(I.flags&z.FLG_DESC)>0,I.method=C.readUInt16LE(z.LOCHOW),I.time=C.readUInt32LE(z.LOCTIM),I.crc=C.readUInt32LE(z.LOCCRC),I.compressedSize=C.readUInt32LE(z.LOCSIZ),I.size=C.readUInt32LE(z.LOCLEN),I.fnameLen=C.readUInt16LE(z.LOCNAM),I.extraLen=C.readUInt16LE(z.LOCEXT);let D=b+z.LOCHDR+I.fnameLen,B=D+I.extraLen;return y.slice(D,B)},loadFromBinary:function(y){if(y.length!==z.CENHDR||y.readUInt32LE(0)!==z.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(z.CENVEM),e=y.readUInt16LE(z.CENVER),r=y.readUInt16LE(z.CENFLG),i=y.readUInt16LE(z.CENHOW),o=y.readUInt32LE(z.CENTIM),c=y.readUInt32LE(z.CENCRC),l=y.readUInt32LE(z.CENSIZ),u=y.readUInt32LE(z.CENLEN),h=y.readUInt16LE(z.CENNAM),x=y.readUInt16LE(z.CENEXT),m=y.readUInt16LE(z.CENCOM),E=y.readUInt16LE(z.CENDSK),S=y.readUInt16LE(z.CENATT),_=y.readUInt32LE(z.CENATX),b=y.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(z.LOCHDR);return y.writeUInt32LE(z.LOCSIG,0),y.writeUInt16LE(e,z.LOCVER),y.writeUInt16LE(r,z.LOCFLG),y.writeUInt16LE(i,z.LOCHOW),y.writeUInt32LE(o,z.LOCTIM),y.writeUInt32LE(c,z.LOCCRC),y.writeUInt32LE(l,z.LOCSIZ),y.writeUInt32LE(u,z.LOCLEN),y.writeUInt16LE(h,z.LOCNAM),y.writeUInt16LE(I.extraLen,z.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(z.CENHDR+h+x+m);return y.writeUInt32LE(z.CENSIG,0),y.writeUInt16LE(t,z.CENVEM),y.writeUInt16LE(e,z.CENVER),y.writeUInt16LE(r,z.CENFLG),y.writeUInt16LE(i,z.CENHOW),y.writeUInt32LE(o,z.CENTIM),y.writeUInt32LE(c,z.CENCRC),y.writeUInt32LE(l,z.CENSIZ),y.writeUInt32LE(u,z.CENLEN),y.writeUInt16LE(h,z.CENNAM),y.writeUInt16LE(x,z.CENEXT),y.writeUInt16LE(m,z.CENCOM),y.writeUInt16LE(E,z.CENDSK),y.writeUInt16LE(S,z.CENATT),y.writeUInt32LE(_,z.CENATX),y.writeUInt32LE(b,z.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(h),extraLength:y(x),commentLength:y(m),diskNumStart:E,inAttr:S,attr:_,offset:b,centralHeaderSize:y(z.CENHDR+h+x+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Kl=oe((B2,Wl)=>{var cr=ar(),we=cr.Constants;Wl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return we.ENDHDR+o},loadFromBinary:function(c){if((c.length!==we.ENDHDR||c.readUInt32LE(0)!==we.ENDSIG)&&(c.length<we.ZIP64HDR||c.readUInt32LE(0)!==we.ZIP64SIG))throw cr.Errors.INVALID_END();c.readUInt32LE(0)===we.ENDSIG?(t=c.readUInt16LE(we.ENDSUB),e=c.readUInt16LE(we.ENDTOT),r=c.readUInt32LE(we.ENDSIZ),i=c.readUInt32LE(we.ENDOFF),o=c.readUInt16LE(we.ENDCOM)):(t=cr.readBigUInt64LE(c,we.ZIP64SUB),e=cr.readBigUInt64LE(c,we.ZIP64TOT),r=cr.readBigUInt64LE(c,we.ZIP64SIZE),i=cr.readBigUInt64LE(c,we.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(we.ENDHDR+o);return c.writeUInt32LE(we.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,we.ENDSUB),c.writeUInt16LE(e,we.ENDTOT),c.writeUInt32LE(r,we.ENDSIZ),c.writeUInt32LE(i,we.ENDOFF),c.writeUInt16LE(o,we.ENDCOM),c.fill(" ",we.ENDHDR),c},toJSON:function(){let c=function(l,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 ka=oe(Ca=>{Ca.EntryHeader=Hl();Ca.MainHeader=Kl()});var Vl=oe((z2,$l)=>{$l.exports=function(t){var e=le("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var x=0;x<c.length;x++){var m=c[x];m.copy(u,h),h+=m.length}i&&i(u)}),o.end(t)}}}});var Zl=oe((U2,Jl)=>{var Zg=+(process.versions?process.versions.node:"").split(".")[0]||0;Jl.exports=function(t,e){var r=le("zlib");let i=Zg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),x=0;h.fill(0);for(var m=0;m<l.length;m++){var E=l[m];E.copy(h,x),x+=E.length}o&&o(h)}),c.end(t)}}}});var tu=oe((G2,eu)=>{"use strict";var{randomFillSync:Yl}=le("crypto"),Yg=fs(),Xg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Ql=(t,e)=>Math.imul(t,e)>>>0,Xl=(t,e)=>Xg[(t^e)&255]^t>>>8,ti=()=>typeof Yl=="function"?Yl(Buffer.alloc(12)):ti.node();ti.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 hs={genSalt:ti};function xs(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}xs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Xl(e[0],t),e[1]+=e[0]&255,e[1]=Ql(e[1],134775813)+1,e[2]=Xl(e[2],e[1]>>>24),t};xs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ql(t,t^1)>>8&255};function Qg(t){let e=new xs(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function em(t){let e=new xs(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 tm(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Qg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Yg.WRONG_PASSWORD();return i(t.slice(12))}function nm(t){Buffer.isBuffer(t)&&t.length>=12?hs.genSalt=function(){return t.slice(0,12)}:t==="node"?hs.genSalt=ti.node:hs.genSalt=ti}function rm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=em(r),c=hs.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)}eu.exports={decrypt:tm,encrypt:rm,_salter:nm}});var nu=oe(ps=>{ps.Deflater=Vl();ps.Inflater=Zl();ps.ZipCrypto=tu()});var Pa=oe((j2,ru)=>{var ae=ar(),im=ka(),be=ae.Constants,Da=nu();ru.exports=function(t,e){var r=new im.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),x=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:ae.decoder;x=E.hasOwnProperty("efs")?E.efs:!1;function S(){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(ae.crc32(y)!==r.localHeader.crc)return!1}else{let C={},D=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(D)==be.LOCSIG||e.readUInt32LE(D)==be.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(D)==be.EXTSIG)C.crc=e.readUInt32LE(D+be.EXTCRC),C.compressedSize=e.readUInt32LE(D+be.EXTSIZ),C.size=e.readUInt32LE(D+be.EXTLEN);else if(e.readUInt16LE(D+12)===19280)C.crc=e.readUInt32LE(D+be.EXTCRC-4),C.compressedSize=e.readUInt32LE(D+be.EXTSIZ-4),C.size=e.readUInt32LE(D+be.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(y)!==C.crc)return!1}return!0}function b(y,C,D){if(typeof C>"u"&&typeof y=="string"&&(D=y,y=void 0),c)return y&&C&&C(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=S();if(B.length===0)return y&&C&&C(B),B;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw ae.Errors.INVALID_PASS_PARAM();B=Da.ZipCrypto.decrypt(B,r,D)}var M=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(B.copy(M),_(M))return y&&C&&C(M),M;throw y&&C&&C(M,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var J=new Da.Inflater(B,r.size);if(y)J.inflateAsync(function(V){V.copy(V,0),C&&(_(V)?C(V):C(V,ae.Errors.BAD_CRC()))});else{if(J.inflate(M).copy(M,0),!_(M))throw ae.Errors.BAD_CRC(`"${E.decode(i)}"`);return M}break;default:throw y&&C&&C(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function I(y,C){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&C&&C(S()),S();if(l.length&&!c){var D;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(l.length),l.copy(D),y&&C&&C(D),D;default:case ae.Constants.DEFLATED:var B=new Da.Deflater(l);if(y)B.deflateAsync(function(J){D=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(D),C&&C(D)});else{var M=B.deflate();return r.compressedSize=M.length,M}B=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,C){return ae.readBigUInt64LE(y,C)}function R(y){try{for(var C=0,D,B,M;C+4<y.length;)D=y.readUInt16LE(C),C+=2,B=y.readUInt16LE(C),C+=2,M=y.slice(C,C+B),C+=B,be.ID_ZIP64===D&&k(M)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function k(y){var C,D,B,M;y.length>=be.EF_ZIP64_SCOMP&&(C=A(y,be.EF_ZIP64_SUNCOMP),r.size===be.EF_ZIP64_OR_32&&(r.size=C)),y.length>=be.EF_ZIP64_RHO&&(D=A(y,be.EF_ZIP64_SCOMP),r.compressedSize===be.EF_ZIP64_OR_32&&(r.compressedSize=D)),y.length>=be.EF_ZIP64_DSN&&(B=A(y,be.EF_ZIP64_RHO),r.offset===be.EF_ZIP64_OR_32&&(r.offset=B)),y.length>=be.EF_ZIP64_DSN+4&&(M=y.readUInt32LE(be.EF_ZIP64_DSN),r.diskNumStart===be.EF_ZIP64_OR_16&&(r.diskNumStart=M))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(y){i=ae.toBuffer(y,E.encode);var C=i[i.length-1];c=C===47||C===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,R(y)},get comment(){return E.decode(o)},set comment(y){if(o=ae.toBuffer(y,E.encode),r.commentLength=o.length,o.length>65535)throw ae.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=ae.toBuffer(y,ae.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ae.Constants.DEFLATED,r.crc=ae.crc32(y),r.changed=!0):r.method=ae.Constants.STORED},getData:function(y){return r.changed?l:b(!1,null,y)},getDataAsync:function(y,C){r.changed?y(l):b(!0,y,C)},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(),C=ae.Constants.CENHDR;return i.copy(y,C),C+=i.length,u.copy(y,C),C+=r.extraLength,o.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let C=r.localHeaderToBinary(),D=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(D,y),y+=C.length,i.copy(D,y),y+=i.length,h.copy(D,y),y+=h.length,D},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ou=oe((H2,su)=>{var iu=Pa(),sm=ka(),qe=ar();su.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new sm.MainHeader,l=!1,u=null;let h=new Set,x=e,{noSort:m,decoder:E}=x;t?b(x.readEntries):l=!0;function S(){let A=new Set;for(let R of Object.keys(i)){let k=R.split("/");if(k.pop(),!!k.length)for(let y=0;y<k.length;y++){let C=k.slice(0,y+1).join("/")+"/";A.add(C)}}for(let R of A)if(!(R in i)){let k=new iu(x);k.entryName=R,k.attr=16,k.temporary=!0,r.push(k),i[k.entryName]=k,h.add(k)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/qe.Constants.CENHDR)throw qe.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,R=0;R<r.length;R++){var k=A,y=new iu(x,t);y.header=t.slice(k,k+=qe.Constants.CENHDR),y.entryName=t.slice(k,k+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(k,k+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(k,k+y.header.commentLength)),A+=y.header.centralHeaderSize,r[R]=y,i[y.entryName]=y}h.clear(),S()}function b(A){var R=t.length-qe.Constants.ENDHDR,k=Math.max(0,R-65535),y=k,C=t.length,D=-1,B=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(k=0),R;R>=y;R--)if(t[R]===80){if(t.readUInt32LE(R)===qe.Constants.ENDSIG){D=R,B=R,C=R+qe.Constants.ENDHDR,y=R-qe.Constants.END64HDR;continue}if(t.readUInt32LE(R)===qe.Constants.END64SIG){y=k;continue}if(t.readUInt32LE(R)===qe.Constants.ZIP64SIG){D=R,C=R+qe.readBigUInt64LE(t,R+qe.Constants.ZIP64SIZE)+qe.Constants.ZIP64LEAD;break}}if(D==-1)throw qe.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,C)),c.commentLength&&(o=t.slice(B+qe.Constants.ENDHDR)),A&&_()}function I(){r.length>1&&!m&&r.sort((A,R)=>A.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(A=>!h.has(A))},get comment(){return E.decode(o)},set comment(A){o=qe.toBuffer(A,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||_(),i[A]||null},setEntry:function(A){l||_(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,R=!0){l||_();let k=i[A];this.getEntryChildren(k,R).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||_();let R=i[A],k=r.indexOf(R);k>=0&&(r.splice(k,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,R=!0){if(l||_(),typeof A=="object")if(A.isDirectory&&R){let k=[],y=A.entryName;for(let C of r)C.entryName.startsWith(y)&&k.push(C);return k}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let R=this.getEntryChildren(A);return R.includes(A)?R.length-1:R.length}return 0},compressToBuffer:function(){l||_(),I();let A=[],R=[],k=0,y=0;c.size=0,c.offset=0;let C=0;for(let M of this.entries){let J=M.getCompressedData();M.header.offset=y;let V=M.packLocalHeader(),ee=V.length+J.length;y+=ee,A.push(V),A.push(J);let Z=M.packCentralHeader();R.push(Z),c.size+=Z.length,k+=ee+Z.length,C++}k+=c.mainHeaderSize,c.offset=y,c.totalEntries=C,y=0;let D=Buffer.alloc(k);for(let M of A)M.copy(D,y),y+=M.length;for(let M of R)M.copy(D,y),y+=M.length;let B=c.toBinary();return o&&o.copy(B,qe.Constants.ENDHDR),B.copy(D,y),t=D,l=!1,D},toAsyncBuffer:function(A,R,k,y){try{l||_(),I();let C=[],D=[],B=0,M=0,J=0;c.size=0,c.offset=0;let V=function(ee){if(ee.length>0){let Z=ee.shift(),re=Z.entryName+Z.extra.toString();k&&k(re),Z.getCompressedDataAsync(function(se){y&&y(re),Z.header.offset=M;let P=Z.packLocalHeader(),q=P.length+se.length;M+=q,C.push(P),C.push(se);let W=Z.packCentralHeader();D.push(W),c.size+=W.length,B+=q+W.length,J++,V(ee)})}else{B+=c.mainHeaderSize,c.offset=M,c.totalEntries=J,M=0;let Z=Buffer.alloc(B);C.forEach(function(se){se.copy(Z,M),M+=se.length}),D.forEach(function(se){se.copy(Z,M),M+=se.length});let re=c.toBinary();o&&o.copy(re,qe.Constants.ENDHDR),re.copy(Z,M),t=Z,l=!1,A(Z)}};V(Array.from(this.entries))}catch(C){R(C)}}}}});var du=oe((W2,cu)=>{var ye=ar(),_e=le("path"),om=Pa(),am=ou(),Rn=(...t)=>ye.findLast(t,e=>typeof e=="boolean"),au=(...t)=>ye.findLast(t,e=>typeof e=="string"),cm=(...t)=>ye.findLast(t,e=>typeof e=="function"),dm={noSort:!1,readEntries:!1,method:ye.Constants.NONE,fs:null};cu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),dm);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=ye.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ye(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ye.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ye.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw ye.Errors.INVALID_FILENAME();let c=new am(r,i),{canonical:l,sanitize:u,zipnamefix:h}=ye;function x(_){if(_&&c){var b;if(typeof _=="string"&&(b=c.getEntry(_e.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(b=c.getEntry(_.entryName)),b)return b}return null}function m(_){let{join:b,normalize:I,sep:A}=_e.posix;return b(_e.isAbsolute(_)?"/":".",I(A+_.split("\\").join(A)+A))}function E(_){return _ instanceof RegExp?(function(b){return function(I){return b.test(I)}})(_):typeof _!="function"?()=>!0:_}let S=(_,b)=>{let I=b.slice(-1);return I=I===o.sep?o.sep:"",_e.relative(_,b)+I};return{readFile:function(_,b){var I=x(_);return I&&I.getData(b)||null},childCount:function(_){let b=x(_);if(b)return c.getChildCount(b)},readFileAsync:function(_,b){var I=x(_);I?I.getDataAsync(b):b(null,"getEntry failed for:"+_)},readAsText:function(_,b){var I=x(_);if(I){var A=I.getData();if(A&&A.length)return A.toString(b||"utf8")}return""},readAsTextAsync:function(_,b,I){var A=x(_);A?A.getDataAsync(function(R,k){if(k){b(R,k);return}R&&R.length?b(R.toString(I||"utf8")):b("")}):b("")},deleteFile:function(_,b=!0){var I=x(_);I&&c.deleteFile(I.entryName,b)},deleteEntry:function(_){var b=x(_);b&&c.deleteEntry(b.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,b){var I=x(_);I&&(I.comment=b)},getZipEntryComment:function(_){var b=x(_);return b&&b.comment||""},updateFile:function(_,b){var I=x(_);I&&I.setData(b)},addLocalFile:function(_,b,I,A){if(o.fs.existsSync(_)){b=b?m(b):"";let R=_e.win32.basename(_e.win32.normalize(_));b+=I||R;let k=o.fs.statSync(_),y=k.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);k.isDirectory()&&(b+=o.sep),this.addFile(b,y,A,k)}else throw ye.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,b){_=typeof _=="object"?_:{localPath:_};let I=_e.resolve(_.localPath),{comment:A}=_,{zipPath:R,zipName:k}=_,y=this;o.fs.stat(I,function(C,D){if(C)return b(C,!1);R=R?m(R):"";let B=_e.win32.basename(_e.win32.normalize(I));if(R+=k||B,D.isFile())o.fs.readFile(I,function(M,J){return M?b(M,!1):(y.addFile(R,J,A,D),setImmediate(b,void 0,!0))});else if(D.isDirectory())return R+=o.sep,y.addFile(R,Buffer.alloc(0),A,D),setImmediate(b,void 0,!0)})},addLocalFolder:function(_,b,I){if(I=E(I),b=b?m(b):"",_=_e.normalize(_),o.fs.existsSync(_)){let A=o.findFiles(_),R=this;if(A.length)for(let k of A){let y=_e.join(b,S(_,k));I(y)&&R.addLocalFile(k,_e.dirname(y))}}else throw ye.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,b,I,A){A=E(A),I=I?m(I):"",_=_e.normalize(_);var R=this;o.fs.open(_,"r",function(k){if(k&&k.code==="ENOENT")b(void 0,ye.Errors.FILE_NOT_FOUND(_));else if(k)b(void 0,k);else{var y=o.findFiles(_),C=-1,D=function(){if(C+=1,C<y.length){var B=y[C],M=S(_,B).split("\\").join("/");M=M.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(M)?o.fs.stat(B,function(J,V){J&&b(void 0,J),V.isFile()?o.fs.readFile(B,function(ee,Z){ee?b(void 0,ee):(R.addFile(I+M,Z,"",V),D())}):(R.addFile(I+M+"/",Buffer.alloc(0),"",V),D())}):process.nextTick(()=>{D()})}else b(!0,void 0)};D()}})},addLocalFolderAsync2:function(_,b){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=_e.resolve(m(_.localPath));let{zipPath:A,filter:R,namefix:k}=_;R instanceof RegExp?R=(function(D){return function(B){return D.test(B)}})(R):typeof R!="function"&&(R=function(){return!0}),A=A?m(A):"",k=="latin1"&&(k=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof k!="function"&&(k=D=>D);let y=D=>_e.join(A,k(S(localPath,D))),C=D=>_e.win32.basename(_e.win32.normalize(k(D)));o.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?b(void 0,ye.Errors.FILE_NOT_FOUND(localPath)):D?b(void 0,D):o.findFilesAsync(localPath,function(B,M){if(B)return b(B);M=M.filter(J=>R(y(J))),M.length||b(void 0,!1),setImmediate(M.reverse().reduce(function(J,V){return function(ee,Z){if(ee||Z===!1)return setImmediate(J,ee,!1);I.addLocalFileAsync({localPath:V,zipPath:_e.dirname(y(V)),zipName:C(V)},J)}},b))})})},addLocalFolderPromise:function(_,b){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},b),(R,k)=>{R&&A(R),k&&I(this)})})},addFile:function(_,b,I,A){_=h(_);let R=x(_),k=R!=null;k||(R=new om(i),R.entryName=_),R.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(R.header.time=A.mtime);var C=R.isDirectory?16:0;let D=R.isDirectory?16384:32768;return y?D|=4095&A.mode:typeof A=="number"?D|=4095&A:D|=R.isDirectory?493:420,C=(C|D<<16)>>>0,R.attr=C,R.setData(b),k||c.setEntry(R),R},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return x(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,b,I,A,R,k){A=Rn(!1,A),R=Rn(!1,R),I=Rn(!0,I),k=au(R,k);var y=x(_);if(!y)throw ye.Errors.NO_ENTRY();var C=l(y.entryName),D=u(b,k&&!y.isDirectory?k:I?C:_e.basename(C));if(y.isDirectory){var B=c.getEntryChildren(y);return B.forEach(function(V){if(V.isDirectory)return;var ee=V.getData();if(!ee)throw ye.Errors.CANT_EXTRACT_FILE();var Z=l(V.entryName),re=u(b,I?Z:_e.basename(Z));let se=R?V.header.fileAttr:void 0;o.writeFileTo(re,ee,A,se)}),!0}var M=y.getData(c.password);if(!M)throw ye.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(D)&&!A)throw ye.Errors.CANT_OVERRIDE();let J=R?_.header.fileAttr:void 0;return o.writeFileTo(D,M,A,J),!0},test:function(_){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var I=c.entries[b].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,b,I,A){if(I=Rn(!1,I),A=au(I,A),b=Rn(!1,b),!c)throw ye.Errors.NO_ZIP();c.entries.forEach(function(R){var k=u(_,l(R.entryName));if(R.isDirectory){o.makeDir(k);return}var y=R.getData(A);if(!y)throw ye.Errors.CANT_EXTRACT_FILE();let C=I?R.header.fileAttr:void 0;o.writeFileTo(k,y,b,C);try{o.fs.utimesSync(k,R.header.time,R.header.time)}catch{throw ye.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,b,I,A){if(A=cm(b,I,A),I=Rn(!1,I),b=Rn(!1,b),!A)return new Promise((D,B)=>{this.extractAllToAsync(_,b,I,function(M){M?B(M):D(this)})});if(!c){A(ye.Errors.NO_ZIP());return}_=_e.resolve(_);let R=D=>u(_,_e.normalize(l(D.entryName))),k=(D,B)=>new Error(D+': "'+B+'"'),y=[],C=[];c.entries.forEach(D=>{D.isDirectory?y.push(D):C.push(D)});for(let D of y){let B=R(D),M=I?D.header.fileAttr:void 0;try{o.makeDir(B),M&&o.fs.chmodSync(B,M),o.fs.utimesSync(B,D.header.time,D.header.time)}catch{A(k("Unable to create folder",B))}}C.reverse().reduce(function(D,B){return function(M){if(M)D(M);else{let J=_e.normalize(l(B.entryName)),V=u(_,J);B.getDataAsync(function(ee,Z){if(Z)D(Z);else if(!ee)D(ye.Errors.CANT_EXTRACT_FILE());else{let re=I?B.header.fileAttr:void 0;o.writeFileToAsync(V,ee,b,re,function(se){se||D(k("Unable to write file",V)),o.fs.utimes(V,B.header.time,B.header.time,function(P){P?D(k("Unable to set times",V)):D()})})}})}}},A)()},writeZip:function(_,b){if(arguments.length===1&&typeof _=="function"&&(b=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(_,I,!0);typeof b=="function"&&b(A?null:new Error("failed"),"")}}},writeZipPromise:function(_,b){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},b);return new Promise((R,k)=>{!_&&i.filename&&(_=i.filename),_||k("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=D=>D?R(D):k("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,I,A,C)},k)})},toBufferPromise:function(){return new Promise((_,b)=>{c.toAsyncBuffer(_,b)})},toBuffer:function(_,b,I,A){return typeof _=="function"?(c.toAsyncBuffer(_,b,I,A),null):c.compressToBuffer()}}}});import{execFile as p_,spawn as g_,spawnSync as dA}from"node:child_process";import{promisify as m_}from"node:util";function __(t){if(process.platform!=="win32")return!1;if(Cf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Cf,"").toLowerCase();return w_.has(r)}function kf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return __(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function nt(t,e=[],r={}){return g_(t,e,kf(t,r))}function Df(t,e=[],r={}){return y_(t,e,kf(t,r))}var w_,Cf,y_,Wt=Ye(()=>{"use strict";w_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Cf=/\.(cmd|bat|ps1)$/i;y_=m_(p_)});var $t=oe((UC,oh)=>{"use strict";var ih=["nodebuffer","arraybuffer","fragments"],sh=typeof Blob<"u";sh&&ih.push("blob");oh.exports={BINARY_TYPES:ih,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sh,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var qi=oe((GC,bo)=>{"use strict";var{EMPTY_BUFFER:nb}=$t(),sd=Buffer[Symbol.species];function rb(t,e){if(t.length===0)return nb;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 sd(r.buffer,r.byteOffset,i):r}function ah(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function ch(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function ib(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function od(t){if(od.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new sd(t):ArrayBuffer.isView(t)?e=new sd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),od.readOnly=!1),e}bo.exports={concat:rb,mask:ah,toArrayBuffer:ib,toBuffer:od,unmask:ch};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");bo.exports.mask=function(e,r,i,o,c){c<48?ah(e,r,i,o,c):t.mask(e,r,i,o,c)},bo.exports.unmask=function(e,r){e.length<32?ch(e,r):t.unmask(e,r)}}catch{}});var uh=oe((qC,lh)=>{"use strict";var dh=Symbol("kDone"),ad=Symbol("kRun"),cd=class{constructor(e){this[dh]=()=>{this.pending--,this[ad]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ad]()}[ad](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[dh])}}};lh.exports=cd});var Lr=oe((jC,ph)=>{"use strict";var ji=le("zlib"),fh=qi(),sb=uh(),{kStatusCode:hh}=$t(),ob=Buffer[Symbol.species],ab=Buffer.from([0,0,255,255]),So=Symbol("permessage-deflate"),Vt=Symbol("total-length"),Pr=Symbol("callback"),vn=Symbol("buffers"),Or=Symbol("error"),vo,dd=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,!vo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;vo=new sb(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[Pr];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){vo.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){vo.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"?ji.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=ji.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[So]=this,this._inflate[Vt]=0,this._inflate[vn]=[],this._inflate.on("error",db),this._inflate.on("data",xh)}this._inflate[Pr]=i,this._inflate.write(e),r&&this._inflate.write(ab),this._inflate.flush(()=>{let c=this._inflate[Or];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=fh.concat(this._inflate[vn],this._inflate[Vt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Vt]=0,this._inflate[vn]=[],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"?ji.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=ji.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Vt]=0,this._deflate[vn]=[],this._deflate.on("data",cb)}this._deflate[Pr]=i,this._deflate.write(e),this._deflate.flush(ji.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=fh.concat(this._deflate[vn],this._deflate[Vt]);r&&(c=new ob(c.buffer,c.byteOffset,c.length-4)),this._deflate[Pr]=null,this._deflate[Vt]=0,this._deflate[vn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};ph.exports=dd;function cb(t){this[vn].push(t),this[Vt]+=t.length}function xh(t){if(this[Vt]+=t.length,this[So]._maxPayload<1||this[Vt]<=this[So]._maxPayload){this[vn].push(t);return}this[Or]=new RangeError("Max payload size exceeded"),this[Or].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Or][hh]=1009,this.removeListener("data",xh),this.reset()}function db(t){if(this[So]._inflate=null,this[Or]){this[Pr](this[Or]);return}t[hh]=1007,this[Pr](t)}});var Nr=oe((HC,Io)=>{"use strict";var{isUtf8:gh}=le("buffer"),{hasBlob:lb}=$t(),ub=[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 fb(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ld(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 hb(t){return lb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Io.exports={isBlob:hb,isValidStatusCode:fb,isValidUTF8:ld,tokenChars:ub};if(gh)Io.exports.isValidUTF8=function(t){return t.length<24?ld(t):gh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Io.exports.isValidUTF8=function(e){return e.length<32?ld(e):t(e)}}catch{}});var pd=oe((WC,vh)=>{"use strict";var{Writable:xb}=le("stream"),mh=Lr(),{BINARY_TYPES:pb,EMPTY_BUFFER:wh,kStatusCode:gb,kWebSocket:mb}=$t(),{concat:ud,toArrayBuffer:wb,unmask:_b}=qi(),{isValidStatusCode:yb,isValidUTF8:_h}=Nr(),Ao=Buffer[Symbol.species],lt=0,yh=1,Eh=2,bh=3,fd=4,hd=5,To=6,xd=class extends xb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||pb[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[mb]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}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 Ao(i.buffer,i.byteOffset+e,i.length-e),new Ao(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 Ao(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case lt:this.getInfo(e);break;case yh:this.getPayloadLength16(e);break;case Eh:this.getPayloadLength64(e);break;case bh:this.getMask();break;case fd:this.getData(e);break;case hd:case To: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[mh.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=yh:this._payloadLength===127?this._state=Eh: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=bh:this._state=fd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=fd}getData(e){let r=wh;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&&_b(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=hd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[mh.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}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let l=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=ud(i,r):this._binaryType==="arraybuffer"?o=wb(ud(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=To,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=ud(i,r);if(!this._skipUTF8Validation&&!_h(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===hd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=To,setImmediate(()=>{this.emit("message",o,!1),this._state=lt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,wh),this.end();else{let i=e.readUInt16BE(0);if(!yb(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Ao(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!_h(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=lt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=lt):(this._state=To,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=lt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[gb]=o,l}};vh.exports=xd});var wd=oe(($C,Ah)=>{"use strict";var{Duplex:KC}=le("stream"),{randomFillSync:Eb}=le("crypto"),{types:{isUint8Array:bb}}=le("util"),Sh=Lr(),{EMPTY_BUFFER:vb,kWebSocket:Sb,NOOP:Ib}=$t(),{isBlob:Mr,isValidStatusCode:Ab}=Nr(),{mask:Ih,toBuffer:jn}=qi(),ut=Symbol("kByteLength"),Tb=Buffer.alloc(4),Ro=8*1024,Hn,Br=Ro,bt=0,Rb=1,Cb=2,gd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=bt,this.onerror=Ib,this[Sb]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||Tb,r.generateMask?r.generateMask(i):(Br===Ro&&(Hn===void 0&&(Hn=Buffer.alloc(Ro)),Eb(Hn,0,Ro),Br=0),i[0]=Hn[Br++],i[1]=Hn[Br++],i[2]=Hn[Br++],i[3]=Hn[Br++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ut]!==void 0?u=r[ut]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let h=u;u>=65536?(c+=8,h=127):u>125&&(c+=2,h=126);let x=Buffer.allocUnsafe(o?u+c:c);return x[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(x[0]|=64),x[1]=h,h===126?x.writeUInt16BE(u,2):h===127&&(x[2]=x[3]=0,x.writeUIntBE(u,4,6)),r.mask?(x[1]|=128,x[c-4]=i[0],x[c-3]=i[1],x[c-2]=i[2],x[c-1]=i[3],l?[x,e]:o?(Ih(e,i,x,c,u),[x]):(Ih(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=vb;else{if(typeof e!="number"||!Ab(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");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(bb(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let l={[ut]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==bt?this.enqueue([this.dispatch,c,!1,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):Mr(e)?(o=e.size,c=!1):(e=jn(e),o=e.length,c=jn.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};Mr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==bt?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):Mr(e)?(o=e.size,c=!1):(e=jn(e),o=e.length,c=jn.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};Mr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==bt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Sh.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Mr(e)?(u=e.size,h=!1):(e=jn(e),u=e.length,h=jn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[ut]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Mr(e)?this._state!==bt?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==bt?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ut],this._state=Cb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(md,this,u,o);return}this._bufferedBytes-=i[ut];let l=jn(c);r?this.dispatch(l,r,i,o):(this._state=bt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(kb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Sh.extensionName];this._bufferedBytes+=i[ut],this._state=Rb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");md(this,h,o);return}this._bufferedBytes-=i[ut],this._state=bt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===bt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][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)}};Ah.exports=gd;function md(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 kb(t,e,r){md(t,e,r),t.onerror(e)}});var Nh=oe((VC,Lh)=>{"use strict";var{kForOnEventAttribute:Hi,kListener:_d}=$t(),Th=Symbol("kCode"),Rh=Symbol("kData"),Ch=Symbol("kError"),kh=Symbol("kMessage"),Dh=Symbol("kReason"),Fr=Symbol("kTarget"),Ph=Symbol("kType"),Oh=Symbol("kWasClean"),Jt=class{constructor(e){this[Fr]=null,this[Ph]=e}get target(){return this[Fr]}get type(){return this[Ph]}};Object.defineProperty(Jt.prototype,"target",{enumerable:!0});Object.defineProperty(Jt.prototype,"type",{enumerable:!0});var Wn=class extends Jt{constructor(e,r={}){super(e),this[Th]=r.code===void 0?0:r.code,this[Dh]=r.reason===void 0?"":r.reason,this[Oh]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Th]}get reason(){return this[Dh]}get wasClean(){return this[Oh]}};Object.defineProperty(Wn.prototype,"code",{enumerable:!0});Object.defineProperty(Wn.prototype,"reason",{enumerable:!0});Object.defineProperty(Wn.prototype,"wasClean",{enumerable:!0});var zr=class extends Jt{constructor(e,r={}){super(e),this[Ch]=r.error===void 0?null:r.error,this[kh]=r.message===void 0?"":r.message}get error(){return this[Ch]}get message(){return this[kh]}};Object.defineProperty(zr.prototype,"error",{enumerable:!0});Object.defineProperty(zr.prototype,"message",{enumerable:!0});var Wi=class extends Jt{constructor(e,r={}){super(e),this[Rh]=r.data===void 0?null:r.data}get data(){return this[Rh]}};Object.defineProperty(Wi.prototype,"data",{enumerable:!0});var Db={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Hi]&&o[_d]===e&&!o[Hi])return;let i;if(t==="message")i=function(c,l){let u=new Wi("message",{data:l?c:c.toString()});u[Fr]=this,Co(e,this,u)};else if(t==="close")i=function(c,l){let u=new Wn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Fr]=this,Co(e,this,u)};else if(t==="error")i=function(c){let l=new zr("error",{error:c,message:c.message});l[Fr]=this,Co(e,this,l)};else if(t==="open")i=function(){let c=new Jt("open");c[Fr]=this,Co(e,this,c)};else return;i[Hi]=!!r[Hi],i[_d]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[_d]===e&&!r[Hi]){this.removeListener(t,r);break}}};Lh.exports={CloseEvent:Wn,ErrorEvent:zr,Event:Jt,EventTarget:Db,MessageEvent:Wi};function Co(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ko=oe((JC,Mh)=>{"use strict";var{tokenChars:Ki}=Nr();function Lt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Pb(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,x=-1,m=-1,E=0;for(;E<t.length;E++)if(x=t.charCodeAt(E),l===void 0)if(m===-1&&Ki[x]===1)h===-1&&(h=E);else if(E!==0&&(x===32||x===9))m===-1&&h!==-1&&(m=E);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(h,m);x===44?(Lt(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&&Ki[x]===1)h===-1&&(h=E);else if(x===32||x===9)m===-1&&h!==-1&&(m=E);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Lt(r,t.slice(h,m),!0),x===44&&(Lt(e,l,r),r=Object.create(null),l=void 0),h=m=-1}else if(x===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(Ki[x]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);h===-1?h=E:i||(i=!0),o=!1}else if(c)if(Ki[x]===1)h===-1&&(h=E);else if(x===34&&h!==-1)c=!1,m=E;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(x===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Ki[x]===1)h===-1&&(h=E);else if(h!==-1&&(x===32||x===9))m===-1&&(m=E);else if(x===59||x===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),Lt(r,u,_),x===44&&(Lt(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||x===32||x===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let S=t.slice(h,m);return l===void 0?Lt(e,S,r):(u===void 0?Lt(r,S,!0):i?Lt(r,u,S.replace(/\\/g,"")):Lt(r,u,S),Lt(e,l,r)),e}function Ob(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(", ")}Mh.exports={format:Ob,parse:Pb}});var Lo=oe((XC,Vh)=>{"use strict";var Lb=le("events"),Nb=le("https"),Mb=le("http"),zh=le("net"),Bb=le("tls"),{randomBytes:Fb,createHash:zb}=le("crypto"),{Duplex:ZC,Readable:YC}=le("stream"),{URL:yd}=le("url"),Sn=Lr(),Ub=pd(),Gb=wd(),{isBlob:qb}=Nr(),{BINARY_TYPES:Bh,CLOSE_TIMEOUT:jb,EMPTY_BUFFER:Do,GUID:Hb,kForOnEventAttribute:Ed,kListener:Wb,kStatusCode:Kb,kWebSocket:Ue,NOOP:Uh}=$t(),{EventTarget:{addEventListener:$b,removeEventListener:Vb}}=Nh(),{format:Jb,parse:Zb}=ko(),{toBuffer:Yb}=qi(),Gh=Symbol("kAborted"),bd=[8,13],Zt=["CONNECTING","OPEN","CLOSING","CLOSED"],Xb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends Lb{constructor(e,r,i){super(),this._binaryType=Bh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Do,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]),qh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Bh.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 Ub({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Gb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ue]=this,c[Ue]=this,e[Ue]=this,o.on("conclude",tv),o.on("drain",nv),o.on("error",rv),o.on("message",iv),o.on("ping",sv),o.on("pong",ov),c.onerror=av,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Wh),e.on("data",Oo),e.on("end",Kh),e.on("error",$h),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[Sn.extensionName]&&this._extensions[Sn.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())}),Hh(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){vd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Do,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){vd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Do,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){vd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Sn.extensionName]||(o.compress=!1),this._sender.send(e||Do,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(ge,"CONNECTING",{enumerable:!0,value:Zt.indexOf("CONNECTING")});Object.defineProperty(ge.prototype,"CONNECTING",{enumerable:!0,value:Zt.indexOf("CONNECTING")});Object.defineProperty(ge,"OPEN",{enumerable:!0,value:Zt.indexOf("OPEN")});Object.defineProperty(ge.prototype,"OPEN",{enumerable:!0,value:Zt.indexOf("OPEN")});Object.defineProperty(ge,"CLOSING",{enumerable:!0,value:Zt.indexOf("CLOSING")});Object.defineProperty(ge.prototype,"CLOSING",{enumerable:!0,value:Zt.indexOf("CLOSING")});Object.defineProperty(ge,"CLOSED",{enumerable:!0,value:Zt.indexOf("CLOSED")});Object.defineProperty(ge.prototype,"CLOSED",{enumerable:!0,value:Zt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ge.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ge.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ed])return e[Wb];return null},set(e){for(let r of this.listeners(t))if(r[Ed]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ed]:!0})}})});ge.prototype.addEventListener=$b;ge.prototype.removeEventListener=Vb;Vh.exports=ge;function qh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:jb,protocolVersion:bd[1],maxBufferedChunks:1048576,maxFragments:131072,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,!bd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${bd.join(", ")})`);let c;if(e instanceof yd)c=e;else try{c=new yd(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;Po(t,I);return}let x=l?443:80,m=Fb(16).toString("base64"),E=l?Nb.request:Mb.request,S=new Set,_;if(o.createConnection=o.createConnection||(l?ev:Qb),o.defaultPort=o.defaultPort||x,o.port=c.port||x,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new Sn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Jb({[Sn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Xb.test(I)||S.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let b;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[A,R]of Object.entries(I))i.headers[A.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!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")),b=t._req=E(o),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=E(o);o.timeout&&b.on("timeout",()=>{ot(t,b,"Opening handshake has timed out")}),b.on("error",I=>{b===null||b[Gh]||(b=t._req=null,Po(t,I))}),b.on("response",I=>{let A=I.headers.location,R=I.statusCode;if(A&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){ot(t,b,"Maximum redirects exceeded");return}b.abort();let k;try{k=new yd(A,e)}catch{let C=new SyntaxError(`Invalid URL: ${A}`);Po(t,C);return}qh(t,k,r,i)}else t.emit("unexpected-response",b,I)||ot(t,b,`Unexpected server response: ${I.statusCode}`)}),b.on("upgrade",(I,A,R)=>{if(t.emit("upgrade",I),t.readyState!==ge.CONNECTING)return;b=t._req=null;let k=I.headers.upgrade;if(k===void 0||k.toLowerCase()!=="websocket"){ot(t,A,"Invalid Upgrade header");return}let y=zb("sha1").update(m+Hb).digest("base64");if(I.headers["sec-websocket-accept"]!==y){ot(t,A,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],D;if(C!==void 0?S.size?S.has(C)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":S.size&&(D="Server sent no subprotocol"),D){ot(t,A,D);return}C&&(t._protocol=C);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!_){ot(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let M;try{M=Zb(B)}catch{ot(t,A,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(M);if(J.length!==1||J[0]!==Sn.extensionName){ot(t,A,"Server indicated an extension that was not requested");return}try{_.accept(M[Sn.extensionName])}catch{ot(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Sn.extensionName]=_}t.setSocket(A,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(b,t):b.end()}function Po(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Qb(t){return t.path=t.socketPath,zh.connect(t)}function ev(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=zh.isIP(t.host)?"":t.host),Bb.connect(t)}function ot(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[Gh]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Po,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function vd(t,e,r){if(e){let i=qb(e)?e.size:Yb(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Zt[t.readyState]})`);process.nextTick(r,i)}}function tv(t,e){let r=this[Ue];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ue]!==void 0&&(r._socket.removeListener("data",Oo),process.nextTick(jh,r._socket),t===1005?r.close():r.close(t,e))}function nv(){let t=this[Ue];t.isPaused||t._socket.resume()}function rv(t){let e=this[Ue];e._socket[Ue]!==void 0&&(e._socket.removeListener("data",Oo),process.nextTick(jh,e._socket),e.close(t[Kb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Fh(){this[Ue].emitClose()}function iv(t,e){this[Ue].emit("message",t,e)}function sv(t){let e=this[Ue];e._autoPong&&e.pong(t,!this._isServer,Uh),e.emit("ping",t)}function ov(t){this[Ue].emit("pong",t)}function jh(t){t.resume()}function av(t){let e=this[Ue];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Hh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Hh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Wh(){let t=this[Ue];if(this.removeListener("close",Wh),this.removeListener("data",Oo),this.removeListener("end",Kh),t._readyState=ge.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Ue]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Fh),t._receiver.on("finish",Fh))}function Oo(t){this[Ue]._receiver.write(t)||this.pause()}function Kh(){let t=this[Ue];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function $h(){let t=this[Ue];this.removeListener("error",$h),this.on("error",Uh),t&&(t._readyState=ge.CLOSING,this.destroy())}});var Xh=oe((ek,Yh)=>{"use strict";var QC=Lo(),{Duplex:cv}=le("stream");function Jh(t){t.emit("close")}function dv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Zh(t){this.removeListener("error",Zh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function lv(t,e){let r=!0,i=new cv({...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(Jh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(Jh,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",dv),i.on("error",Zh),i}Yh.exports=lv});var Sd=oe((tk,Qh)=>{"use strict";var{tokenChars:uv}=Nr();function fv(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&&uv[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}Qh.exports={parse:fv}});var ox=oe((rk,sx)=>{"use strict";var hv=le("events"),No=le("http"),{Duplex:nk}=le("stream"),{createHash:xv}=le("crypto"),ex=ko(),Kn=Lr(),pv=Sd(),gv=Lo(),{CLOSE_TIMEOUT:mv,GUID:wv,kWebSocket:_v}=$t(),yv=/^[+/0-9A-Za-z]{22}==$/,tx=0,nx=1,ix=2,Id=class extends hv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:mv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:gv,...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=No.createServer((i,o)=>{let c=No.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=Ev(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=tx}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===ix){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick($i,this);return}if(e&&this.once("close",e),this._state!==nx)if(this._state=nx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick($i,this):process.nextTick($i,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{$i(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",rx);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){$n(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){$n(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!yv.test(c)){$n(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){$n(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Vi(r,400);return}let h=e.headers["sec-websocket-protocol"],x=new Set;if(h!==void 0)try{x=pv.parse(h)}catch{$n(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 S=new Kn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=ex.parse(m);_[Kn.extensionName]&&(S.accept(_[Kn.extensionName]),E[Kn.extensionName]=S)}catch{$n(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(_,b,I,A)=>{if(!_)return Vi(r,b||401,I,A);this.completeUpgrade(E,c,x,e,r,i,o)});return}if(!this.options.verifyClient(S))return Vi(r,401)}this.completeUpgrade(E,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[_v])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>tx)return Vi(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${xv("sha1").update(r+wv).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&&(x.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[Kn.extensionName]){let E=e[Kn.extensionName].params,S=ex.format({[Kn.extensionName]:[E]});x.push(`Sec-WebSocket-Extensions: ${S}`),m._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",rx),m.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,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($i,this)})),u(m,o)}};sx.exports=Id;function Ev(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 $i(t){t._state=ix,t.emit("close")}function rx(){this.destroy()}function Vi(t,e,r,i){r=r||No.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} ${No.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 Zn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,Zn),t.emit("wsClientError",d,r,e)}else Yi(r,i,o,c)}});var Eh=oe(Oe=>{"use strict";var M=U;(function(t,e){let r=U,i=t();for(;;)try{if(parseInt(r(1064))/1*(parseInt(r(699))/2)+-parseInt(r(798))/3+-parseInt(r(857))/4+-parseInt(r(594))/5*(parseInt(r(994))/6)+parseInt(r(1160))/7*(-parseInt(r(1736))/8)+parseInt(r(957))/9*(-parseInt(r(836))/10)+parseInt(r(1191))/11*(parseInt(r(1284))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Ho,568343);var C1=Object[M(960)+M(1430)],R1=Object[M(229)+M(374)+M(1613)],gh=(t,e)=>function(){return t&&(e=(0,t[{ezBBl:function(c,d){return c(d)}}[M(932)](R1,t)[0]])(t=0)),e},k1=(t,e)=>{let r={RIhGf:function(o,c,d,u){return o(c,d,u)}};for(var i in e)r.RIhGf(C1,t,i,{get:e[i],enumerable:!0})};function D1(){return uh||(uh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function P1(){let t=M;return fh||(fh=[IDBCursor[t(1727)+"e"][t(1101)],IDBCursor[t(1727)+"e"][t(1520)],IDBCursor[t(1727)+"e"][t(1520)+t(942)+"ey"]])}function O1(t){let e=M,r={oCLGB:e(987),YFRox:e(461),dYDfQ:function(o,c){return o(c)},OuHQm:function(o){return o()}},i=new Promise((o,c)=>{let d=e,u={AtmjP:function(_,S){return r[U(1687)](_,S)},tLazC:function(_){return r[U(1125)](_)},VaVHe:function(_){return _()}},x=()=>{let _=U;t["removeEv"+_(1675)+_(1115)](r[_(559)],p),t[_(1301)+_(1675)+"ner"](r[_(895)],g)},p=()=>{let _=U;u.AtmjP(o,u[_(477)](Ft,t[_(786)])),u[_(731)](x)},g=()=>{let _=U;c(t[_(461)]),u[_(555)](x)};t[d(1619)+d(576)](r.oCLGB,p),t["addEvent"+d(576)](r[d(895)],g)});return i[e(1711)](o=>{let c=e;o instanceof IDBCursor&&Rd[c(1194)](o,t)})[e(1612)](()=>{}),qo[e(1194)](i,t),i}function L1(t){let e=M,r={BPtVV:function(o,c){return o(c)},foNei:e(310)+"or",BWvCC:function(o){return o()},gxcCY:function(o,c){return o===c},LgsGc:function(o,c){return o|c},xuDwA:function(o,c){return o<<c},nJllt:function(o,c){return o>>>c},bBVbv:function(o,c){return o|c},hnYHr:function(o,c){return o|c},ddVGd:function(o,c){return o|c},oqqHZ:function(o,c){return o<<c},HCYfq:"complete",RpmES:e(461),CtIyZ:e(408),XUhis:function(o){return o()},vKrZl:"qMugn"};if(jo[e(1013)](t))return;let i=new Promise((o,c)=>{let d=e,u={ljHjr:r[d(1575)],TIqZd:r[d(1111)],FIpqP:r[d(1638)],JPgfJ:function(x){return r[d(297)](x)}};if(r[d(304)](r[d(1281)],r[d(1281)])){let x=()=>{let _=d;t["removeEventListe"+_(1115)](u.ljHjr,p),t[_(1301)+_(1675)+_(1115)](u[_(604)],g),t[_(1301)+_(1675)+_(1115)](u[_(1202)],g)},p=()=>{let _=d;u.JPgfJ(o),u[_(1515)](x)},g=()=>{let _=d;r[_(1386)](c,t[_(461)]||new DOMException(r[_(1087)],r.foNei)),r[_(1425)](x)};t["addEvent"+d(576)](r.HCYfq,p),t["addEvent"+d(576)](r.RpmES,g),t["addEvent"+d(576)](r[d(1638)],g)}else return r.gxcCY(_0x407866,_0x5953bf)?_0x87eea:new _0x107ba4((r.LgsGc(r[d(1549)](_0x185f24.call(_0x23bd8e,0),_0x1f4dc5.call(_0x284e50,1)<<8),_0x4aac7c.call(_0x4491cd,2)<<16)|r[d(1548)](_0x3a1354.call(_0x1f2482,3),24))>>>0,r[d(439)](r[d(999)](r[d(1036)](r[d(642)](_0x51a18e[d(474)](_0x45e852,4),r[d(823)](_0x2dbcb6[d(474)](_0x5ba89c,5),8)),_0x1a2bd7[d(474)](_0x127714,6)<<16),_0x27ccc9[d(474)](_0x4664c3,7)<<24),0),!0)});jo.set(t,i)}function N1(t){Wo={mgwdO:function(r,i){return r(i)}}.mgwdO(t,Wo)}function Ho(){let t=["DgvZDa","zxzkre0","ELjrA2e","BuDjuvq","vuXQz2y","quPAtxK","zxH0zw5ZAw8","tvDvvNa","v21MEuG","BgLZDgvUtMu","yxjyAg8","x29Ut3bLBG","CfbLrgC","B2jQzwn0u3q","u1PwrMe","Aw5KzxHpzG","ywvxyum","vMr6Agm","svzdCuS","r1jPCLu","Ahr0Chm6","txPRqw8","yw1LoIa","ywzL","sw1QDeG","y2HLy2Tszwe","x2LZsw5PDa","qw1jwK8","x2LUAxq","quDyqwS","EvjMBMO","sLbNzKO","uMfuq0q","DgvushG","AK5csMK","v1HRqMK","y29UDgLUDwu","D3jPDgvvAw4","sfzutxO","rLPprNC","DhbyvLi","CNHpt1m","vujHy3i","yw5ZzM9YBvq","y2HnyxHuCMK","x2rYB3bhBg8","wgX3rgm","rKnQCgm","Dgf2Cey","yw5Nzq","v3b4vfq","Du5wrKq","u3n0s3i","uwrLvfC","Aw9U","DMvYC2LVBG","C0vIugC","x3DZsw5ZDge","rwzXEKi","y0Hquvq","zvztrLa","BurysuS","mtb8nNW0Fda","ufDuz0W","EhveD0e","tgDZr2m","BMncuxy","v0zmvxO","EsbJBg9Zzwq","v3nMwuW","wK1VuNa","CMXWCwu","wNriyuC","ExbL","zMzMzG","sMXhu3C","qwXrsw8","BezpAue","tM1ZvNi","C0ThDwq","zKjjs1y","CMvUDevUzha","Ec1TC2CTy3u","y2XVC2uSihC","y291BNq","C1vQtuK","DgLUzYbZzxi","ALj2v0G","C0Xf","zNjVBu51Bwi","sgfuBMq","senzzNe","z2v0q3vYCMu","BLDKs0y","AMnxzNy","qxvrtxy","DhbPs0u","Bg93","sKPNsNK","tffTzNe","z1PIshe","zNjVBuHHC2G","BxnN","rxLcz3K","sKrLvha","AuT0sum","Cw1qqNy","q3vfv0u","q09oveLovuu","uxvLDwu","s1roq1u","BvvhDNi","BeL3s0W","x2HHBMrSzvi","BwLUzW","whvYBNy","u3rYyxrLz3K","z29PBMCGyxC","Axnby2TdBgu","CNfHALO","n3WWFdz8na","B0fnCvi","CNnyqxi","x2XPC3rLBMu","tg9qBu4","BeHHBMrSzxi","rKHNs0e","rgvKAwnHDgu","y2f0y2G","BwvZ","qNjPzgDL","tvbmvM0","r2zyyuK","AvbVtfe","we9owhm","ywrKrxzLBNq","tNDrzxm","AgDNyLC","yw5Hz2vY","B2zMBgLUzq","uLfsz3e","t1v5EuS","B3Hyweu","sgXKC3i","vgfN","uKjgqNe","z0vgseW","DunbCuy","suvtx0vsuK8","ELjlwg0","q0Xpu0LorW","C3nHz2vfDMu","tgvfDLq","v1LLz0i","q3rjEvO","sKngr2G","y2vZC0HHBMq","EM52v00","zxjFAxnFywm","vwvVsuu","BhrPCgXLihq","EMvbqM8","seHWru8","D3nZoI8V","DxrVuMvJB24","z2TZEwC","BMfTzq","y3Horge","C2fNzq","thzkDM8","tffJBuS","EwzHqw4","Bwf4uMv0CMK","CejkDvq","tNPHqKm","BfjgyMO","mdaWma","x2rItMfTzq","y3vYC29YlNm","rxjtBg4","yK1Tv2O","AxnbCNjHEq","B0PJr0u","DeXcAw0","EwXNy3a","x2nSzwfYugK","tKPVAhG","Ef9MCM9UDgK","zxrxB3jRq2G","B1PfrM0","BM1uq0m","zw50tgLZDgu","yMXVy2TLza","y2XVC2veqG","txPQyNq","DNbSuuq","y2vbAeC","vM5cDeW","vLfjEw0","y3jLyxrLuMu","DMfSDwu","CMvJzxzPzwq","AwrI","zfLezLe","Dw5RBM93BIa","A1fZwvy","BM5Ly3q","Ce1Nuxu","ufLhqKW","CMvZB2X2zq","EvbTDxC","AxjLza","zePPsLK","vNfhtKC","yxKSig5LDhC","we10sK8","zw1PDa","uMjxDum","D0nsCu8","z2v0sxrLBq","rxjiC3G","x2nVBM5Ly3q","BLHZDNK","z1bVA3C","q09otKvdveK","zfDVCMTLCKC","CMvWBgfJzq","DgHLBG","CMvXDwLYzwq","Axb0sM0","AgfZt3DUuhi","BefIDu8","AgnSv3K","Dg9cExrLC0W","wurAELO","q2rUsNK","BeTvzKW","x3fVC0rc","rwrMsuG","zxjHDg9Y","zffquhu","DKr3wM4","x2zVCM1HDeu","ChjVDg90Exa","Cfz1DxO","zvnvsKu","sgrWCwW","yLv2EKC","rg1YrNy","CvbnEuK","A0LHrhK","sfDSr0m","ohLIDunvzW","x3nVy2TLDa","DNrYvNK","zMvY","EKvztLi","C2HPzNq","x2n1CNnVCK0","yxnL","AuTLzMW","zxjYtM8","qvrnwwG","DNrXtKS","y0XjyMq","yxnZAwDU","zw5JB2rPBMC","ywnR","B3DkwMe","uMf6CwG","Ae1Tu2e","CMTLCKDSB2i","Dgv4Dc9WBge","tvLAuuS","yw1Lu3bHy2u","B25LCNjVCG","Cxrzte8","yxKSihrYEsa","BMvLzf9Hy2S","zxH0ugf5Bg8","CvzTr2C","sfHkvuO","CxzguKe","BuTMthm","zfjxt1y","Dg9tDhjPBMC","x2rLC3rYB3K","CgfdrLK","A3v2AfC","z3vZtgG","ufLOtem","z2v0t3DUuhi","yxv0B21HDgK","x2vUzhbVAw4","vxbKyxrLq28","AMruCLq","mdaWmdaWmda","uwjXs3y","CLzwBxa","wfrPA0G","A2v5CW","v1DRwuG","zw5HyMXLvhi","C2DPza","x2fKzfDZtgK","CYbHBhjLywq","DeLK","CMvHzhDYAxq","A25kwwO","Aw5KzxG","x2n1CNnVCK4","sKXsrve","y1DLt0S","DhrYu0S","zw5NDgG","x194x21Zz18","y2XVC2u","CeH2s1q","nhWX","rNfbAg4","zgvJB2rLzey","zNrUquO","uMjiyNy","y0jsvMK","yKfMtvG","twPyyMC","tw9mtgO","y29UBMvJDa","zw5XDwv1zq","vM1xDe0","z2v0","B3jLtMfTzxm","CgvLDM8","wxbuEKO","reXHrMe","suPAENG","svfcCwy","x29UtwvZC2e","vu10EuS","BMCGzMfPBgu","ELnSswC","BgP4vLi","Eunmreq","ig1LC3nHz2u","y29Kzq","u1f2vNe","uhLLyum","A1n0yxr1C0m","C3bSAwnL","y3zduKe","D05xug4","CM92AwrLihC","sNrQCvy","Ae1LC3nHz2u","sKnjAvu","qNr6ugm","AuLRywC","q0LzELq","vwD5v3m","wfvOAxm","BgvgqKC","BMTSA1u","uM1WDK8","u0vNzuG","veLOsw4","BMvPCxG","z3HJq1K","uufMqxa","Cgf5Bg9Hzfq","x3DHAxq","zxjFCw9Z","q3vZDg9Trxi","qwjVCNrfCNi","quPVBuS","CgvYC2LZDgu","qMPgr3u","tef6Bxy","zeL0Cfq","x2LZtwLUAvq","u0nTquG","Dfjot0K","y3jLyxrLt3a","DgfYz2v0","uu9WBK4","uw1KvNe","C0jf","BufYvxK","A21JuKm","ywzlzfO","wgnZAMy","x3bYB3rVy28","qNv5q08","rMzHsxi","AM9PBG","DMzMrKO","DfjLrMq","BMrWB2LUDca","twP1z1i","tgLMC0O","zufJAW","tejiqM8","tKvUtM8","wMP3zxm","twLZC2LUzYa","wfjorve","yurjtfm","t2nSC1O","wffrCK0","BwvZC2fNzv8","m3WYFdr8mxW","z1rPBwvVDxq","vgPSCK4","vg9ruvC","BNrLCG","DhPctve","y3vYCMvUDeK","AgfUz2u","z2v0qwXSs2u","ywX3yxLZ","Eg9fBha","zMnHBey","uLvQtgC","CLzHBhvLCW","y2TLrgG","BwrKu3e","CM5cy3i","yw1Is0i","te1PC0e","Bhm6ia","DfDiC1u","y2HHCKnVzgu","ywXSzwqGBxu","q0Xpu0ve","C0zYsum","rw1dEMK","tufyx1jfvfi","B3bLCNr5tMe","z1LYDK4","ru5gAKu","CM9YrxzLBNq","AevYCM9Yrxy","BKXPBMu","zxmGCMvHy2G","CgLUz0LUDgu","AwXAr3K","DLDxCKC","ihrPBwvZ","vfbNrwe","vMPJC2K","CMvZzxrfBMq","tuHltLq","C0X5vvi","CMvHzhLtDge","svnhr1K","Aw9UvgLTzw8","ww9ZsNK","CNnVCL9Uyw0","x3nLCuLK","DhftEeC","CMvHzfvjBNq","suDRs1e","zMLUza","id4G","uLzjrfO","vuzKBKm","yMLUyxj5vhK","v05csfm","wuHIA1m","z1zjrhu","yuHWvMK","ywjVCNq","DMvY","Aw5L","rhj1zvG","vvPKywW","x3vYBa","sxnysvm","ywnRtxnNswq","ignVzgu6ia","C29YDa","EgfdD2m","swnps04","DhnzDwK","EMP1rvC","t25HB0u","suHrz3K","y29UC3rYDwm","rLDt","yxrLq291BNq","zcbLCNjVCI4","BfrPBwvVDxq","y2fYv0q","vK1kuKu","Chzktwm","A3fkBxO","vMr0ChK","sgHht3i","DvHQvhO","Bwf4tg9ZC0m","ihrVihjLDhi","x2LZv29YA2u","BKPSBhq","vuvgCMS","ChjVy2vZCW","ANnpCgq","s0Tfv2O","wu5swxe","y2HLy2TdDxi","y2fXrg8","pxv0zI04","Buj4BuG","x2HHBMrSzu8","zgf0yq","rK94s0u","D1Htzgu","zfnLv24","qNzYueu","uuXZD2q","uMvHzcbWyxm","Ag1Kq3m","s1byt0G","vgzuB3K","DhPzEvO","zxjYB3i","sxbRs0y","rg10Ahu","uM1LC1q","vfnIugO","D05lC3K","zLfMz1m","AgvKtwf4uMu","zM5hyLq","vMH6DKe","uuzLs1m","EgXVuui","zNrwuvu","y2fSBa","B25tDg9Wsw0","wenKs2C","qxrTALa","qMr1Dhe","ihn1y2nLC3m","AgrtDhi","z0fMvxi","C3Lovve","y3jLyxrLrwW","y3jLyxrLt2i","D0TkwvC","CMvHzg9UBhK","teDny2C","x2LZtwLUAvC","z2v0q3vYC28","zxjFywnRx20","tKDFrvjst1i","EhbsuxO","mNW0Fdb8m3W","zgvSzxrL","tvv4qwK","Aw1LCYbPBIa","ufzSyLu","s3v3uNa","s21qzwm","u0PXwwm","CM92AwrLigi","v2L4AKu","Dgryt1a","rLnmAg8","r1ffBNe","DfzQruW","uLbPr1i","C2LhEue","Chv0","BwjdvgW","BMrtvLy","CgfYC2u","y29UDgv4Da","vgLTzw91Da","rxrquvm","CeXmEhK","B2nYCMK","BuDeB08","ihzHBgLKihm","y3vYC29Yx2y","tg9Nsuq","suDtBui","vhjAEfa","seLMuLu","tuLfwM8","EgvPAK4","x2nSzwfYvgK","Dgv4DfbHEwW","uLjpuG","sePyAwy","ENj4que","B2nRzxq","s2TQvvC","yNHgB1a","AgLNAa","C3rLBMvYCW","DMnRAei","r2D1C3m","yM9L","x19LC01Vzhu","Aw5JBhvKzxm","wuLwBeu","BwvZC2fNzq","yNL0zxm","CNfyA0e","y3jLyxrLrxi","vxvPDgm","Bwv0Ag9K","Au9vz0q","Dw9itvC","z1vSv1u","yLPXwK8","tg9fuNu","zLHxt0u","vMfwsgu","zwntDui","yMfJA3vWigu","sM92qvC","B0nmr0i","svn0rKC","twvZC2fNzuu","Eg5pAum","B2XKvMvYC2K","r25lC0O","rwDIq3i","y29SBM8","yundBwC","zxjYtxnN","Ewv2s2e","nxW3Fdn8mxW","DxbNCMfKzw4","EhLlwfe","Dg9cExrLCW","C2v0zgi","wLD6u3y","tgLZDgvUzxi","C09Zr2m","Bw5Kuwq","sLjrwMO","A2nztvq","yLPMCfe","y3ruAw1LB3u","vMjyD0u","uuzVsvK","zuPyz2G","yM9KEq","DuLZu3i","DKT0tNq","x29UugfNzu4","lcbTyxGGCMu","vxDYD2W","DuXjuMG","q3fKt1y","mJa4otCWvKfcu29w","Ahj3r2e","zKTcwgK","Ae9Wzw5fDMu","B0Ldtg4","yw51Ce1LC3m","BNrbBMrvCgq","C2vYDMLJzq","zM9Yy2u","BNLrBwW","veLXwMq","ugzkBfe","Be5Lrfe","Dw5KzwzPBMu","vxj3z2O","t2r5yvi","rwfJCKG","AgvnyxK","nhW2FdL8mNW","D2P6yKG","B1PmCLm","qNnpB1a","BvzwzMW","BLbhtw4","Dhj1y3rVCIa","CMvJzwL2zwq","y2retKm","rKPdBwW","wNvmBeK","D3DYyKy","u05hEMW","vhjeENq","z3LrqLi","DxDuDuu","C2v0q3vYC28","CMvZzxruCMK","Cw9Z","De1IzM0","y09Wzw4","x2LZtM9Kzq","zwPbve0","C2XPy2u","r0nwCu0","r21WvLu","zxj2AwnL","ywnRpwzYB24","ywnRx2nVzgu","tK1YBvq","zgrwr2q","t3bxBem","Ag9VweS","v0Huveq","BufXDxG","wKz0zei","AMLZt2e","D25zyw4","q1r0whq","AwXLx25HBwu","CNzHBa","igzPzwXKoIa","ugnTD0i","AgvHzgvYCW","mxW0Fdb8mNW","BgvUz3rO","zLzcseW","Eg9ZA3u","zxHWB3j0CW","x21LC3nHz2u","C2XoA3m","zxf1ywXZ","y3jLyxrLtwu","DgTiCKW","AxnFywnR","yw9rwNK","rer2v2S","igXHCMDLCIa","zvLYtum","CgLUz09Uy2u","Ce91Cxq","r0L5tK4","A1HRvee","reTvr20","uhPjrKO","DKrjDe8","z2v0u3rVCMe","BgLUzw5V","ENLgq2e","yMfSu2nVCgu","Bu5oywe","sLPkqMy","rLz2wvy","rfrYCfi","EhbvAfa","zeTrzey","ywnOzwq","BwLUAvbYB2C","v1nVC0G","D2LSBfjLy28","B25fCNjVCG","wxbYEMS","Ag9AvuO","z2vY","tNLRv2m","Bwj0C20","B25szwnLAxy","mJaXndG0uxf3uxjm","DMfSDwvZ","CMfUzg9T","zNjHBwvuExa","uuzHz3m","DKHrz2O","ywDLu2HVDW","zw50","B1rJr2q","zeD0A3O","C2vUDa","x3bPBMDqB24","Cg9PBNrdB24","qMjXAK4","y29UBMvJDca","C2nYAxb0","sNnkCK4","whPKzw4","z2vtEw5J","B25VCgvU","ywDL","v0vzvxa","x3DZ","Cg93","ywDLrxzLBNq","rgL3whO","B1PtA3K","CMvZzxrdB3u","BNruCMLLC0m","x2nYzwf0zvm","zgD5v0y","x2TLEvbHDgG","DeXHEKm","uLjIseS","Chb1wxu","zfHAC0C","vKPvCha","sgT6ELm","vvjOqwi","zMzpzMy","vvfhsNa","AxnmB25N","zw5JB2rLrNi","s25wvLG","ugjxDMS","A1ziuuW","B0jUCu4","wMzfA2K","yNvMzMvYzwq","ANbSv08","AefJA01LC3m","vwjuyLy","B2nRzxrtDwm","zfLftxe","rxPyCei","C29Tzq","uKnYqLq","AKXHwLO","CgXLyxnLiha","BMCGB3iGyw4","Ahr0Ca","B25Uzwn0Aw4","rLjptLrjrvi","D3LUu2y","u3zevMq","C3rYAw5N","BM9Uzv9UB24","zMXVB3i","C0rkueO","vxnYrfy","B3ruvvy","wxbMEey","s09xs1O","zfD4vuK","q1njENO","yMz5uva","sfLsvNy","BhnmqMW","rLPXBve","wu9gBxO","s0rkBeu","ruDvALG","CMLLC0nVDw4","zNjVBujPDhm","yNLL","Bwf4twvZC2e","yNL0zuXLBMC","CMvZDwX0","DhvbqK4","qwHIu04","ref5sLK","AwXSihvZzsa","wunYr0K","y09lsu0","x1fVu01HBMe","u25Mr0i","yKrpB3O","AhjAChq","AenSB3nLrxy","mtaWmJCXngHmBgn1uq","zMX1C2HfEha","m3WWFdj8nNW","AxnszwfKEq","vxzswMC","x2LUAxrhBg8","x2rPC3bHDgm","DeLUDgvYy2u","DhDVCMTdAge","u2vXsuq","zg1huKi","wLnnugS","uu9cA2i","yMLUyxj5","uhvquu4","wuXiD2O","Aw9NA2u","CxfhuNy","wwDIuhe","rNPVuwC","BfnswLa","zhffExO","sfncrMC","BLbfELu","y3vYCMvUDeu","B3fXsfO","u0X6rNO","tvrQqNu","zMzmAw5L","v2LUzg93","t1bftL9fuLi","y0DbtNe","B3bLBKrc","x3jLywr5q2W","Dg9VigXHCMC","x29UrxjYB3i","yLzHrKK","Aw50zwDLCIa","mta5ntmWC2r6s1zY","BMrLEa","C0fSBeK","q0v4DNm","AurVzfK","tLHKyMG","qufzDvC","uLDgA0m","CNzHBfzHBhu","sw1HzgC","zxjFCw9Zx2e","B2nvCvK","nhW1Fde","C2fotLm","vNncB1u","vKH6t3y","wgntAui","DxLRuNu","sM5RtMC","B3bLBIa","DuLUEem","odGZmJy0CfzvCNzL","CMfNzvn5BMm","CNnVCKzPBgu","sgvhvLa","y3vYDMfSDwu","rNfiBMe","CgLUz1rPBwu","y29UBMvJDgK","EwXHwwW","x2LZqNjVD3m","BML0AwfSAxO","tNHLu2q","sKDNAem","zM9YrwfJAa","DgHyAMe","q1fZzvC","C1rHrg8","qw1VDw50","ruv1z3a","t3zTAeC","t3bLBKv2zw4","Bw1Mz2W","wuHSuwG","Bw9SDxK","ueHSt20","x2HHBMrSzva","BNjZBKS","zw5fDMvUDa","Ae53sgK","vg90D0u","CMvHC29U","qxnkv2O","ChvZAa","B25JBg9Zzq","rxjYB3jdB2q","zgDetuS","DxLiAgm","qwPmzK0","wuzsB3G","DMvUDa","ALrvD1C","s056t3e","yNL0zu9MzNm","uvnyvMO","tw9KDwXL","yxbWBhK","uMvJB25Uzwm","zw1LBNq","wxbyrhq","q3ncqMm","CM92AwrLihy","AKneCuO","DMvYC2LVBMm","B3bLBG","ywnRDxbfBMq","CuvbANK","rMvtD3i","BwT6wuK","m3WYFdf8nxW","EuTLz1q","ywrKq291BNq","zNvUy3rPB24","u0ztBwm","CM92AwrLige","yMLUza","x3bPBMC","q21MDxK","shznwgK","AMDYwe4","y3r4","ywTxyuO","Bg9N","CgLUz0XVC3m","x29Uq2XVC2u","tNPPswe","zxPcqMW","wfr5DwG","x2DLBMvYyxq","DxnLCKLW","rKTPu1G","ChDor24","t3beAwu","CgfNzwHPzgu","rLbVteW","DeTbsKG","uhjPBwfYEuS","D2fpDKO","BNvTyMvY","DxrMofDYAxq","DMLJzuLeig8","Dw5ZAwDUzwq","Dev2zw50","B3nLrxzLBNq","qMTru1C","shvyueS","lcbxzwjtB2m","B2zMC2v0","B3jpBMXPBMu","vujftw0","x3jLy29UBMu","nZGZrfLvAuLL","BuXfEuS","yMTdv2K","zgvMAw5Luhi","q2rZBhO","D2jssvq","nxWWFdf8mNW","De1HBMfNzxi","CNDev3O","re9TDwy","ww5wB00","BezSDxnO","z3b1v3i","ALn3qvq","B25tDgfYDfi","z2u6ia","B3nLza","DvfTvxO","DgzkBhm","y1vltwy","BMvJDa","ue1JvNi","B2LUDfjLywm","s0nqr0K","qMnTrMO","shnyALG","y29TCgXLDgu","tMvLrNq","mhWYFdn8nxW","u0XjDKy","C3vJy2vZCW","yNvMzMvY","DcbVzIbYyw4","yM9bEvK","DNjxs3i","icSG","swvcu08","mtuWrMn5EurM","y2XLyxi","vNzMs28","u0HcDeO","wxzYD0y","yKjwyNy","FdD8mNWXFdG","x0vysvnu","B3jRzxjhBg8","EvjLy29UBMu","rw9VzNy","zg9Uzq","rKHqwgG","r0XWuNu","CMfTzq","ugDJBLe","z2v0qwXS","zefvrxq","DcbSAw1PDa","AgfZ","BMLqsvG","CNjVCK1LC3m","wevvv2m","zevstvm","Dxrjza","rKLmrv9ot1q","z1PqvhG","y3zms2q","vxPABKK","zMLN","x21PBMLoyxy","u2TPCcbWyxm","s21quuq","DgThB3C","AwLcCMy","BNrfBMrWB2K","zwn0","q3zOsg4","rxzLBNq","tfrXuKK","twHmq2S","tg9NsurozxC","Ag5zshi","CwXewLG","vwr3C3m","CM1rELq","BMnLq2XVC2u","zNjVBuj5Dgu","yNzbC0S","Dg9oDw1Izxi","rw54t28","sLnptLa","tMXlDKK","zxnjqxy","vePiu0S","q1PruwS","x2LUDgvYDMe","zgvS","vhvADxe","ywPztwy","yMfSrxzLBNq","ENz3re4","vw5Oyw5KBgu","senkr0q","zxq9DxrMltG","ENzAz3u","rxvSu2y","yLzozwK","v2zwBgW","zxzrExK","mtfbDKXrEvO","y2P6v2K","Cgu6ia","ruTiENG","r1jMyMq","B2zM","Fdv8oxWZFde","A3jxDLG","A2PAzgK","rNfpA1q","tNDlrwe","ExvxCKi","uLfdzvu","we9evfe","B2nRzxrgywK","sxfVDMO","BgvY","DxjS","zcWG","A2Xdqum","Aw47y2HHCNm","CffuCvO","yM1gD1q","zM9ozwK","ywDLsgLKzq","v2vIu29JA2u","yvfMuuO","A0jcBNm","reL2BwG","tKfusvzfx0u","BgLUzq","wMDTDg0","wMDKvvO","BMrWB2LUDfq","AwDHDg9Yt24","C1PUrem","CgvOr1C","ywr2yw5Jzq","tMfTzq","zNjVBunOyxi","zcWGDw5RBM8","x3bPBMDmB3m","s2jTsvy","Dgv4Dc9Qyxy","B25SAw5L","C3rYAw5NAwy","Bg9NsurozxC","uNbTrvm","BMDLza","C2vYDMLJzs0","BMv4DcGPigm","BMvY","aaaaaaaaaaa","uMvkqMG","DMzzBxu","rKfArxG","svvMq3u","z2DSwxa","tvD6yM4","Dhr3Awq","EvznDeG","t3viuw0","DxbKyxrLq3u","Cu9qCfq","DgLLCKPtt04","x2DLDeLUDgu","Cevswgq","BMDuAw1LCG","v2vPEgLUsLm","sePUCLm","Aw9Ul2PZB24","yuPou0e","zsbHihn0CMK","rhHjBwy","B25ozxr3B3i","u2TpzLa","CYbPBNn0yw4","z2HTsuS","uvfZvwu","zMLSDgvY","uurdwfO","AM9YBg4","BwLZzq","Dg9Y","BwvKAwf0zwW","vu1mDNy","uwDNzxe","B25mAw5L","AMPosKS","q0z6C0O","t2PbsMC","vMnyDMm","CMvKDwnL","ChrVCG","yuv4BM4","se5PDfa","mZmZmZCWmxvRBhD3vW","rwXHCeG","AfvVzfa","zwnVBM5Ly3q","Ec1TC2CTCw8","BwfUDwfSihi","B0T4rhm","x2n1CNnVCKy","CKXRqwC","C3rVCcbPBw0","C3vIyxjYyxK","ChjVDg9JB2W","y29UBMvJDeu","mNWZFdb8mxW","DhjPzxmGCMu","ANvVEwu","rvHwvKu","rvjst1i","A0PpCxG","BwvY","BeXTyuu","A1Hou08","rev5A3u","rev4qxu","zfLAD0i","Dw50","tvnUwe4","wev5v2m","ihrPBwvVDxq","BMv3vMvYC2K","yNHKq2S","mtfkt2DRwgm","u0Tos3i","s0P0CvC","C2v0","DgjXCvm","DgHHBIbSB2m","Exb1Bxy","zxjFBxnNAwq","zg1fz3G","D09Zt0u","uhjTr0W","rKLWCva","zLrpwxC","u3HABe4","wKXruuK","DhjHBNnHy3q","DLnyB3i","CMvTB3zLq2G","ihzHBgLKigq","BvDiuMK","Dfj2u1e","CwHXvvK","Aunowvi","Bwu6ia","AuTyseG","Bg9IywXty28","tLLiC1y","B2fK","wu5dq1m","DhjPzxm","wwXZwum","rfnOsKO","vKDvu08","B3v0sw50zxi","yxv0BW","yw1L","BhLsugW","qwzMvKW","rxjIuem","qwfJDgi","zv9ZDwnJzxm","DMfS","ywrKt25L","B2vArwS","s1PZwNe","y2HnyxHdB3u","ywXSB2nvBNm","vg5st20","AxnrB1nnzxm","DKXyv1a","BKfiz0q","BwvZC2fNztO","D24GCMvHC28","tfPmr0y","v2Xmvhi","AgjTt1a","Bvbrrxu","C21Wr2O","q2zNDg4","u0P4uw8","CxnuqM0","De5RBvC","sM1nAMy","tw1fCu0","yLz3rgi","o2nOyxjZzxq","vgHsy1O","y3vYC29Y","zw5HyMXLuw8","BMnVzgLUzW","q29Kzq","AvDYALG","qKDfBMC","ww1Aswi","zNzRy3y","yMfcC1i","q21hBg4","Cg9PBNrbBMq","y09ptM4","BgLTAxq","DwnrBKi","x25HDMLNyxq","ufPnwu4","uuLUtLG","rMnpzNm","ywzODfe","Dw1TAMC","DgfUuLG","rNjVBNrPzxi","turdqNy","DKTYwMW","CgH6r28","C0XPC3rLBMu","mJK4nZa4nJHxwwvrqvC","tgXMufa","EwXJqLC","uLLUuNq","tujZDhy","D2fZq2XLyw4","DgvmB2Djre4","Cgf5Bg9Hza","wgHRsfa","AwXLtMfTzq","AwXmCuO","wNfnA3u","t2jQzwn0","ywXPzcb1CMW","Dg9hzw5LCMe","zgXItNq","A2v5","CMvTB3zLrxy","ugTvz2S","ywXSq3vYC28","Bhb0zfG","y3jLyxrLq2W","zNjVBNrPzxi","yLLWy3a","AxnAzxjV","C2v0sxrLBq","v1riuLe","wufuDMG","wLbrzLe","B25nzxnZywC","B25TzxnZywC","DNHlBNK","CMvJB25Uzwm","EuPOEui","zv90Aw1LB3u","s1zirwq","BfjVrKy","ruTLy2O","zwzSs3a","uLHPzhu","CgfNzxnOB3C","CLbQAvu","rMfltLC","ufv1C3O","s2v0uxi","x3bHDgHlzxK","yxGGCMv0CMK","wuzJyKu","A3LvsMu","Egrdsw4","CgLUz19VBMm","vw5PBxbSzw0","sNvvuKq","BNP1qwi","uwzPtwu","Aw9ftfC","x3nLBMrby2S","zNDZxZeUmc4","B3vUDa","tKnLDKG","C3vIC3rYAw4","qLDQqvC","m3W0","BM93","zw5HyMXLqxu","zfnpCuG","tercAKm","zvvYBa","sgXvwLa","z1rbt2u","D3jPDgu","AxfpuMO","DwX6D0y","r2fTBg0","B3jL","rfDiugC","zgLZywjSzue","Aw5KzxGGB3u","zw5KCg9PBNq","wgPQwwS","zwjuqMm","rMzJrgC","CMvWBgfJzui","yxnJCMLWDa","wuDSsLO","ywnRx2LK","l3DZl3yY","u05rsu8","x2rLyNvN","y29UBMvJDfm","vLzpr04","x2jPBMfYEvq","BxnNsuq","sejqrLe","swLMt2C","DwXLBgq","AMLSBuC","C0nVDw50zxi","sLjttgS","shHjuue","sNjby0G","uxLvy1K","qLb0vLy","ChbL","u2XWDha","t1bftG","CMfTugfYyw0","t1jfyM0","uwTRv3a","jMPZy2fSBgi","rvj4sNO","wNfXruG","uLvrAg4","svfJr2K","Cgf5Bg9Hzeu","A2v0ignVBNm","Buj3CwC","AxnrB1nby2S","wwnLDwO","yK1pDeC","Du50CLK","x2rPC2nVBM4","ywWGy3vYC28","C1jfse8","vNrzDKW","C2vUza","q3vZDg9Tq2W","BIWGAg9ZDg4","ywrK","C3rHCNq","Ew5KAvu","q29UzMLN","wMzhANC","uurzCha","vKHQtMG","BxDRB2W","C3rVCMu","rw5suNm","yKDwq0u","yxbWzw5Kq2G","C2vYDMvYvgK","qLD2q0m","Evn5uuu","x29UvgLTzw8","y3vYC29Yx24","v05MrLa","B3bLCNr5","s25eD04","y2uGBM90igK","ohWWFdeW","ExndDwe","x3jLBw92zvC","BeXIvNy","x0rctMfTzq","v3P4yLa","yMrFzgLK","yKDirLm","D3m6lY8","zgvIDwC","r3zMvvi","C0rmufa","AwXK","Du1eD2q","ihbYB3rVy28","r29RExO","yujHDhC","s3Hus1q","ihrYEsbYzwm","svf5CuW","Dvbzyue","DhbizwfKzxi","tg9JAW","yxbWBgLJyxq","DhLWzq","t3Dnu1C","EvzdqNa","Dg9mB3DLCKm","zxDgruW","BfrPyLa","yxjYyxLIDwy","rLPQEKm","C2v0u3rVCMe","vwT2vKG","DgLTzw91Da","vNjJzNK","C3bSAxq","tu9yDw4","igfYCMf5yNu","x29WDgLVBNm","x3bYzwzPEa","y29Uy2f0","AMf3t2u","DMDQEMu","z2vjBMzVu3K","seTmEvO","DhjPBq","x2LUAxrqCM8","uvzhAfC","uNLrzgG","igzHAwWSig0"];return Ho=function(){return t},Ho()}function M1(t){let e=M,r={EnxOo:function(i,o){return i(o)},SkOfP:function(i,o){return i(o)},EtPQS:function(i,o){return i in o},kCHxz:"objectSt"+e(269),sJjSZ:function(i){return i()}};return t===IDBDatabase[e(1727)+"e"][e(1206)+e(1538)]&&!r[e(515)](r.kCHxz,IDBTransaction[e(1727)+"e"])?function(i,...o){let c=e,d=t.call(r.EnxOo(Xi,this),i,...o);return Cd[c(1194)](d,i.sort?i[c(417)]():[i]),r[c(1044)](Ft,d)}:r.sJjSZ(P1)[e(541)](t)?function(...i){let o=e;return t[o(902)](r[o(1139)](Xi,this),i),r[o(1044)](Ft,Rd[o(268)](this))}:function(...i){return Ft(t[e(902)](Xi(this),i))}}function U(t,e){t=t-223;let r=Ho(),i=r[t];if(U.jqQCXG===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",g="",_="";for(let S=0,w,v,I=0;v=x.charAt(I++);~v&&(w=S%4?w*64+v:v,S++%4)?g+=String.fromCharCode(255&w>>(-2*S&6)):0)v=p.indexOf(v);for(let S=0,w=g.length;S<w;S++)_+="%"+("00"+g.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(_)};U.VHBHwQ=o,U.SWyyhM={},U.jqQCXG=!0}let c=r[0],d=t+c,u=U.SWyyhM[d];return u?i=u:(i=U.VHBHwQ(i),U.SWyyhM[d]=i),i}function B1(t){let e=M,r={fnGbT:function(i,o){return i===o},VJUpp:e(918),SEgeH:function(i,o){return i(o)},nyQml:function(i,o){return i instanceof o},cLIbd:function(i,o,c){return i(o,c)}};return r[e(469)](typeof t,r[e(735)])?r[e(301)](M1,t):(r[e(603)](t,IDBTransaction)&&L1(t),r[e(1748)](mh,t,D1())?new Proxy(t,Wo):t)}function Ft(t){let e=M,r={GRirU:function(o,c){return o instanceof c},ffSVT:function(o,c){return o(c)},ZqMku:function(o,c){return o!==c},GCVqM:e(1053)};if(r[e(1503)](t,IDBRequest))return r.ffSVT(O1,t);if(Uo[e(1013)](t))return Uo.get(t);let i=B1(t);return r[e(1295)](i,t)&&(r[e(1295)](r[e(636)],r[e(636)])?_0x11196d.d=(o,c)=>{let d=e;for(var u in c)_0xd5060f.o(c,u)&&!_0xc5f091.o(o,u)&&_0x4d6a27[d(960)+d(1430)](o,u,{enumerable:!0,get:c[u]})}:(Uo[e(1194)](t,i),qo.set(i,t))),i}var mh,uh,fh,Rd,jo,Cd,Uo,qo,Wo,Xi,xh=gh({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={nzuAb:function(r,i){return r instanceof i},bYpcp:"application/json",aCCmg:t(1456)+t(1134)+t(1256)+t(447),dxFKq:t(811),yKegT:function(r,i,o,c){return r(i,o,c)},WsfYL:function(r,i){return r+i},arXho:function(r,i){return r instanceof i},ReJBh:function(r,i){return r===i},TotwE:"eWnjb",URhAb:t(1005),BjFGu:function(r,i){return r===i},JCIiU:t(290),QLswd:t(1420),wjzbH:function(r,i){return r(i)},JDGZI:function(r,i){return r>>>i},uoHMW:function(r,i){return r&i},OvmhG:function(r,i){return r>>>i},ffOff:function(r,i){return r|i},JYNBz:function(r,i){return r<<i},hNaqP:function(r,i){return r!==i},tzYyZ:t(464),EAigC:function(r,i){return r in i}};mh=(r,i)=>i[t(754)](o=>r instanceof o),Rd=new WeakMap,jo=new WeakMap,Cd=new WeakMap,Uo=new WeakMap,qo=new WeakMap,Wo={get(r,i,o){let c=t,d={hmdCs:function(u,x){return e[U(1337)](u,x)},AjLfM:c(1756)+"in;chars"+c(1058),slNks:e[c(1307)],QlhVJ:e[c(567)],KnVVX:c(765)+"e",lptdX:e.dxFKq,ToQQW:function(u,x,p,g){return e[c(916)](u,x,p,g)},AmIZO:function(u,x){return e[c(1553)](u,x)}};if(e[c(1494)](r,IDBTransaction))if(e[c(1117)](e[c(886)],e.TotwE)){if(i===e[c(737)])return jo.get(r);if(e[c(313)](i,"objectSt"+c(269))){if(e[c(313)](e.JCIiU,e[c(292)]))return r[c(1497)+c(269)]||Cd[c(268)](r);{let u=this[c(1472)][c(1398)+c(1260)]instanceof _0x5e3d24?{force:!!this._options.payloadEncoding.force,encoding:this[c(1472)][c(1398)+c(1260)][c(1750)]?this[c(1472)][c(1398)+c(1260)].encoding[c(1710)](/\s/g,"")[c(1460)+"ase"]():""}:{force:!1,encoding:this[c(1472)][c(1398)+"ncoding"]?this[c(1472)][c(1398)+"ncoding"][c(1710)](/\s/g,"")[c(1460)+c(1743)]():""},x=_0x43cdeb[c(1398)+c(1260)]?_0x42db54[c(1398)+c(1260)][c(1710)](/\s/g,"")["toLowerC"+c(1743)]():"",p=d[c(457)](this[c(1472)][c(306)+"ype"],_0xb0f60f)?{force:!!this[c(1472)][c(306)+c(1557)].force,type:this[c(1472)]["payloadT"+c(1557)][c(1457)]?this[c(1472)][c(306)+c(1557)][c(1457)][c(1710)](/\s/g,"")[c(1460)+"ase"]():""}:{force:!1,type:this[c(1472)][c(306)+c(1557)]?this._options[c(306)+c(1557)][c(1710)](/\s/g,"")[c(1460)+c(1743)]():""},g=_0x2e2cfc[c(306)+c(1557)]?_0x1f865d["payloadT"+c(1557)][c(1710)](/\s/g,"")[c(1460)+c(1743)]():"",_=p[c(602)]?p[c(1457)]:g||p[c(1457)],S=u[c(602)]?u.encoding:x||u.encoding,w=[d[c(894)],d[c(662)],d.QlhVJ,c(764)],v=[d[c(742)],d[c(1304)]];this[c(1472)][c(240)+c(1527)+"extPayload"]&&w[c(541)](_)&&(!S||v[c(541)](S))?_0x193c97[c(528)+c(1218)]=d[c(350)](_0xdad063,_0x49d388[c(1291)],0,_0x3bfa50[c(1291)].byteLength):_0x4ff063[c(528)+"oad"]=""}}if(e[c(1117)](i,e[c(455)]))return o[c(1497)+c(269)][1]?void 0:o["objectSt"+c(1358)](o.objectStoreNames[0])}else{let u=_0x57d17e(_0x223509,_0x1b3343);return _0x39df40.bytes[c(1170)](u,d[c(1511)](u,_0xa17b81))}return e[c(613)](Ft,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t,c={UEFrk:function(d,u){return e.JDGZI(d,u)},tVjEL:function(d,u){return d&u},VQIym:function(d,u){return e[U(550)](d,u)},BsOoP:function(d,u){return e[U(876)](d,u)},vfYmu:function(d,u){return d&u},XEyWc:function(d,u){return d+u},zeABo:function(d,u){return e[U(738)](d,u)},tuABN:function(d,u){return e.JYNBz(d,u)},aOpop:function(d,u){return e[U(738)](d,u)}};if(e.hNaqP(e.tzYyZ,e[o(460)])){_0x2dcc6c.isLong(_0x5887e3)||(_0x1c4245=_0x55991a[o(1573)+"er"](_0x4a2de6));let d=c[o(440)](this[o(535)],16),u=c[o(506)](65535,this[o(535)]),x=this[o(1581)]>>>16,p=c[o(1682)](65535,this[o(1581)]),g=c[o(615)](_0x34102d[o(535)],16),_=c[o(1118)](65535,_0x2512ed[o(535)]),S=c[o(615)](_0x21ddc0[o(1581)],16),w=65535&_0x38b1e2[o(1581)],v=0,I=0,T=0,R=0;return R+=c.XEyWc(p,w),T+=c.BsOoP(R,16),R&=65535,T+=c[o(1187)](x,S),I+=T>>>16,T&=65535,I+=c[o(1187)](u,_),v+=c.BsOoP(I,16),I&=65535,v+=c[o(1187)](d,g),v&=65535,_0x4f9de8[o(782)](c[o(1645)](c[o(787)](T,16),R),c.aOpop(c[o(787)](v,16),I),this.unsigned)}else return e[o(1494)](r,IDBTransaction)&&(e.ReJBh(i,o(1005))||i===e[o(455)])?!0:e.EAigC(i,r)}},Xi=r=>qo[t(268)](r)}}),wh={};k1(wh,{deleteDB:()=>z1,openDB:()=>F1,unwrap:()=>Xi,wrap:()=>Ft});function F1(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let d=M,u={xsxri:function(g,_,S,w,v){return g(_,S,w,v)},pMgQu:function(g,_){return g(_)},jiPBF:d(883),otTUV:"close",yBZUK:d(571)+"eeded",HHpEO:d(1676)},x=indexedDB[d(910)](t,e),p=Ft(x);return i&&x[d(1619)+d(576)](u.yBZUK,g=>{let _=d;u.xsxri(i,u[_(1691)](Ft,x[_(786)]),g[_(563)+"on"],g[_(1189)+"on"],Ft(x[_(1206)+_(1538)]))}),r&&x[d(1619)+d(576)](u[d(1646)],()=>r()),p[d(1711)](g=>{let _=d;if(u.jiPBF==="fNMcs")return{bytes:_0x494ee8,offset:0,limit:_0x231fa1[_(657)]};c&&g[_(1619)+_(576)](u[_(769)],()=>c()),o&&g[_(1619)+_(576)](_(909)+_(354),()=>o())}).catch(()=>{}),p}function z1(t,{blocked:e}={}){let r=M,i={ZSMPk:r(1676),sKGud:function(c,d){return c(d)}},o=indexedDB.deleteDatabase(t);return e&&o["addEvent"+r(576)](i[r(809)],()=>e()),i[r(1563)](Ft,o)[r(1711)](()=>{})}function hh(t,e){let r=M,i={uInxC:r(245)+"e",iOUgD:function(x,p){return x instanceof p},UzZnI:function(x,p){return x in p},FqOkT:function(x,p){return x===p},QihhV:"string",ymzGJ:function(x,p){return x!==p}};if(!(i[r(549)](t,IDBDatabase)&&!i[r(1022)](e,t)&&i[r(1073)](typeof e,i.QihhV)))return;if(Go.get(e))return Go.get(e);let o=e[r(1710)](/FromIndex$/,""),c=i.ymzGJ(e,o),d=yh[r(541)](o);if(!i.UzZnI(o,(c?IDBIndex:IDBObjectStore)[r(1727)+"e"])||!(d||_h.includes(o)))return;let u=async function(x,...p){let g=r,_=this[g(1206)+g(1538)](x,d?i[g(856)]:g(486)),S=_.store;return c&&(S=S[g(247)](p[g(1741)]())),(await Promise.all([S[o](...p),d&&_[g(1005)]]))[0]};return Go.set(e,u),u}var _h,yh,Go,U1=gh({"node_modules/idb/build/index.js"(){let t=M,e={uWTok:function(o){return o()},Imadg:t(268),WHTTD:"getKey",Yceuj:"getAllKeys",qqGRv:t(1568),RQCeU:t(509),wnYan:t(494),fBMBR:"clear",uvfGk:function(o,c){return o(c)}},r=(t(963)+t(1346))[t(1469)]("|"),i=0;for(;;){switch(r[i++]){case"0":e.uWTok(xh);continue;case"1":_h=[e[t(845)],e[t(645)],"getAll",e[t(1402)],e[t(815)]];continue;case"2":yh=[e[t(1076)],"add",e[t(649)],e.fBMBR];continue;case"3":Go=new Map;continue;case"4":e.uvfGk(N1,o=>({...o,get:(c,d,u)=>hh(c,d)||o.get(c,d,u),has:(c,d)=>!!hh(c,d)||o[t(1013)](c,d)}));continue;case"5":xh();continue}break}}}),G1={idb:function(t){let e=M;t[e(660)]=Promise[e(1693)]()[e(1711)](()=>(U1(),wh)).then(function(r){return r})}},ph={};function Bt(t){let e=M,r={tbqqS:e(656)+"3",HvMXi:function(u,x){return u!==x}},i=r[e(1195)][e(1469)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=ph[t]={exports:{}};continue;case"1":var d=ph[t];continue;case"2":G1[t](c,c[e(660)],Bt);continue;case"3":return c[e(660)];case"4":if(r[e(924)](void 0,d))return d[e(660)];continue}break}}Bt.d=(t,e)=>{let r=U;for(var i in e)Bt.o(e,i)&&!Bt.o(t,i)&&Object[r(960)+r(1430)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Bt.o=(e,r)=>Object.prototype[t(1714)+t(1430)].call(e,r)})(),(()=>{let t=M,e={hdStr:function(r,i){return r!=i},mLEyK:"undefined",aBatw:t(901),IeBSO:t(540)+"le"};Bt.r=r=>{let i=t;e[i(480)](e[i(958)],typeof Symbol)&&Symbol[i(223)+i(1628)]&&Object[i(960)+"operty"](r,Symbol[i(223)+i(1628)],{value:e[i(1449)]}),Object["definePr"+i(1430)](r,e[i(993)],{value:!0})}})();var Te={};(()=>{let t=M,e={YDZzZ:function(a,n){return a(n)},Eoofv:function(a,n){return a+n},kIaDy:function(a,n){return a+n},KnDwN:function(a,n){return a+n},oZSky:function(a,n){return a*n},BGEng:function(a,n){return a+n},YGlJZ:function(a,n){return a(n)},oBnqN:function(a,n){return a!==n},LDBjC:"DRArk",Vdtpy:function(a,n){return a(n)},rqajZ:"0000",qmPBv:t(1558),dWxUI:t(987),CExvs:t(461),cjzWi:function(a,n){return a===n},eJXgh:t(458),RCrBT:t(682),uPYaA:function(a,n){return a(n)},KZsZq:t(1334)+t(1231)+"s",ppuYu:function(a,n,s){return a(n,s)},OpDie:t(1280),SnfGB:function(a,n){return a>n},vWWrG:function(a,n){return a!==n},VkKsp:function(a,n){return a>n},jawOe:function(a,n){return a-n},OdyaR:function(a,n){return a<n},rwDWz:function(a,n){return a===n},pPeDg:function(a,n){return a<n},pwNGn:function(a,n){return a!==n},EbjQs:t(505),ysCua:function(a,n){return a!==n},MPLVm:t(523),nklkU:t(303),RUQhn:function(a,n,s){return a(n,s)},NxeSd:function(a,n){return a&n},VMJRE:t(341)+t(1712)+t(653)+t(1300),QQsUe:function(a,n){return a===n},ZqqEH:function(a){return a()},qhqUY:function(a,n){return a instanceof n},RPiGR:function(a,n){return a+n},WzxbP:function(a,n){return a===n},QyUcY:function(a,n){return a<<n},vKtNt:function(a,n){return a>>n},RXidu:function(a,n){return a>>n},NwQes:function(a,n){return a&n},LoERu:t(493)+"1|5",KmPec:function(a,n){return a|n},KDJlE:function(a,n){return a+n},iKtIC:function(a,n){return a>>n},jgrXN:function(a,n){return a|n},sfHzZ:"svRks",TIhIn:t(1422),xfjhf:function(a,n){return a!==n},jdTrT:function(a,n){return a===n},SQvVq:t(694),kmcRC:function(a,n){return a!==n},tqSxG:function(a,n){return a(n)},MBstv:function(a,n){return a!==n},zvwDN:function(a,n,s){return a(n,s)},GfXaI:function(a,n,s){return a(n,s)},CIYzT:function(a,n){return a!==n},FOxKE:"fzWli",CZQQk:function(a,n,s){return a(n,s)},yxMac:function(a,n,s){return a(n,s)},mwkol:function(a,n,s){return a(n,s)},mGDoO:function(a,n,s){return a(n,s)},XTikH:t(1407),Urwgj:"yLsTU",FSLho:function(a,n,s){return a(n,s)},Zgmtm:function(a,n){return a!==n},TrDzt:function(a,n){return a(n)},MUxAi:t(1686),fVBHL:function(a,n){return a===n},HCJGD:t(421),eflKp:t(1343),YNCCS:function(a,n){return a(n)},VqGNG:function(a,n){return a(n)},OjAJg:function(a,n){return a>>>n},EKecj:function(a,n,s){return a(n,s)},EgbCr:function(a,n,s){return a(n,s)},moluy:function(a,n){return a(n)},LMisA:function(a,n){return a(n)},RYnRt:function(a,n,s){return a(n,s)},LAzmv:function(a,n,s){return a(n,s)},RaTCD:function(a,n,s){return a(n,s)},ZOjFc:function(a,n){return a(n)},IHQgy:function(a,n,s){return a(n,s)},QDCXZ:function(a,n){return a&n},niPIX:t(341)+"required field: "+t(807),Gamlm:function(a,n){return a===n},KVHEd:function(a,n){return a===n},EnRRs:t(341)+t(1712)+" field: service",lIwKL:function(a,n){return a===n},XODTQ:function(a,n){return a(n)},wUyMw:function(a,n){return a+n},yVCBp:t(1335)+"ented ty"+t(1066),HBPFQ:t(1577),SJxQo:function(a,n){return a==n},IGSmB:t(764),mkzYI:function(a,n,s,l){return a(n,s,l)},KxTKT:function(a,n){return a instanceof n},lLmaE:function(a,n){return a!==n},ULjgf:t(1135),SLzFz:function(a,n){return a+n},GnKsJ:t(1025)+t(1012),qlDZX:t(1725),BuyCO:function(a,n){return a>=n},ecSuB:function(a,n){return a>n},kXkTA:function(a,n){return a>n},aHpVi:t(456)+t(1012),RWFkC:function(a,n){return a===n},MxrrL:t(1027),lNeDQ:function(a,n,s){return a(n,s)},HNitP:function(a,n){return a===n},TjlrN:function(a,n){return a&n},iEfJa:function(a,n){return a(n)},dSOqH:function(a,n){return a+n},tWHsU:function(a,n){return a!==n},EyBgy:function(a,n){return a&n},DIvmh:function(a,n){return a==n},ejATM:function(a,n){return a>=n},UbTbV:function(a,n){return a+n},TSbPj:function(a,n){return a|n},FfcDg:function(a,n){return a&n},leFBG:function(a,n){return a<n},HhGOr:function(a,n){return a>=n},Cfgtn:function(a,n){return a<=n},Vrcfy:function(a,n){return a==n},pehGW:function(a,n){return a&n},lRFbj:function(a,n){return a>=n},hrwGa:function(a,n){return a+n},iIkag:function(a,n){return a+n},iiBrf:function(a,n){return a+n},zRQka:function(a,n){return a<<n},NlKvI:function(a,n){return a&n},HIfRU:function(a,n,s){return a(n,s)},TnROm:function(a,n){return a>=n},ucQnB:function(a,n){return a+n},PYhLC:function(a,n){return a-n},pvJMc:function(a,n){return a<<n},Aactb:function(a,n){return a<n},cBRVi:function(a,n){return a<n},FeSwr:function(a,n){return a<n},XuKEp:function(a,n,s){return a(n,s)},QkkWp:function(a,n){return a+n},kVHQL:function(a,n){return a-n},AsJWj:function(a,n){return a&n},JRSLk:t(1561),DDvWk:t(1106),uCAqF:function(a,n){return a&n},VHjNh:function(a,n){return a>>n},bVNei:t(687),bTscS:t(1591),uNtrY:function(a,n){return a&n},wNWPn:function(a,n){return a>>n},owJZa:function(a,n){return a|n},gEFHL:function(a,n){return a&n},TdHHX:function(a,n){return a!==n},DEyku:t(646),EulSf:function(a,n,s){return a(n,s)},qEAjy:function(a,n){return a&n},jTUwW:t(659),BvrPE:"ebWfw",jjNJK:function(a,n){return a>=n},Vdzhc:function(a,n){return a&n},WnaLO:t(630),NsLzZ:function(a,n){return a(n)},iCNYR:function(a,n){return a&n},FHgKA:function(a,n){return a===n},sDLPP:t(296),EfqzB:t(1578),mInUi:function(a,n){return a&n},ckeDh:function(a,n){return a(n)},Razqh:function(a,n){return a&n},RQRgq:function(a,n){return a<<n},SstKr:function(a,n){return a&n},PVlbU:function(a,n){return a&n},WixjE:function(a,n){return a&n},Yprzk:function(a,n){return a<<n},zvZgu:function(a,n){return a&n},QmdVq:function(a,n){return a&n},FqHna:function(a,n){return a&n},LifsJ:function(a,n){return a<<n},jCDqJ:function(a,n){return a<<n},BkQSW:function(a,n){return a>>>n},Xzden:function(a,n){return a&n},rlpqe:function(a,n){return a>>>n},MAJyk:function(a,n){return a&n},XQQrM:"bZSSs",ewFEL:function(a,n){return a>>>n},cGANq:function(a,n){return a>>>n},NYHsV:function(a,n){return a<<n},ozNpy:function(a,n){return a>>>n},pLLxy:function(a,n){return a<n},XjjYk:function(a,n){return a<n},gzeGf:function(a,n){return a<n},yybRG:function(a,n){return a&n},mndQd:function(a,n){return a+n},gZbHq:function(a,n){return a!==n},YNRYq:function(a,n){return a|n},mDrST:function(a,n){return a+n},uQmUz:function(a,n){return a>>>n},lKUfL:function(a,n){return a+n},xnOiC:function(a,n){return a>>>n},AuQMv:function(a,n){return a!==n},mbtsm:function(a,n){return a&n},LoPmN:function(a,n){return a!==n},iptJm:function(a,n){return a|n},uleld:function(a,n){return a>>>n},ErSln:function(a,n){return a|n},VmWtM:function(a,n){return a&n},KngVo:function(a,n){return a>>>n},Aioce:function(a,n){return a!==n},kJOqx:function(a,n){return a>>>n},XdFoa:function(a,n){return a&n},YpTzJ:function(a,n){return a(n)},SKNKr:function(a,n){return a!==n},YHbkS:t(406),ttrSK:function(a,n){return a(n)},yndiU:function(a,n){return a|n},mVVfl:function(a,n){return a===n},VsBoU:function(a,n){return a<<n},JnkNg:function(a,n){return a|n},kkjBL:function(a,n){return a<<n},KNzOq:function(a,n){return a<<n},VcXvc:function(a,n){return a<<n},dRWOV:function(a,n){return a===n},XWMNn:function(a,n){return a>>>n},RbWuC:function(a,n){return a|n},ZKYlv:function(a,n){return a<<n},uZiFK:function(a,n){return a>>>n},FZqmQ:function(a,n){return a|n},hclWy:function(a,n){return a|n},Gokyz:function(a,n){return a|n},ffUVX:function(a,n){return a&n},FiGJs:function(a,n){return a&n},WNBHS:function(a,n){return a>>>n},qVmGg:function(a,n){return a>>>n},uLIRh:function(a,n){return a<=n},gZPTx:function(a,n){return a<<n},HYRVv:function(a,n){return a&n},CSIzz:function(a,n){return a<n},teTHx:function(a,n){return a<<n},dmGRB:function(a,n){return a&n},KCqNU:function(a,n){return a|n},HaTnd:function(a,n){return a|n},rqXkA:function(a,n){return a&n},kXNSO:function(a,n){return a<<n},vplQD:function(a,n){return a&n},LBasK:function(a,n){return a&n},bVaFI:function(a,n){return a!==n},UQGJp:t(1190),DxImf:function(a,n){return a>=n},SNGzl:function(a,n){return a<=n},YpfxF:function(a,n){return a+n},uNVFD:function(a,n){return a|n},lTibP:function(a,n){return a/n},uMDwd:t(1688)+t(887),nvKFQ:"YLHwj",DExAu:function(a,n){return a*n},RRbHK:function(a,n){return a>>>n},cUKMf:function(a,n){return a===n},iDodY:function(a,n){return a===n},dJiJY:function(a,n){return a>>>n},vLXWP:function(a,n){return a+n},MqjqL:function(a,n){return a>>>n},NEnNo:function(a,n){return a+n},sOsGc:function(a,n){return a|n},JAMrv:function(a,n){return a<<n},wNHuP:function(a,n){return a>>>n},tsYui:function(a,n){return a===n},YCrGI:function(a,n){return a===n},ZPQfQ:function(a,n){return a===n},HxIQA:function(a,n){return a===n},xoElp:function(a,n){return a+n},iuOCL:function(a,n){return a>>>n},eVSFP:function(a,n){return a&n},DiwXz:function(a,n){return a>>>n},aeWaC:function(a,n){return a&n},waOvJ:function(a,n){return a>>>n},yfaAn:function(a,n){return a&n},GXnBV:function(a,n){return a&n},VzLOr:function(a,n){return a>>>n},eYrMC:function(a,n){return a&n},GRfbd:function(a,n){return a>>>n},ZuLlI:t(1093)+t(529),JJgJy:"CONNECTI"+t(491),lAbuO:t(373)+"IES_ERROR",WtCmz:"MESSAGE_"+t(1177),BWjAW:t(828)+"OR",wbRIT:t(272),iogke:t(800)+t(848),AGXAk:function(a,n){return a&&n},ndSVV:t(666),Mzjbt:t(1369),MWUVp:t(640),Xcsjf:function(a,n){return a!==n},ZfGjw:"tPPMI",IVCqK:function(a,n){return a!==n},jplWO:t(610),xeijN:"zXwmo",XONXs:t(1543),MjXbg:function(a,n){return a||n},IpkKF:function(a,n){return a!==n},fcwVR:t(1666),RBFBq:function(a,n){return a!==n},xpUhP:"LwzqO",saNNS:"ULVYk",tkHrL:function(a,n){return a>=n},NziIa:function(a,n){return a===n},TfToy:function(a,n){return a>n},ylcBW:"timeout,"+t(1451)+t(760)+"g",gglYp:t(246),LQcmK:t(1162),rxkAR:function(a,n){return a===n},cOONn:function(a,n){return a instanceof n},cxNDa:function(a,n){return a+n},ytvdN:function(a,n){return a+n},tMbfm:function(a,n){return a<n},yCloE:function(a,n){return a>=n},mWHRi:function(a,n){return a|n},PgcnQ:"iEcFd",QDYpp:function(a,n,s){return a(n,s)},ZtHaG:"open",EADoo:t(1667),gYrvN:function(a,n,s){return a(n,s)},GvfUR:t(254),bkCWi:"message",fQfgS:function(a,n,s){return a(n,s)},mddSq:"CwUbE",YgbPq:function(a,n){return a+n},gyQBR:function(a,n){return a(n)},YnVoM:function(a,n){return a===n},ZFtdB:t(1158),dlbNt:"JqkDY",peevo:function(a,n){return a!=n},NeeFt:t(607)+"d",ZLWAi:t(493)+"1",PzIFJ:function(a,n){return a||n},CmGln:function(a,n){return a<=n},nAHgD:t(1114)+t(369)+t(1644)+t(496)+t(441),CvhHn:function(a,n){return a!==n},tNkmW:t(1605),dGtkz:t(531),MjugR:function(a,n){return a(n)},lRoFF:function(a,n){return a(n)},mArUy:function(a,n){return a===n},xyKXQ:function(a,n){return a&n},bmFwT:function(a,n){return a&n},IQBqf:t(762),HXJUJ:t(1380),GmpVU:function(a,n){return a<=n},PrmGL:function(a,n){return a<n},XEUWc:function(a,n){return a>=n},gAfUr:function(a,n){return a|n},KetQr:function(a,n){return a<<n},ceAhG:function(a,n){return a&n},PHlOm:function(a,n){return a&n},EEugp:function(a,n){return a-n},tRvSQ:function(a,n){return a|n},bMOtG:function(a,n){return a&n},QfiMe:function(a,n){return a<<n},QbqKv:function(a,n){return a===n},klCAC:t(1397),OwMSW:function(a,n){return a|n},YHlQh:function(a,n){return a&n},hrZpt:function(a,n){return a&n},fTOYw:function(a,n){return a===n},KkjUW:function(a,n){return a&n},RShRl:function(a,n){return a+n},krWvX:t(985)+t(256),OclsZ:function(a,n){return a+n},yCLDD:function(a,n){return a+n},Vifkp:function(a,n){return a&n},NJohx:function(a,n){return a>>n},qPMyI:function(a,n){return a>>n},VvfKo:function(a,n){return a|n},jNBJi:function(a,n){return a>>n},oKxDs:function(a,n){return a&n},MTjBu:function(a,n,s,l){return a(n,s,l)},UsrDV:function(a,n){return a!=n},rVVmp:function(a,n){return a instanceof n},wNKsy:t(1456)+"ion/json",LQmfq:function(a,n){return a!==n},JGghC:"znTMG",aDILS:function(a,n){return a<n},IUfCu:"CqdOV",qveJf:t(1387),PbWvk:t(1107)+t(1367),LBHBo:function(a,n){return a+n},carWD:t(1393)+t(639)+t(1128)+"P",PcmwB:function(a,n){return a(n)},QzkDr:function(a,n){return a!=n},MIEZo:function(a,n){return a instanceof n},HWlGC:function(a,n){return a==n},WYegB:t(1756)+"in;chars"+t(1058),EXVVE:t(1332),uPlVI:function(a,n){return a+n},wKJYW:function(a,n,s){return a(n,s)},Cmfuy:"cBQPe",Gguss:function(a,n){return a!==n},bZqZO:t(851),tKAJH:function(a,n){return a|n},HJXif:function(a,n){return a&n},XCdKg:function(a,n){return a(n)},mmfgl:function(a,n){return a===n},vckhB:t(1657),bVwDb:function(a,n){return a+n},kwqFw:t(385),qSQIF:t(951),xpRQz:function(a,n){return a!==n},UeoIE:"HNUgy",tpiKE:t(820),evJDM:function(a,n){return a||n},fttbJ:function(a,n){return a!==n},MYZQK:t(580),hMmSa:t(1325),sDJPJ:function(a,n){return a===n},NzaBC:t(1292),JrAcH:t(498),nPEzU:function(a,n){return a||n},HkzzS:function(a,n){return a||n},EGUjX:function(a,n){return a||n},ElapH:"message_id",ZLQQI:function(a,n){return a(n)},SNQIO:function(a){return a()},kqJmz:function(a,n){return a!==n},QhFAB:"TWIae",bsZAZ:"x_fronti"+t(308),kQsYV:function(a,n,s,l){return a(n,s,l)},qpMcM:t(1671)+t(846)+"ck",evQyy:t(1671)+t(1642)+"k",CHWZx:function(a,n,s){return a(n,s)},FKiSX:function(a,n){return a||n},afKdZ:function(a,n,s,l){return a(n,s,l)},ifdco:t(1762),oTcGd:function(a,n){return a&&n},lsLBl:function(a,n){return a===n},yxBhC:t(885),AAYuW:"naMnO",baBsR:function(a){return a()},gUlWU:t(619),LTqRI:"Module",GopkK:function(a,n){return a instanceof n},qsTBm:"wHdVz",PYGBL:t(1456)+"ion/json;charset"+t(447),Hdpql:t(765)+"e",esIAv:t(811),ambKB:function(a,n){return a+n},KOWKZ:function(a,n){return a<<n},uwTuE:function(a,n){return a+n},xaCwc:function(a,n){return a<<n},cWeOK:function(a,n){return a===n},smpGj:"wWYcw",XaPQM:function(a,n){return a>n},CJVHV:function(a,n){return a+n},WKWiM:function(a,n){return a|n},zyFCa:function(a,n){return a||n},WEYUp:function(a,n){return a(n)},ylaYl:function(a,n){return a+n},vSXor:function(a,n){return a||n},iKefl:function(a,n){return a>n},PZMYN:function(a,n){return a>=n},uXjTz:function(a,n,s,l){return a(n,s,l)},IifOg:function(a,n){return a<n},RUjLg:function(a,n,s){return a(n,s)},eSUJE:function(a,n){return a<<n},dDPIS:function(a,n){return a!==n},JLREQ:t(847),HKLyZ:t(554),EmCzi:function(a,n){return a<n},hmykc:function(a,n){return a+n},YvrwF:function(a,n){return a+n},ljxVR:function(a,n){return a+n},IcOKN:function(a,n){return a|n},ldlqo:function(a,n){return a+n},oeZEk:function(a,n){return a+n},SFSmc:function(a,n){return a<<n},gTVXs:function(a,n){return a|n},tdXOP:function(a,n){return a+n},JovAW:function(a,n){return a&n},OUyyK:function(a,n){return a>>>n},LCuzv:function(a,n){return a+n},UrjSZ:function(a,n){return a&n},UBacr:function(a,n){return a&n},DTrpR:function(a,n){return a&n},juoye:function(a,n){return a+n},siGyA:function(a,n){return a&n},YGJed:function(a,n){return a>>>n},bMmWj:function(a,n){return a<n},vtqNK:function(a,n){return a|n},gqHnP:function(a,n){return a<<n},ZHDWN:function(a,n){return a|n},DKUGm:function(a,n){return a&n},ThKWb:function(a,n){return a<n},boAyY:function(a,n){return a>>>n},mUGvr:function(a,n){return a<<n},RmpvO:function(a,n){return a|n},ZWzSv:function(a,n){return a>>>n},QwqZs:function(a,n){return a&n},NXdbh:function(a,n){return a<n},Slptp:t(729),wOsOE:function(a,n){return a|n},YosJy:function(a,n){return a<n},syNUQ:function(a,n){return a(n)},zSlIg:function(a,n){return a+n},iqORj:t(570)+t(612)+t(1433),YlsYC:function(a,n,s,l){return a(n,s,l)},WfVll:function(a,n,s,l){return a(n,s,l)},bvAsK:"header",aHsYW:"name",spwFT:t(1113)+t(1650),jSwAT:t(861),pOuqt:"QvQZr",OXefB:t(1227),QOpnN:function(a,n){return a<n},DmrFv:t(332),Xurnv:function(a,n,s){return a(n,s)},Lyibg:function(a,n,s,l){return a(n,s,l)},OqEaS:"cursor_file_name",bDOoz:t(1019)+t(1001),HsXjX:t(1428)+t(1226),OREbm:"sZRvu",kBBns:t(1303)+t(360),LZLGF:function(a,n,s,l){return a(n,s,l)},fcalF:"INSTANT",PWTgL:t(1592),pGMKO:function(a,n){return a===n},XTyuh:t(581),rLkAg:t(574),FaKNW:t(412),TAikc:t(1264),GLpRu:function(a,n){return a(n)},RwWGx:function(a,n){return a!==n},ALILU:"nSytz",MzkAo:t(287),ErbPC:t(1504),zRKXm:t(1441),lLbVv:t(983),MWzbn:function(a,n){return a!==n},GIyNN:t(1492),ZfEki:"WsbDQ",qYOTo:t(282),TJHSK:function(a,n,s,l){return a(n,s,l)},YFcbE:function(a,n,s){return a(n,s)},JZJBf:t(1671)+t(1198),ISGGY:function(a,n){return a(n)},jorln:function(a,n,s){return a(n,s)},ZMoRp:t(1671)+"er_ttl",MTkdp:t(1566)+t(394)+"e",ktPBN:function(a,n){return a(n)},tpXVR:function(a,n){return a>n},gTAOe:function(a){return a()},ftnAJ:function(a,n){return a<n},NykWc:function(a){return a()},jisOa:t(783),DOmuf:function(a,n){return a(n)},EdfIH:t(276),EzXpB:function(a,n){return a(n)},mGVvV:t(955),gEznc:t(1265),FqAhn:function(a,n){return a!==n},vxRLl:function(a){return a()},gPokw:"CFzsJ",vxKny:function(a,n){return a===n},oZLrS:t(1225),WFLUz:function(a,n,s){return a(n,s)},qOPpT:function(a,n,s){return a(n,s)},KTNCU:function(a,n){return a===n},QFeKS:function(a,n){return a(n)},vDItO:function(a,n,s){return a(n,s)},FzoQg:function(a,n){return a!==n},VckHM:function(a,n,s,l){return a(n,s,l)},LnBqt:t(1463)+t(1739),MSnXN:"pbbp2",iWrjX:function(a,n){return a/n},MHKNT:function(a,n){return a==n},QdeTW:"please p"+t(907)+t(1297),Cdslz:"please p"+t(289)+"s params"+t(952)+t(1399)+t(618)+"is undefined",BbqjN:t(788),IGkKQ:function(a,n,s){return a(n,s)},hHaYk:"reconnect",jsOpd:t(1169)+"ediately reconnect",KKEWj:t(1108),QAfAp:t(1623),aQfQJ:t(1324),YpXDt:t(939),JDeTp:t(1408),QFoIY:t(1294),sEbPg:function(a,n){return a!==n},ThRcZ:t(1647),OnaoE:t(1439),paCFY:t(1123),CdnJy:"device_id",FAZEx:function(a,n){return a==n},dERMS:"function",oxXXE:function(a){return a()},aJNmg:function(a,n,s){return a(n,s)},iwfqW:t(1341)+"0",WpxTT:function(a){return a()},caqDo:function(a,n){return a&n},hIjWt:function(a,n){return a===n},sTaDo:function(a,n){return a&n},PfJlQ:t(1034),pERXd:function(a,n){return a!==n},qqGDQ:t(239),sFrIC:"yioxH",mGIQT:function(a,n,s){return a(n,s)},Uuitc:function(a,n){return a||n},QSXVj:function(a,n,s){return a(n,s)},heMay:t(1413),gksyg:function(a,n,s){return a(n,s)},FjSzq:function(a,n){return a!==n},hhlDy:t(978),gRyro:function(a,n){return a(n)},ummjg:function(a,n){return a(n)},rmQzT:function(a,n){return a!==n},SCmAH:t(1452),tzBMQ:t(1334)+t(1318)+"t",afhtQ:"timeout",VGUSO:t(1601)+t(1761)+"reconnec"+t(1570)+t(409),LDoZi:t(927),qZwYW:function(a,n,s){return a(n,s)},MmEqM:t(1038),rnBcr:t(1394),ImjtH:t(1546)+t(1e3)+t(1070)+"1",JuURD:function(a,n){return a|n},wXSde:function(a,n){return a&n},ioELW:function(a,n){return a|n},aYuXO:function(a,n){return a>n},ENFjE:function(a,n,s,l){return a(n,s,l)},fBIKV:function(a,n){return a&n},oFtsf:t(617),mKfLs:function(a,n){return a(n)},JRQZj:"Dflpf",pVuuz:"QVtnZ",SvDVd:function(a,n){return a===n},KCPGI:function(a,n){return a===n},vHQgj:t(1333),TsegZ:"CYDLP",DAyJY:function(a,n,s){return a(n,s)},LFvzS:function(a,n,s){return a(n,s)},QuhDE:t(1601)+t(1698)+"ork offl"+t(410),UkvVH:t(915)+t(1604),GSOGY:t(1567)+t(1140)+t(1432)+t(867)+"ed",VVOGN:function(a,n){return a===n},FPoLL:function(a,n){return a===n},EKHzx:t(1567)+t(243)+t(1552),dYEMq:function(a,n){return a==n},WTHRQ:t(757)+"rovide a"+t(1209)+"ata, data must b"+t(1136)+t(758)+t(1471)+"ffer",DWHPg:function(a,n){return a==n},uykRu:t(944),Qggeq:function(a,n){return a instanceof n},ZIBst:function(a,n){return a(n)},AJZMy:function(a,n){return a(n)},FcOfs:t(757)+t(920)+t(519)+t(638),kHlPn:function(a,n){return a instanceof n},WSosH:function(a,n){return a(n)},UvRZg:function(a,n){return a===n},wwrbF:t(709),KmPQD:t(266),rPyuN:t(255),UZUbx:t(621),dAUEt:t(347)+"0",jLaZZ:function(a,n){return a===n},oZEFm:function(a,n){return a(n)},CKljJ:function(a,n){return a/n},YATvh:function(a,n){return a!=n},AMMeZ:t(827),RVIDZ:function(a,n){return a!=n},ncBQv:function(a,n){return a!=n},tfJls:t(1611)+t(1709)+t(1216)+"pe",Bdutq:function(a,n){return a!=n},yRfnj:t(1296),IbhvN:function(a,n){return a!=n},PyeaC:function(a,n){return a!=n},aQPop:function(a,n){return a!=n},hooXK:function(a,n){return a===n},tanRX:function(a,n){return a===n},bCYiw:function(a,n){return a!=n},qtYLO:function(a,n){return a!=n},JlGSw:function(a,n,s){return a(n,s)},sLyUR:t(253)+"qos__"};Bt.r(Te),Bt.d(Te,{FWS:()=>eg,CustomErrorEvent:()=>Jd,createCloseEvent:()=>xt,ReconnectEvent:()=>Vd,createErrorEvent:()=>at,decodedFrame:()=>tn,createOpenEvent:()=>tl,CustomCloseEvent:()=>Zd,createReconnectEvent:()=>da,FrontierMessageEvent:()=>Xd,encodeFrame:()=>zt,createMessageEvent:()=>el,OpenEvent:()=>Qd,ErrorCode:()=>rn,Event:()=>Qn,MessageEvent:()=>Yd});let r="";function i(a=""){let n=t,s="02",l=""+Date[n(1347)](),f=r||(r=e.YDZzZ(x,a)),h=Math[n(701)]()[n(223)](16).slice(-6);return e[n(1004)](e[n(1734)](e[n(1431)](s,l),f),h)}function o(){let a=t;return e[a(725)](1e4,Date[a(1347)]())+Math[a(766)](1e4*Math.random())}function c(a){let n=t;return e[n(1263)](e[n(1368)](Array,8).join("0"),parseInt(a,10)[n(223)](2))[n(635)](-8)}function d(a){let n=t;return e[n(745)](e.LDBjC,e[n(1350)])?this[n(1737)].protocol:e[n(1263)](e[n(433)](Array,4)[n(331)]("0"),parseInt(a,2)[n(223)](16))[n(635)](-4)}function u(a){let n=t,s=a[n(1469)](/\./).map(h=>c(h)),l=[];return l[0]=d(s[0]+s[1]),l[1]=d(s[2]+s[3]),[e[n(1603)],e.rqajZ,n(1660),e[n(1603)],e[n(1603)],e[n(1590)],l[0],l[1]][n(331)]("")}function x(a){let n=t;if(e.cjzWi(e[n(585)],e[n(755)]))_0x5a6383[n(1301)+"entListener"](beOYEp[n(772)],_0x3416e8),_0x35d296["removeEventListe"+n(1115)](beOYEp[n(839)],_0x25b060);else{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}/[n(1484)](a),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1484)](a);return s?e[n(1453)](u,a):l?e.YGlJZ(p,a):"00000000"+n(234)+n(234)+n(234)}}function p(a){let n=t;if(e[n(745)](e[n(938)],n(1280))){let s={WlLTr:e.KZsZq,WXkBi:function(l,f,h){return e.ppuYu(l,f,h)}};return new _0x1f6e81((l,f)=>{let h=n,E={mbCTl:function(A,D){return A(D)},lSRZP:h(987),DShJJ:s.WlLTr,vtrVy:h(1467),XMtJO:h(1334)+"e_timeout"};this["_clearPi"+h(1131)](),this["_pingPon"+h(348)+"Id"]=s[h(1519)](_0x12b268,this[h(922)][h(921)](this),this[h(1472)]["pingInte"+h(652)]);let b=()=>{let A=h;E[A(510)](l,E[A(818)]),this[A(1069)](E[A(1222)],b),this[A(1069)](A(1334)+"e_timeout",m)},m=()=>{let A=h;E[A(510)](f,E[A(1738)]),this[A(1069)](E.DShJJ,b),this[A(1069)](E[A(1699)],m)};this.on(s[h(1245)],b),this.on("ping_once_timeout",m),this[h(922)]()})}else{let s="",l=[],f=0,h=0,E=!0,b=e[n(1603)];if(e.SnfGB(a.indexOf("::"),-1))if(e[n(383)](n(667),n(1674))){let m=a[n(1469)]("::");for(let D=0;D<m[n(657)];D++){let B=m[D];if(e.VkKsp(B.indexOf(":"),0)){let $=B[n(1469)](":");E&&(f=$[n(657)]),h+=$[n(657)];for(let V=0;V<$.length;V++)if(e[n(745)](4,$[V].length)){let Le=b[n(1344)+"g"](0,e[n(1475)](4,$[V][n(657)])),ht=Le[n(1474)]($[V]);l.push(ht)}else l[n(889)]($[V]);E=!1}else{if(B[n(657)]!==4){let $=b[n(1344)+"g"](0,e[n(1475)](4,B[n(657)])),V=$.concat(B);l[n(889)](V)}else l[n(889)](B);E&&(f+=1),h+=1,E=!1}}let A="";for(let D=0;e[n(609)](D,e.jawOe(8,h));D++)A=A[n(1474)](b);for(let D=0;e.OdyaR(D,l[n(657)]);D++)e.rwDWz(D,f)?(s=s[n(1474)](A),s=s.concat(l[D])):s=s[n(1474)](l[D]);return s}else return _0xbc6105;{let m=a[n(1469)](":");for(let A=0;e[n(1496)](A,m[n(657)]);A++){let D=m[A];if(e[n(937)](4,m[A][n(657)])){let B=b[n(1344)+"g"](0,e[n(1475)](4,m[A][n(657)])),$=B[n(1474)](D);s=s[n(1474)]($)}else s=s.concat(D)}return s}}}function g(a,n){let s=t;if(e.pwNGn(s(473),e.EbjQs)){let l=a.key;e[s(1434)](void 0,l)&&(e.ysCua(e[s(1615)],e[s(299)])?(e[s(733)](xe,n,10),e[s(733)](H,n,l)):(this[s(661)+s(1593)].shift(),this[s(661)+s(1593)][s(889)](_0x383b39)));let f=a[s(1684)];f!==void 0&&(e[s(733)](xe,n,18),H(n,f))}else return this[s(1737)][s(1081)]}function _(a){let n=t,s={};e:for(;!e.uPYaA(K,a);){let l=e.Vdtpy(fe,a);switch(l>>>3){case 0:break e;case 1:s.key=e[n(733)](L,a,e.Vdtpy(fe,a));break;case 2:s[n(1684)]=e.ppuYu(L,a,fe(a));break;default:e[n(1396)](R,a,e[n(868)](7,l))}}if(s.key===void 0)throw new Error(e[n(430)]);if(e[n(1142)](void 0,s[n(1684)]))throw new Error(n(341)+n(1712)+" field: "+n(1684));return s}function S(a){let n=t,s=e[n(1395)](k);return e[n(1396)](w,a,s),e.uPYaA(N,s)}function w(a,n){let s=t,l={uIsSr:function(f,h,E){return e[U(1396)](f,h,E)},FCjpc:e[s(839)],AlQIo:function(f,h){return f|h},QInNX:function(f,h){return e.QyUcY(f,h)},FVvYV:function(f,h){return e[s(868)](f,h)},FfaIr:function(f,h){return e[s(1385)](f,h)},ulzwF:function(f,h){return f<h},MOXun:function(f,h){return e[s(507)](f,h)},HpFsc:function(f,h){return e[s(588)](f,h)},IsXIS:function(f,h){return e[s(868)](f,h)},kuvhW:function(f,h){return f<h},mDXIK:function(f,h){return f|h},ACqTn:function(f,h){return e[s(1323)](f,h)},UMLvv:function(f,h){return f===h},rAwgA:function(f,h){return e[s(1620)](f,h)},VhzvA:function(f,h){return f&h},HrBOj:e[s(553)],KJtqW:function(f,h){return f>>h},QOBkb:function(f,h){return e[s(499)](f,h)},Zjwes:function(f,h){return e[s(779)](f,h)},ebTBc:function(f,h){return e[s(1431)](f,h)},moLyg:function(f,h){return e[s(499)](f,h)},bxFoP:function(f,h){return e[s(499)](f,h)},PkUgk:function(f,h){return e[s(1589)](f,h)},XcSiB:function(f,h){return e[s(925)](f,h)},dXZsG:function(f,h){return e[s(1589)](f,h)}};if(e[s(937)](e.sfHzZ,"LiYhJ")){let f=a[s(807)];if(e[s(745)](void 0,f))if(e[s(302)]===e[s(302)])xe(n,8),ft(n,f);else return this[s(661)+s(1593)][s(1156)]((je,Ze)=>(je+=Ze&&Ze[s(785)+"th"]||0,je),0)+(this[s(721)]?this[s(721)]["buffered"+s(874)]:0);let h=a[s(521)];if(e.xfjhf(void 0,h))if(e[s(233)](e[s(283)],"hoZUJ"))e.RUQhn(xe,n,16),ft(n,h);else{let Ut={hcVqL:function(je,Ze,pt){return e[s(733)](je,Ze,pt)},SZVFa:e.CExvs};if(e[s(1212)](_0x3c09e1,_0x28546f)){let je=_0x5a61c4[s(988)][s(635)](_0x18a39b[s(899)+"et"],e[s(507)](_0x1d9fbb[s(785)+"th"],_0x44d6f7[s(899)+"et"]));this[s(1737)]&&this._socket[s(1409)]({data:je,fail:Ze=>{let pt=s;this[pt(1700)](pt(461),l[pt(587)](_0x2941c0,l[pt(1531)],{message:this["_formatE"+pt(1015)+pt(719)](Ze)}))}})}else this[s(1737)]&&this._socket[s(1409)]({data:_0xf41432,fail:je=>{let Ze=s;this[Ze(1700)]("error",Ut.hcVqL(_0x31d2a6,Ut[Ze(1498)],{message:this[Ze(1726)+"rrorMess"+Ze(719)](je)}))}})}let E=a[s(601)];e[s(325)](void 0,E)&&(e[s(1396)](xe,n,24),e.ppuYu(ft,n,e[s(1453)](P,E)));let b=a[s(548)];e[s(1434)](void 0,b)&&(e.RUQhn(xe,n,32),e[s(733)](ft,n,e[s(396)](P,b)));let m=a[s(655)];if(e[s(1288)](void 0,m))for(let Ut of m){e[s(1055)](xe,n,42);let je=k();g(Ut,je),e[s(1616)](xe,n,je[s(1270)]),e.RUQhn(W,n,je),O(je)}let A=a[s(1398)+s(1260)];e.vWWrG(void 0,A)&&(e[s(733)](xe,n,50),e.ppuYu(H,n,A));let D=a[s(306)+s(1557)];if(e.CIYzT(void 0,D))if(e.FOxKE===e[s(451)])e.ppuYu(xe,n,58),e[s(1049)](H,n,D);else return!!(this[s(353)+s(837)]>=this[s(1362)+"s"][s(657)]||e[s(1438)](this.currentIndex,this[s(1362)+"s"][s(657)]-1)&&e[s(965)](this[s(822)+s(1097)+s(781)+"t"],this[s(1656)+"es"]));let B=a.payload;B!==void 0&&(xe(n,66),xe(n,B[s(657)]),e[s(733)](se,n,B));let $=a[s(1035)];e.CIYzT(void 0,$)&&(e.yxMac(xe,n,74),e[s(1419)](H,n,$));let V=a[s(1424)+s(1598)];V!==void 0&&(e.mGDoO(xe,n,82),H(n,V));let Le=a[s(1376)];e[s(295)](void 0,Le)&&(e[s(1065)](e[s(237)],e[s(608)])?(_0x3b8bf8=l[s(1560)](l.AlQIo(l[s(1274)](l[s(684)](7,_0x3b6527),18),l[s(330)](l.FVvYV(63,_0x301a65),12))|l[s(1274)](l[s(684)](63,_0x2161d2),6),l[s(684)](63,_0x307056)),l[s(1356)](_0x5100a4,65536)||_0xe2d92e>1114111?_0x27b158+=_0x54e728:(_0x78464a-=65536,_0x6d4048+=_0x2e0dbf(l[s(1470)](l.HpFsc(_0x3b939a,10),55296),l[s(1470)](l[s(414)](1023,_0xc071e),56320)),_0x179b06+=3)):(e[s(1419)](xe,n,90),e[s(504)](H,n,Le)));let ht=a.frameType;e[s(1095)](void 0,ht)&&(e[s(504)](xe,n,96),e[s(518)](ft,n,e.TrDzt(P,ht)))}else if(_0x2bbd6c=_0x2cb937[s(368)+"At"](_0x527546),l[s(226)](_0x1f8a84,128))_0x37f4b5[_0xe7d4a3++]=_0x78f259;else if(_0xe327cc<2048)_0x10c881[_0x3fca84++]=l[s(1545)](l.ACqTn(_0x504d62,6),192),_0xe16207[_0x1fdcc9++]=l[s(414)](63,_0x5dd26b)|128;else if(l[s(1149)](l.rAwgA(64512,_0x37f98d),55296)&&l[s(1149)](l[s(470)](64512,_0x524c39=_0x4f2c6f[s(368)+"At"](l[s(1470)](_0x3f5412,1))),56320)){let f=l.HrBOj[s(1469)]("|"),h=0;for(;;){switch(f[h++]){case"0":_0x4dde5f[_0x1049c0++]=l[s(1193)](_0x3f0c70,18)|240;continue;case"1":_0x3419c8[_0x83c5a4++]=l[s(810)](l[s(470)](l.KJtqW(_0x19addb,6),63),128);continue;case"2":_0x464e3b=l[s(340)](l[s(1364)](65536,l[s(1274)](l[s(684)](1023,_0x19a5a2),10)),l[s(470)](1023,_0x52c48b));continue;case"3":_0x2462bf[_0x4e1539++]=l.moLyg(l[s(414)](_0x5121bd>>12,63),128);continue;case"4":++_0x148e37;continue;case"5":_0x19cb31[_0x3ac930++]=l[s(534)](l.VhzvA(63,_0x33fce1),128);continue}break}}else _0x19f651[_0x7db0bc++]=l[s(1302)](_0x4bf9d3,12)|224,_0x597cc7[_0x382a96++]=l[s(852)](l[s(414)](l[s(734)](_0xc0bf8a,6),63),128),_0x5f3176[_0x5c60ec++]=l.mDXIK(63&_0x36749c,128)}function v(a){let n=t;return e[n(658)](e[n(1057)],e[n(1322)])?(_0x5f33e4||(_0x44d692=_0x20e4ff.resolve()[n(1711)](_0x1c8b37[n(921)](_0x5e86ad,e[n(495)]))),_0x495472):e.YNCCS(I,F(a))}function I(a){let n=t,s={};e:for(;!K(a);){let l=e[n(1697)](fe,a);switch(e[n(1154)](l,3)){case 0:break e;case 1:s.SeqID=e[n(1321)](It,a,!0);break;case 2:s[n(521)]=e.EgbCr(It,a,!0);break;case 3:s[n(601)]=e[n(1219)](fe,a);break;case 4:s[n(548)]=fe(a);break;case 5:{let f=e[n(880)](T,a);(s[n(655)]||(s[n(655)]=[])).push(e[n(365)](_,a)),a[n(1270)]=f;break}case 6:s[n(1398)+n(1260)]=L(a,e[n(625)](fe,a));break;case 7:s[n(306)+"ype"]=e[n(1287)](L,a,fe(a));break;case 8:s[n(1291)]=e[n(314)](re,a,fe(a));break;case 9:s[n(1035)]=e[n(518)](L,a,e[n(1219)](fe,a));break;case 10:s[n(1424)+n(1598)]=e[n(1516)](L,a,e.ZOjFc(fe,a));break;case 11:s[n(1376)]=e[n(423)](L,a,e[n(1697)](fe,a));break;case 12:s.frameType=e[n(1368)](fe,a);break;default:R(a,e[n(1144)](7,l))}}if(e.cjzWi(void 0,s.SeqID))throw new Error(e[n(1014)]);if(e[n(1357)](void 0,s[n(521)]))throw new Error(n(341)+n(1712)+n(653)+n(521));if(e.KVHEd(void 0,s[n(601)]))throw new Error(e[n(1421)]);if(e[n(1596)](void 0,s[n(548)]))throw new Error(n(341)+n(1712)+" field: "+n(548));return s}function T(a){let n=t,s=e[n(365)](fe,a),l=a[n(1270)];return a.limit=a[n(953)]+s,l}function R(a,n){let s=t;switch(n){case 0:for(;e[s(868)](128,ie(a)););break;case 2:J(a,e[s(1077)](fe,a));break;case 5:e[s(565)](J,a,4);break;case 1:J(a,8);break;default:throw new Error(e.wUyMw(e[s(1459)],n))}}function P(a){return a|=0,{low:a,high:a>>31,unsigned:a>=0}}let y=[];function k(){let a=t,n=y.pop();return n?(n[a(953)]=n[a(1270)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){y.push(a)}function F(a){let n=t;return e[n(745)](n(1766),e[n(1377)])?{bytes:a,offset:0,limit:a[n(657)]}:_0x211029?_0x5222e0[n(1041)+n(1572)](_0x4047c2,_0x4aa77e):_0x27bc0e["fromByte"+n(323)](_0x52c887,_0x185b41)}function N(a){let n=t,s=a[n(544)],l=a[n(1270)];return e[n(1319)](s[n(657)],l)?s:s[n(1170)](0,l)}function J(a,n){let s=t;if(e[s(1180)](e[s(1488)],e[s(1488)])){if(e[s(1250)](e[s(522)],typeof _0x4133b8)){let l=new _0x1e64b0(e[s(365)](_0x2d9673,_0xf09a93));return e.mkzYI(_0x5d2e43,_0x42c885,l,0),l}return e[s(1450)](_0x3c270b,_0x1fd0fb)?new _0xace226(_0x3167a7):new _0x53adbd(_0x8e8ebd.buffer,_0x46f92f[s(899)+"et"],_0x21200f[s(785)+"th"])}else{if(e[s(794)](e[s(824)](a.offset,n),a[s(1270)]))throw new Error(e[s(564)]);a[s(953)]+=n}}function K(a){let n=t;return e[n(1434)](n(1725),e[n(1037)])?!!this[n(1721)]:e[n(329)](a.offset,a[n(1270)])}function ee(a,n){let s=t,l=a[s(544)],f=a.offset,h=a[s(1270)],E=e[s(1263)](f,n);if(e.ecSuB(E,l[s(657)])){let b=new Uint8Array(e.oZSky(2,E));b[s(1194)](l),a[s(544)]=b}return a[s(953)]=E,e[s(556)](E,h)&&(a[s(1270)]=E),f}function Z(a,n){let s=t,l=a[s(953)];if(e[s(674)](e[s(507)](l,n),a.limit))throw new Error(e[s(407)]);return a[s(953)]+=n,l}function re(a,n){let s=t,l=e.IHQgy(Z,a,n);return a[s(544)][s(1170)](l,e[s(824)](l,n))}function se(a,n){let s=t,l=e[s(1287)](ee,a,n[s(657)]);a.bytes[s(1194)](n,l)}function L(a,n){let s=t;if(e[s(843)](e.MxrrL,s(1027))){let l=e[s(606)](Z,a,n),f=String["fromChar"+s(1261)],h=a[s(544)],E="\uFFFD",b="";for(let m=0;e[s(609)](m,n);m++){let A=h[e[s(1734)](m,l)],D,B,$,V;e.HNitP(e[s(349)](128,A),0)?b+=e.iEfJa(f,A):e.RWFkC(e[s(1144)](224,A),192)?e.BuyCO(e[s(824)](m,1),n)?b+=E:(D=h[e[s(1349)](e[s(779)](m,l),1)],e[s(367)](192&D,128)?b+=E:(V=e.jgrXN(e[s(1385)](31&A,6),e.EyBgy(63,D)),e[s(609)](V,128)?b+=E:(b+=f(V),m++))):e[s(1092)](e[s(1144)](240,A),224)?e[s(634)](e.kIaDy(m,2),n)?b+=E:(D=h[e[s(750)](m,l)+1],B=h[e[s(1431)](m,l)+2],e[s(349)](e[s(465)](D,e.QyUcY(B,8)),49344)!==32896?b+=E:(V=e[s(925)](e[s(499)]((15&A)<<12,e.QyUcY(e.FfcDg(63,D),6)),e[s(1144)](63,B)),e[s(298)](V,2048)||e[s(434)](V,55296)&&e[s(1249)](V,57343)?b+=E:(b+=f(V),m+=2))):e[s(1468)](e[s(1100)](248,A),240)?e[s(1659)](e[s(595)](m,3),n)?b+=E:(D=h[e[s(294)](e[s(1263)](m,l),1)],B=h[e[s(1028)](m,l)+2],$=h[e.dSOqH(m+l,3)],e[s(1095)](e[s(1100)](e.KmPec(D|e[s(1385)](B,8),$<<16),12632256),8421504)?b+=E:(V=e[s(499)](e.jgrXN(e[s(1144)](7,A)<<18,e.zRQka(e[s(1144)](63,D),12)),(63&B)<<6)|e[s(1046)](63,$),V<65536||V>1114111?b+=E:(V-=65536,b+=e[s(524)](f,e[s(1263)](V>>10,55296),e.pehGW(1023,V)+56320),m+=3))):b+=E}return b}else this["_miniNav"+s(1098)+s(1094)]=_0x4bc83f,_0x5e7497?this[s(449)+s(379)]():this[s(449)+s(826)]()}function H(a,n){let s=t,l=n[s(657)],f=0;for(let b=0;e[s(609)](b,l);b++){let m=n[s(368)+"At"](b);e[s(1238)](m,55296)&&e.Cfgtn(m,56319)&&e[s(1496)](e.ucQnB(b,1),l)&&(m=e[s(228)](e.pvJMc(m,10)+n[s(368)+"At"](++b),56613888)),f+=e[s(1230)](m,128)?1:e[s(261)](m,2048)?2:e[s(913)](m,65536)?3:4}e.XuKEp(xe,a,f);let h=e[s(504)](ee,a,f),E=a[s(544)];for(let b=0;b<l;b++){let m=n[s(368)+"At"](b);if(e.HhGOr(m,55296)&&e.Cfgtn(m,56319)&&e[s(1496)](e.QkkWp(b,1),l)&&(m=e[s(744)](e[s(1271)](e[s(1385)](m,10),n[s(368)+"At"](++b)),56613888)),e.leFBG(m,128))E[h++]=m;else{if(m<2048)E[h++]=e[s(888)](m>>6,31)|192;else{if(e[s(1596)](e[s(1382)],e[s(668)]))return this[s(1737)][s(390)+"te"];e[s(1496)](m,65536)?E[h++]=e[s(465)](e[s(1631)](e[s(1418)](m,12),15),224):e[s(1434)](e[s(1061)],e.bTscS)?(E[h++]=e[s(499)](e.uNtrY(e.RXidu(m,18),7),240),E[h++]=e[s(465)](e[s(288)](m,12)&63,128)):_0xd1be12&&this[s(1742)+"anager"][s(1126)+s(859)+s(1102)](_0x8db1b0),E[h++]=e.owJZa(e[s(1323)](m,6)&63,128)}E[h++]=e[s(1630)](63,m)|128}}}function W(a,n){let s=t;if(e.TdHHX(s(1621),e[s(1182)])){let l=ee(a,n[s(1270)]),f=a[s(544)],h=n.bytes;for(let E=0,b=n.limit;E<b;E++)f[E+l]=h[E]}else _0x42f489[s(528)+"oad"]="",_0x50347f[s(928)](_0x13741b)}function ie(a){let n=t;return a[n(544)][e[n(1060)](Z,a,1)]}function Je(a,n){let s=t,l=e[s(1516)](ee,a,1);a.bytes[l]=n}function fe(a){let n=t,s=0,l=0,f;do f=e.YDZzZ(ie,a),s<32&&(l|=(127&f)<<s),s+=7;while(e[n(912)](128,f));return l}function xe(a,n){let s=t;if(e[s(1319)](e[s(897)],e[s(454)]))this["_dispatc"+s(291)+s(1032)](_0x4c1530),_0x850f2c[s(1194)](_0x111251,_0x48c924,_0x33afc9[s(543)][s(601)]);else{for(n>>>=0;e[s(1152)](n,128);)e.mwkol(Je,a,e[s(1501)](127,n)|128),n>>>=7;e[s(1060)](Je,a,n)}}function It(a,n){let s=t,l={tavpF:function(m,A,D){return e[U(518)](m,A,D)},yPmuw:e.WnaLO},f=0,h=0,E=0,b;return b=e.NsLzZ(ie,a),f=127&b,e.iCNYR(128,b)&&(b=ie(a),f|=e[s(1486)](127&b,7),128&b&&(e[s(1610)](e[s(1444)],e[s(1542)])?(this[s(1050)+s(428)+"Id"]=null,this[s(1050)+"l"]=36e5,this._qosDB=l[s(1532)](_0x32932a,l[s(1694)],s(346)+"id")):(b=e[s(880)](ie,a),f|=e[s(1631)](127,b)<<14,e.mInUi(128,b)&&(b=e.ckeDh(ie,a),f|=e[s(431)](127&b,21),128&b&&(b=e[s(1697)](ie,a),h=e[s(1365)](127,b),e[s(1753)](128,b)&&(b=ie(a),h|=e[s(1624)](e.SstKr(127,b),7),e[s(497)](128,b)&&(b=e.moluy(ie,a),h|=e.RQRgq(e[s(1213)](127,b),14),e.WixjE(128,b)&&(b=ie(a),h|=e[s(693)](e[s(1059)](127,b),21),e[s(1536)](128,b)&&(b=ie(a),E=e[s(322)](127,b),e[s(862)](128,b)&&(b=e[s(361)](ie,a),E|=e[s(336)](e[s(1404)](127,b),7))))))))))),{low:f|e[s(908)](h,28),high:e[s(950)](h,4)|E<<24,unsigned:n}}function ft(a,n){let s=t,l={oICLn:function(f,h){return e[U(1404)](f,h)},JsJrN:function(f,h){return f>>>h},sZnDC:function(f,h){return e.Xzden(f,h)},XawZH:function(f,h){return e[U(1555)](f,h)},AffVL:function(f,h){return f&h},opIKB:function(f,h){return e[U(1154)](f,h)},dnPNI:function(f,h){return e.MAJyk(f,h)},rsXAr:function(f,h){return f>>>h}};if(e[s(345)]===s(1476)){let f=this.high,h=this[s(1581)];return[l[s(598)](255,h),l[s(715)](h,8)&255,l[s(1099)](l.XawZH(h,16),255),l[s(715)](h,24),l[s(1099)](255,f),l[s(1228)](l.opIKB(f,8),255),l.dnPNI(f>>>16,255),l[s(1606)](f,24)]}else{let f=e[s(1461)](n.low,0),h=e[s(829)](e[s(1752)](e[s(829)](n[s(1581)],28),e[s(1217)](n[s(535)],4)),0),E=e.ozNpy(n.high,24),b=e[s(1610)](0,E)?e[s(1596)](0,h)?e[s(516)](f,16384)?e[s(1363)](f,128)?1:2:e[s(298)](f,2097152)?3:4:e[s(298)](h,16384)?e.gzeGf(h,128)?5:6:h<2097152?7:8:e.Aactb(E,128)?9:10,m=e[s(733)](ee,a,b),A=a[s(544)];switch(b){case 10:A[e[s(1734)](m,9)]=e.yybRG(E>>>7,1);case 9:A[e[s(578)](m,8)]=e[s(1584)](9,b)?e[s(444)](128,E):e.FqHna(127,E);case 8:A[e.mDrST(m,7)]=b!==8?h>>>21|128:e[s(1404)](e[s(974)](h,21),127);case 7:A[e[s(1720)](m,6)]=b!==7?e[s(562)](h,14)|128:e[s(502)](h>>>14,127);case 6:A[e[s(1734)](m,5)]=e[s(1579)](6,b)?e[s(1154)](h,7)|128:e[s(697)](h>>>7,127);case 5:A[e[s(1004)](m,4)]=e.LoPmN(5,b)?e.jgrXN(128,h):e[s(1046)](127,h);case 4:A[e.mDrST(m,3)]=e[s(937)](4,b)?e[s(1713)](e[s(1379)](f,21),128):e[s(697)](e[s(974)](f,21),127);case 3:A[m+2]=e[s(1608)](3,b)?e[s(1663)](e.uleld(f,14),128):e[s(267)](e.KngVo(f,14),127);case 2:A[e[s(1392)](m,1)]=e.Aioce(2,b)?e.owJZa(e[s(1178)](f,7),128):e.XdFoa(e[s(1379)](f,7),127);case 1:A[m]=e[s(295)](1,b)?e.KmPec(128,f):e[s(888)](127,f)}}}function tn(a){return e[t(271)](v,a)}function zt(a){let n=t;return e[n(1192)](e[n(405)],e[n(405)])?new _0x592d1a(_0x3c9adf,{code:_0x87759d,reason:_0x464d4c,wasClean:_0x57166a,willReconnect:_0x3d32bc}):e[n(251)](S,a)}let nn=65536,Vr=t(1116),ge=e[t(1183)](nn,nn),Se=e[t(725)](ge,ge),Xn=e.CKljJ(Se,2),Re=String[t(1727)+"e"][t(368)+"At"];class ue{constructor(n,s,l){let f=t;this[f(740)]=!0,this[f(1581)]=0|n,this.high=e[f(1414)](0,s),this[f(947)]=!!l}static[t(740)](n){let s=t;return n&&e.mVVfl(!0,n[s(740)])}static[t(782)](n,s,l){return new ue(n,s,l)}static fromBytes(n,s,l){let f=t;return l?ue[f(1041)+f(1572)](n,s):ue["fromByte"+f(323)](n,s)}static[t(1041)+"sLE"](n,s){let l=t;return new ue(e.ErSln(e[l(1663)](n[0],n[1]<<8)|e[l(693)](n[2],16),e[l(850)](n[3],24)),e.jgrXN(e[l(854)](n[4],n[5]<<8)|n[6]<<16,n[7]<<24),s)}static[t(1041)+"sBE"](n,s){let l=t;return new ue(e.owJZa(e[l(925)](e[l(1414)](e.kkjBL(n[4],24),e[l(1486)](n[5],16)),e[l(898)](n[6],8)),n[7]),e.owJZa(e[l(465)](e[l(1414)](n[0]<<24,e[l(1155)](n[1],16)),n[2]<<8),n[3]),s)}static[t(1585)](n){let s=t;return e.dRWOV(n,Vr)?$d:new ue(e.XWMNn(e[s(1701)](e[s(465)](Re.call(n,0)|e[s(1624)](Re[s(474)](n,1),8),e.ZKYlv(Re[s(474)](n,2),16)),e[s(1217)](Re.call(n,3),24)),0),e.uZiFK(e[s(777)](e[s(1716)](e[s(1448)](Re[s(474)](n,4),e[s(1155)](Re[s(474)](n,5),8)),e[s(431)](Re[s(474)](n,6),16)),e.zRQka(Re.call(n,7),24)),0),!0)}toHash(){let n=t;return String.fromCharCode(255&this[n(1581)],e[n(502)](e.uZiFK(this[n(1581)],8),255),e.ffUVX(e[n(950)](this[n(1581)],16),255),this[n(1581)]>>>24,e[n(1365)](255,this[n(535)]),e.FiGJs(e[n(404)](this[n(535)],8),255),e[n(1764)](this[n(535)],16)&255,e[n(404)](this.high,24))}static fromNumber(n,s=!0){let l=t;if(isNaN(n))return s?fp:$d;if(s){if(e[l(834)](e[l(739)],e[l(739)])){let f=_0x3362fa[_0x33dcbd++];if(e[l(592)](f,127))_0x3347ae+=_0x4df113[l(1103)+l(1261)](f);else if(e[l(634)](f,192)&&e.OdyaR(f,224))_0x43e89f+=_0x11b1c8[l(1103)+"Code"](e[l(1020)](e[l(775)](31,f),6)|e[l(1501)](63,_0x543fa3[_0x21acae++]));else if(e[l(1152)](f,224)&&e[l(773)](f,240))_0x214f34+=_0x75d909[l(1103)+l(1261)](e[l(854)](e.Gokyz(e[l(1517)](e[l(1587)](15,f),12),e[l(336)](e.QDCXZ(63,_0x4c272f[_0x3b6c66++]),6)),e[l(808)](63,_0x4ff387[_0x29c522++])));else if(e[l(1152)](f,240)){let h=e.KCqNU(e[l(1574)](e[l(1155)](e[l(716)](7,f),18)|e.VcXvc(e[l(545)](63,_0x4120a0[_0x32fcb4++]),12),e[l(1181)](e[l(1679)](63,_0x1ae4e5[_0x283f56++]),6)),e.LBasK(63,_0x366684[_0x59eedf++]))-65536;_0x3cc9ee+=_0x407182[l(1103)+l(1261)](e.SLzFz(55296,e[l(1589)](h,10))),_0x1c8975+=_0x5e216e[l(1103)+l(1261)](e[l(1392)](56320,1023&h))}}else if(e[l(1137)](n,Se))return hp}else{if(e[l(624)](n,-Xn))return pp;if(e[l(1152)](e.YpfxF(n,1),Xn))return xp}return ue[l(782)](n%ge|0,e[l(1535)](e[l(1462)](n,ge),0),s)}toNumber(){let n=t;if(e[n(1596)](n(813),e.nvKFQ))return this[n(947)]?e[n(1183)](e.uQmUz(this[n(535)],0),ge)+e[n(732)](this[n(1581)],0):e.DExAu(this[n(535)],ge)+(this.low>>>0);_0x30cf27[n(586)][n(1208)+n(1445)](_0x43823a),_0x51da3c["frontier"+n(1045)]=void 0,_0x4602e5(_0x2959c7&&_0x5f1218[n(1586)]||e[n(1446)])}[t(1308)](){let n=t;return e[n(976)](0,this[n(535)])&&e.iDodY(0,this[n(1581)])}[t(1412)](n){let s=t;ue[s(740)](n)||(n=ue[s(1573)+"er"](n));let l=e[s(1696)](this[s(535)],16),f=e.NlKvI(65535,this[s(535)]),h=e[s(1461)](this[s(1581)],16),E=e[s(808)](65535,this[s(1581)]),b=e[s(562)](n.high,16),m=65535&n[s(535)],A=n.low>>>16,D=e[s(1144)](65535,n[s(1581)]),B=0,$=0,V=0,Le=0;return Le+=e[s(1240)](E,D),V+=Le>>>16,Le&=65535,V+=h+A,$+=e.MqjqL(V,16),V&=65535,$+=e[s(339)](f,m),B+=$>>>16,$&=65535,B+=l+b,B&=65535,ue[s(782)](e[s(898)](V,16)|Le,e.sOsGc(e.JAMrv(B,16),$),this[s(947)])}[t(663)](n){let s=t;return ue[s(740)](n)||(n=ue[s(1573)+"er"](n)),this[s(947)]!==n[s(947)]&&e.wNHuP(this[s(535)],31)===1&&e.RWFkC(e.uleld(n[s(535)],31),1)?!1:e[s(420)](this[s(535)],n[s(535)])&&this[s(1581)]===n[s(1581)]}[t(1233)](){let n=t;return e[n(791)](-1,this[n(1581)])&&e.ZPQfQ(-1,this[n(535)])?ue[n(782)](0,0,this[n(947)]):e[n(1383)](-1,this[n(1581)])?ue[n(782)](0,this.high+1,this[n(947)]):ue.fromBits(e[n(357)](this[n(1581)],1),this[n(535)],this[n(947)])}[t(573)](n){return n?this[t(1717)+"E"]():this.toBytesBE()}[t(1717)+"E"](){let n=t,s=this.high,l=this[n(1581)];return[e[n(349)](255,l),e[n(502)](e[n(562)](l,8),255),e.iuOCL(l,16)&255,e.iuOCL(l,24),e[n(1544)](255,s),e[n(724)](s,8)&255,e[n(1500)](e.ozNpy(s,16),255),s>>>24]}toBytesBE(){let n=t,s=this[n(535)],l=this[n(1581)];return[e[n(943)](s,24),e.yfaAn(s>>>16,255),e.GXnBV(e.VzLOr(s,8),255),e[n(670)](255,s),e[n(1068)](l,24),e[n(1679)](l>>>16,255),e[n(1753)](e[n(1555)](l,8),255),e[n(808)](255,l)]}}let $d=new ue(0,0,!1),fp=new ue(0,0,!0),xp=ue[t(782)](-1,2147483647,!1),hp=ue[t(782)](-1,-1,!0),pp=ue.fromBits(0,-2147483648,!1);var rn=(function(a){let n=t;return a[a[n(1093)+n(529)]=5001]=e[n(622)],a[a[e[n(1582)]]=5002]="CONNECTI"+n(491),a[a[e.lAbuO]=5003]=e[n(1715)],a[a[e.WtCmz]=5004]="MESSAGE_"+n(1177),a[a.OPEN_ERROR=5005]=e[n(1345)],a})({});class Qn{constructor(n){let s=t;this[s(1457)]=n,this[s(320)]=null}}class Vd extends Qn{constructor(n,s){let l=t;e[l(962)]!==e[l(962)]?_0x6b1620[l(928)](_0x2c71d7):(super(n),this[l(543)]=s&&s[l(543)]||null)}}class Jd extends Qn{constructor(n,s){let l=t,f=e[l(814)][l(1469)]("|"),h=0;for(;;){switch(f[h++]){case"0":this[l(461)]=s&&s[l(461)]||null;continue;case"1":this[l(282)]=s&&s[l(282)]||5001;continue;case"2":this[l(566)]=s&&s.colno||0;continue;case"3":super(n);continue;case"4":this[l(679)]=s&&s[l(679)]||0;continue;case"5":this[l(543)]=s&&s[l(543)]||"";continue;case"6":this.filename=s&&s.filename||"";continue}break}}}class Zd extends Qn{constructor(n,s){let l=t;super(n),this[l(282)]=s&&s[l(282)]||0,this.reason=s&&s.reason||"",this.wasClean=s&&s[l(1289)]||!1,this[l(691)+l(1690)]=s&&s[l(691)+l(1690)]||!1}}class Yd extends Qn{constructor(n,s){let l=t;super(n),this[l(450)]=s&&s[l(450)]||null}}class Xd extends Yd{constructor(n,s){let l=t,f={bUvzG:function(h,E,b,m){return h(E,b,m)},WNfFP:"need_ack",RfLbe:function(h,E,b,m){return h(E,b,m)},HlUZP:function(h,E){return e[U(1513)](h,E)},mBxmH:e[l(511)],ghmIK:e.Mzjbt,OKVUI:function(h,E){return h||E},FHPXh:e[l(1491)]};if(e[l(327)](e[l(1416)],e[l(1416)])){let{enableAutoAck:h}=this[l(1472)],E=f[l(1731)](_0x214490,_0x4dd2e0[l(543)][l(655)],f[l(1429)],"1"),b=f.RfLbe(_0x60e70c,_0x1519ff[l(543)].headers,l(666),"1"),m=_0x5b9726[l(474)](this,_0x155367);if(f[l(1352)](h,E)){let{SeqID:A,LogID:D,service:B,LogIDNew:$,method:V}=_0x5e81c0[l(543)];this[l(1340)]({SeqID:A,LogID:D,LogIDNew:$,service:B,method:V,headers:[{key:f[l(448)],value:"1"},{key:f[l(1141)],value:f.OKVUI($,"")},{key:f[l(1006)],value:"0"}]})}b&&!m.isQoSAck&&this[l(804)+l(749)+l(723)](_0x5630fd),_0x1d1b40()}else super(n),this[l(450)]=s&&s[l(450)]||null,this[l(543)]=s&&s[l(543)]||null}}class Qd extends Qn{constructor(n,s){let l=t;super(n),this[l(450)]=s&&s[l(450)]||null}}function at(a,{message:n,code:s,error:l}){return new Jd(a,{message:n,code:s,error:l})}function xt(a,{code:n,reason:s,wasClean:l,willReconnect:f}){let h=t;if(e[h(1502)](e[h(748)],e[h(526)]))return new Zd(a,{code:n,reason:s,wasClean:l,willReconnect:f});{let E=_0x1fc923[h(1344)+"g"](0,e[h(1475)](4,_0x592c25[_0x130b6e][h(657)])),b=E[h(1474)](_0x344e1d[_0x3346fe]);_0x1eb941[h(889)](b)}}function el(a,{data:n,message:s}){return new Xd(a,{data:n,message:s})}function tl(a,{data:n}){let s=t,l={pswwm:function(f,h){return f|h}};if(e[s(367)](e[s(1618)],e[s(1618)]))_0x32b6c7[_0xe50d5c++]=l.pswwm(_0x3be361>>6,192),_0xbb6226[_0x26bf92++]=l.pswwm(63&_0x385fa5,128);else return new Qd(a,{data:n})}function da(a,{message:n}){return new Vd(a,{message:n})}class nl{constructor(n,s){let l=t;this[l(1362)+"s"]=n,this[l(1656)+"es"]=s,this[l(353)+l(837)]=0,this[l(822)+l(1097)+l(781)+"t"]=0}["resetEnd"+t(711)+t(1023)](){let n=t;this[n(353)+n(837)]=0,this[n(822)+"ndpointT"+n(781)+"t"]=0}[t(629)+"es"](){let n=t;if(e[n(462)](e.fcwVR,n(1666))){let s=this._qosDB.getItem(this[n(1473)]),l=_0x5b9e41[n(512)](e[n(263)](s,"{}"));return l[_0x66f713]=void 0,this[n(1721)].setItem(this[n(1473)],_0x5873fb[n(1109)+"y"](l))}else this["currentEndpointT"+n(781)+"t"]=0}[t(1576)+"ntEndpoint"](){let n=t,s={tReFd:function(l,f,h){return l(f,h)},RiLLI:n(461)};if(e[n(1629)](e[n(686)],e.xpUhP)){let l=n(713)+_0x368f74+(n(1483)+n(1330)+n(380)+"ed");this[n(804)+n(378)+n(706)](s[n(333)](_0x273c4e,s.RiLLI,{message:l,code:_0x118243[n(373)+n(1632)+"R"],error:_0x16fe6b}));return}else return this[n(1362)+"s"][this["currentI"+n(837)]]}[t(1576)+"ntEndpoi"+t(727)+t(1342)](){let n=t;return this[n(822)+n(1097)+n(781)+"t"]}[t(1509)+t(1528)+"es"](){let n=t;return e[n(849)]!==e[n(849)]?_0x406389||(_0x72f44b=[_0x1b0160[n(1727)+"e"][n(1101)],_0x186b0e[n(1727)+"e"][n(1520)],_0x380b5d.prototype[n(1520)+n(942)+"ey"]]):!!(e[n(665)](this[n(353)+"ndex"],this[n(1362)+"s"].length)||e[n(931)](this[n(353)+n(837)],this.endpoints[n(657)]-1)&&e[n(1383)](this[n(822)+n(1097)+"riesCount"],this[n(1656)+"es"]))}["checkCur"+t(1565)+t(979)+"hedMaxRe"+t(1220)](){let n=t;return this["currentI"+n(837)]==this[n(1362)+"s"][n(657)]?!0:e[n(459)](this[n(822)+n(1097)+n(781)+"t"],this[n(1656)+"es"])}[t(1366)+t(911)+"pointAnd"+t(232)+t(1185)](){let n=t;if(e.iDodY(e[n(1121)],e[n(1654)])){let s=this["_endpoin"+n(964)]?.["getCurre"+n(1029)+"nt"]();this._debug(n(713)+s+n(1188)),this[n(1405)+n(1030)](1001,e[n(1286)],!0)}else return this[n(822)+n(1097)+n(781)+"t"]=1,this[n(353)+n(837)]++,this[n(1362)+"s"][this[n(353)+n(837)]]}["getCurre"+t(1029)+t(600)+t(426)](){let n=t;return this[n(822)+n(1097)+n(781)+"t"]++,this[n(1576)+n(1029)+"nt"]()}}let er=(e.YATvh(e[t(984)],typeof globalThis)&&t(827)===globalThis.constructor[t(1650)]||e.peevo(e[t(984)],typeof window)&&e[t(1142)](e.AMMeZ,window[t(424)+t(1147)][t(1650)]))&&e[t(401)](e.NeeFt,typeof document),Rn=e[t(1550)](e[t(984)],typeof globalThis)&&(e.fVBHL(t(1296),globalThis[t(424)+t(1147)][t(1650)])||e[t(1319)](e[t(975)],globalThis[t(424)+"tor"][t(1650)]))&&e[t(768)](e[t(984)],typeof tt),Jr=(e[t(478)](e[t(984)],typeof globalThis)&&e[t(802)](e[t(1514)],globalThis["construc"+t(1147)].name)||e[t(984)]==typeof globalThis||e.IbhvN(e.NeeFt,typeof globalThis)&&!!globalThis[t(1132)+t(1614)])&&e[t(284)](t(607)+"d",typeof wx),Zr=e.aQPop(t(607)+"d",typeof globalThis)&&(e[t(235)](e.tfJls,globalThis[t(424)+t(1147)][t(1650)])||e[t(644)]("SharedWo"+t(1755)+"alScope",globalThis[t(424)+t(1147)].name)||"ServiceW"+t(1002)+t(681)===globalThis[t(424)+t(1147)][t(1650)])&&e[t(270)](e[t(984)],typeof self),gp=e[t(1311)](e[t(984)],typeof globalThis)&&e[t(1278)](e.yRfnj,globalThis[t(424)+t(1147)][t(1650)])&&e[t(768)](e[t(984)],typeof global)&&e.cWeOK(e.yRfnj,global.constructor[t(1650)])&&e.bCYiw(e.NeeFt,typeof process)&&!!process[t(1539)];class la{constructor(){let n=t;this[n(1607)+"rs"]={}}[t(1700)](n,...s){let l=t,f=this[l(1607)+"rs"][n];if(f)f[l(635)]()[l(870)](h=>h.fn[l(902)](h[l(926)],s));else if(e.rxkAR(e[l(839)],n)&&!this[l(1759)]){let h=s[l(657)]&&s[0];if(e[l(1269)](h,Error))throw h;let E=new Error(l(1056)+l(427)+(h?e[l(1651)](e.ytvdN(" (",h.message),")"):""));throw E[l(513)]=h,h}return this}off(n,s){let l=t;if(e[l(965)](void 0,n))this[l(1607)+"rs"]={};else if(s===void 0)this[l(1607)+"rs"][n]=null;else{let f=this._listeners[n];if(f)for(let h=0;e[l(631)](h,f[l(657)]);)e[l(1319)](f[h].fn,s)?f.splice(h,1):++h}return this}on(n,s,l){return(this[t(1607)+"rs"][n]||(this._listeners[n]=[])).push({fn:s,ctx:l||this}),this}}class mp extends la{["_formatErrorMess"+t(719)](n){let s=t;return n[s(568)]||n.errNo?(s(1242)+" "+(n[s(568)]||"")+s(416)+(n[s(1745)]||""))[s(1479)]():JSON[s(1109)+"y"](n)}constructor(n,s,l){let f=t,h={zxkEG:function(E,b){return e[U(361)](E,b)},NMrmT:function(E,b){return e[U(1249)](E,b)},PuPQN:function(E,b){return e.yCloE(E,b)},wWJgU:function(E,b){return E|b},AJomK:function(E,b){return e[U(1210)](E,b)}};if(e[f(1009)]!==e.PgcnQ){if(nSlkNL.zxkEG(_0x160ba9,_0x2deada))return _0x2433d6?_0x189fbe:_0x2a835c;if(_0x28e608){if(_0x40057e>=_0x90a519)return _0x54b26a}else{if(nSlkNL[f(641)](_0x20ceb7,-_0x58c373))return _0xf74a43;if(nSlkNL[f(812)](_0xd35016+1,_0x3e664d))return _0x298602}return _0x5a2b42.fromBits(nSlkNL.wWJgU(_0x2758d7%_0xd8d3ed,0),nSlkNL[f(311)](_0x7b9ac/_0x2c9a43,0),_0x5460a7)}else super(),this[f(1737)]=null,Jr&&wx[f(1373)+f(532)]&&(this[f(1737)]=wx[f(1373)+f(532)]({url:n,protocols:s,header:l,fail:this[f(728)+f(1078)+"lHandler"][f(921)](this),success:this[f(728)+f(751)+f(1640)+"ler"].bind(this)})),Rn&&tt[f(1373)+f(532)]&&(this[f(1737)]=tt[f(1373)+"ocket"]({url:n,protocols:s,header:l,fail:this["_createSocketFai"+f(1609)].bind(this),success:this[f(728)+f(751)+f(1640)+f(1080)][f(921)](this)}))}["_createS"+t(751)+t(1640)+t(1080)](){let n=t;Promise[n(1693)]()[n(1711)](()=>{this[n(242)+"steners"]()})}[t(728)+t(1078)+"lHandler"](n){let s=t,l={dYZwB:"hSMsv",JEpJz:s(1706),QVGhW:function(f,h,E){return e[s(733)](f,h,E)},JmMjf:e[s(839)],dSeWn:s(254)};Promise[s(1693)]().then(()=>{let f=s;if(l[f(1184)]===l.JEpJz)return this[f(721)]?this[f(721)][f(1171)]:"";{let h=l[f(1481)](at,l[f(1253)],{message:this["_formatE"+f(1015)+"age"](n)});this[f(1700)](l[f(1253)],h);let E=l[f(1481)](xt,l[f(453)],{reason:this[f(1726)+f(1015)+f(719)](n)});this[f(1700)](l[f(453)],E)}})}[t(242)+t(536)](){let n=t,s={vrWKr:function(l,f){return l===f},hbmOP:e.EADoo,DQXjr:function(l,f,h){return e[U(375)](l,f,h)},CsBBc:e[n(1443)],yevKa:e[n(959)]};this[n(1737)].onOpen(l=>{let f=n;this[f(1700)](f(910),e[f(1417)](tl,e[f(1556)],{...l,data:l[f(568)]||""}))}),this[n(1737)].onClose(l=>{let f=n;s[f(991)](s[f(1246)],s[f(1246)])?this.emit(f(254),s.DQXjr(xt,s[f(906)],{...l})):(this[f(436)+"ount"]=_0x378dbe,this[f(1568)]=0)}),this[n(1737)][n(1313)+"e"](l=>{let f=n;this[f(1700)](s[f(569)],el(s[f(569)],{...l}))}),this._socket[n(692)](l=>{let f=n;this[f(1700)](e[f(839)],e[f(1516)](at,e[f(839)],{...l,message:l[f(568)]||""}))})}send(n){let s=t,l={Hldsr:e[s(839)],SLIvF:function(f,h,E){return e[s(467)](f,h,E)},SxZlN:function(f,h){return e[s(840)](f,h)},bfyQP:e[s(362)],SJqYc:function(f,h,E){return f(h,E)}};if(n instanceof Uint8Array){let f=n.buffer[s(635)](n[s(899)+"et"],e[s(816)](n[s(785)+"th"],n[s(899)+"et"]));this[s(1737)]&&this[s(1737)][s(1409)]({data:f,fail:h=>{let E=s;this[E(1700)](l[E(1627)],l.SLIvF(at,E(461),{message:this["_formatE"+E(1015)+"age"](h)}))}})}else this[s(1737)]&&this._socket[s(1409)]({data:n,fail:f=>{let h=s,E={rxOOS:function(b,m,A){return l[U(986)](b,m,A)}};l[h(1204)](l[h(774)],l[h(774)])?this[h(1700)](l[h(1627)],l[h(500)](at,l[h(1627)],{message:this[h(1726)+"rrorMessage"](f)})):E[h(1525)](_0x1725e0,_0x2b4336,this._getIntervalValue(_0x17e388))}})}close(n,s){let l=t;this[l(1737)]&&this[l(1737)][l(254)]({code:n,reason:s})}[t(1619)+t(576)](n,s){this.on(n,s)}[t(1301)+t(1675)+"ner"](n,s){this.off(n,s)}get[t(390)+"te"](){let n=t;return this[n(1737)][n(390)+"te"]}get binaryType(){let n=t;return this[n(1737)][n(403)+"pe"]}set[t(403)+"pe"](n){}get[t(1081)](){let n=t,s={Iqovj:function(l,f){return e[U(626)](l,f)}};if(e[n(967)](e[n(647)],e[n(1299)]))s[n(1079)](_0x3ff4fb,this["_connect"+n(392)+"utId"]),this[n(1705)+n(392)+"utId"]=null;else return this[n(1737)][n(1081)]}get[t(1171)](){let n=t;return this[n(1737)][n(1171)]}get[t(1490)+"ns"](){let n=t;return this[n(1737)][n(1490)+"ns"]}get["buffered"+t(874)](){return 0}}function wp(a,n){let s=t;if(n)return new n(a[s(1081)],a[s(1171)]);if(e[s(263)](Jr,Rn))return new mp(a[s(1081)],a[s(1171)],a.headers);if(e.MjXbg(er,Zr)&&e.peevo(e[s(984)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a.protocols)}function _p(a){let n=t,s=e.ZLWAi.split("|"),l=0;for(;;){switch(s[l++]){case"0":if(Rn&&tt[n(1373)+"ocket"])return!0;continue;case"1":return!1;case"2":if(a)return!0;continue;case"3":if(e[n(676)](er,Zr)&&n(607)+"d"!=typeof WebSocket&&WebSocket)return!0;continue;case"4":if(Jr&&wx[n(1373)+n(532)])return!0;continue}break}}function rl(a,n,s){let l=t;if(e[l(1031)](e[l(1252)],e[l(708)])){let f=-1;async function h(E){let b=l;return e[b(1267)](E,f)?Promise.reject(new Error(e[b(1241)])):(f=E,e[b(420)](E,s.length)?Promise.resolve():s[E][b(921)](a)(n,h[b(921)](null,e.wUyMw(E,1))))}e[l(335)](h,0)}else{let f=this[l(1721)][l(678)+l(1477)+"nc"](this._prefix),h=_0x3f9950[l(512)](e.MjXbg(f,"{}"));return _0x10251f[l(238)](h)}}function il(a){let n=t,s={HeGVP:function(h,E){return e[U(1320)](h,E)},mBwqg:function(h){return h()}},l=0,f=0;for(let h=0;e[n(261)](h,a[n(657)]);++h)f=a[n(368)+"At"](h),e[n(631)](f,128)?l+=1:f<2048?l+=2:e[n(324)](e[n(572)](64512,f),55296)&&e[n(1086)](64512,a[n(368)+"At"](e.cxNDa(h,1)))===56320?e[n(834)](e[n(274)],e[n(274)])?(_0x4a2015(dQtAXl[n(860)](_0x1ebe8b,_0x560518[n(786)])),dQtAXl[n(1400)](_0x472412)):(++h,l+=4):l+=3;return l}function sl(a,n,s){let l=t;if(e[l(1230)](e[l(1475)](s,n),1))return"";let f="";for(let h=n;h<s;)if(e[l(383)](l(620),e[l(1765)])){let E=a[h++];if(e[l(637)](E,127))f+=String[l(1103)+"Code"](E);else if(e[l(434)](E,192)&&e[l(1201)](E,224))f+=String[l(1103)+l(1261)](e[l(1663)](e[l(1217)](e[l(862)](31,E),6),63&a[h++]));else if(e[l(1016)](E,224)&&e.FeSwr(E,240))f+=String[l(1103)+l(1261)](e[l(481)](e[l(1328)](e[l(1680)](15,E),12)|e[l(881)](63,a[h++])<<6,63&a[h++]));else if(E>=240){let b=e[l(875)](e[l(481)](e[l(1211)](e[l(1517)](7&E,18),e[l(1403)](63,a[h++])<<12),e[l(1338)](e[l(670)](63,a[h++]),6))|63&a[h++],65536);f+=String.fromCharCode(e[l(339)](55296,b>>10)),f+=String["fromChar"+l(1261)](e.KDJlE(56320,e[l(349)](1023,b)))}}else this[l(721)]&&this[l(721)][l(1409)](_0x3b07ea),this["_message"+l(1593)][_0x9fb64e]=null;return f}function ua(a,n,s){let l=t,f=s,h,E;for(let b=0;b<a[l(657)];++b)if(e.QbqKv(e[l(1083)],e[l(1083)]))if(h=a[l(368)+"At"](b),e.pLLxy(h,128))n[s++]=h;else if(e[l(1363)](h,2048))n[s++]=e[l(1458)](e[l(1418)](h,6),192),n[s++]=e[l(879)](63,h)|128;else if(e[l(931)](e[l(796)](64512,h),55296)&&e[l(1203)](e[l(533)](64512,E=a[l(368)+"At"](e.RShRl(b,1))),56320)){let m=e[l(1071)][l(1469)]("|"),A=0;for(;;){switch(m[A++]){case"0":h=e[l(344)](e[l(280)](65536,e[l(1517)](1023&h,10)),e.Vifkp(1023,E));continue;case"1":n[s++]=e[l(1448)](63&h,128);continue;case"2":++b;continue;case"3":n[s++]=e[l(1574)](e[l(1670)](h,18),240);continue;case"4":n[s++]=e.KCqNU(e[l(502)](e[l(1418)](h,6),63),128);continue;case"5":n[s++]=e[l(777)](e[l(1046)](e[l(1733)](h,12),63),128);continue}break}}else n[s++]=h>>12|224,n[s++]=e[l(996)](e[l(1518)](h,6)&63,128),n[s++]=e[l(1166)](63,h)|128;else return _0x1bfaa9(_0x49f310);return e[l(1475)](s,f)}async function ol(a){let n=t;if(n(764)==typeof a){let s=new Uint8Array(e[n(335)](il,a));return e[n(825)](ua,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a[n(988)],a.byteOffset,a[n(785)+"th"])}function yp(a){let n=t;try{return e[n(768)](e[n(522)],typeof a)&&(e[n(236)](a,ArrayBuffer)||a[n(988)]&&a[n(988)]instanceof ArrayBuffer)||e[n(270)](e[n(522)],typeof a)?"":(JSON[n(512)](a),e[n(466)])}catch{return e[n(1583)]("NuLzk",e[n(869)])?e[n(522)]==typeof a?n(1756)+n(1084)+n(1058):"":(_0x436bc9[_0x57184c]=_0x5d0881,!0)}}let Ep=(a,n)=>{let s=t,l={LlfPP:function(f,h){return e.DxImf(f,h)},Uwrwl:function(f,h){return e[U(1249)](f,h)},dmEgx:function(f,h){return e.XjjYk(f,h)},RyQdh:function(f,h){return e.xoElp(f,h)},dgDMK:function(f,h){return e[U(875)](f,h)},lpAeT:function(f,h){return e.pvJMc(f,h)},RCzIl:function(f,h){return e[U(343)](f,h)},Eurbv:function(f,h){return e[U(773)](f,h)}};if(e[s(1629)](s(593),e[s(1120)])){let f=_0x4db5f7.charCodeAt(_0x5f13fa);sfUouZ[s(1285)](f,55296)&&sfUouZ[s(591)](f,56319)&&sfUouZ[s(1199)](sfUouZ.RyQdh(_0x5dcd30,1),_0x216ec0)&&(f=sfUouZ[s(892)](sfUouZ[s(1482)](sfUouZ.lpAeT(f,10),_0xd5c8a2.charCodeAt(++_0x1706ba)),56613888)),_0x21e5d9+=sfUouZ[s(1199)](f,128)?1:sfUouZ.RCzIl(f,2048)?2:sfUouZ.Eurbv(f,65536)?3:4}else switch(a){case s(539):case e.qveJf:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class bp{constructor(n){let s=t;this[s(436)+s(1342)]=n,this[s(1568)]=0}[t(917)](){this.count++}[t(1509)+t(1236)+"nt"](){let n=t;return e[n(434)](this.count,this[n(436)+"ount"])}[t(726)+t(351)](n=0){let s=t;this[s(436)+s(1342)]=n,this.count=0}}async function vp(a){return new Promise(n=>{let s=U;if(!er)return n(e[s(1446)]);try{let l=document[s(483)+s(904)](s(714));window[s(1306)+s(1045)]=f=>{let h=s;document[h(586)][h(1208)+h(1445)](l),window[h(1306)+h(1045)]=void 0,n(f&&f[h(1586)]||h(1688)+"reason")},l[s(1457)]=e[s(743)],l.src=e[s(338)](a.replace(/^ws/,s(759)),e[s(429)]);try{document.body[s(1423)+"ild"](l)}catch{document[s(586)].removeChild(l)}}catch{window[s(1306)+s(1045)]=void 0,e[s(654)](n,e[s(1446)])}})}function sn(a,n,s){let l=t;if(e[l(1176)]!==e[l(1176)])try{return e.QzkDr(l(764),typeof _0x28ca1d)&&(e[l(236)](_0x302d8b,_0x519f06)||_0x35a5f3[l(988)]&&e[l(525)](_0x588c64[l(988)],_0x9676d4))||e.IGSmB!=typeof _0x2db694?"":(_0x2de681[l(512)](_0x1f0cda),e[l(466)])}catch{return e[l(1735)](e[l(522)],typeof _0x939564)?e[l(1637)]:""}else return!!a?.[l(399)](f=>f[l(1300)]===n&&f.value===s)}function tr(a,n){let s=t;return a?.[s(399)](l=>l[s(1300)]===n)?.[s(1684)]}let fa=null;async function Sp(){let a=t,n={FZOFw:function(s,l,f){return e[U(485)](s,l,f)}};if(e[a(843)](a(315),e[a(923)])){let s=_0x187b38.buffer[a(635)](_0x3a16cb[a(899)+"et"],e.uPlVI(_0x4c8d26[a(785)+"th"],_0x15a1c9[a(899)+"et"]));this[a(1737)]&&this[a(1737)][a(1409)]({data:s,fail:l=>{let f=a;this.emit(f(461),JztriB[f(1523)](_0x463319,f(461),{message:this["_formatErrorMess"+f(719)](l)}))}})}else return fa||(fa=Promise.resolve()[a(1711)](Bt[a(921)](Bt,e.MUxAi))),fa}class Ip extends la{constructor(n,s){let l=t;e[l(538)](e[l(552)],l(851))?(_0x5069c0&&_0x27ac8e["addEvent"+l(576)](beOYEp[l(1443)],()=>_0x47f2f5()),_0x5ba740&&_0x489479[l(1619)+l(576)](l(909)+"hange",()=>_0xa52367())):(super(),this[l(1661)]=n,this[l(730)]=s,this[l(1721)]=void 0,this["_initPro"+l(1146)]=null)}async openDB(){await this[t(1512)]()}async[t(1512)](){let n=t;if(!this._qosDB){if(this["_initPro"+n(1146)])return this[n(1480)+n(1146)];try{if(e[n(878)](e[n(537)],n(227)))_0x2056cb=e[n(941)]((31&_0xd7b84c)<<6,e[n(530)](63,_0x5778ed)),e[n(343)](_0x214f09,128)?_0x5ea3f8+=_0x5eae72:(_0x1c6e4f+=e[n(476)](_0x38a417,_0x3b8983),_0x4e8e3b++);else{let s=this._dbName,l=this[n(730)];this[n(1480)+"mise"]=(async()=>{let f=n,{openDB:h}=await e[f(1395)](Sp);this[f(1721)]=await h("frontier_"+s,1,{upgrade(E){E[f(484)+"jectStore"](s,{keyPath:l})}})})(),await this[n(1480)+n(1146)]}}catch(s){console[n(928)](s)}finally{this["_initPro"+n(1146)]=null}}}async[t(268)](n){let s=t;try{return await this[s(1512)](),this[s(1721)]?.[s(268)](this._dbName,n)}catch(l){console[s(928)](l)}}async[t(1194)](n,s){let l=t,f={CQseW:function(h,E){return e.MjugR(h,E)},cvLKd:function(h,E){return e[U(1392)](h,E)},jRvWH:function(h,E){return e[U(1255)](h,E)}};if(e.kwqFw!=="tdMDY")return await this[l(1512)](),this._qosDB?.[l(509)](this[l(1661)],n);{let E=""+_0x2b407e[l(1347)](),b=_0x55da05||(_0x59a699=ieDujg[l(872)](_0x3da891,_0x1b0a7f)),m=_0x57b4b8.random()[l(223)](16)[l(635)](-6);return ieDujg[l(1021)](ieDujg[l(1571)]("02",E)+b,m)}}async del(n){let s=t;try{return await this[s(1512)](),this._qosDB?.[s(494)](this[s(1661)],n)}catch(l){console.log(l)}}async[t(995)](){let n=t;try{if(e[n(1312)](e.qSQIF,n(542)))this.emit(n(254),_0x24578f(e[n(1443)],{..._0x1a4854}));else return await this[n(1512)](),this._qosDB?.[n(995)](this._dbName)}catch(s){console[n(928)](s)}}async[t(238)](){let n=t;return await this[n(1512)](),this[n(1721)]?.[n(355)+"ys"](this[n(1661)])}async[t(1010)](){let n=t;if(e[n(492)]("cnqCE",e[n(1643)]))return await this[n(1512)](),this[n(1721)]?.[n(1010)](this[n(1661)]);_0x1905c4(e[n(772)]),this[n(1069)](e[n(1235)],_0x14b67a),this[n(1069)](n(1334)+"e_timeout",_0x332348)}async[t(1677)](){let n=t;try{this[n(1721)]?.[n(254)](),this[n(1721)]=void 0}catch(s){console[n(928)](s)}}get[t(801)](){let n=t;try{return!!this[n(1721)]}catch(s){if(e[n(1580)]!==n(820))this[n(1510)]=!0,this[n(1705)]();else return console[n(928)](s),!1}}}class Ap{constructor(n,s){let l=t;this._DBName=n,this[l(1329)]=s,this[l(1721)]=localStorage}async[t(830)](){}get[t(1473)](){let n=t;return n(1306)+"_"+this[n(1437)]}async[t(268)](n){let s=t,l=this._qosDB[s(1703)](this._prefix);return JSON[s(512)](e.PzIFJ(l,"{}"))[n]}async[t(1194)](n,s){let l=t,f=this[l(1721)][l(1703)](this[l(1473)]),h=JSON[l(512)](f||"{}");return h[s||n[this[l(1329)]]]=n,this[l(1721)][l(1309)](this[l(1473)],JSON[l(1109)+"y"](h)),s||n[this[l(1329)]]}async del(n){let s=t,l=this[s(1721)][s(1703)](this[s(1473)]),f=JSON[s(512)](l||"{}");return f[n]=void 0,this[s(1721)][s(1309)](this[s(1473)],JSON[s(1109)+"y"](f))}async clear(){return this[t(1721)].clear()}async keys(){let n=t,s=this._qosDB.getItem(this[n(1473)]),l=JSON[n(512)](e.evJDM(s,"{}"));return Object[n(238)](l)}async getAll(){let n=t,s=this[n(1721)].getItem(this._prefix),l=JSON[n(512)](s||"{}");return Object[n(700)](l)}[t(1677)](){return Promise[t(1693)]()}get[t(801)](){return!!this[t(1721)]}}class Tp{constructor(n,s){let l=t;this[l(1437)]=n,this._pathKey=s,this[l(1721)]=Rn?tt:Jr?wx:null}async[t(830)](){}get[t(1473)](){let n=t;if(e.fttbJ(e[n(1757)],e[n(1754)]))return n(1306)+"_"+this._DBName;this[n(799)+n(1695)]()}async[t(268)](n){let s=t,l=this[s(1721)]["getStora"+s(717)](this[s(1473)]);return JSON[s(512)](l||"{}")[n]}async[t(1194)](n,s){let l=t;if(e[l(767)](e[l(1658)],e[l(1384)]))this[l(242)+l(536)]();else{let f=this[l(1721)][l(678)+l(717)](this[l(1473)]),h=JSON[l(512)](f||"{}");return h[s||n[this._pathKey]]=n,this[l(1721)][l(1465)+"geSync"](this._prefix,JSON.stringify(h)),s||n[this[l(1329)]]}}async[t(1051)](n){let s=t,l=this[s(1721)][s(678)+"geSync"](this[s(1473)]),f=JSON[s(512)](e[s(821)](l,"{}"));return f[n]=void 0,this[s(1721)]["setStora"+s(717)](this._prefix,JSON[s(1109)+"y"](f))}async[t(995)](){let n=t;return this._qosDB["clearSto"+n(858)]()}async keys(){let n=t,s=this[n(1721)][n(678)+n(1477)+"nc"](this[n(1473)]),l=JSON[n(512)](e[n(1485)](s,"{}"));return Object[n(238)](l)}async[t(1010)](){let n=t,s=this[n(1721)][n(678)+n(1477)+"nc"](this[n(1473)]),l=JSON[n(512)](s||"{}");return Object[n(700)](l)}[t(1677)](){return Promise[t(1693)]()}get[t(801)](){return!!this[t(1721)]}}function al(a,n){let s=t;if(e[s(676)](Rn,Rn))return new Tp(a,n);if(e[s(736)](er,Zr)&&e.NeeFt!=typeof indexedDB)return new Ip(a,n);if(e[s(780)](er,Zr)&&e[s(984)]!=typeof localStorage)return new Ap(a,n);throw new Error("init QoSDB failed")}class Cp{constructor(){let n=t;this[n(1050)+"lTimeoutId"]=null,this[n(1050)+"l"]=36e5,this[n(1721)]=e[n(423)](al,e.WnaLO,e[n(1161)])}async[t(1050)+t(968)](){let n=t;e[n(1205)](clearInterval,this._intervalTimeoutId),this["_interva"+n(428)+"Id"]=e.QDYpp(setInterval,()=>{let s=n;this[s(799)+s(1695)]()},this._interval)}async[t(830)](){let n=t;e[n(432)](e.QhFAB,e.QhFAB)?(_0x4cdd3b(_0x53bfc5[n(461)]),beOYEp[n(1371)](_0xb41cc2)):await this._qosDB.openDB().then(()=>{let s=n;this[s(1050)+s(968)]()})}async[t(799)+t(1695)](){let n=t;(await this[n(1721)]?.[n(1010)]()||[])[n(1143)](({timestamp:f})=>f<Date[n(1347)]())[n(870)](f=>{let h=n;this[h(1721)]?.[h(1051)](f[h(346)+"id"])})}async del(n){return this[t(1721)]?.del(n)}async[t(1194)](n,s){let l=t;return this[l(1721)]?.[l(1194)]({message_id:n,timestamp:s})}async get(n){let s=t;return s(463)==="Dmthu"?this[s(1721)]?.[s(268)](n):this[s(721)]?this._ws[s(403)+"pe"]:this[s(1375)+s(1557)]}async[t(1677)](){let n=t;clearInterval(this[n(1050)+n(428)+"Id"]),await this[n(1721)]?.closeDB()}get[t(801)](){let n=t;return this._qosDB?.[n(801)]}}function xa(a){let n=t,s=!!this[n(1472)][n(1259)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e.mkzYI(sn,a[n(543)][n(655)],e.bsZAZ,"2"),f=l&&e[n(1689)](sn,a[n(543)][n(655)],e.qpMcM,"1"),h=l&&sn(a[n(543)].headers,e[n(1063)],"1"),E=h?e.CHWZx(tr,a[n(543)][n(655)],n(1671)+n(490)+n(241))?.[n(1469)](",")[n(1143)](Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:f,isAckCleanupMessage:h,ackMsgIds:E}}async function cl(){let a=t;return this[a(793)+a(695)]||(this[a(793)+a(695)]=new Cp),this[a(793)+"ger"][a(801)]||await this[a(793)+a(695)][a(830)](),this["_QoSMana"+a(695)]}async function Rp(a,n){let s=t,l={yuWrB:function(m,A){return e[U(936)](m,A)}},{enableAutoAck:f}=this[s(1472)],h=e[s(326)](sn,a[s(543)].headers,e.ifdco,"1"),E=sn(a[s(543)][s(655)],e[s(511)],"1"),b=xa[s(474)](this,a);if(e[s(707)](f,h))if(e[s(776)](e.yxBhC,e[s(842)])){let m=this._qosDB[s(1703)](this[s(1473)]),A=_0x2885de.parse(YgUJMO[s(1075)](m,"{}"));return _0x4836fc[s(238)](A)}else{let{SeqID:m,LogID:A,service:D,LogIDNew:B,method:$}=a[s(543)];this[s(1340)]({SeqID:m,LogID:A,LogIDNew:B,service:D,method:$,headers:[{key:e.ndSVV,value:"1"},{key:e[s(1678)],value:B||""},{key:e[s(1491)],value:"0"}]})}E&&!b[s(1401)]&&this[s(804)+s(749)+s(723)](a),e[s(1266)](n)}async function kp(a,n){let s=t;this[s(1372)](e[s(551)],a[s(543)]),e[s(1395)](n)}async function Dp(a,n){let s=t,l={PUusz:function(h,E){return e[U(768)](h,E)},iKXHH:e[s(984)],LGMcg:e[s(1033)]},f=tn(await e[s(1718)](ol,a.data));try{if(e.GopkK(f[s(1291)],Uint8Array))if(e[s(1251)]!==e[s(1251)])zkZcjz[s(1327)](zkZcjz[s(1215)],typeof _0x3cd4e2)&&_0x1e470a[s(223)+s(1628)]&&_0x3180da[s(960)+"operty"](_0xe7ec17,_0x4c034f[s(223)+s(1628)],{value:zkZcjz[s(487)]}),_0x8f830b[s(960)+s(1430)](_0x14ac54,"__esModule",{value:!0});else{let h=e[s(1212)](this[s(1472)][s(1398)+s(1260)],Object)?{force:!!this[s(1472)][s(1398)+"ncoding"][s(602)],encoding:this[s(1472)][s(1398)+s(1260)][s(1750)]?this._options[s(1398)+s(1260)][s(1750)][s(1710)](/\s/g,"")[s(1460)+s(1743)]():""}:{force:!1,encoding:this[s(1472)][s(1398)+"ncoding"]?this[s(1472)]["payloadE"+s(1260)][s(1710)](/\s/g,"")[s(1460)+s(1743)]():""},E=f[s(1398)+"ncoding"]?f[s(1398)+"ncoding"][s(1710)](/\s/g,"")[s(1460)+s(1743)]():"",b=this[s(1472)][s(306)+s(1557)]instanceof Object?{force:!!this[s(1472)][s(306)+s(1557)][s(602)],type:this[s(1472)][s(306)+s(1557)][s(1457)]?this[s(1472)][s(306)+s(1557)][s(1457)][s(1710)](/\s/g,"")[s(1460)+s(1743)]():""}:{force:!1,type:this[s(1472)][s(306)+s(1557)]?this[s(1472)]["payloadT"+s(1557)][s(1710)](/\s/g,"")["toLowerC"+s(1743)]():""},m=f[s(306)+s(1557)]?f[s(306)+s(1557)][s(1710)](/\s/g,"")[s(1460)+s(1743)]():"",A=b[s(602)]?b[s(1457)]:m||b[s(1457)],D=h[s(602)]?h.encoding:E||h.encoding,B=[e.WYegB,e[s(466)],e[s(1692)],s(764)],$=[e[s(1730)],e[s(1047)]];this[s(1472)][s(240)+s(1527)+s(1763)+"ad"]&&B.includes(A)&&(!D||$[s(541)](D))?f["textPayl"+s(1218)]=sl(f[s(1291)],0,f[s(1291)][s(785)+"th"]):f[s(528)+s(1218)]=""}else f[s(528)+s(1218)]=""}catch(h){f["textPayl"+s(1218)]="",console[s(928)](h)}a.message=f,n()}function Pp(a,n,s){let l=t,f={IStFG:function(A,D){return e[U(577)](A,D)},QFags:function(A,D){return e[U(1217)](A,D)},BcmFj:function(A,D){return e[U(1028)](A,D)},ZgdUZ:function(A,D){return e[U(364)](A,D)},cOKIM:function(A,D){return A|D},dqEyz:function(A,D){return e[U(771)](A,D)},ilZGy:function(A,D){return e[U(627)](A,D)},FZjzC:function(A,D){return e[U(418)](A,D)},zEset:function(A,D){return A+D},yJhyB:function(A,D){return e[U(250)](A,D)},ylgcp:e[l(1248)],bGHFS:function(A,D){return e[l(298)](A,D)},Kuvfc:function(A,D){return e[l(1219)](A,D)},pqztn:function(A,D){return e.XaPQM(A,D)},YOFmz:function(A,D){return e.CJVHV(A,D)},bAfMX:function(A,D){return e.WKWiM(A,D)}},h=e[l(680)](s,8192),E=e.ewFEL(h,1),b=null,m=h;return function(A){let D=l;if(f[D(1317)](f[D(1668)],f.ylgcp)){if(f[D(1440)](A,1)||A>E)return f.Kuvfc(a,A);f.pqztn(f[D(778)](m,A),h)&&(b=f.Kuvfc(a,h),m=0);let B=n.call(b,m,m+=A);return 7&m&&(m=f.BcmFj(f[D(262)](7,m),1)),B}else{let B=new _0x39fd52(f[D(560)](f[D(703)](_0x3ba2ad[f[D(981)](_0x3ed0af,4)],24),_0x50f5a6[_0x1ce03d+5]<<16)|_0x44875d[f[D(981)](_0x3756e5,6)]<<8|_0x492f7c[f[D(1096)](_0x45c41d,7)],f[D(792)](f[D(819)](_0x46317c[f[D(382)](_0x272595,0)],24)|_0x23a666[f[D(981)](_0x2ee54a,1)]<<16,f[D(1464)](_0x477391[f.zEset(_0x5c1a1d,2)],8))|_0x532a85[f[D(1096)](_0xbb900b,3)],!0);return _0x54aff5+=8,{value:B,offset:_0x110f10+8}}}}let Op=4294967295;function Lp(a,n,s){let l=t;return e[l(1159)](l(596),l(596))?e[l(720)](RangeError,e[l(595)](e[l(770)](e.ambKB(e[l(865)](e[l(1734)](l(1361)+l(989)+l(972),a),l(992)),e[l(1207)](n,1)),l(400)),s)):((this[l(1607)+"rs"][_0x10bebb]||(this._listeners[_0x3397db]=[]))[l(889)]({fn:_0x53f184,ctx:_0x24d154||this}),this)}function Np(a,n,s){let l=t;if(e[l(1744)](s,Op))throw new Error(l(835)+l(832)+"e");let f=3;for(;e[l(1273)](f,0);){let h=e.FfcDg(255,s);e[l(435)](pa,h,a,e[l(1349)](n,f)),s>>>=8,f--}return n+4}function Mp(a,n){let s=t,l=0,f=n,h=e[s(779)](n,4);for(;e[s(1378)](f,h);){let{value:E,offset:b}=e[s(359)](ha,a,f);f=b,l=e[s(829)](e[s(1729)](l,8),0),l+=E}return{value:l,offset:h}}function Bp(a,n,s){let l=t;if(e.dDPIS(e[l(249)],e[l(1478)]))return a?e[l(372)](a[l(657)],40)?e.hmykc(e[l(326)](ua,a,n,s),s):n[l(945)+"e"]?e.YvrwF(n[l(945)+"e"](a,s),s):n.write?e[l(627)](n[l(1354)](a,s),s):e[l(279)](e[l(1689)](ua,a,n,s),s):s;this[l(721)]&&this[l(721)][l(1409)](_0x436915),this._debug("send_ack",_0xacdf3d)}function Fp(a,n){let s=t,l=new ue(e[s(419)](e.ErSln(a[e.ldlqo(n,4)]<<24,e[s(1155)](a[e[s(1234)](n,5)],16)),e[s(919)](a[n+6],8))|a[n+7],e.gTVXs(e.VvfKo(a[e[s(770)](n,0)]<<24,e[s(1338)](a[e[s(1392)](n,1)],16))|e[s(1217)](a[n+2],8),a[n+3]),!0);return n+=8,{value:l,offset:e.KDJlE(n,8)}}function zp(a,n,s){let l=t,f=a[l(1581)],h=a.high;return n[s]=e.rlpqe(h,24),n[e[l(503)](s,1)]=e[l(558)](e[l(1625)](h,16),255),n[e.LCuzv(s,2)]=e.UrjSZ(e[l(1625)](h,8),255),n[e[l(339)](s,3)]=e[l(879)](255,h),n[s+4]=e[l(1379)](f,24),n[s+5]=e.AsJWj(e[l(1178)](f,16),255),n[s+6]=e[l(1526)](e[l(1154)](f,8),255),n[s+7]=e[l(685)](255,f),s+=8,s}function ha(a,n){let s=t;return a.readUInt8?{value:a[s(397)+"8"](n),offset:e[s(1175)](n,1)}:{value:e[s(508)](255,a[n]),offset:n+1}}function pa(a,n,s){let l=t;return n.writeUint8?n[l(1521)+"t8"](a,s):n[s]=e.Razqh(255,a),e.BGEng(s,1)}let Up=function(a){return new Uint8Array(a)},Gp=e[t(1760)](e.NeeFt,typeof Buffer)?Buffer[t(1237)+t(1507)]:e[t(1559)](Pp,Up,Uint8Array[t(1727)+"e"][t(1170)]),Hp=16,ga=32;function jp(a){let n=t,s=0,l={};for(let f=0;e[n(393)](f,a[n(657)]);f++)l[a[f][n(1428)+"ame"]]=e[n(482)](il,a[f]["cursor_n"+n(1226)]),s+=e[n(278)](14,l[a[f][n(1428)+"ame"]]);return[s,l]}function dl(a,n,s){let l=t,[f,h]=jp(a),E=e[l(335)](Gp,f),b=0;return a[l(870)](m=>{let A=l,D=e[A(1355)][A(1469)]("|"),B=0;for(;;){switch(D[B++]){case"0":b=e[A(435)](zp,ue[A(1573)+"er"](m.cursor||n),E,b);continue;case"1":b=e.YlsYC(Np,E,b,m[A(601)]||0);continue;case"2":b=e[A(1062)](Bp,m[A(1428)+"ame"],E,b);continue;case"3":console.log(e[A(1042)],b);continue;case"4":console[A(928)]("service",b);continue;case"5":console.log(A(1662)+A(638),m,m[A(601)]);continue;case"6":b=e[A(1221)](pa,h[m["cursor_n"+A(1226)]],E,b);continue;case"7":b=pa(0,E,b);continue;case"8":console[A(928)](e.aHsYW,b);continue;case"9":console[A(928)](e.spwFT,b);continue;case"10":console[A(928)](e[A(970)],b);continue}break}}),{frameType:ga,headers:[{key:l(520)+l(651),value:s}],payload:E}}function qp(a){let n=t,s={RbHbv:function(l,f,h){return l(f,h)},ypumv:"close"};if(e[n(672)]!==e.OXefB){let l=0,f=[];for(;e[n(321)](l,a[n(785)+"th"]);)if(e.LoPmN(e[n(1732)],e[n(1732)])){let h=_0x2e260a(e[n(839)],{message:_0x474df6[n(543)],code:_0x4ab02b[n(828)+"OR"],error:_0x396126});this[n(804)+n(378)+n(706)](h)}else{let{offset:h}=e[n(1599)](ha,a,l);l=h;let E={cursor_name:"",cursor:0,service:0},{value:b,offset:m}=e[n(504)](Mp,a,l);E[n(601)]=b,l=m;let{value:A,offset:D}=ha(a,l);l=D,E[n(1428)+n(1226)]=e.Lyibg(sl,a,l,l+A),l+=A;let{value:B,offset:$}=Fp(a,l);E.cursor=B[n(1043)](),l=$,f.push(E)}return f}else{let l=this[n(231)+n(964)]?.[n(1576)+n(1029)+"nt"](),f=this[n(1472)]["reconnec"+n(805)+"ptor"](_0x592deb[n(282)],_0x8eee6a.reason);this["_dispatc"+n(797)+n(706)](s[n(260)](_0x4e093f,s[n(1197)],{code:1006,reason:_0x34f576[n(887)]||"connecti"+n(277)+n(1104)+n(1243)+n(1411)+"ame: "+l,willReconnect:f})),f&&this[n(1705)]();return}}function Wp(){let a=t;return{frameType:ga,headers:[{key:e.OqEaS,value:e[a(795)]}],payload:void 0}}class Kp{constructor(n,s,l){let f=t;this[f(248)+"ameSpace"]=n,this[f(1167)+f(1293)]=s,this[f(661)+f(1600)]=l,this._qosDB=al(this["_cursorN"+f(1758)],e[f(982)])}async[t(830)](){await this[t(1721)].openDB()}async[t(489)+"rs"](){let n=t;if(e[n(250)](e[n(1391)],e[n(1391)])){if(!this[n(1721)][n(801)])return;let s=this[n(661)+n(1600)],l=await this[n(1721)].getAll();switch(console[n(928)](e[n(1091)],l),s){case"ALL":return l&&l.length?e[n(1244)](dl,l,0,this[n(1167)+n(1293)]):void 0;case e[n(358)]:return;case e[n(1547)]:return l&&l[n(657)]?e[n(1244)](dl,l,0,this[n(1167)+n(1293)]):Wp()}}else return _0x205bc8||(_0x15515b=[_0xb9c311,_0xc30f37,_0x1d3881,_0x16ad39,_0x2789b2])}async[t(1194)](n,s,l){let f=t;if(e.XTyuh!==e[f(933)]){let h=this._listeners[_0x5d73c4];if(h)for(let E=0;E<h[f(657)];)e.pGMKO(h[E].fn,_0x189ac9)?h[f(286)](E,1):++E}else return console[f(928)](e[f(1168)],n,s,l),this[f(1721)].set({cursor_name:n,cursor:s,service:l})}async[t(628)+"rs"](n){let s=t;if(e.gZbHq(e[s(1326)],e.TAikc)){let l=e[s(1007)](qp,n);for(let f of l)console[s(928)]("setcursor",l),await this[s(1721)].set(f)}else{let l=this[s(1721)][s(1703)](this[s(1473)]),f=_0x43b8e8[s(512)](e.EGUjX(l,"{}"));return f[_0x2bff66||_0x211fb0[this._pathKey]]=_0x5b96fa,this[s(1721)].setItem(this._prefix,_0x381cc7[s(1109)+"y"](f)),_0x2a483a||_0x2d5f73[this[s(1329)]]}}async[t(268)](n){let s=t;return(await this._qosDB[s(268)](n))?.[s(1258)]}async[t(1677)](){let n=t;if(e.RwWGx(e.ALILU,e[n(1505)]))await this._qosDB[n(1677)]();else return this[n(1721)][n(801)]}[t(1126)+t(859)+t(1102)](n){let s=t;this[s(1167)+"ileName"]=n}get[t(801)](){return this[t(1721)].isReady}}let $p=e[t(389)];async function ll(a){let n=t;if(e[n(1122)](e.GIyNN,e[n(673)]))_0x14ceef=_0x390954&&e[n(1229)]==_0x32cf50[n(1171)]?n(1647):e[n(1633)],_0x489c31=_0x5b509d[n(1710)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x2184f7=/^wss(.*:\/\/)/.test(_0x5d355c)?_0x46d6ce:""+_0x26ad89+_0x214157;else{if(!this[n(1472)].enableQoS)return null;let{aID:s,fpID:l,messageStrategy:f}=this[n(1472)],h=e[n(263)](a,$p);try{if(e[n(746)]===e[n(746)])return this["_cursorM"+n(1622)]?a&&this[n(1742)+n(1622)].updateCursorFileName(a):this["_cursorM"+n(1622)]=new Kp(l+"_"+s+"_"+h,h,f),this[n(1742)+n(1622)][n(801)]||await this._cursorManager[n(830)](),this[n(1742)+n(1622)];_0x47827f[n(1301)+n(1675)+n(1115)](beOYEp[n(1436)],_0x4f2096),_0x2724e3[n(1301)+n(1675)+n(1115)](beOYEp[n(839)],_0x398cb7),_0x4944a2[n(1301)+n(1675)+"ner"](n(408),_0xeea7f2)}catch{return null}}}async function Vp(a,n){let s=t,l=e[s(914)](sn,a.message[s(655)],e.qYOTo,"-1"),f=e[s(1048)](sn,a[s(543)][s(655)],e[s(511)],"1"),h=e[s(1331)](tr,a[s(543)][s(655)],e[s(683)]),E=e[s(391)](Number,e[s(1145)](tr,a[s(543)].headers,e[s(1554)]))||0,b=xa[s(474)](this,a),m=sn(a.message[s(655)],s(1164)+"s","2"),A=e.LAzmv(tr,a.message[s(655)],e.MTkdp),D=e.ktPBN(Number,tr(a.message[s(655)],s(1566)+"rsor_value"));if(b[s(1401)])return e[s(1395)](n);let B=b[s(1239)+s(1652)]?await cl[s(474)](this):null;if(a[s(543)][s(601)]>0&&f&&!l||e[s(1524)](a[s(543)][s(601)],0)){if(h&&b[s(1239)+s(1652)]&&B)return!!!await B[s(268)](h)&&(this["_dispatc"+s(291)+s(1032)](a),await B[s(1194)](h,e.juoye(Date[s(1347)](),E))),n();if(m){let $=await ll[s(474)](this);if(!$)return this["_dispatc"+s(291)+s(1032)](a),e[s(1353)](n);let V=await $.get(A)??-1;if(e[s(259)](V,D))this["_dispatchMessage"+s(1032)](a),$[s(1194)](A,D,a.message.service);else throw new Error(s(1685)+s(281)+" cursor "+D+(s(669)+s(1196)+s(1406)+"r ")+V);return e.baBsR(n)}return this[s(804)+s(291)+s(1032)](a),e[s(1353)](n)}}async function Jp(a,n){let s=t,l=xa.call(this,a);if(!l[s(1239)+s(1652)])return e[s(696)](n);let f=await cl[s(474)](this);if(l[s(1602)+s(599)+s(719)]&&l[s(415)+"s"][s(657)])for(let h of l.ackMsgIds)await f[s(1051)](h);e[s(696)](n)}async function Zp(a,n){let s=t,l={kvDIF:function(m,A,D){return e[U(314)](m,A,D)},OpWlC:e[s(648)]},f=e[s(791)](a[s(543)][s(702)+"e"],Hp),h=e[s(1438)](a[s(543)][s(702)+"e"],ga);if(e.oTcGd(!f,!h))return e[s(1353)](n);let E=e[s(375)](tr,a[s(543)][s(655)],s(520)+"ile_name");if(!E)return e[s(1371)](n);let b=await ll[s(474)](this,E);if(!b)return n();if(f){let m=await b.getCursors(),A={frameType:m?.[s(702)+"e"],SeqID:ue[s(1573)+"er"](this[s(395)]++),LogID:ue.fromNumber(this[s(1472)]["logIDGen"+s(1723)]()),service:9e3,method:5,headers:m?.[s(655)],payload:m?.[s(1291)]},D=e[s(966)](S,A);this[s(721)]&&this[s(721)][s(390)+"te"]&&this[s(721)].send(D)}if(h)if(e[s(1722)]!=="KusPM"){let m=a[s(543)][s(1291)];m&&b.setCursors(m)}else{this[s(804)+s(797)+"ent"](l.kvDIF(_0x330b1d,s(254),{code:1e3,reason:l[s(643)]})),this[s(231)+s(964)]?.[s(387)+"pointCon"+s(1023)](),this[s(1105)+s(1381)]?.[s(726)+s(351)]();return}}let Yp=async function(a,n){let s=t;this._isInit=!1,e[s(753)](clearTimeout,this[s(1705)+s(392)+s(1018)]),n()},Xp=async function(a,n){let s=t;if(e.Xcsjf(e.mGVvV,e.gEznc)){if(!this[s(721)]||e[s(257)](this[s(721)][s(390)+"te"],this.OPEN))return e.vxRLl(n);let{pingInterval:l}=this[s(1472)];this[s(231)+s(964)]?.[s(387)+s(711)+s(1023)]();for(let h=0;e[s(261)](h,this["_message"+s(1593)][s(657)]);h++){let E=this._messageQueue[h];if(e[s(791)](this[s(721)][s(390)+"te"],this.OPEN)&&e[s(325)](null,E))this._ws&&this._ws[s(1409)](E),this[s(661)+s(1593)][h]=null;else break}this[s(661)+"Queue"]=this[s(661)+s(1593)][s(1143)](h=>!!h),this[s(710)+s(348)+"Id"]=e[s(606)](setTimeout,()=>this[s(922)](),l),this[s(804)+s(597)+"nt"](a),this[s(866)+"er"]&&this[s(721)]&&(this._ws[s(403)+"pe"]=this[s(1375)+s(1557)]);let f=this[s(231)+s(964)]?.[s(1576)+s(1029)+"nt"]();this[s(1372)](s(855)+f+s(479)),e.vxRLl(n)}else this[s(1069)](_0x230b77,_0x2283b6)},Qp=async function(a,n){let s=t;if(e[s(1180)](s(1153),e[s(1707)])){let l=this[s(1721)][s(1703)](this[s(1473)]);return _0x1cdeae[s(512)](e[s(263)](l,"{}"))[_0x2cfc3b]}else{let l=this[s(231)+s(964)]?.["getCurre"+s(1029)+"nt"]();this[s(1372)](s(855)+l),e.SNQIO(n)}};class eg extends la{constructor(n){let s=t,l={yVMtH:function(b,m,A,D){return e.VckHM(b,m,A,D)},wCRqO:e[s(839)]};super(),this[s(1024)+s(1098)+s(1094)]=!0,this[s(866)+"er"]=er,this[s(633)]=gp,this[s(316)+"T"]=Rn,this._isMiniWX=Jr,this[s(438)+"r"]=Zr,this[s(661)+s(1593)]=[],this._endpointManager=null,this[s(831)+s(973)]=!1,this[s(1375)+s(1557)]=e.LnBqt,this[s(1705)+s(1455)]=!1,this["_connect"+s(392)+s(1018)]=null,this[s(956)+s(582)+s(244)]=null,this[s(710)+s(348)+"Id"]=null,this[s(395)]=0,this._isInit=!1,this[s(413)]="",this[s(793)+s(695)]=null,this._cursorManager=null,this[s(1105)+s(1381)]=null,this[s(328)+"ls"]=e[s(1186)],this.CLOSED=3,this[s(1708)+"NG"]=0,this[s(1389)]=1,this.CLOSING=2,this[s(1495)]=b=>{let m=s;try{l[m(1124)](rl,this,b,[Yp,Xp,Qp])}catch(A){let D=at(l[m(1702)],{message:A[m(543)],code:rn[m(828)+"OR"],error:A});this[m(804)+"hErrorEvent"](D)}},this[s(275)+"ge"]=async b=>{let m=s,{pingInterval:A,pingFrequency:D}=this[m(1472)];if((e[m(1768)]("hi",b[m(450)])&&e[m(1315)](m(356),D)||e[m(1438)](e[m(614)],D))&&(this[m(1669)+"ngTimer"](),this.emit(e[m(1235)],e[m(772)]),this["_pingPon"+m(348)+"Id"]=e.IHQgy(setTimeout,this._ping[m(921)](this),A)),!e[m(616)]("hi",b[m(450)]))try{rl(this,b,[Dp,Rp,Jp,Zp,Vp,kp])}catch(B){let $=e[m(1551)](at,m(461),{message:B[m(543)],code:rn["MESSAGE_"+m(1177)],error:B});this["_dispatc"+m(378)+m(706)]($)}},this[s(833)]=b=>{let m=s,A=this[m(231)+"tManager"]?.[m(1509)+m(1528)+"es"](),D=this[m(231)+m(964)]?.[m(1576)+"ntEndpoint"]();if(A&&!b[m(543)]){let B=m(713)+D+" fail, max retries reached";this[m(804)+m(378)+m(706)](e[m(1127)](at,e.CExvs,{message:B,code:rn[m(373)+m(1632)+"R"],error:b}));return}this[m(721)]&&e[m(1594)](this[m(721)][m(390)+"te"],this[m(1389)])&&this[m(1405)+m(1030)](),this[m(804)+m(378)+m(706)](at(e[m(839)],{message:b[m(543)],code:rn[m(1093)+m(529)],error:b}))},this._onClose=async b=>{let m=s;this[m(527)+m(1179)](),this[m(1669)+m(1131)](),this[m(1435)+m(1283)+"rs"](),this[m(721)]=null,this._connectLock=!1;let A=this._endpointManager?.[m(1509)+m(1528)+"es"]();if(!A&&this[m(1272)+"orOnline"]()&&!this[m(831)+m(973)]){let D=this[m(231)+m(964)]?.getCurrentEndpoint(),B=this[m(1472)]["reconnec"+m(805)+m(1157)](b[m(282)],b[m(887)]);this[m(804)+m(797)+"ent"](xt(m(254),{code:1006,reason:b.reason||m(864)+"ng faile"+m(1104)+m(1243)+"n, hostn"+m(1506)+D,willReconnect:B})),B&&this[m(1705)]();return}if(e[m(1192)](1e3,b[m(282)])&&this["_readyCl"+m(973)]){this[m(804)+m(797)+m(706)](e.RaTCD(xt,e[m(1443)],{code:1e3,reason:e.jisOa})),this[m(231)+m(964)]?.resetEndpointConfig(),this[m(1105)+m(1381)]?.[m(726)+m(351)]();return}if(e[m(1584)](1e3,b[m(282)])&&A){let D=this[m(231)+"tManager"]?.[m(1576)+m(1029)+"nt"](),B=b[m(887)];B||(B=await e[m(471)](vp,this._url)),B=m(864)+m(277)+m(1082)+B+(", hostna"+m(1214))+D+(m(590)+m(1174)+m(688)),this[m(804)+"hCloseEvent"](e[m(677)](xt,"close",{code:b[m(282)],reason:B}));let $=m(713)+D+(m(1483)+m(1330)+"es reached");this["_dispatchErrorEv"+m(706)](e[m(1331)](at,e.CExvs,{message:$,code:rn[m(373)+m(1632)+"R"]})),this["_endpoin"+m(964)]?.[m(387)+m(711)+m(1023)](),this[m(1105)+"sCounter"]?.["resetCou"+m(351)]();return}if(e[m(817)](1e3,b[m(282)])&&!b[m(887)]){let D=this._endpointManager?.[m(1576)+m(1029)+"nt"]();this["_dispatc"+m(797)+"ent"](e[m(1060)](xt,m(254),{code:b.code,reason:m(864)+"ng failed, unknown reaso"+m(1411)+m(1506)+D})),this["_endpoin"+m(964)]?.[m(387)+m(711)+m(1023)](),this[m(1105)+m(1381)]?.[m(726)+m(351)]();return}this["_dispatc"+m(797)+m(706)](b),this[m(231)+m(964)]?.[m(387)+"pointCon"+m(1023)](),this[m(1105)+"sCounter"]?.[m(726)+m(351)]()},this[s(890)]=null,this.onerror=null,this[s(1314)+"e"]=null,this.onopen=null,this[s(971)+s(1163)]=null,this[s(698)+s(337)]=null,this[s(475)+s(1148)+s(1003)+"ct"]=null,this[s(449)+s(379)]=this[s(449)+s(379)][s(921)](this),this[s(449)+s(826)]=this[s(449)+"ffLine"][s(921)](this),this["_handleP"+s(1088)]=this._handlePageHide[s(921)](this),this._handlePageShow=this[s(882)+s(705)][s(921)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1262)](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(614)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(1592),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:h}=n,E=Array[s(1665)](f)?f:e[s(388)](e[s(522)],typeof f)?[f]:[];if(!E||e[s(1357)](0,E[s(657)]))throw new Error(e[s(1537)]);if(!e[s(1077)](_p,h))throw new Error(e[s(961)]);if(Object.assign(this[s(1472)],n),this[s(231)+s(964)]=new nl(E,this._options[s(1656)+"es"]),this[s(1105)+"sCounter"]=new bp(this[s(1472)].pingLossCount),this[s(1472)][s(230)+"cOpen"]&&(this._isInit=!0,this[s(1705)]()),this[s(1472)][s(1493)+s(806)+s(1112)])if(e[s(712)]==="AhbSN")this[s(316)+"T"]||this[s(488)+"X"]?this[s(589)+s(1672)+s(1533)]():this[s(866)+"er"]&&this["_initGlobalEvent"+s(576)]();else return _0x5e6559[s(1693)]()}[t(449)+t(379)](){let n=t;this[n(1472)][n(1360)+n(1648)+n(977)]||this["_readyCl"+n(973)]||this[n(1597)+n(1163)]()}_handleOffLine(){let n=t;this["_destroy"+n(1089)+"t"]();let s=e[n(398)](da,e.hHaYk,{message:e[n(442)]});this[n(475)+n(1148)+n(1003)+"ct"]&&this["onStopIm"+n(1148)+n(1003)+"ct"](s)}[t(803)+t(1054)+t(576)](){let n=t;this[n(866)+"er"]&&window[n(1619)+n(576)](e[n(443)],this[n(449)+n(379)]),this[n(866)+"er"]&&window[n(1619)+"Listener"](e.QAfAp,this[n(449)+n(826)]),this[n(866)+"er"]&&window[n(1619)+n(576)](n(939),this["_handleP"+n(1088)]),this[n(866)+"er"]&&window["addEvent"+n(576)](e[n(1090)],this._handlePageShow)}[t(1529)+t(1054)+"Listener"](){let n=t;this[n(866)+"er"]&&window[n(1301)+n(1675)+n(1115)](e[n(443)],this[n(449)+n(379)]),this._isBrowser&&window[n(1301)+n(1675)+n(1115)](e[n(305)],this[n(449)+n(826)]),this[n(866)+"er"]&&window[n(1301)+n(1675)+n(1115)](e[n(905)],this[n(882)+n(1088)]),this[n(866)+"er"]&&window[n(1301)+n(1675)+n(1115)](e[n(1090)],this["_handleP"+n(705)])}["_handleP"+t(1088)](n){let s=t;!n[s(312)+"d"]&&(e[s(840)](e[s(1588)],e[s(584)])?this["_interva"+s(968)]():(this[s(866)+"er"]&&window[s(1301)+s(1675)+s(1115)](e.YpXDt,this["_handleP"+s(1088)]),this._isBrowser&&window[s(1301)+s(1675)+s(1115)](e[s(1090)],this[s(882)+s(705)]),this.close())),this._isBrowser&&window[s(1301)+s(1675)+s(1115)](s(1108),this[s(449)+s(379)]),this._isBrowser&&window[s(1301)+s(1675)+s(1115)](s(1623),this[s(449)+s(826)])}[t(882)+t(705)](n){let s=t;n[s(312)+"d"]&&(this[s(1272)+s(954)]()&&(!this[s(721)]||e.oBnqN(this._ws.readyState,this[s(1389)])||e[s(1540)](this[s(721)][s(390)+"te"],this.CONNECTING))&&this[s(449)+s(379)](),this[s(866)+"er"]&&window[s(1619)+"Listener"](e[s(443)],this["_handleO"+s(379)]),this[s(866)+"er"]&&window[s(1619)+s(576)](e[s(305)],this[s(449)+s(826)]))}async[t(934)+t(1351)](n){let s=t,{fpID:l,deviceID:f,bddID:h,ttwID:E,accessKey:b,aID:m,customParams:A={},enableAutoAck:D,enableQoS:B,QoSLevel:$,env:V}=this[s(1472)],Le,ht,Ut;this[s(866)+"er"]||this[s(488)+"X"]||this._isMiniTT?(Le=location&&e.ErbPC==location.protocol?"wss://":"ws://",ht=n[s(1710)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Ut=/^wss(.*:\/\/)/[s(1484)](n)?n:""+Le+ht):(Le=e[s(1257)],ht=n[s(1710)](/(^http)((?:[s]*:\/\/))/,""),Ut=/(^ws)((?:[s]*:\/\/))/[s(1484)](ht)?ht:""+Le+ht);let je=h?e[s(422)]:E?e[s(225)]:e[s(1719)],Ze=h||E||f;if(e[s(263)](!Ze,!je))throw new Error(s(757)+s(501)+"ddID, de"+s(946)+"r ttwID");let pt=e[s(1119)](e[s(1017)],typeof A)?await e[s(1626)](A):A,ul=V?e.aJNmg(Ep,V.xUseEnv,V.xTTEnv):{},ma=Object[s(1749)]({device_platform:"web",version_code:e.iwfqW,access_key:b,fpid:l,aid:m,[je]:Ze,xsack:D?1:0,xaack:D?1:0,xsqos:B?1:0,qos_level:B?$:void 0,qos_sdk_version:2,...ul},pt),tg=Object.keys(ma).reduce((wa,_a)=>ma[_a]!==void 0?""+wa+(wa?"&":"?")+_a+"="+ma[_a]:wa,"");return Ut+s(1370)+tg}async[t(1705)](){let n=t,s={CTtXt:function(l,f){return l<f},NwKEa:function(l,f){return e[U(446)](l,f)},DrueX:function(l,f){return e.hIjWt(l,f)},ocrri:function(l,f){return e[U(873)](l,f)},mPQEu:function(l,f){return e[U(1175)](l,f)}};if(e[n(605)]!==e[n(605)]){let l=e[n(1534)](_0x8ca64b);return e[n(518)](_0x4ffaa9,_0x4791b0,l),_0x20e570(l)}else{if(this[n(1705)+n(1455)]||this["_readyCl"+n(973)])return;this[n(1705)+"Lock"]=!0;try{let l=this[n(231)+n(964)]?.[n(445)+n(1565)+n(979)+n(468)+n(1220)](),{timeoutInterval:f}=this._options;if(l){let E=this[n(231)+n(964)]?.getCurrentEndpoint(),b=this[n(231)+n(964)]?.[n(1366)+n(911)+n(1268)+n(232)+n(1185)](),m=this[n(231)+n(964)]?.[n(1576)+n(1029)+"ntTriesC"+n(1342)]();if(b)if(e[n(1130)](e.qqGDQ,e[n(371)])){let A=n(713)+E+(" timeout"+n(590)+n(1174)+"ached, w"+n(790)+n(557)+n(334))+b+(n(437)+"y"),D=e[n(1487)](at,n(461),{message:A,code:rn[n(373)+n(1632)+"R"]});this._debug(A),this[n(804)+n(378)+n(706)](D),this[n(413)]=await this[n(934)+n(1351)](b),this[n(1372)](n(713)+b+" "+m+n(384)),this[n(1435)+n(1283)+"rs"]()}else{let A=0,D=0;for(let B=0;B<_0x35099d[n(657)];++B)D=_0x33c06e[n(368)+"At"](B),oujELV[n(650)](D,128)?A+=1:oujELV.CTtXt(D,2048)?A+=2:oujELV[n(1074)](64512,D)===55296&&oujELV[n(411)](oujELV[n(517)](64512,_0x2f07b1.charCodeAt(oujELV[n(1247)](B,1))),56320)?(++B,A+=4):A+=3;return A}else{let A=n(713)+E+(n(1188)+", max retries re"+n(688));this[n(1372)](A),this[n(804)+"hErrorEvent"](e.wKJYW(at,e[n(839)],{message:A,code:rn["MAX_RETR"+n(1632)+"R"]}));return}}else{let E=this[n(231)+n(964)]?.["getCurre"+n(1029)+"ntAndUpdateCount"](),b=this[n(231)+n(964)]?.[n(1576)+n(1029)+n(727)+n(1342)]();this[n(413)]=await this["_generat"+n(1351)](e[n(547)](E,"")),this._debug(n(713)+E+" "+b+n(384)),this[n(1435)+n(1283)+"rs"]()}if(this._isInit)this[n(1510)]=!1;else{let E=e[n(900)](da,e.hHaYk,{message:e[n(611)]});this["onStartR"+n(1163)]&&this[n(971)+"econnect"](E)}let h=this["_endpoin"+n(964)]?.["getCurre"+n(1029)+n(727)+n(1342)]()||0;h>1&&await this[n(307)](e[n(228)](h,1)),this._debug(n(864)+"ng url: "+this[n(413)]+(n(1447)+n(366))+this[n(328)+"ls"]),this._ws=e[n(1396)](wp,{url:this[n(413)],protocols:[this._protocols],headers:this[n(1472)][n(689)+n(1390)+"s"]["customHt"+n(1454)]},this[n(1472)].ws),(this[n(866)+"er"]||this[n(438)+"r"])&&this[n(721)]&&(this._ws[n(403)+"pe"]=this._binaryType),this["_addWsLi"+n(536)](),this["_connect"+n(392)+n(1018)]=e[n(1649)](setTimeout,this._onTimeout[n(921)](this),f)}catch(l){throw this[n(1705)+"Lock"]=!1,l}}}[t(527)+"mer"](){let n=t;clearTimeout(this[n(1705)+"ionTimeo"+n(1018)]),this["_connect"+n(392)+n(1018)]=null}["_clearPi"+t(1131)](){let n=t;if(e.FjSzq(e.hhlDy,e.hhlDy))return this[n(1721)][n(995)]();e.gRyro(clearTimeout,this[n(710)+"gTimeoutId"]),e[n(1277)](clearTimeout,this["_reconne"+n(582)+"tId"]),this["_pingPon"+n(348)+"Id"]=null,this[n(956)+n(582)+n(244)]=null}_debug(...n){let s=t;if(e[s(1039)](e[s(317)],e.SCmAH)){let{type:l}=_0x14b692;this[s(1700)](l,_0x560474)}else this._options[s(1442)]&&console[s(928)][s(902)](console,[s(761)+">",...n])}[t(1129)+t(844)+"e"](n){let s=t,{initReconnectInterval:l,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[s(1472)],E=l*Math[s(722)](h,n-1);return E>f?f:E}[t(922)](){let n=t;if(this[n(721)]&&this[n(721)][n(390)+"te"]===this[n(1708)+"NG"]){this[n(1669)+"ngTimer"](),this[n(710)+n(348)+"Id"]=e[n(1487)](setTimeout,this[n(922)][n(921)](this),this[n(1472)][n(381)+n(652)]);return}if(!this[n(721)]||e.xfjhf(this._ws[n(390)+"te"],this[n(1389)]))return void this[n(1597)+"econnect"]();this[n(721)]&&this[n(721)][n(1409)]("hi"),this["_reconnectTimeou"+n(244)]=setTimeout(this[n(1597)+n(1163)+n(514)].bind(this),this[n(1472)][n(863)+n(1224)+n(1232)])}[t(1597)+t(1163)+t(514)](){let n=t;this["_pingLos"+n(1381)]?.addCount(),this.emit(e[n(352)],e.afhtQ),this[n(1105)+n(1381)]?.[n(1509)+"chMaxCount"]()?this[n(1597)+n(1163)]():this._ping()}["_navigat"+t(954)](){let n=t;return this._isMiniTT||this[n(488)+"X"]?this[n(1024)+n(1098)+n(1094)]:(this[n(866)+"er"]||this[n(438)+"r"])&&this[n(1472)][n(1493)+n(806)+n(1112)]?navigator[n(1151)]:!0}["_handleR"+t(1163)](){let n=t;!this[n(1272)+n(954)]()||this[n(831)+n(973)]||(this[n(231)+"tManager"]?.[n(387)+"pointCon"+n(1023)](),this[n(1105)+n(1381)]?.[n(726)+"nter"](),this[n(721)]?this[n(1405)+n(1030)](1001,e[n(1223)],!0):this[n(1705)]())}[t(589)+t(1672)+t(1533)](){let n=t,s={NmsVr:function(l,f){return e[U(1747)](l,f)},iPoLQ:function(l,f){return e[U(1655)](l,f)},XlwDc:function(l,f){return l>>f},BtzPc:function(l,f){return e.VHjNh(l,f)}};e[n(1288)](n(273),e.LDoZi)?this._isMiniTT?tt[n(1138)+"kStatusC"+n(354)](({isConnected:l})=>{let f=n;this[f(1024)+f(1098)+f(1094)]=l,l?this[f(449)+f(379)]():this["_handleO"+f(826)]()}):this[n(488)+"X"]&&wx[n(1138)+n(285)+n(354)](({isConnected:l})=>{let f=n;this[f(1024)+"igatorOn"+f(1094)]=l,l?this[f(449)+f(379)]():this["_handleO"+f(826)]()}):(_0x5d33f6[_0x28b5eb++]=RXckyY.NmsVr(RXckyY[n(1617)](RXckyY[n(1530)](_0x33e688,18),7),240),_0x483ce7[_0x57ce53++]=RXckyY[n(1562)](RXckyY[n(1617)](RXckyY[n(293)](_0x12be43,12),63),128))}[t(307)](n){return new Promise(s=>{let l=U;e.qZwYW(setTimeout,s,this[l(1129)+l(844)+"e"](n))})}["_disconn"+t(1030)](n=1e3,s="",l=!1){let f=t;if(e[f(1254)]===e[f(363)]){let h={znvWM:function(E,b){return beOYEp.LMisA(E,b)}};return function(E,...b){let m=f,A=_0x4dee0a[m(474)](h.znvWM(_0x586a08,this),E,...b);return _0x52374a[m(1194)](A,E[m(417)]?E[m(417)]():[E]),h[m(1641)](_0x544950,A)}}else{if(!this[f(721)])return;this[f(224)+"WebSocket"](n,s,l)}}[t(1427)+"ut"](){let n=t,s=this["_endpoin"+n(964)]?.["getCurre"+n(1029)+"nt"]();this[n(1372)](n(713)+s+n(1188)),this[n(1405)+n(1030)](1001,e[n(1286)],!0)}[t(1340)](n){let s=t,l={ATMYh:e[s(1508)],thXja:function(f,h){return e[s(1336)](f,h)},phzGo:function(f,h){return f>>>h},ySyQE:function(f,h){return e.gZPTx(f,h)},DYqoz:function(f,h){return e[s(452)](f,h)},sUjMI:function(f,h){return e[s(1339)](f,h)},ErHsx:function(f,h){return e.aYuXO(f,h)},LvJvo:function(f,h,E,b){return e[s(376)](f,h,E,b)},pQTqZ:function(f,h){return f|h},TCqtE:function(f,h){return f<<h},VbXwE:function(f,h){return f|h},zEYNR:function(f,h){return e[s(1564)](f,h)},dBYbp:function(f,h){return f<h},gpuWr:function(f,h){return f>>>h},MXQBr:function(f,h){return e[s(1701)](f,h)}};if(e.oFtsf==="nPGMn"){let f=e[s(1767)](zt,n);this[s(721)]&&this._ws.readyState===this.OPEN&&(this._ws&&this._ws[s(1409)](f),this[s(1372)]("send_ack",n))}else{let f=l[s(1746)][s(1469)]("|"),h=0;for(;;){switch(f[h++]){case"0":if(_0x277af2[_0x2d311b++]<128)return{value:_0x30e477?_0x5ea23f:IFjPNH[s(871)](0,_0x1eafc3),offset:_0x58e07d};continue;case"1":_0x9460af=IFjPNH[s(1282)](_0xa14a34|IFjPNH[s(1426)](IFjPNH.DYqoz(127,_0x5e873b[_0x1767da]),21),0);continue;case"2":if(_0x1948e3[_0x2887b2++]<128)return{value:_0x1b2d6f?_0x4b3596:IFjPNH[s(1569)](0,_0x5f1ca8),offset:_0x23d65e};continue;case"3":if(IFjPNH[s(1704)](_0x11cbdd+=5,_0x47066a[s(657)]))throw _0x4d9511=_0x2a801f[s(657)],IFjPNH[s(1653)](_0x25de55,_0x37e47e,10,_0x4bc431[s(657)]);continue;case"4":_0x337116=IFjPNH[s(1085)](_0x270c00,IFjPNH.TCqtE(IFjPNH.DYqoz(127,_0x2090b1[_0x454ddc]),7))>>>0;continue;case"5":_0x49b676=IFjPNH[s(1282)](IFjPNH[s(583)](_0x5d9d0f,IFjPNH[s(1426)](IFjPNH[s(1740)](15,_0x315896[_0x3f001b]),28)),0);continue;case"6":if(IFjPNH.dBYbp(_0xb9a97c[_0x46156e++],128))return{value:_0x29cd15?_0x1d094a:0|_0x4a4483,offset:_0x1646eb};continue;case"7":_0x1204f6=IFjPNH[s(969)](IFjPNH.MXQBr(_0xb003b9,IFjPNH.TCqtE(IFjPNH[s(1740)](127,_0xb7a01d[_0x372ecc]),14)),0);continue;case"8":if(_0x11e88a[_0x434bbf++]<128)return{value:_0x3a9fa5?_0x364bea:0|_0x19c119,offset:_0x470064};continue;case"9":if(IFjPNH.dBYbp(_0x5282b2[_0x131cc8++],128))return{value:_0x4cbbf4?_0x2bdcd0:IFjPNH[s(1569)](0,_0x13bb14),offset:_0x2b1da1};continue;case"10":_0x1b2f74=(127&_0x425700[_0x30e66a])>>>0;continue;case"11":return{value:_0x337335?_0x5074ab:IFjPNH.MXQBr(0,_0x2889d0),offset:_0x18eada}}break}}}[t(1435)+t(1283)+"rs"](){let n=t;this._ws&&(this[n(721)]["removeEv"+n(1675)+n(1115)]("open",this._onOpen),this[n(721)][n(1301)+"entListener"](e[n(1443)],this[n(930)]),this._ws[n(1301)+n(1675)+n(1115)](e[n(959)],this[n(275)+"ge"]),this[n(721)][n(1301)+n(1675)+n(1115)](n(461),this[n(833)]))}[t(242)+t(536)](){let n=t,s=(n(1173)+"4")[n(1469)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(721)]["addEvent"+n(576)](e[n(1443)],this[n(930)]);continue;case"1":this[n(721)]["addEvent"+n(576)](e[n(959)],this[n(275)+"ge"]);continue;case"2":if(!this[n(721)])return;continue;case"3":this._ws[n(1619)+"Listener"](e[n(1556)],this[n(1495)]);continue;case"4":this[n(721)][n(1619)+n(576)]("error",this[n(833)]);continue}break}}[t(1541)+t(1040)](n=1e3,s=""){let l=t;if(e[l(579)]===e[l(1728)])this[l(316)+"T"]?_0x342b57[l(1138)+l(285)+"hange"](({isConnected:f})=>{let h=l;this[h(1024)+h(1098)+h(1094)]=f,f?this[h(449)+"nLine"]():this["_handleO"+h(826)]()}):this[l(488)+"X"]&&_0xce7b91["onNetwor"+l(285)+l(354)](({isConnected:f})=>{let h=l;this["_miniNav"+h(1098)+h(1094)]=f,f?this[h(449)+h(379)]():this[h(449)+h(826)]()});else try{this._ws&&this[l(721)][l(254)](n,s)}catch{}}[t(224)+t(1089)+"t"](n=1e3,s="",l=!1){let f=t,h={MoLLj:function(E,b){return e[U(1357)](E,b)},kjZdi:function(E,b){return e[U(763)](E,b)},skjFq:function(E,b){return E<b}};if(this[f(1669)+"ngTimer"](),this[f(527)+"mer"](),this[f(1435)+f(1283)+"rs"](),this._wsInstanceClose(1e3,s),this[f(1705)+f(1455)]=!1,l&&this[f(1272)+f(954)]()&&!this[f(831)+f(973)])if(e[f(980)](e[f(704)],e.TsegZ)){if(jzcNYF[f(264)](void 0,_0x1aba29))this[f(1607)+"rs"]={};else if(jzcNYF[f(1072)](void 0,_0x303aa1))this[f(1607)+"rs"][_0x274563]=null;else{let E=this[f(1607)+"rs"][_0x1dfd84];if(E)for(let b=0;jzcNYF.skjFq(b,E.length);)jzcNYF[f(1072)](E[b].fn,_0x4fd938)?E[f(286)](b,1):++b}return this}else{if(this["_endpoin"+f(964)]?.[f(1509)+f(1528)+"es"]()){let b=this[f(231)+"tManager"]?.[f(1576)+f(1029)+"nt"]();this[f(804)+f(797)+f(706)](xt(e[f(1443)],{code:1006,reason:f(713)+b+(f(1188)+f(590)+f(1174)+f(688)),wasClean:!0}))}else{let b=this[f(1472)][f(1316)+f(805)+f(1157)](n,s);this[f(804)+"hCloseEvent"](e[f(789)](xt,e[f(1443)],{code:n,reason:s,wasClean:!0,willReconnect:b})),b&&this[f(1705)]()}return}this[f(1272)+f(954)]()||this[f(831)+f(973)]?this[f(804)+"hCloseEv"+f(706)](e.LFvzS(xt,e[f(1443)],{code:n,reason:f(783)})):this[f(804)+f(797)+f(706)](xt(e[f(1443)],{code:1006,reason:e.QuhDE})),this[f(721)]=null,this[f(231)+"tManager"]?.[f(387)+f(711)+f(1023)](),this[f(1105)+f(1381)]?.[f(726)+f(351)]()}["_dispatc"+t(597)+"nt"](n){let s=t;this.emit(e[s(1556)],n),this.onopen&&this[s(718)](n)}[t(804)+"hMessage"+t(1032)](n){let s=t;this[s(1700)](e.bkCWi,n),this[s(1314)+"e"]&&this[s(1314)+"e"](n)}["_dispatc"+t(749)+"ageEvent"](n){let s=t;this[s(1700)](s(1751),n),this[s(698)+s(337)]&&this[s(698)+"eAck"](n)}[t(804)+"hErrorEv"+t(706)](n){let s=t;this[s(1700)](e.CExvs,n),this[s(1759)]&&this[s(1759)](n)}["_dispatchCloseEv"+t(706)](n){let s=t;this[s(1700)](e[s(1443)],n),this[s(890)]&&this.onclose(n)}get binaryType(){let n=t;return this._ws?this[n(721)][n(403)+"pe"]:this[n(1375)+n(1557)]}set binaryType(n){let s=t;this[s(1375)+s(1557)]=n,this[s(721)]&&(this._ws[s(403)+"pe"]=n)}get retryCount(){let n=t;return this[n(231)+n(964)]?.["getCurrentEndpoi"+n(727)+"ount"]()||0}get["buffered"+t(874)](){let n=t;return this[n(661)+"Queue"][n(1156)]((l,f)=>(l+=f&&f.byteLength||0,l),0)+(this[n(721)]?this[n(721)][n(747)+n(874)]:0)}get[t(1490)+"ns"](){let n=t;return this[n(721)]?this[n(721)][n(1490)+"ns"]:""}get[t(1171)](){return this._ws?this._ws.protocol:""}get[t(390)+"te"](){let n=t;return this[n(721)]?this[n(721)].readyState:this._options[n(230)+n(632)]?this[n(1708)+"NG"]:this[n(370)]}get[t(1081)](){let n=t;return this[n(721)]?this[n(721)][n(1081)]:this._url}[t(254)](n=1e3,s){let l=t,f=e[l(1466)][l(1469)]("|"),h=0;for(;;){switch(f[h++]){case"0":if(!this._ws)return void this._debug(e.GSOGY);continue;case"1":this._clearPingTimer();continue;case"2":this[l(527)+l(1179)]();continue;case"3":this["_readyCl"+l(973)]=!0;continue;case"4":this[l(224)+l(1089)+"t"](n,s);continue;case"5":this["_dropGlo"+l(1054)+l(576)]();continue;case"6":if(e[l(1374)](this[l(721)][l(390)+"te"],this[l(370)])||e[l(940)](this._ws[l(390)+"te"],this[l(1634)]))return void this._debug(e[l(1067)]);continue;case"7":this[l(793)+l(695)]?.[l(1677)]();continue}break}}async[t(1409)](n,s){let l=t;if(e[l(752)](null,n))throw new Error(e[l(1310)]);e[l(1359)](e[l(853)],typeof n)&&(n=JSON[l(1109)+"y"](n)),e[l(270)](e.IGSmB,typeof n)&&!(n instanceof ArrayBuffer)&&!(n[l(988)]&&e[l(1150)](n[l(988)],ArrayBuffer))&&(n=JSON.stringify(n));let f=await e[l(361)](ol,n),h=e.ZIBst(yp,n),{method:E=0,service:b=this[l(1472)][l(601)],logID:m=this[l(1472)]["logIDGen"+l(1723)](),headers:A=this[l(1472)][l(655)],payloadEncoding:D=this[l(1472)][l(1398)+l(1260)],payloadType:B=this[l(1472)].payloadType,logIDNew:$=this[l(1472)][l(1110)+l(1415)][l(1348)+l(1298)+l(1290)+"ew"]?e[l(1489)](i,this[l(1472)][l(1110)+l(1415)][l(935)]):""}=s||{};if(!b)throw new Error(e[l(1275)]);let V={SeqID:ue[l(1573)+"er"](this[l(395)]++),LogID:ue[l(1573)+"er"](m),service:b,method:E,headers:A,payloadEncoding:D instanceof Object?D.encoding?D.encoding:"":D,payloadType:e.kHlPn(B,Object)?B[l(1457)]?B[l(1457)]:h:B||h,payload:f,LogIDNew:$},Le=e[l(690)](zt,V);return this[l(721)]&&e.UvRZg(this[l(721)][l(390)+"te"],this[l(1389)])?(this[l(721)]&&this[l(721)][l(1409)](Le),this[l(1372)](e[l(623)],V)):e[l(841)](this[l(661)+l(1593)][l(657)],this._options[l(784)+"geQueueL"+l(252)])?(this._messageQueue.push(Le),this[l(1372)](e[l(1026)],V)):(this[l(661)+l(1593)].shift(),this["_message"+l(1593)][l(889)](Le)),{seqID:this[l(395)],logID:m,logIDNew:$}}async[t(1316)+"t"](n){let s=t,{url:l}=e[s(936)](n,{}),f=Array[s(1665)](l)?l:e.IGSmB==typeof l?[l]:[];n&&Object[s(1749)](this[s(1472)],n),f&&f[s(657)]?this["_endpoin"+s(964)]=new nl(f,this[s(1472)][s(1656)+"es"]):this[s(231)+s(964)]?.["resetEnd"+s(711)+s(1023)](),this[s(1105)+"sCounter"]?.[s(726)+s(351)](this[s(1472)][s(929)+"Count"]),this["_readyCl"+s(973)]=!1,this[s(721)]&&e[s(1039)](this._ws[s(390)+"te"],this[s(370)])?this[s(1405)+s(1030)](1e3,s(1165)+s(1163)+"ing",!0):(this[s(1510)]=!0,this[s(1705)]())}async[t(265)](){let n=t,s={SHBtJ:function(l,f){return l+f},hccph:function(l,f){return e[U(998)](l,f)},sAllI:function(l,f){return l!==f},uyHhc:function(l,f){return e[U(685)](l,f)},HJnrS:function(l,f){return l&f},JhrFX:function(l,f){return l<f},CmsgG:function(l,f){return e[U(1697)](l,f)}};if(!this[n(1705)+n(1455)])if(e.ZPQfQ(e.rPyuN,e.UZUbx))_0x5ee736=_0x200d11[msTfcv[n(997)](msTfcv.hccph(_0x25ae5b,_0x267740),1)],msTfcv[n(838)](msTfcv[n(893)](192,_0x40a2a4),128)?_0x40712d+=_0x430bf0:(_0x5c39e2=msTfcv[n(1133)](31,_0x8c9a47)<<6|63&_0x5055d9,msTfcv.JhrFX(_0x33247b,128)?_0x2e7e6c+=_0x3b5770:(_0x3cb641+=msTfcv.CmsgG(_0x503454,_0x3c8615),_0xfd940d++));else{let l=e[n(1011)][n(1469)]("|"),f=0;for(;;){switch(l[f++]){case"0":this[n(1705)]();continue;case"1":this[n(1510)]=!0;continue;case"2":this[n(1105)+"sCounter"]?.[n(726)+n(351)]();continue;case"3":this[n(231)+n(964)]?.["resetEnd"+n(711)+"fig"]();continue;case"4":this[n(831)+n(973)]=!1;continue}break}}}[t(1619)+t(576)](n,s){this.on(n,s)}["dispatch"+t(1032)](n){let s=t,{type:l}=n;this[s(1700)](l,n)}[t(1301)+"entListener"](n,s){this.off(n,s)}[t(671)](){let n=t,s={tRNOI:function(l,f){return e[U(756)](l,f)},XRNEQ:n(1522),Vjcsi:function(l,f){return e[n(1673)](l,f)},xloQB:e.tzBMQ,TuZuq:function(l,f){return l>=f},UgWPR:function(l,f){return e.YNCCS(l,f)},dJBJJ:e[n(1276)],VnBtL:e[n(1235)]};return new Promise((l,f)=>{let h=n,E={RGPID:function(A,D){return s[U(1052)](A,D)},JCFGh:function(A,D){return s.UgWPR(A,D)},dQPPu:s.dJBJJ,UFdnC:s[h(1681)]};this["_clearPi"+h(1131)](),this[h(710)+h(348)+"Id"]=setTimeout(this._ping[h(921)](this),this[h(1472)][h(381)+h(652)]);let b=()=>{let A=h;if(s[A(318)]("HVTMz",s[A(342)]))s[A(386)](l,A(987)),this[A(1069)]("ping_onc"+A(1231)+"s",b),this.off(s[A(472)],m);else return ughgIO.RGPID(_0x561cf8[A(953)],_0x43594f.limit)},m=()=>{let A=h;E[A(1639)](f,E[A(1724)]),this[A(1069)](E[A(402)],b),this[A(1069)]("ping_onc"+A(1318)+"t",m)};this.on(s[h(1681)],b),this.on(s.xloQB,m),this._ping()})}}})(),Oe[M(1410)+"oseEvent"]=Te[M(1410)+M(949)],Oe[M(309)+M(377)]=Te[M(309)+M(377)],Oe[M(891)+"e"]=Te[M(891)+"e"],Oe[M(1032)]=Te[M(1032)],Oe.FWS=Te.FWS,Oe[M(1279)+M(561)+M(896)]=Te[M(1279)+M(561)+M(896)],Oe[M(561)+"vent"]=Te["MessageE"+M(896)],Oe[M(877)+"t"]=Te[M(877)+"t"],Oe[M(903)+"tEvent"]=Te[M(903)+M(948)],Oe[M(1305)+"oseEvent"]=Te[M(1305)+M(949)],Oe.createErrorEvent=Te[M(546)+M(377)],Oe[M(664)+M(1635)+"nt"]=Te.createMessageEvent,Oe.createOpenEvent=Te[M(319)+M(884)],Oe[M(1683)+M(1172)+"vent"]=Te["createRe"+M(1172)+M(896)],Oe[M(258)+"rame"]=Te[M(258)+"rame"],Oe["encodeFr"+M(1226)]=Te[M(741)+"ame"];for(zo in Te)[M(1410)+M(949),M(309)+M(377),M(891)+"e",M(1032),M(425),M(1279)+M(561)+"vent","MessageE"+M(896),"OpenEvent",M(903)+"tEvent","createCl"+M(949),M(546)+M(377),M(664)+M(1635)+"nt",M(319)+"enEvent",M(1683)+M(1172)+M(896),M(258)+M(1008),"encodeFr"+M(1226)][M(1499)](zo)===-1&&(Oe[zo]=Te[zo]);var zo;Object.defineProperty(Oe,M(540)+"le",{value:!0})});import{existsSync as av,openSync as cv}from"node:fs";import{mkdir as dv}from"node:fs/promises";import{dirname as lv}from"node:path";import{fileURLToPath as uv}from"node:url";function xv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ld(t=X()){return av(t.libEntry)?t.libEntry:uv(new URL("../index.ts",import.meta.url))}async function Dh(t={}){let e=t.paths??X(),r=t.entryOverride??Ld(e),i=xv(e,process.env.COZE_BRIDGE_LOG_MODE);await dv(lv(i),{recursive:!0});let o=cv(i,"a"),d=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=nt(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[ts]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return fv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var fv,ts,Zo=Ye(()=>{"use strict";Vt();te();ke();fv=G("spawn-daemon"),ts="COZE_BRIDGE_DAEMON"});import{spawn as oS}from"node:child_process";import{mkdir as aS,unlink as cS,writeFile as dS}from"node:fs/promises";import{dirname as lS,join as uS}from"node:path";function Kr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function fS(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Kr(r)}</key>
|
|
21
|
-
<string>${
|
|
20
|
+
`+r)}function $n(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,$n),t.emit("wsClientError",l,r,e)}else Vi(r,i,o,c)}});var yx=oe(Le=>{"use strict";var N=F;(function(t,e){let r=F,i=t();for(;;)try{if(-parseInt(r(968))/1*(parseInt(r(1619))/2)+parseInt(r(901))/3+parseInt(r(1434))/4*(-parseInt(r(1852))/5)+-parseInt(r(934))/6*(-parseInt(r(1311))/7)+-parseInt(r(836))/8+-parseInt(r(1196))/9*(-parseInt(r(1177))/10)+parseInt(r(1307))/11*(-parseInt(r(1857))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(qo,159468);var Cv=Object.defineProperty,kv=Object[N(1240)+N(804)+"mes"],xx=(t,e)=>function(){return t&&(e=(0,t[{IWIXd:function(o,c){return o(c)}}.IWIXd(kv,t)[0]])(t=0)),e},Dv=(t,e)=>{let r=N,i={mGnWj:function(c,l,u,h){return c(l,u,h)}};for(var o in e)i[r(1699)](Cv,t,o,{get:e[o],enumerable:!0})};function Pv(){return dx||(dx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ov(){let t=N;return lx||(lx=[IDBCursor[t(483)+"e"][t(619)],IDBCursor[t(483)+"e"][t(1663)],IDBCursor[t(483)+"e"][t(1663)+t(669)+"ey"]])}function Lv(t){let e=N,r={sYjhE:function(o,c){return o(c)},XsboY:function(o){return o()},KEWKY:e(1697),ZOdap:"success",MsTTa:function(o,c){return o===c},plblD:"gUqOn",yAOnN:"eDYrj"},i=new Promise((o,c)=>{let l=e,u={jEfHl:l(887),OLxAE:r.KEWKY},h=()=>{let E=l;t[E(839)+E(1717)+E(538)](u[E(1553)],x),t[E(839)+"entListe"+E(538)](u[E(1058)],m)},x=()=>{r.sYjhE(o,Mt(t.result)),h()},m=()=>{c(t.error),r.XsboY(h)};t[l(1079)+l(1222)](r.ZOdap,x),t[l(1079)+l(1222)](r[l(1736)],m)});return i.then(o=>{let c=e;r[c(1458)](r[c(990)],r[c(782)])?(this[c(1818)+c(1876)]=0,this[c(966)+c(1791)+c(1868)+"t"]=0):o instanceof IDBCursor&&Td[c(588)](o,t)})[e(904)](()=>{}),Uo[e(588)](i,t),i}function Nv(t){let e=N,r={JPnAd:function(o){return o()},ktFsI:function(o){return o()},RphQG:function(o,c){return o!==c},aIILW:"RNynQ",TXTyS:e(790),CPAkK:function(o,c){return o(c)},lwIVF:e(795)+"or",QGXcc:e(1722),nAwvu:e(1697)};if(zo[e(753)](t))return;let i=new Promise((o,c)=>{let l=e,u={rzTJA:function(E,S){return r[F(731)](E,S)},zvKTl:r[l(1515)],mZqEO:l(1697),YhSSb:r.TXTyS,FCyrM:function(E,S){return r.CPAkK(E,S)},OOPKJ:r[l(1721)],Skemn:function(E){return r[l(1338)](E)}},h=()=>{let E=l;if(u[E(1086)](u[E(1059)],u.zvKTl))return this._socket[E(464)+"te"];t["removeEv"+E(1717)+E(538)](E(1722),x),t[E(839)+"entListe"+E(538)](u.mZqEO,m),t["removeEventListe"+E(538)](u.YhSSb,m)},x=()=>{r[l(1338)](o),r.ktFsI(h)},m=()=>{let E=l;u[E(1096)](c,t.error||new DOMException(u.OOPKJ,E(795)+"or")),u.Skemn(h)};t[l(1079)+l(1222)](r[l(1243)],x),t[l(1079)+"Listener"](r.nAwvu,m),t[l(1079)+l(1222)](r.TXTyS,m)});zo.set(t,i)}function Mv(t){Go={XakRS:function(r,i){return r(i)}}.XakRS(t,Go)}function Bv(t){let e=N,r={jbUjC:function(i,o){return i===o},WDGAb:"WxjDt",JkHEv:"QpIaU",IIbkg:function(i,o){return i(o)},KTRHl:function(i,o){return i(o)},QksdX:function(i,o){return i||o},RDeSC:e(1161),QhKWh:function(i,o){return i===o},Fkmvs:e(640)+"oreNames",HIiFM:function(i){return i()},RmpGD:e(676)};if(r[e(469)](t,IDBDatabase[e(483)+"e"][e(864)+"ion"])&&!(r[e(1611)]in IDBTransaction[e(483)+"e"]))return function(i,...o){let c=e;if(r[c(444)](r[c(1472)],r[c(858)]))_0x207c16=_0x1d1141[c(1901)](_0x9a89ba),_0x2e9a55=_0x1474c6.concat(_0x408bfa[_0x3ecc9d]);else{let l=t[c(1125)](r.IIbkg(Ji,this),i,...o);return Ad.set(l,i.sort?i[c(1308)]():[i]),r[c(1671)](Mt,l)}};if(r[e(1643)](Ov).includes(t))if(r.RmpGD!=="glRUQ"){let i=this._qosDB[e(664)+"geInfoSync"](this[e(559)]),o=_0x573ec5[e(476)](r.QksdX(i,"{}"));return _0x1abe9b[e(566)](o)}else return function(...i){let o=e;return t[o(1738)](r[o(1382)](Ji,this),i),Mt(Td[o(1040)](this))};return function(...i){let o=e;return r.jbUjC("yuhkn",r[o(531)])?Mt(t[o(1738)](r[o(1382)](Ji,this),i)):_0x1437c8.offset>=_0x389bdc[o(973)]}}function Fv(t){let e=N,r={vEmQs:function(i,o){return i===o},EkxRP:e(1186),qsExz:function(i,o){return i(o)},HFqxD:function(i,o){return i instanceof o},sojqq:function(i){return i()}};return r[e(896)](typeof t,r[e(1289)])?r[e(701)](Bv,t):(r[e(1858)](t,IDBTransaction)&&Nv(t),px(t,r[e(846)](Pv))?new Proxy(t,Go):t)}function Mt(t){let e=N,r={UizdP:function(o,c){return o(c)},OThZk:function(o,c){return o(c)},WIRUN:function(o,c){return o!==c}};if(t instanceof IDBRequest)return r.UizdP(Lv,t);if(Bo[e(753)](t))return Bo.get(t);let i=r.OThZk(Fv,t);return r[e(438)](i,t)&&(Bo[e(588)](t,i),Uo.set(i,t)),i}var px,dx,lx,Td,zo,Ad,Bo,Uo,Go,Ji,ux=xx({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={TFFoA:function(r,i){return r(i)},XPLqp:function(r,i){return r!==i},ogMTE:"RPKUE",UVZWW:function(r,i){return r===i},EDMnE:"aTFyG",mKuLG:function(r,i){return r===i},CQJnt:t(1865),ZMRhY:function(r,i){return r(i)},gYlCP:function(r,i){return r instanceof i},Ktewu:t(1864),ToBou:function(r,i){return r in i}};px=(r,i)=>i.some(o=>r instanceof o),Td=new WeakMap,zo=new WeakMap,Ad=new WeakMap,Bo=new WeakMap,Uo=new WeakMap,Go={get(r,i,o){let c=t;if(e.XPLqp(c(1403),e.ogMTE))_0x4b4aa0[c(1226)+c(1563)]="",_0x48e6e6[c(890)](_0x2a6fdb);else{if(r instanceof IDBTransaction){if(e[c(541)](i,c(1864)))return zo[c(1040)](r);if(e[c(541)](i,c(640)+"oreNames")){if(e.EDMnE===e[c(1348)])return r[c(640)+c(1712)]||Ad.get(r);_0x146248+=e[c(1214)](_0xbbd1fe,_0x2f1761),_0x4b2ec8+=2}if(e[c(1767)](i,e[c(1430)]))return o[c(640)+"oreNames"][1]?void 0:o[c(640)+c(982)](o[c(640)+c(1712)][0])}return e.ZMRhY(Mt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(1333)](r,IDBTransaction)&&(i===e.Ktewu||i===o(1865))?!0:e[o(1850)](i,r)}},Ji=r=>Uo.get(r)}}),gx={};function F(t,e){t=t-394;let r=qo(),i=r[t];if(F.FmonwY===void 0){var o=function(h){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let S=0,_,b,I=0;b=h.charAt(I++);~b&&(_=S%4?_*64+b:b,S++%4)?m+=String.fromCharCode(255&_>>(-2*S&6)):0)b=x.indexOf(b);for(let S=0,_=m.length;S<_;S++)E+="%"+("00"+m.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(E)};F.nhLSoy=o,F.IjDoyn={},F.FmonwY=!0}let c=r[0],l=t+c,u=F.IjDoyn[l];return u?i=u:(i=F.nhLSoy(i),F.IjDoyn[l]=i),i}Dv(gx,{deleteDB:()=>Uv,openDB:()=>zv,unwrap:()=>Ji,wrap:()=>Mt});function zv(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=N,u={exjOG:function(m,E,S,_,b){return m(E,S,_,b)},UadAM:function(m,E){return m(E)},xnhoB:l(908),FSebl:l(1896)+l(940),VjyTk:l(1861)},h=indexedDB[l(776)](t,e),x=u[l(545)](Mt,h);return i&&h[l(1079)+l(1222)]("upgraden"+l(1447),m=>{let E=l;u[E(639)](i,u.UadAM(Mt,h.result),m[E(571)+"on"],m[E(679)+"on"],u[E(545)](Mt,h[E(864)+"ion"]))}),r&&h["addEvent"+l(1222)](u[l(407)],()=>r()),x.then(m=>{let E=l;c&&m[E(1079)+E(1222)](u[E(1653)],()=>c()),o&&m[E(1079)+E(1222)](u.FSebl,()=>o())})[l(904)](()=>{}),x}function Uv(t,{blocked:e}={}){let r=N,i={NwcYD:function(c,l){return c(l)}},o=indexedDB[r(499)+r(1212)](t);return e&&o[r(1079)+"Listener"](r(1861),()=>e()),i[r(1474)](Mt,o).then(()=>{})}function fx(t,e){let r=N,i={lQsRJ:function(h,x){return h||x},TLnVg:function(h,x){return h!==x},sHOyp:r(1057),NkmFM:function(h,x){return h instanceof x},ZbFiO:r(988),JmDvb:function(h,x){return h!==x},JHIMR:function(h,x){return h in x}};if(!(i[r(1335)](t,IDBDatabase)&&!(e in t)&&typeof e===i[r(739)]))return;if(Fo[r(1040)](e))return Fo[r(1040)](e);let o=e[r(1669)](/FromIndex$/,""),c=i[r(835)](e,o),l=_x[r(1206)](o);if(!i[r(1731)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(l||mx[r(1206)](o)))return;let u=async function(h,...x){let m=r,E={mynYj:function(S,_){return i.lQsRJ(S,_)}};if(i[m(1244)]("gVUqE",i[m(1716)])){let S=this[m(397)][m(1787)](this[m(559)]),_=_0x1b2eab.parse(E.mynYj(S,"{}"));return _0x151c4b[m(1197)](_)}else{let S=this[m(864)+m(1673)](h,l?m(1773)+"e":m(810)),_=S.store;return c&&(_=_[m(1137)](x[m(752)]())),(await Promise[m(1367)]([_[o](...x),l&&S[m(1864)]]))[0]}};return Fo.set(e,u),u}var mx,_x,Fo,Gv=xx({"node_modules/idb/build/index.js"(){let t=N,e={Wukkt:"4|0|2|3|1|5",JtoAD:function(o){return o()},eXVIT:"get",HogBQ:"getKey",ZxwBj:t(1032),lMhJL:"getAllKeys",abPbF:t(1028),zgYll:t(615),ngSQb:t(501),ZlxBO:"delete",kQjfm:t(526),QJJwu:function(o,c){return o(c)}},r=e.Wukkt.split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(425)](ux);continue;case"1":Fo=new Map;continue;case"2":mx=[e[t(942)],e[t(601)],e[t(635)],e[t(994)],e[t(860)]];continue;case"3":_x=[e[t(999)],e[t(473)],e[t(1574)],e.kQjfm];continue;case"4":e.JtoAD(ux);continue;case"5":e[t(907)](Mv,o=>({...o,get:(c,l,u)=>fx(c,l)||o[t(1040)](c,l,u),has:(c,l)=>!!fx(c,l)||o[t(753)](c,l)}));continue}break}}}),qv={idb:function(t){let e=N;t.exports=Promise[e(587)]()[e(1872)](()=>(Gv(),gx)).then(function(r){return r})}},hx={};function qo(){let t=["Bfb5q2q","Dgv4Dc9Qyxy","uvHryLi","uKHpA2u","zwvKzwq","BMCGzMfPBgu","tvv0q1G","ywzL","Aw1ouKe","z2PeAeq","Cgf5Bg9Hzeu","AwrVBe0","ENHgrxC","rxzLBNq","y3jLyxrLt3a","txnuvge","y0zozwy","rMrSBK4","BgLUzw5V","Efrurw52","z0Pvtwm","thDowu8","EMruwhi","zxmGCMvHy2G","vxv1AvG","AxnMwwS","C3Lrvey","qLHlwg4","qNrkCeG","v0rhqwi","B0rwuM8","tNDJwuq","yMLUyxj5","DxnLCKLW","EMzuA2q","zNjHBwvuExa","Dvb5Bwq","Axnby2TdBgu","v3jlB1C","v2rLEeS","zM9Yy2u","x3DZsw5ZDge","x1fVu01HBMe","z2jtCKm","ywXPzcb1CMW","rgvKAwnHDgu","v1fbzwm","CNbZvuC","rgnRDeK","yxKSihrYEsa","z2rwuuC","z0nQzhO","sNrry24","v1zxwwu","sMT6thG","DMLJzuLeig8","zNjVBu51Bwi","mhWX","zNjVBunOyxi","uNr4z2S","sxDWqLe","q3vZDg9Trxi","Fdb8mxW4Fde","svniEgG","s3zKvMq","Dhj2ueC","uxnpBhG","BgfSqKG","BMDuAw1LCG","y3vYC29Yx2y","uvbvB3i","BfL4s3q","yuLjtfC","y2HnyxHdB3u","uLj6tgW","A0fmy04","y29UDgv4Da","Bg9Nsurhzw4","C2vUzf9Hy2S","s3fntvK","z1v5ENq","zgTSvKS","C3nHz2vfDMu","x29WDgLVBNm","t1bftG","vu5ozNK","yMrFzgLK","CeXzBMG","D3ztrgK","Bwf4twvZC2e","Dev2zw50","x2HHBMrSzva","vwTAwg4","Cg93","C0XPC3rLBMu","zvvYBa","DMrxv1O","CYbHBhjLywq","tgHfvgS","zLvRv00","BLnRyu8","EM1ZuM8","zMLSDgvY","ihn1y2nLC3m","uNLMugC","y0nbz2e","C3zQDKO","EvLPt0K","yw1Lu3bHy2u","yLnkvvu","AKvMsgW","uenyz3u","Dg9cExrLC0i","Du12rMy","ufrYvg8","BLzxt04","AgrWA1u","C2vUDa","u0zPqKG","rvviuuC","B2fK","wxHrvM4","DMjWAwS","m3W0Fdj8nxW","z29PBMCGyxC","EgHTzvq","AMLnu0K","CMvJzxzPzwq","yMLUza","x2n1CNnVCK4","EwnMEfq","wMX4qK8","AefJA01LC3m","CLb5CeS","igzHAwWSig0","qLDwyu8","swryyK0","DKHVrgu","u2veweC","Ec1TC2CTCw8","rgz2tKC","C1fWBNm","CvLetNq","ELvOCey","rwvdu0O","zg9Yv2e","vuDfCfq","BKXPBMu","C3bSAwnL","BvPRtwm","DKf5EgG","DwLiu0S","zufJAW","y3vYC29Yx24","Bg9bs3G","Cfzdzxe","B2nRzxrgywK","tvPpshO","ueTlDfe","q3v1yvC","B21KyK8","x3bYB3rVy28","ruvczNq","AxnmB25N","ign1CNnVCIa","BwfUDwfSihi","CMvHC29U","swzdqLO","rMTTDNm","zv9ZDwnJzxm","tvnytue","z0DyzMm","CM92AwrLihy","CMfTugfYyw0","tMjjCg8","AhfMCNG","mJm0mJmYweDpuxLm","C2vYDMLJzq","qxjRruu","ChrKwfa","AgTlDeW","ywDLsgLKzq","Bensq2q","sw9Lt1y","vLjevNe","ywnRx2LK","uNzbvMe","x2HHBMrSzu8","x2LZsw5PDa","veXpDKW","suvtx0vsuK8","zw5JB2rPBMC","qMjiBgq","qKXzDwK","uhbozKq","x29UrxjYB3i","q29Kzq","D2LSBfjLy28","sxfqt3e","qvjvs3a","seLPrK0","DNjns0S","Dg9Y","BgLZDgvUtMu","t3rUyLK","y0nbuhq","tKLtthK","x2TLEvbHDgG","D3m6lY8","runAt1u","Eg5OB0i","rfblCgu","y2XLyxjtDg8","D2vI","y2HHCKnVzgu","qKfkuwu","C2vYDMvYvgK","AevYCM9Yrxy","y2uGBM90igK","rwv4Afe","y29UDgLUDwu","tfnPEMG","whrOrwi","BM93","tNHqwLi","r2LXy0K","CMvWBgfJzq","wuTJwM4","s1rssgW","uMvJB25Uzwm","Aw9U","DcbSAw1PDa","sNfUA20","x2nVBM5Ly3q","Bwvgq24","C3H5DfG","AfHKAgW","Bg1kuu0","Ec11C2uT","Ec1TC2CTy3u","ywDLrxzLBNq","x2LZv29YA2u","z0zAqxe","BfLkEfe","DgHHBIbSB2m","EefPBhi","BKvnz3C","A0LHBva","zMftsfm","Aw5KzxGGB3u","Bg93","y3jLyxrLt2i","ENDvC0K","x194x21Zz18","zxjYB3i","C2r1EMq","BuDUv2O","Agz4vxi","ChD2zMe","yxnJCMLWDa","yNPwDgi","Ef9MCM9UDgK","x2HHBMrSzvi","yxrLq291BNq","B25JBg9Zzq","tMncDLG","AwPmufu","zxjFBxnNAwq","wvPnBva","B3jLtMfTzxm","B25Uzwn0Aw4","D3bbuK4","wKPfAe0","C0HpExa","zw50tgLZDgu","A3fRsKe","rKXkuge","A3bvtvy","BhDjvKy","y29TCgXLDgu","y01bA0S","ywnRtxnNswq","DLj0qwi","ChrVCG","r3zSwee","x2LUDgvYDMe","zuLUyNq","DvDHugu","sKHjtvi","zfDVCMTLCKC","ywnR","tvHpD2O","AMvJDfn0B3i","s0vxs1K","mdaWma","yxbWBhK","BwLUzW","zgPLv1e","z1PNAuC","nhWYFdz8nxW","y2HLy2Tszwe","yM9IsK4","wgf1rgm","AM9PBG","qKvJB3u","zuT4Cxm","Bu1LseC","CMvUDevUzha","D092rLG","C2Xqu0y","wLzVBuq","EMTMDgO","B2nRzxq","DfLrtfK","z2v0q3vYCMu","x2rPC3bHDgm","A2v0ignVBNm","zMXVB3i","C3bSAxq","DwzbBLm","thvxD0S","CMvZzxrfBMq","tKrzEuG","q291BNq","BuT1teC","ExbL","BxbluK0","ExHbvNi","DgfYz2v0","swPhsMe","CMvHzhDYAxq","CgLUz0LUDgu","B0vcugy","AhHxDvO","x3nLBMrby2S","C3DAq1i","ugTzwu8","uMDvuhm","uvH1r0u","DgHhtKq","CNzHBa","tu1SAfC","sLjxtem","rMv4Aei","z2v0sxrLBq","sgDhrgW","A0TRqNq","Dw5ZAwDUzwq","BMrWB2LUDfq","A2LmA20","DuXuvue","B3bLCNr5","Cfr3EKO","Fdv8m3WYFdq","y3r4","wwfLwMK","EKvNDg8","C3vIyxjYyxK","C2nYAxb0","zxjYtM8","zw50zwqGDhK","Cgu6ia","C0Hxz3a","Aw5KzxHpzG","Aun0tKG","C3HYtwi","zND6Dey","C1jRBei","yu9Nt1i","tg9JAW","Cgf6txK","EwTMB0i","ze1Qt3m","BwLUAvbYB2C","tgDmBfu","y3vYCMvUDeK","EeDOBMy","AwTztKe","zxjFCw9Z","mhWYFdf8m3W","t0zZANi","BLLtzhq","zw5HyMXLvhi","B2nRzxrtDwm","sfLNq3q","su55z0u","t1bftL9fuLi","uKvIq08","zenXD2m","BxnN","BMCGDxjSoIa","A3jtDNq","Cg9PBNrdB24","Dhr3Awq","EMj0vLG","s0Hptuu","qxbeDxG","Dwnswuq","CNzSvLO","B25dBg9Zzq","ExvbCwu","C2XPy2u","CeXHreO","q29UzMLN","B2LUDfjLywm","tfDPy2W","ywj2vKK","vg9cB3u","nhW1","nxnXtNf3ra","AenSB3nLrxy","BgLUzq","yMfJA3vWigu","yvnVv1C","oda0BvvJuxbT","sezXEeq","yxzqs1a","Duf5zLe","yMXVy2TLza","Au5ut0C","zgvuyKu","zg9Uzq","C3rVCMu","yxbWBgLJyxq","vKLjC0q","CMLLC0nVDw4","qMztBeq","rNnSA3C","BwvZC2fNzv8","DgHLBG","z2vrDwv1zuW","x29Uq2XVC2u","C3LnDKm","BMrLEa","CgjICdi","s1fjvvC","ugnlwLe","zxj2AwnL","vMjQquu","yxKSig5LDhC","y29Kzq","EKDfExC","sKXXA0O","BND2sxy","y0fTAuC","D3nTA2i","BLLdDvu","C2vUza","BNrbBMrvCgq","vgzWt1K","zMLN","C09tshO","C1zZDgK","DMvYC2LVBMm","B3jRig9MzMW","x2zVCM1HDeu","zxjFCw9Zx2e","u3Pvvxq","y29Uy2f0","tKzQD0q","vMjHrge","uLLhDwC","x2LUAxrqCM8","vfLJB0e","uuz2rKm","zgf0yq","x3fVC0rc","tgj6wMW","EvbyAu4","yvfwAMq","sxjyuK8","CxP2DgG","wxPyAvq","x3nLCuLK","mhW2Fdf8m3W","t0vvrM8","vMP5vgS","q2Lxq2i","wKPYvNG","t0vjAfm","wNL3Exi","uwX2DeW","BIWGAg9ZDg4","zer4rwe","zNDZxZeUmc4","yxnL","EKfireO","zg5jCvi","vM55uLK","AxnszwfKEq","BgDjuLe","tM1YwLm","t1LOEu4","Cw9Zx18","sNrVquq","yw1L","ihrPBwvZ","rKLqD2K","ue5ABwu","rhLKrMm","ELjVuMK","x21LC3nHz2u","vxbKyxrLq28","Egr5EKO","AxjLza","ihzHBgLKihm","uNnUBeW","v0Lsvu4","wNLUBgO","DNPoDK0","z2vtEw5J","Cgf5Bg9Hzfq","AxnFywnR","AMjvAKm","vezfrvm","C09XtgS","rxjYB3jdB2q","z3bLuwu","u2vVsvO","z2v0q3vYC28","zeLMDKm","s3HIDLy","Aw5Lza","vgXnuKe","s0LVzfy","BMnLq2XVC2u","yw5Hz2vY","t3vIA1K","qvDxrvO","Ahfws2W","vgfN","z2XdsKm","B2zMBgLUzq","CMvHzhLtDge","uuniCM4","wMT3Age","DK9lvNO","uKX0rwm","uwHlv2G","CvLZB20","A09XtLq","DxbAChy","BMDtuwi","Ew5YsKy","CxzuCui","CgfYC2u","wLrLBum","vg5HAxy","tfLuruW","CNzHBfzHBhu","C0jf","vgv5Dwy","ChjVDg90Exa","twLZC2LUzYa","EMLdvg8","zgvJB2rLzey","t09isvq","zxjHDg9Y","B25VCgvU","Aw47y2HHCNm","wxL1uKS","yw1LoIa","ChbL","AwXLx25HBwu","quHkA3G","C1bTAKS","vgXzuvG","txzZuNy","zgvSzxrLrge","t05sv1a","ywrK","vw5Oyw5KBgu","vwnvAgS","Aw9cBKi","vLHby3u","zgvS","zuPqy1m","t2vIDwq","yNL0zuXLBMC","BMv4DcGPigm","CLjPyLa","tNPXtfG","AevIz00","yxv0BW","txzwD0K","C2vYDMLJzs0","CMvYrvy","vevtrwW","rvzPwxy","Fdv8n3W0","x2jPBMfYEvq","vMHZzhC","twfHAui","uxvLDwu","vMvjExm","y2XLyxi","x3bPBMDmB3m","Egzkr28","CMvZzxruCMK","vLftCeS","uKrLu0m","Dg9tDhjPBMC","s1fHCwe","x2rLC3rYB3K","Dg1zuwi","z2v0qwXSs2u","r3jptuu","BMvY","ENb3AxO","Aw9TwfC","vvzAv1C","DhzAtuK","tfLjDMO","Bg9IywXty28","vwfKqu0","whD3Ae0","DuPSvue","shvVuwO","yw51Ce1LC3m","y2nVrLK","uLLfy1G","AxnrB1nnzxm","zgvIDwC","B25fCNjVCG","q0Xpu0LorW","yLvSr1O","tNnYA2O","DfPWBwS","x3bYzwzPEa","ANrIAMe","Aw9UvgLTzw8","rK16suS","y29fAeO","AuTHteu","veTfBhe","A2v5CW","AgvHzgvY","B2rTwKu","CMvJzwL2zwq","zxLjuw0","B2XKvMvYC2K","Bwu6ia","yunXvK4","qMrSwMm","x3bPBMC","sKzmAwe","vLvsuNO","A1DXEMK","nhWYFdf8mhW","zw56rwm","yNrkwfy","veLosMi","zwXkzwS","yxjStvG","AfvAwNG","CNjVCK1LC3m","CMvZB2X2zq","C2v0","x0vysvnu","u1HVvKK","ChjVy2vZCW","Dw9fqu8","DvDtC0O","Dg5Kt3i","u3rYyxrLz3K","C3nItM8","zw50A1G","tvHVqMG","x2rItMfTzq","DMvUDa","sg9NqLe","EM1NBwC","wwrot0C","t2fvuu0","Dfv3wxO","C2DPza","yvfvuNu","zvb3t3G","DxLMChy","B25TzxnZywC","ALrUyxK","AwXK","Ahr0Chm6","Ae9Wzw5fDMu","Chv0","r05js04","y3vpC00","x2rPC2nVBM4","ywr2yw5Jzq","t1bHwgy","Aw1ZD3C","tKXlsMC","yvzODwW","wNP2zg4","y0vcwLi","t1fjyM8","id4G","BNrfBMrWB2K","BhDNwgC","DcbVzIbYyw4","CgfoANm","vMD4zuS","A2ztsu0","x3DZ","wNH3qMO","D3DwvLe","Dxrjza","t3bLBKv2zw4","zxHQt0C","B2jQzwn0u3q","CIb0DhDjra","v0DVtve","x2n1CNnVCKy","qwvIz0O","qMflq0m","AwXSihvZzsa","CMTLCKDSB2i","DeLUDgvYy2u","wxPAtxK","Bhb1qNK","q3vZDg9Tq2W","B3jpBMXPBMu","z2DsuhK","wKr0ueq","q3newva","AKLArgC","EMnyy0W","x3jLywr5q2W","z2u6ia","BMCGB3iGyw4","z05Sugq","EwHWANe","CLzHBhvLCW","z2v0u3rVCMe","wM1Xr1q","z0XJAgC","tKvUu1C","wuDTrwW","uhjPBwfYEuS","AhDesuK","BMrNswC","ywrKt25L","qvbyzKK","ELvRvwW","u2HHCMvKv28","z2Xsvve","uLjpuG","CMvZDwX0","BMv3vMvYC2K","t3P4uvG","rg16BNG","CNnVCL9Uyw0","zNjVBuHHC2G","terXAuC","CMfUzg9T","twvZC2fNzuu","zw9er20","zff0wLO","ChvZAa","CMfTzq","rLDt","rKDIzeW","x0rctMfTzq","Cgf5Bg9Hza","C0nVDw50zxi","ignVzgu6ia","BNrLCG","z1rPBwvVDxq","o2nOyxjZzxq","t0n6Ahy","CxnfEhO","r1LnCg8","y3jLyxrLrwW","Dw5KzwzPBMu","yM9KEq","ELjevNq","DxrVuMvJB24","BMDru0i","vuvUre0","s2TdsNi","yNvYufu","x2XPC3rLBMu","Au5Jv1C","zMD4t24","rvnkz2W","yMDkt2i","CM51CMq","ihzHBgLKigq","pxv0zI04","BKPPDuG","vKPjBhq","AuriCu0","Avzmrwy","qMLtA1i","reToDuy","ze9cCfm","BgvY","x2LZtM9Kzq","ywWGy3vYC28","zv90Aw1LB3u","uNbOuuC","BNzXugm","z2vjBMzVu3K","DM51zNe","vLLAu0O","CenAshi","mhWYFdn8nhW","EuzZugW","wMjgAu8","q09oveLovuu","C2v0sxrLBq","qMTMD0S","q2LsqMO","vuLPExa","sxvfrMe","ueruCMi","aaaaaaaaaaa","B25nzxnZywC","x19LC01Vzhu","rfnAD1m","AfLwBgy","C2HPzNq","AgfZ","ihbYB3rVy28","thPdBha","DNLAqNq","qNjPzgDL","x2DLBMvYyxq","Dgv4Dc9WBge","De1HBMfNzxi","yxnZAwDU","qvrbBhO","yw5Nzq","qLDfte0","BNruCMLLC0m","BfrPBwvVDxq","tufyx1jfvfi","wwzOvfO","Bvj3uLa","zKXXrwO","y2rXDw0","CMvKDwnL","igzPzwXKoIa","vw5rDuO","B0jJt2K","B3bLBG","Ae1LC3nHz2u","DePttum","yNvMzMvYzwq","Dg9cExrLCW","y3jLyxrLuMu","EufpBK4","CwDyuuK","DML2ywO","CLDouum","rKDXCfG","BK50veG","zw5fDMvUDa","z0Dks2m","ywjVCNq","D1vgBui","AgvHzgvYCW","BMvJDa","AgLNAa","qwjVCNrfCNi","CgfNzwHPzgu","zurNDe8","u1LABwO","yMrVCMu","runzv3u","ChHpr2q","tuvtu0fhrv8","yxjYyxLIDwy","B3bLCNr5tMe","y09Wzw4","D25lsNi","B25mAw5L","s0HhA0u","v2LdDeq","CMvHzg9UBhK","B3v0sw50zxi","yLfqC1q","yNL0zxm","DMfSDwu","x21PBMLoyxy","u2vYDMLJzvC","whDtq2O","AxnbCNjHEq","tNfAuvi","BfPmq3u","rKrjz0S","yNjOBNu","B25ozxr3B3i","EwX3qvK","EenHs0y","Bhn2rwu","renvAhi","BNvTyMvY","n3W5Fdz8mte","BwvZC2fNzq","v0H4DKW","s3HXDhC","D2fZq2XLyw4","BwvKAwf0zwW","sM1eDMi","mtuYndu2oef0DhbpzW","AvnhEeC","v29oseC","CMvTB3zLrxy","C3rYAw5NAwy","yNvMzMvY","zMX1C2HfEha","igXHCMDLCIa","CwDsrfC","y2HLy2TdDxi","C29QCxe","t29gsNK","uLfRrwi","uKXevva","y3zKv3C","sgDru1C","CwfVCfK","ANHPtfa","B3bLBKrc","EvjLy29UBMu","Bufzve4","Eerqs3q","sMTirxy","sgDAyve","ywjqyKy","tfrfAfq","C3vIC3rYAw4","wu96zhK","DhjHBNnHy3q","uw9IrNa","y29UBMvJDfm","wgLevfu","ALnqvfm","yxbQuMy","wuHRD2q","B2zgsMS","sNLeDLG","C0Xf","lcbTyxGGCMu","zxq9DxrMltG","CgfJA2S","C2v0zgi","ywnRx2nVzgu","CMLNAu8","B2X0wvC","wuHnCuu","ihrPBwvVDxq","ywfpuu0","vNvMC0q","zgPvEvq","D3jPDgu","C3vJy2vZCW","Eg1JuKy","BMfTzq","Bg9N","v3jxtNC","BezSDxnO","B2zM","Cg9W","x2nYzwf0zvm","DKvTuxm","Aez0Aum","Dg9mB3DLCKm","BfzjDuq","zgLZywjSzue","mZG1nJy1CM96zenL","BM9Uzv9UB24","sLv5ALG","y2f0y2G","r3bqyuy","rKrpy2K","uuPkD3u","y2XVC2u","CMXxEha","wNbUyKi","zxrxB3jRq2G","AxnrB1nby2S","yxGGCMv0CMK","CKPpD1u","BML0AwfSAxO","zgvSzxrL","q3fPvNa","CMLOu0i","yw5ZzM9YBvq","rKnZrfq","x2vUzhbVAw4","y29SBM8","y3vYC29YlNm","y29UC3rYDwm","zcWG","Be1Xuey","Dhj1y3rVCIa","zNjVBuj5Dgu","D3fiqNu","D3DVu2u","tNL1rgy","C2v0y3vYC28","v0Dqr2e","mtu1ndCWmMrcyxLRvq","tuPvywG","r3v4qKW","qMjAuNO","EeTVz0K","tNHgveK","AgfUz2u","uMDzwvC","zvHwsvq","wwTLtg0","qLDPywS","BLLUyNq","igfYCMf5yNu","x2LUAxq","jMPZy2fSBgi","z2vY","Evv2BNi","vLPnDhy","rMrOru4","Bg9NsurozxC","y3ruAw1LB3u","u3jTyui","zgLAEMi","EgznCMi","y3jLyxrLrxi","DhDVCMTdAge","vgLTzw91Da","CM92AwrLige","CgLUz19VBMm","BxvzDMq","rgTwAMC","x2fKzfDZtgK","y3vYCMvUDeu","zMzMzG","muzdBvDHua","y3rRD1m","DhjPBq","BgvXv0K","AKPWvvm","BgLTAxq","EwPOwKK","zeDWq0C","CMjLAhK","x2nSzwfYugK","vMPLt2m","DwX3sK4","l3DZl3yY","wxPAuvi","B3jL","rKPRtwC","AhjhAwG","B2zisgW","r2HYyu0","ENrurxC","C3rYAw5N","A3PsALe","CgXIBeq","zsbHihn0CMK","wK1xs0W","nxW0Fdi","Be1OsKW","zfn1B1y","v1PWy24","Chzzt3y","zwXdD1a","EMDzBgW","r0LwEgi","ywDL","BwLZzq","CK9xDey","zxHWB3j0CW","t3jusge","CuzoCxq","zxjYtxnN","yuHJDu8","rgzowu0","y0zJrMm","x2rYB3bhBg8","DhjPzxm","zg9hrfy","rvbzCuO","y2fhC1q","vwrXweO","zw50","Du56v1e","wuDsuvq","y29UBMvJDgK","zwLcsNa","B25LCNjVCG","rNDRvMe","CgLUz1rPBwu","ugHXy0K","s0LwBvq","A0Tptuq","y291BNq","BwvZC2fNztO","x29Ut3bLBG","ywnRpwzYB24","z2v0qwXS","uw9eq3q","ChjVDg9JB2W","ruXmrMu","vgLMyxu","AujABgy","rM5LD3q","ihrVihjLDhi","z2v0","DMzuCfm","zxH0ugf5Bg8","t2zdy2m","EMj1z1m","rwTdCxO","CxjqreC","sLnptLa","zezesvm","zgLZCgf0y2G","x2LUAxrhBg8","x29UugfNzu4","tLzYz0e","ruX4sLG","y29UBMvJDa","x2rLyNvN","m3WXFdb8mNW","z1zvCuu","t0X4quu","ENzlvgW","BxnNsuq","u3HurxO","rvLlrKW","C2fNzq","AxnAzxjV","D292s08","CM92AwrLigi","BvrJuvK","x29UvgLTzw8","suvfs3G","ywjQDvK","y3vYC29Y","u25kB2i","zxjFAxnFywm","q1zvqwu","y2HnyxHuCMK","zxjFDhrS","y3vYDMfSDwu","zMzmAw5L","ywrKrxzLBNq","u2TPCcbWyxm","CMfNzvn5BMm","zuHYzNK","DhPxrui","AgPLzuW","qMPbswy","CNPusKe","vwfJtwq","B3vUDa","CxjmEha","Dg9oDw1Izxi","x25HDMLNyxq","DKDKz1e","q1nHBvG","CgXLyxnLiha","uuXzsem","rKn5CK0","EfzXyLK","qw1VDw50","lcbOB3n0BMe","Eunzywy","tMfTzq","tg9Nsuq","qwfpAfq","x3vYBa","wwPhAw8","rLjptLrjrvi","zMvMEu4","rKLmrv9ot1q","CKHrs3e","z1vWsem","EMTRuLe","B3nLza","vMX0DNK","x3jLBw92zvC","Aw5PDcbrB1m","x3jLy29UBMu","B25pCgvU","zwrPyxrLBhK","DgvZDa","BgvUz3rO","AMzTC08","vw5PBxbSzw0","C0Llz3q","AwrI","y2fSBa","B1DRyvC","D24GCMvHC28","ywzMEwG","DMfS","CM92AwrLihC","x2LZtwLUAvC","D3nZoI8V","CNnVCKzPBgu","BffOEvC","yxjLrNC","uKfOsva","Aw5KzxG","DgLTzw91Da","rwfJsfe","z1fltNa","rwvVELq","m3WXFdr8mhW","qxbcB3C","B25tDgfYDfi","zMLUza","uM1dtMO","DhbizwfKzxi","y2XVC2uSihC","mhWZFdr8mxW","Bhm6ia","ywDLu2HVDW","C2rju2y","DuPWEfy","zgvmAuq","rwzUzue","BMnVzgLUzW","CwvjweG","sgfTuLO","v3L0C1q","CefKvvG","ExvOA24","rNP5tfu","tNvTyvC","Aw1SsNG","x3bPBMDqB24","yMfSrxzLBNq","Aw5N","Aw9Ul2PZB24","B3bLBIa","CMvTB3zLq2G","AwXLtMfTzq","ywnRDxbfBMq","B1LmtM4","DxbKyxrLq3u","BhDbsha","Bwv0Ag9K","mZyZotbnrurjAee","Bw9vr3m","A2Xbt00","tgjJvgS","C3jJ","Dg9cExrLC0W","x2nSzwfYvgK","qvnPu3a","y3vZDg9Tshq","zNvUy3rPB24","uwLPwuC","CMvXDwLYzwq","t21tBNK","CfnfwNO","AgvKtwf4uMu","t3vSCuq","yNL0zu9MzNm","x3bHDgHlzxK","AKHgsgm","ntqWze9iAhrU","DMfSDwvZ","zM9YrwfJAa","Duzrsvu","CefMww4","wgPLzuW","twPUuLG","tNf2rLC","ywHpCNu","A0PwzMS","Aw5JBhvKzxm","zwn0","vLPRv00","y2XVC2veqG","AuLQA0e","BeLls28","DgfIyxnL","ywXSzwqGBxu","vezgB0e","B25SAw5L","Cw1bsKu","y29UBMvJDeu","B3feB1K","yKznzhi","ig1LC3nHz2u","EsbJBg9Zzwq","tgLZDgvUzxi","tNrwwKO","x2DLDeLUDgu","CK9Xzhe","Dgv4DfbHEwW","BLjRtvy","rNjVBNrPzxi","q09otKvdveK","r3HYDha","vfPfBwK","zxf1ywXZ","BMrWB2LUDca","icSG","zMDms1C","CMnmswW","y2nQANO","qvfhEgK","Bwf4uMv0CMK","z2v0t3DUuhi","rKf0t0y","v2fzv0y","uuDyy2m","veXUvMC","AgPXvMq","EfvZzuvUDG","BM5mENq","vLrbCg8","qwf6s28","B3jRzxjhBg8","Bw1VCKK","D1f6sLi","rfHRDva","x2n1CNnVCK0","zw5NDgG","yxrHlcbKyxq","C3rVCcbPBw0","tfLgBhO","Cg9PBNrbBMq","x2LZtwLUAvq","Be1bt1m","t2T1tg8","CMjgv2e","yxbWzw5Kq2G","wfPjBK0","zw5HyMXLuw8","CM9YrxzLBNq","zw5JB2rLrNi","wuX2D28","AxPMzee","CgvYC2LZDgu","C1v0sMO","CNPpuwu","y29UBMvJDca","seDXuKC","yMjjyw4","vwznCfq","C1nryMm","mxWWFdj8m3W","DgHsuxK","se1yqMK","B3nLrxzLBNq","C3rLBMvYCW","Ahnvrxy","CMvQzwn0","wKfxuLO","yM9L","BxfluvG","rwT4uLa","BeHHBMrSzxi","qwDSChq","sfPtEvy","zw1PDa","CMv0CNLdB3u","u3L2Euy","DwPkuLq","vNrJzeW","swnsz0q","AfjwBwi","vLrgvMG","s1L3wNq","zhD4sLm","sePJAKW","zNjVBNrPzxi","zw5HyMXLqxu","zw5KCg9PBNq","oda2m3fkBMLvCa","C29YDa","v3HJqKu","ueTsENC","n3bIsvngDa","q0Lsz0C","vgLuB2m","AuXHreK","qwj4yKS","zNjVBujPDhm","ruDmq0W","B2zMC2v0","CfrsBKW","EwvKDgW","suXlz0i","z0XotLO","rgnwExG","mdaWmdaWmda","DgLUzYbZzxi","AeDjqLK","DhLWzq","BvjdBeW","D3jPDgvvAw4","ywnOzwq","qMfUq3a","x2LZqNjVD3m","z1LSq1a","DgvmB2Djre4","tMTTrK0","swz1q1K","q0DuC3C","sLbUqwq","sMvbtMO","ywrKq291BNq","qvfdDwO","wuj3z0S","ywXSq3vYC28","BefmCK4","CgfNzxnOB3C","vg52Buu","AwDHDg9Yt24","rurnBKu","Bwf4tg9ZC0m","yLzIDKq","tvjNA1a","y2vZC0HHBMq","ExPvCeK","A2LcDee","quvADfm","BKP4qw8","CgLUz09Uy2u","DNDPvgu","vLfPBgS","DKH6D2G","AgfZt3DUuhi","tenTuKq","CxjbsLe","zxH0zw5ZAw8","sfHmsMi","yKnpt2i","ywXS","vwLgy0S","sgvLrK0","C2v0q3vYC28","x3DHAxq","y3jLyxrLq2W","yKfQALG","DeLK","CMvZzxrdB3u","A2v5","ENPkrxm","zgvMAw5Luhi","Egvcq1O","yu5othm","u0v3qu0","suLIA2C","Exj5z0O","EeLsDwi","q0Xpu0ve","zLjiveC","x29UtwvZC2e","A1neEeG","C09hEMe","s0LgDgG","A3jSsgG","D0D5Ceu","zw5XDwv1zq","CgLUz0XVC3m","Dfvxshi","uMPXzgK","CYbWyxjHBxm","EhvbEw0","BwvY","tgreC0C","s09fuu8","DhjPzxmGCMu","uLblvuu","su5tvefova","sgXMq3C","Bw5utxO","s29fwhm","x3nVy2TLDa","mhWZFdD8mq","zMLSzw5HBwu","sej1rK8","zwnVBM5Ly3q","y3jLyxrLtwu","quXm","tw9KDwXL","DxjS","AMnTuKO","yMLUyxj5vhK","Ewz3z1O","zcWGDw5RBM8","yxv0B21HDgK","tLHnBKe","BMvLzf9Hy2S","BM5Ly3q","swX0yxG","u2vXsuq","DNz6wuy","CMvWBgfJzui","B25szwnLAxy","q1fkBNq","CMvJB25Uzwm","vxzwy1m","uwvPzhO","mZu4otG0zLDXC1rr","tu1Stxa","DgLTzw91DcW","ChD5rLG","qvrtwfK","s1frr2u","DeTODM8","v2vIu29JA2u","rvjst1i"];return qo=function(){return t},qo()}function Nt(t){let e=N,r={entkX:e(737)+"1"},i=r[e(597)][e(1761)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=hx[t];continue;case"1":return l.exports;case"2":if(c!==void 0)return c[e(1004)];continue;case"3":var l=hx[t]={exports:{}};continue;case"4":qv[t](l,l[e(1004)],Nt);continue}break}}Nt.d=(t,e)=>{let r=F;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object["definePr"+r(1794)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;Nt.o=(e,r)=>Object[t(483)+"e"][t(1361)+t(1794)][t(1125)](e,r)})(),(()=>{let t=N,e={HgQSW:function(r,i){return r!==i},aHcuO:t(406),bzVtb:function(r,i){return r!=i},xfMrb:"undefined",tsNUy:t(1415),aVhul:t(749)+"le"};Nt.r=r=>{let i=t;if(e[i(851)](e[i(1008)],e.aHcuO)){let o=_0x5c8b1d[i(862)+"g"](0,4-_0x272e30[_0x3e4b2c][i(1120)]),c=o[i(1901)](_0x4f03ad);_0x1300bc=_0x303363[i(1901)](c)}else e[i(1703)](e[i(957)],typeof Symbol)&&Symbol[i(532)+"Tag"]&&Object[i(1378)+i(1794)](r,Symbol[i(532)+i(461)],{value:e.tsNUy}),Object[i(1378)+"operty"](r,e[i(623)],{value:!0})}})();var Re={};(()=>{let t=N,e={YBwgK:function(a,n){return a+n},xhmeT:function(a,n){return a+n},yxAVr:function(a,n){return a+n},bobJN:function(a,n){return a*n},TFEES:function(a,n){return a+n},HGqRG:function(a,n,s){return a(n,s)},gFZAq:function(a,n){return a(n)},kqkJA:function(a,n){return a(n)},paNjs:function(a,n){return a+n},gdVQG:t(1737),BdlZc:t(967),iBZlf:function(a,n){return a(n)},dOBpS:"00000000"+t(1324)+"00000000"+t(1324),VIIsD:function(a,n){return a>n},ylwAY:function(a,n){return a<n},jfmsO:function(a,n){return a!==n},mAYTN:function(a,n){return a-n},aSoWW:function(a,n){return a===n},IdXbM:t(1400),cuOsM:t(681),qgXQI:t(1320),rigiO:function(a,n){return a<n},NqvFW:function(a,n){return a===n},packk:function(a,n){return a<n},ARUKp:function(a,n,s){return a(n,s)},VeIys:function(a,n){return a!==n},sOSHz:t(1665),tzWEB:function(a,n,s){return a(n,s)},OQIbo:t(1648),NFjwD:function(a,n,s){return a(n,s)},LYIvj:function(a,n){return a(n)},SYZmj:t(887),rerEV:function(a,n){return a===n},wGypE:t(1870),DcVyx:t(1237),qaopY:function(a,n){return a>>>n},UvVcS:function(a,n,s){return a(n,s)},RkLQn:function(a,n){return a(n)},CsDYP:function(a,n){return a&n},jxiLP:function(a,n){return a===n},uWSsJ:t(484)+"required"+t(773)+t(1376),ECZOU:function(a,n){return a===n},OzxQX:t(484)+t(1188)+t(773)+t(814),ltqVL:t(1530),HBuFO:function(a){return a()},wEuFD:function(a,n){return a!==n},hdpkU:function(a,n){return a(n)},qrLxp:function(a,n){return a!==n},iVLEf:function(a,n,s){return a(n,s)},NxFTI:function(a,n){return a!==n},cMAkK:function(a,n,s){return a(n,s)},bQPsT:function(a,n){return a!==n},EexhQ:function(a,n,s){return a(n,s)},mZscJ:function(a,n){return a!==n},RgYYW:function(a,n,s){return a(n,s)},ujJRT:function(a,n){return a(n)},NzqLX:function(a,n){return a(n)},ndgIg:function(a,n){return a(n)},thGND:function(a,n){return a>>>n},xIRub:function(a,n,s){return a(n,s)},uiHSK:function(a,n){return a(n)},xTYYG:function(a,n){return a(n)},jIZDg:function(a,n,s){return a(n,s)},ZpnbB:function(a,n,s){return a(n,s)},MUtCX:function(a,n){return a(n)},RYEcX:function(a,n,s){return a(n,s)},TpEhy:function(a,n){return a(n)},BbHld:function(a,n){return a(n)},CZQEB:function(a,n,s){return a(n,s)},gUpHC:t(484)+"required"+t(773)+"LogID",gAgRT:t(484)+"required"+t(773)+"method",oDVRo:function(a,n){return a(n)},LwdsS:t(1581),tatlg:function(a,n){return a(n)},xfJGo:function(a,n){return a+n},SEwAM:"QbVrF",IHYhv:"ShHfo",GhraM:function(a,n,s){return a(n,s)},QEhlh:function(a,n){return a(n)},sxrMb:function(a,n,s){return a(n,s)},yzZRd:t(1122)+t(1803)+t(1804),OYhyN:function(a,n){return a>=n},AaOhT:function(a,n){return a===n},XwwhM:function(a,n){return a+n},YYSwv:t(1080)+"t limit",qvTqB:function(a,n){return a>n},oXNYm:"Read pas"+t(1674),bUlGZ:function(a,n){return a+n},UfMpT:t(1580),gKRUF:function(a,n,s){return a(n,s)},OulqD:function(a,n){return a<n},BkfwK:function(a,n){return a===n},tYQLY:function(a,n){return a===n},meFCn:function(a,n){return a&n},vHzwh:function(a,n){return a+n},DCUhr:function(a,n){return a&n},qmAJE:function(a,n){return a==n},wpARN:function(a,n){return a&n},doGDV:function(a,n){return a+n},brhnu:function(a,n){return a&n},YyuRK:function(a,n){return a|n},vdWWZ:function(a,n){return a<<n},zUkUl:function(a,n){return a<=n},FJkMg:function(a,n){return a+n},hkKtL:function(a,n){return a!==n},ePwOx:function(a,n){return a|n},DKNuF:function(a,n){return a&n},krSvt:function(a,n){return a&n},XwSCj:function(a,n){return a>n},tmYQb:function(a,n){return a>>n},areFw:function(a,n){return a+n},eHrfy:function(a,n){return a-n},rOWtF:function(a,n){return a<<n},HYgCt:function(a,n){return a<n},zbugS:function(a,n){return a>=n},rcLIl:function(a,n){return a+n},vznal:function(a,n){return a+n},WrWNw:function(a,n){return a|n},egtHf:function(a,n){return a&n},OrTHa:function(a,n){return a&n},ZJEhM:function(a,n){return a!==n},vRtAb:t(1807),etpMO:"ETBNg",BAJQe:function(a,n){return a&n},RQkEb:function(a,n){return a&n},KQIUW:function(a,n){return a>>n},KQQGe:function(a,n){return a&n},FDOci:function(a,n,s){return a(n,s)},LbcTk:function(a,n){return a(n)},hCSPw:function(a,n){return a<n},APXfI:function(a,n){return a&n},rlWxp:function(a,n){return a-n},uWaPe:function(a,n){return a!==n},hqVKl:t(1175),arlMX:function(a,n,s){return a(n,s)},OtnbY:function(a,n){return a(n)},krlHh:function(a,n){return a(n)},fxucG:function(a,n){return a<<n},gZgiG:function(a,n){return a&n},iDHqM:function(a,n){return a&n},sHWgp:function(a,n){return a&n},kSDxH:function(a,n){return a&n},burPU:function(a,n){return a(n)},pAdUX:function(a,n){return a<<n},QFvFC:t(448),nlQSH:function(a,n){return a(n)},lQWOD:function(a,n){return a<<n},dSuoV:function(a,n){return a&n},zzJEs:function(a,n){return a(n)},INygE:function(a,n){return a<<n},kALcN:function(a,n){return a|n},Rtxgk:function(a,n){return a<<n},eoDGm:function(a,n){return a>>>n},zxFEw:function(a,n){return a<<n},ikYNA:function(a,n){return a|n},LTEhT:function(a,n){return a<<n},HamRZ:function(a,n){return a===n},qgRDW:function(a,n){return a<n},elCwP:function(a,n){return a<n},LuWwK:function(a,n){return a&n},LYTEL:function(a,n){return a>>>n},OmSny:function(a,n){return a!==n},eInbt:function(a,n){return a|n},ApBow:function(a,n){return a>>>n},RoDej:function(a,n){return a+n},leqWI:function(a,n){return a|n},sOqLk:function(a,n){return a&n},hRVmb:function(a,n){return a|n},RHOke:function(a,n){return a>>>n},hFtiC:function(a,n){return a>>>n},Qeidz:function(a,n){return a&n},FwkVa:function(a,n){return a>>>n},cAmiG:function(a,n){return a+n},aaOQM:function(a,n){return a>>>n},ykfoB:function(a,n){return a|n},ofFJk:function(a,n){return a(n)},YGmEl:function(a,n){return a|n},BtJpH:function(a,n){return a|n},xCaKF:function(a,n){return a|n},AbxbK:function(a,n){return a<<n},rJOwU:function(a,n){return a<<n},MjnRX:function(a,n){return a|n},GiqcI:function(a,n){return a<<n},zwUsI:function(a,n){return a|n},jSPTS:function(a,n){return a<<n},AWWEZ:function(a,n){return a<<n},vOKVz:function(a,n){return a<<n},xVqbY:function(a,n){return a|n},ATSXY:function(a,n){return a|n},yjhZI:function(a,n){return a|n},EacHQ:function(a,n){return a&n},odmZE:function(a,n){return a&n},lCRCd:function(a,n){return a>>>n},JeANj:function(a,n){return a>>>n},hGIBY:function(a,n){return a>>>n},xKogI:function(a,n){return a(n)},PhqcI:function(a,n){return a+n},EYKFL:function(a,n){return a|n},NfzQI:function(a,n){return a%n},pxOGd:function(a,n){return a+n},hrGih:function(a,n){return a*n},YkeLm:function(a,n){return a*n},SFiBH:function(a,n,s){return a(n,s)},oAtHQ:t(1587),uoEAO:function(a,n){return a===n},ZTemC:function(a,n){return a&n},CiRBj:function(a,n){return a>>>n},NEnSW:function(a,n){return a>>>n},IPwRQ:function(a,n){return a&n},vAyxh:function(a,n){return a+n},bMZOb:function(a,n){return a+n},IcRgD:function(a,n){return a+n},vGdgQ:function(a,n){return a>>>n},VnyRY:function(a,n){return a|n},nwvIv:function(a,n){return a<<n},VXAcu:function(a,n){return a!==n},nBeVF:function(a,n){return a===n},imNRA:function(a,n){return a>>>n},uLTUA:function(a,n){return a===n},xmcRF:function(a,n){return a===n},yzUpI:t(1142)+"2",TINJb:function(a,n){return a||n},kfSIM:function(a,n){return a!=n},Zynlj:"undefined",CuuaW:t(819),JoeAQ:t(867),EGLCL:function(a,n){return a+n},QiiYG:function(a,n){return a&n},Zzvdn:function(a,n){return a>>>n},AazKo:function(a,n){return a&n},uyfpv:function(a,n){return a>>>n},KoEXs:function(a,n){return a&n},QobFp:function(a,n){return a>>>n},sIKgt:function(a,n){return a>>>n},rnurd:function(a,n){return a&n},JLqkJ:function(a,n){return a>>>n},LWicl:function(a,n){return a&n},rRibP:"NATIVE_E"+t(677),czoNa:t(767)+t(1633)+"R",wnKJr:t(802)+t(1442),YGRQT:t(1829)+"OR",bIpIo:t(405)+t(993),GXxRD:"4|3|1|0|2",UiFcK:t(988),WVWYe:function(a,n){return a instanceof n},ggRPy:t(1866)+t(1168),eiBJp:t(759)+t(490)+t(875),yPOuw:t(504),kIamP:function(a){return a()},hUZZx:t(1495),rihSB:t(799),aQURu:t(603),vnufq:function(a,n){return a===n},aJEwG:function(a,n){return a-n},Iltax:function(a,n){return a===n},LphjF:function(a,n){return a==n},imlJx:t(1541),tvZMI:t(1697),YHMqE:t(502)+"d error.",PEPHx:function(a,n){return a===n},gLchg:function(a,n){return a!==n},OubkY:t(1445),uJpxV:t(908),jHFHc:t(830),IfCBZ:function(a,n,s){return a(n,s)},NumaW:function(a,n,s){return a(n,s)},kGXfE:"open",pLaDJ:t(735),fRHTG:function(a,n){return a+n},ufAnS:t(1204),FexhB:function(a,n){return a+n},VJIlt:t(1621),oltYW:t(820),UVrmB:function(a,n){return a<<n},YHkwd:function(a,n){return a&n},hHmeu:function(a,n){return a(n)},pTwzJ:function(a,n){return a&n},wEFlv:function(a,n){return a!==n},uMvFf:"qnrky",HlfCw:t(578),BLYui:t(1279)+"4",qYsom:function(a,n){return a||n},kBSIf:t(510)+t(1213)+"ltiple times in "+t(591),XZInM:function(a,n){return a===n},tUWHr:function(a,n){return a+n},QLYHC:function(a,n){return a<n},mnTMz:function(a,n){return a===n},OaUQM:function(a,n){return a&n},UcUhk:function(a,n){return a<=n},FlvEC:function(a,n){return a|n},abvVI:function(a,n){return a<<n},FMzIK:function(a,n){return a<<n},diZzb:function(a,n){return a>=n},WaYWF:function(a,n){return a<<n},NLKJg:function(a,n){return a&n},nRkMV:function(a,n){return a&n},aNNLs:function(a,n){return a+n},REbCO:function(a,n){return a*n},sxytX:t(1522),TYcoA:t(863),oVyES:function(a,n){return a<n},bgJOb:function(a,n){return a|n},kKkBt:function(a,n){return a&n},Teyuf:function(a,n){return a===n},VtcdL:function(a,n){return a&n},uFQIU:function(a,n){return a!==n},hYVlf:t(1111),mmorI:"zKvxP",KxbvV:t(1566)+t(1500),mmdcm:function(a,n){return a|n},rHQKq:function(a,n){return a|n},IoeOV:function(a,n){return a+n},yuAqe:function(a,n){return a|n},MSXMA:t(1558),CqiVp:function(a,n){return a===n},IrXRO:function(a,n,s,d){return a(n,s,d)},aEPRo:function(a,n){return a instanceof n},OfCcc:function(a,n){return a==n},GYMpo:"kiLkm",KvdVd:t(1287),cCAga:t(493),MvVwI:function(a,n){return a(n)},VbjAE:"unknown "+t(1609),XnVHB:t(1444)+t(1702),FySus:function(a,n){return a+n},ucRYD:"http",EeozT:t(948)+t(1031)+"tierJSONP",zmsRo:t(1124),mMeHG:t(519),HMXBi:t(1823),deLiD:t(650),bAjjX:t(1162),eJPcS:function(a,n){return a&n},mpKRM:function(a,n){return a!==n},GNIKN:"fgxOn",deTbE:t(975),tZpmk:function(a,n){return a||n},mqKQX:t(1866)+t(1168)+t(699)+t(719),LCmRD:t(902)+"e",QXuGE:t(1475),cFcFc:function(a,n){return a===n},BfSlD:t(1354),yhpjq:"nytTT",xGhnf:function(a,n){return a||n},YKcZn:function(a,n){return a||n},DfNYM:function(a,n){return a+n},gGJKc:t(1813),xeBCZ:t(899),ngQSB:function(a,n){return a(n)},ZDtPD:function(a,n){return a<n},WiCtD:function(a,n){return a===n},LGVTV:t(417),hXdhl:function(a,n){return a||n},MRgkP:function(a,n){return a||n},NcBvX:function(a,n){return a||n},faSHS:t(500),ZVomD:t(1578),DcktI:"kOlnL",maTWw:t(1859),FGbdL:function(a,n){return a||n},siYJG:t(1115)+"DB failed",QPUor:"qos",gLNNZ:"message_id",TlYQX:function(a,n){return a(n)},ijLPU:t(550),RYGug:t(1649),Aglpt:function(a,n){return a(n)},DkVjg:function(a,n,s,d){return a(n,s,d)},zZkVt:t(1704)+t(1821),oEBPf:"x_fronti"+t(1899)+"ck",VQilk:"x_fronti"+t(1073)+"k",GIVxb:function(a,n,s){return a(n,s)},oDpPp:t(1704)+"er_ack_m"+t(606),eKxqs:"pjHXa",rzOQe:function(a,n,s,d){return a(n,s,d)},rtCTF:t(1423),uNzWQ:t(443),qeIXH:function(a,n){return a&&n},pwyFX:t(1628),lYJxQ:t(878),vbpik:t(1722),wOvFX:function(a,n){return a!==n},ofHHl:t(533),AHJkx:t(1573),IfuCY:t(569),nvqPc:function(a,n){return a(n)},TZEmi:function(a,n){return a!==n},KOEQO:t(837),sUtJj:function(a,n){return a instanceof n},xnGMf:function(a,n){return a instanceof n},lPfze:function(a,n){return a>n},muYvd:function(a,n){return a+n},ZaTZt:function(a,n){return a&n},YFKVV:function(a,n){return a+n},mRClL:function(a,n){return a>>>n},Zkwha:function(a,n){return a+n},TiToc:t(1692)+t(630)+t(659),Vltvy:t(1234),DSZwS:t(598),JUyjX:"integer too large",pAfYn:function(a,n){return a>=n},AIrlE:t(872),hxWuZ:t(1839),RLtEc:function(a,n){return a|n},gGXfc:function(a,n){return a|n},wovKO:function(a,n){return a===n},dMjOs:t(1302),uJlUA:function(a,n){return a<n},hActY:t(540),VQSpK:function(a,n){return a>>>n},HJcjL:function(a,n){return a<<n},TKElq:function(a,n){return a+n},ILKgB:function(a,n){return a+n},fUkWM:function(a,n,s,d){return a(n,s,d)},AebgJ:function(a,n){return a|n},swZCR:function(a,n){return a<<n},ASiSp:function(a,n){return a+n},UhYwM:function(a,n){return a|n},LgLlU:function(a,n){return a+n},lALrN:function(a,n){return a+n},TLOvL:function(a,n){return a&n},xdyzJ:function(a,n){return a+n},LzClp:function(a,n){return a+n},JFLia:function(a,n){return a&n},PCXgu:function(a,n){return a>>>n},lIKKo:function(a,n){return a+n},sdISf:function(a,n){return a&n},RPRgi:function(a,n){return a==n},KHOME:t(613),llXCM:"wss://",vyZBt:t(1651),aOgOR:function(a,n){return a!==n},UGEpT:t(1350),MvYfA:function(a,n){return a+n},BWELM:function(a,n){return a&n},zGEyw:function(a,n){return a|n},RmCNj:function(a,n){return a>>>n},YTZEy:function(a,n){return a|n},KIFth:function(a,n){return a>n},ctkwS:function(a,n,s,d){return a(n,s,d)},vzNvM:function(a,n){return a(n)},Vhsdw:function(a,n){return a!==n},RRzLl:function(a,n,s){return a(n,s)},UuuiX:function(a,n){return a+n},WZpcn:function(a,n){return a!==n},gJUMc:t(736),lYxKt:function(a,n,s,d){return a(n,s,d)},ASVGn:function(a,n,s,d){return a(n,s,d)},moUGs:t(1077),qSVro:t(889),bZMAP:t(516)+t(889),qrPDG:function(a,n){return a(n)},lsvEe:function(a,n){return a<n},OlYPr:function(a,n,s){return a(n,s)},NXMnA:function(a,n,s,d){return a(n,s,d)},rOqdq:"cursor_file_name",OEIhS:t(1108)+t(589),IuEFa:t(1596)+"ame",bCOOb:function(a,n){return a===n},UdqXJ:t(1592),YjGio:t(1343)+t(663),JYtfM:t(1414),bpcMC:t(1404),IqPOq:t(740),bfCEh:t(877),pDTVJ:function(a,n){return a(n)},iNTOG:t(932)+"r",WGPGa:t(657),rvlVZ:t(1892),kKOMD:function(a,n){return a(n)},CIRgG:function(a,n){return a!==n},KIodV:t(1688),abjuY:function(a,n,s,d){return a(n,s,d)},cuQzg:function(a,n,s){return a(n,s)},ATAlz:"x_fronti"+t(1710),slPSF:function(a,n,s){return a(n,s)},pTRnL:t(1704)+t(1076),vidIW:t(1582)+"s",YaeZi:function(a,n,s){return a(n,s)},PkYYO:function(a,n,s){return a(n,s)},cHhNX:t(1682)+"rsor_value",Gxrtp:function(a){return a()},QCHrn:function(a,n){return a>n},WoNHG:function(a){return a()},dklVK:function(a){return a()},rWNQC:t(1889),PcKZQ:t(1140),eyIQm:function(a,n){return a===n},dDxEa:function(a,n){return a&&n},zUhpF:function(a){return a()},IEEKx:function(a,n){return a(n)},bbIan:function(a,n){return a(n)},elJek:"timeout",ELLFe:t(962)+t(1612)+"s",caGsT:function(a,n){return a!==n},VgxeK:function(a,n){return a<n},PTrTo:function(a){return a()},UEnDM:function(a,n,s,d){return a(n,s,d)},MJUah:function(a,n,s){return a(n,s)},ptdXP:t(1567)+t(1492)+"reconnec"+t(1325)+"ver",vrEmk:"always",gUyzt:function(a,n,s){return a(n,s)},kpUMV:function(a,n){return a===n},nEMgw:"HgGDl",HitDs:function(a,n,s,d){return a(n,s,d)},YLvwo:function(a,n,s){return a(n,s)},eDgtO:function(a,n,s){return a(n,s)},HeeFM:"bye",UNNfy:function(a,n){return a!==n},KcaqL:function(a,n,s){return a(n,s)},DfvNG:function(a,n){return a===n},MXOwj:t(1186),qkUyU:"DyguF",nYSdt:t(803)+"fer",vrMKK:t(1877),dFDIS:function(a,n){return a/n},iIjkA:t(1094)+t(1615)+t(1487),ILkPo:function(a,n){return a(n)},uJYgH:function(a,n){return a!==n},IwpBQ:t(1598),yhgWh:t(1041),VZMtv:t(1431)+"t",CSamX:t(1215),pwvfa:t(463),dorWa:t(1345),BbZRz:function(a,n){return a!==n},nJxAo:function(a,n){return a instanceof n},YzZMy:function(a,n){return a(n)},kJVfk:function(a,n){return a===n},rbehy:t(451),VjeOc:function(a,n){return a==n},cvdWw:t(411),DSsSM:t(1529),wtyal:t(1836),WQAec:function(a,n){return a||n},Tifau:t(1094)+t(1066)+"ddID, de"+t(1498)+t(641),zkftj:function(a,n){return a==n},WytsT:t(1656),UgDNx:t(415)+"0",bFMdr:function(a,n){return a<n},AQCuj:function(a,n){return a>>n},lwgXg:function(a,n){return a&n},GpPaF:t(1822)+t(1851),wwoSe:function(a,n){return a+n},pvYOv:function(a,n){return a>>n},ssbNo:function(a,n){return a|n},MaaiB:function(a,n,s){return a(n,s)},TESEl:function(a,n){return a(n)},gbSrC:t(1417),klAOM:t(1508),idolM:"SmIad",sPmjK:function(a,n){return a||n},ZMWKL:"start",WdexK:function(a,n){return a>n},jTnay:function(a,n){return a!==n},oWkaW:t(1765),vwiTe:function(a,n){return a===n},fLqEj:function(a,n){return a+n},sOGza:function(a,n){return a(n)},QiPyW:"versionc"+t(940),aCqVN:t(487),loAKx:t(1106)+">",aTsiD:function(a,n){return a-n},zbtVX:function(a,n){return a===n},ulwJN:t(429),ECYWu:function(a,n){return a-n},Rjqdi:function(a,n){return a>n},jAbWQ:function(a,n){return a!==n},UIkLN:function(a,n){return a(n)},NOvHa:t(1627),ESJgl:t(1270),CVUAe:t(962)+"e_timeout",zFBKE:function(a,n){return a!==n},coEhJ:t(1310),VTApo:t(1436)+" try rec"+t(1713)+"g",pSEZz:function(a,n){return a(n)},GvlXA:t(1521),rdbZc:t(579)+"3",UIiyp:function(a,n){return a-n},PpNfD:function(a,n){return a<=n},ziCTo:function(a,n){return a|n},djeWQ:function(a,n){return a&n},imsww:function(a,n){return a<<n},KYwZt:function(a,n){return a>>n},eTMOm:function(a,n){return a!==n},qFNqt:t(950),ltkfG:t(1460),yPXiN:t(1452),fwztF:t(478),wwVVQ:function(a,n,s){return a(n,s)},QlvtL:"going aw"+t(1882)+t(1897)+"ine",jJpUS:t(1733),tUwYz:t(749)+"le",syQTF:t(1468),nSkaO:"AzCVx",MvsRv:"pagehide",FGqpX:function(a,n){return a!==n},YZMmP:"oxsPg",TWtkq:t(1629),BBJov:function(a,n,s){return a(n,s)},oBcOi:t(1280),lmJQM:t(403),qrAJQ:t(1742)+t(1409),VjlEn:t(1148)+"s instan"+t(1661)+t(915)+"ed",BWiak:function(a,n){return a===n},MqeAg:function(a,n){return a===n},iLaDI:t(1148)+t(1540)+t(1221),lQhyW:function(a,n){return a==n},qYDNt:t(1094)+"rovide a"+t(718)+t(1256)+"a must b"+t(991)+t(660)+t(946)+"ffer",MMlMp:function(a,n){return a==n},aevpz:t(828),WHxvL:function(a,n){return a!=n},cEyLT:function(a,n){return a(n)},NtVZJ:t(1094)+t(961)+t(436)+t(1880),xikSQ:function(a,n){return a instanceof n},CGTsw:function(a,n){return a(n)},iKaLE:t(1393),hwDII:function(a,n){return a||n},iNcWW:function(a,n){return a!==n},tjLxp:t(1608)+t(1412)+t(1167),omdbO:t(1056)+"4",HgZaQ:function(a,n,s){return a(n,s)},OPaXf:function(a,n){return a(n)},RLDUP:t(747),AIsYq:function(a,n){return a*n},BiSkR:"Window",PqAEp:function(a,n){return a!=n},zpwiz:"Object",MMlhW:function(a,n){return a===n},rPypK:t(1488)+t(1732)+t(544)+"pe",enzEc:function(a,n){return a!=n},EPYqJ:function(a,n){return a!=n},ZmqGT:function(a,n){return a===n},wvSDi:function(a,n){return a==n},kOqNT:t(816)+t(1250)+"balScope",VufsD:function(a,n){return a!=n},wUFmB:t(1696)+t(424)};Nt.r(Re),Nt.d(Re,{FWS:()=>Qp,CustomErrorEvent:()=>$d,createCloseEvent:()=>ht,ReconnectEvent:()=>Kd,createErrorEvent:()=>at,decodedFrame:()=>Xt,createOpenEvent:()=>Qd,CustomCloseEvent:()=>Vd,createReconnectEvent:()=>oa,FrontierMessageEvent:()=>Zd,encodeFrame:()=>Bt,createMessageEvent:()=>Xd,OpenEvent:()=>Yd,ErrorCode:()=>en,Event:()=>Zn,MessageEvent:()=>Jd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(1666)](),f=r||(r=h(a)),p=Math[n(685)]()[n(532)](16)[n(1844)](-6);return e.YBwgK(e[n(1568)](e[n(1770)](s,d),f),p)}function o(){let a=t;return e[a(1744)](1e4,Date[a(1666)]())+Math[a(1760)](e[a(1744)](1e4,Math.random()))}function c(a){let n=t;return e[n(445)](Array(8)[n(1746)]("0"),e.HGqRG(parseInt,a,10)[n(532)](2))[n(1844)](-8)}function l(a){let n=t;return e[n(1568)](e.gFZAq(Array,4)[n(1746)]("0"),parseInt(a,2).toString(16))[n(1844)](-4)}function u(a){let n=t,s=a.split(/\./).map(p=>c(p)),d=[];return d[0]=e[n(1685)](l,e[n(1568)](s[0],s[1])),d[1]=e[n(1718)](l,e[n(631)](s[2],s[3])),[e[n(1493)],e[n(1493)],e[n(1493)],e[n(1493)],e[n(1493)],e[n(574)],d[0],d[1]][n(1746)]("")}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(1119)](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(1119)](a);return s?e[n(1037)](u,a):d?x(a):e[n(726)]}function x(a){let n=t,s="",d=[],f=0,p=0,w=!0,v=n(1737);if(e.VIIsD(a[n(1806)]("::"),-1)){let g=a[n(1761)]("::");for(let L=0;e[n(824)](L,g[n(1120)]);L++){let U=g[L];if(U[n(1806)](":")>0){let $=U.split(":");w&&(f=$[n(1120)]),p+=$[n(1120)];for(let K=0;e[n(824)](K,$[n(1120)]);K++)if(e[n(1121)](4,$[K][n(1120)])){let fe=v.substring(0,e[n(856)](4,$[K][n(1120)])),Ze=fe[n(1901)]($[K]);d[n(689)](Ze)}else d[n(689)]($[K]);w=!1}else if(e[n(1856)](e[n(1579)],e[n(1579)])){if(U[n(1120)]!==4)if(e[n(617)]!==e[n(783)]){let $=v[n(862)+"g"](0,4-U[n(1120)]),K=$[n(1901)](U);d[n(689)](K)}else return _0x31497a.errMsg||_0x43efaf[n(1802)]?(n(1029)+" "+(_0x461428[n(1007)]||"")+n(696)+(_0x558f29[n(1802)]||""))[n(970)]():_0x14df9f[n(840)+"y"](_0x261c0c);else d[n(689)](U);w&&(f+=1),p+=1,w=!1}else{if(this[n(1526)][n(900)+n(707)+"nect"]||this["_readyCl"+n(1112)])return;this[n(1705)+n(1412)]()}}let O="";for(let L=0;L<e.mAYTN(8,p);L++)O=O[n(1901)](v);for(let L=0;e[n(879)](L,d[n(1120)]);L++)e.NqvFW(L,f)&&(s=s[n(1901)](O)),s=s[n(1901)](d[L]);return s}{let g=a[n(1761)](":");for(let O=0;e[n(876)](O,g[n(1120)]);O++){let L=g[O];if(e[n(1121)](4,g[O][n(1120)])){let U=v.substring(0,4-g[O][n(1120)]),$=U[n(1901)](L);s=s[n(1901)]($)}else s=s[n(1901)](L)}return s}}function m(a,n){let s=t,d={nYnbt:function(f,p,w){return e[F(1642)](f,p,w)}};if(e[s(525)](e.sOSHz,e[s(1894)]))this[s(1293)]("message",d[s(945)](_0x370bb8,s(830),{..._0x1b91f9}));else{let f=a[s(1376)];e[s(525)](void 0,f)&&(e.ARUKp(xe,n,10),e[s(1083)](q,n,f));let p=a[s(814)];if(p!==void 0)if(e.aSoWW(e[s(626)],e[s(626)]))e[s(1902)](xe,n,18),q(n,p);else{let w=e[s(1718)](_0x2ede7e,_0x54cb53),v=_0xc39bc[s(973)];return _0x55b189[s(973)]=e[s(631)](_0x50ea1f.offset,w),v}}}function E(a){let n=t,s={aQVjd:function(f,p){return f(p)},FLJPa:function(f,p){return e[F(543)](f,p)},XauDc:function(f){return f()},hfxUr:e[n(798)],JRWLC:n(1697)},d={};e:for(;!V(a);)if(e.rerEV(e[n(1392)],e[n(1323)])){let f={FdhEN:fRtnJB[n(1700)],FDIgK:fRtnJB[n(1785)],qzvth:function(g){let O=n;return fRtnJB[O(1745)](g)}},p=()=>{let g=n;_0xa04ea[g(839)+g(1717)+g(538)](f[g(952)],w),_0x323074.removeEventListener(f[g(821)],v)},w=()=>{let g=n;fRtnJB[g(400)](_0x2ebb7d,fRtnJB[g(1719)](_0x3ffeb6,_0x2bc672[g(678)])),fRtnJB[g(1745)](p)},v=()=>{let g=n;_0x2f2da4(_0x1a978d[g(1697)]),f[g(402)](p)};_0x4f642d[n(1079)+n(1222)](n(887),w),_0x342f6e[n(1079)+"Listener"](n(1697),v)}else{let f=he(a);switch(e[n(852)](f,3)){case 0:break e;case 1:d[n(1376)]=e[n(1432)](P,a,e.RkLQn(he,a));break;case 2:d[n(814)]=P(a,e.gFZAq(he,a));break;default:e[n(1642)](R,a,e[n(655)](7,f))}}if(e[n(853)](void 0,d[n(1376)]))throw new Error(e[n(593)]);if(e.ECZOU(void 0,d[n(814)]))throw new Error(e[n(680)]);return d}function S(a){let n=t;if(e[n(1652)](n(1530),e.ltqVL)){let s=e[n(1411)](C);return e.ARUKp(_,a,s),e.LYIvj(M,s)}else return!!_0x29bb1a?.[n(1145)](s=>s[n(1376)]===_0xb49c5c&&s[n(814)]===_0x26c111)}function _(a,n){let s=t,d=a[s(1426)];e[s(525)](void 0,d)&&(e[s(1642)](xe,n,8),e.NFjwD(ft,n,d));let f=a[s(1102)];e[s(525)](void 0,f)&&(e.UvVcS(xe,n,16),e[s(1902)](ft,n,f));let p=a[s(1620)];e.wEuFD(void 0,p)&&(e[s(1432)](xe,n,24),e[s(1432)](ft,n,k(p)));let w=a[s(1176)];w!==void 0&&(e[s(1642)](xe,n,32),e.HGqRG(ft,n,e.RkLQn(k,w)));let v=a[s(792)];if(e[s(1121)](void 0,v))for(let Ze of v){xe(n,42);let je=C();m(Ze,je),e[s(1902)](xe,n,je[s(973)]),W(n,je),e[s(1559)](D,je)}let g=a[s(1453)+"ncoding"];e[s(1089)](void 0,g)&&(xe(n,50),e[s(723)](q,n,g));let O=a[s(442)+s(1768)];e[s(1089)](void 0,O)&&(e[s(1083)](xe,n,58),e[s(1275)](q,n,O));let L=a.payload;e[s(939)](void 0,L)&&(e[s(1723)](xe,n,66),e.UvVcS(xe,n,L.length),e[s(1432)](se,n,L));let U=a.LogIDNew;e[s(1089)](void 0,U)&&(xe(n,74),q(n,U));let $=a[s(1659)+s(1739)];e[s(1089)](void 0,$)&&(e[s(723)](xe,n,82),q(n,$));let K=a[s(1060)];e.bQPsT(void 0,K)&&(xe(n,90),e[s(1662)](q,n,K));let fe=a[s(1478)+"e"];e.mZscJ(void 0,fe)&&(e[s(941)](xe,n,96),ft(n,e[s(1296)](k,fe)))}function b(a){let n=t;return e[n(512)](I,e[n(1718)](B,a))}function I(a){let n=t,s={};e:for(;!e[n(671)](V,a);){let d=he(a);switch(e[n(1782)](d,3)){case 0:break e;case 1:s[n(1426)]=e[n(1083)](vt,a,!0);break;case 2:s[n(1102)]=e[n(1384)](vt,a,!0);break;case 3:s[n(1620)]=e[n(543)](he,a);break;case 4:s[n(1176)]=e.gFZAq(he,a);break;case 5:{let f=A(a);(s[n(792)]||(s[n(792)]=[]))[n(689)](e[n(1594)](E,a)),a.limit=f;break}case 6:s[n(1453)+n(1156)]=e[n(1384)](P,a,e.xTYYG(he,a));break;case 7:s[n(442)+n(1768)]=e[n(656)](P,a,e.RkLQn(he,a));break;case 8:s.payload=e[n(910)](re,a,e[n(1449)](he,a));break;case 9:s.LogIDNew=e[n(551)](P,a,e.TpEhy(he,a));break;case 10:s[n(1659)+n(1739)]=e.NFjwD(P,a,e[n(1635)](he,a));break;case 11:s.msgID=e[n(1902)](P,a,e[n(1037)](he,a));break;case 12:s.frameType=e[n(1449)](he,a);break;default:e.CZQEB(R,a,e[n(655)](7,d))}}if(e[n(1652)](void 0,s.SeqID))throw new Error(n(484)+n(1188)+n(773)+n(1426));if(e[n(1856)](void 0,s[n(1102)]))throw new Error(e[n(1110)]);if(s[n(1620)]===void 0)throw new Error("Missing "+n(1188)+n(773)+n(1620));if(s[n(1176)]===void 0)throw new Error(e.gAgRT);return s}function A(a){let n=t,s={lMAOS:function(d,f){return e.oDVRo(d,f)}};if(e.VeIys(n(1581),e.LwdsS))_0x41fa9e=s[n(1261)](_0x25993d,_0x24abb7),_0x48047a=0;else{let d=e.tatlg(he,a),f=a[n(973)];return a[n(973)]=e[n(528)](a[n(1318)],d),f}}function R(a,n){let s=t;if(e[s(1856)](e[s(1381)],e.IHYhv))this[s(893)](_0x514540,_0x41be77);else switch(n){case 0:for(;e[s(655)](128,ie(a)););break;case 2:e[s(986)](J,a,e.QEhlh(he,a));break;case 5:e[s(1723)](J,a,4);break;case 1:e[s(1808)](J,a,8);break;default:throw new Error(e.yzZRd+n)}}function k(a){let n=t;return a|=0,{low:a,high:a>>31,unsigned:e[n(423)](a,0)}}let y=[];function C(){let a=t,n=y[a(894)]();return n?(n[a(1318)]=n[a(973)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function D(a){y[t(689)](a)}function B(a){return{bytes:a,offset:0,limit:a.length}}function M(a){let n=t,s=a[n(813)],d=a.limit;return e[n(1103)](s[n(1120)],d)?s:s[n(1800)](0,d)}function J(a,n){let s=t;if(e[s(1867)](e[s(546)](a[s(1318)],n),a[s(973)]))throw new Error(e.YYSwv);a[s(1318)]+=n}function V(a){let n=t;return e[n(423)](a[n(1318)],a[n(973)])}function ee(a,n){let s=t,d=a[s(813)],f=a.offset,p=a[s(973)],w=f+n;if(e[s(1867)](w,d.length)){let v=new Uint8Array(2*w);v[s(588)](d),a.bytes=v}return a[s(1318)]=w,e[s(475)](w,p)&&(a[s(973)]=w),f}function Z(a,n){let s=t,d=a[s(1318)];if(e[s(1867)](e[s(1568)](d,n),a.limit))throw new Error(e.oXNYm);return a.offset+=n,d}function re(a,n){let s=t,d=Z(a,n);return a[s(813)][s(1800)](d,e.bUlGZ(d,n))}function se(a,n){let s=t,d=e[s(1083)](ee,a,n[s(1120)]);a[s(813)][s(588)](n,d)}function P(a,n){let s=t;if(e[s(1089)](e[s(1277)],e[s(1277)]))this[s(1905)+s(1002)]=null;else{let d=e.gKRUF(Z,a,n),f=String[s(1501)+s(1639)],p=a.bytes,w="\uFFFD",v="";for(let g=0;e.OulqD(g,n);g++){let O=p[e[s(546)](g,d)],L,U,$,K;e[s(742)](128&O,0)?v+=e[s(1473)](f,O):e[s(1756)](e[s(1677)](224,O),192)?g+1>=n?v+=w:(L=p[e[s(1360)](e[s(528)](g,d),1)],e.NxFTI(e.meFCn(192,L),128)?v+=w:(K=e[s(655)](31,O)<<6|e[s(827)](63,L),e[s(1192)](K,128)?v+=w:(v+=e[s(1559)](f,K),g++))):e[s(1216)](e.wpARN(240,O),224)?e[s(1013)](g,2)>=n?v+=w:(L=p[e[s(1342)](g+d,1)],U=p[e[s(1568)](g,d)+2],e[s(822)](e[s(491)](L,e[s(1539)](U,8)),49344)!==32896?v+=w:(K=e.YyuRK(e[s(827)](15,O)<<12,e[s(1539)](63&L,6))|63&U,K<2048||K>=55296&&e[s(674)](K,57343)?v+=w:(v+=f(K),g+=2))):e.qmAJE(e[s(822)](248,O),240)?e.XwwhM(g,3)>=n?v+=w:(L=p[e.xfJGo(e.doGDV(g,d),1)],U=p[e[s(1770)](g+d,2)],$=p[e[s(1568)](e[s(983)](g,d),3)],e[s(1623)](e[s(827)](e[s(491)](e[s(608)](L,U<<8),$<<16),12632256),8421504)?v+=w:(K=e.ePwOx(e.meFCn(7,O)<<18,e[s(822)](63,L)<<12)|e[s(1539)](e.DKNuF(63,U),6)|e[s(1834)](63,$),e[s(879)](K,65536)||e.XwSCj(K,1114111)?v+=w:(K-=65536,v+=f(e[s(1342)](e[s(535)](K,10),55296),e.paNjs(1023&K,56320)),g+=3))):v+=w}return v}}function q(a,n){let s=t,d=n[s(1120)],f=0;for(let v=0;e[s(879)](v,d);v++){let g=n.charCodeAt(v);e[s(423)](g,55296)&&e.zUkUl(g,56319)&&e[s(1192)](e.areFw(v,1),d)&&(g=e[s(1082)](e[s(1013)](e.rOWtF(g,10),n.charCodeAt(++v)),56613888)),f+=g<128?1:g<2048?2:g<65536?3:4}xe(a,f);let p=e[s(1662)](ee,a,f),w=a[s(813)];for(let v=0;e[s(1827)](v,d);v++){let g=n[s(1657)+"At"](v);e[s(1044)](g,55296)&&g<=56319&&e[s(1236)](v,1)<d&&(g=e[s(856)](e.vznal(e[s(1003)](g,10),n[s(1657)+"At"](++v)),56613888)),e[s(1827)](g,128)?w[p++]=g:(e[s(879)](g,2048)?w[p++]=e[s(891)](e.egtHf(g>>6,31),192):(g<65536?w[p++]=e[s(1005)](e[s(535)](g,12),15)|224:e[s(1715)](e[s(1725)],e.etpMO)?(w[p++]=e[s(1658)](g>>18,7)|240,w[p++]=e[s(848)](g>>12,63)|128):_0xa2fe76&&this[s(1254)+s(457)][s(1174)+s(1133)+s(1101)](_0x5b60cd),w[p++]=e[s(491)](e[s(822)](e[s(1878)](g,6),63),128)),w[p++]=e[s(1439)](63,g)|128)}}function W(a,n){let s=t,d=e[s(906)](ee,a,n[s(973)]),f=a[s(813)],p=n[s(813)];for(let w=0,v=n[s(973)];e[s(824)](w,v);w++)f[e.doGDV(w,d)]=p[w]}function ie(a){return a[t(813)][e.RYEcX(Z,a,1)]}function Je(a,n){let s=t,d=e[s(986)](ee,a,1);a[s(813)][d]=n}function he(a){let n=t,s=0,d=0,f;do f=e[n(1180)](ie,a),e.hCSPw(s,32)&&(d|=e[n(1658)](127,f)<<s),s+=7;while(e[n(673)](128,f));return d}function xe(a,n){let s=t,d={zdQdm:function(f,p){return e.rlWxp(f,p)},sVsti:function(f,p){return e[F(1867)](f,p)}};if(e[s(1730)](e[s(460)],s(987))){for(n>>>=0;e.zbugS(n,128);)e[s(584)](Je,a,e.WrWNw(e[s(822)](127,n),128)),n>>>=7;Je(a,n)}else{let{initReconnectInterval:f,maxReconnectInterval:p,reconnectIntervalGrowFactor:w}=this._options,v=f*_0xc81834[s(1536)](w,d.zdQdm(_0x3ea786,1));return d[s(1895)](v,p)?p:v}}function vt(a,n){let s=t,d=0,f=0,p=0,w;return w=e[s(1647)](ie,a),d=e.DCUhr(127,w),128&w&&(w=e[s(1391)](ie,a),d|=e.vdWWZ(e[s(1677)](127,w),7),e.APXfI(128,w)&&(w=e[s(671)](ie,a),d|=e.fxucG(e[s(1741)](127,w),14),e[s(722)](128,w)&&(w=ie(a),d|=e[s(822)](127,w)<<21,e.APXfI(128,w)&&(w=e.xTYYG(ie,a),f=e.sHWgp(127,w),e[s(1658)](128,w)&&(w=e[s(512)](ie,a),f|=e[s(1388)](127,w)<<7,e[s(827)](128,w)&&(w=e[s(711)](ie,a),f|=e[s(1160)](127&w,14),128&w&&(e[s(939)]("uzaab",e[s(395)])?(w=e.nlQSH(ie,a),f|=e.lQWOD(e[s(822)](127,w),21),e[s(995)](128,w)&&(w=e.MUtCX(ie,a),p=e[s(1834)](127,w),128&w&&(w=e.zzJEs(ie,a),p|=e[s(1828)](e[s(1805)](127,w),7)))):this[s(842)+s(435)]()))))))),{low:e[s(1518)](d,e[s(1502)](f,28)),high:e[s(687)](f,4)|e.zxFEw(p,24),unsigned:n}}function ft(a,n){let s=t,d=n[s(1693)]>>>0,f=e[s(1782)](e[s(1820)](e[s(687)](n[s(1693)],28),e[s(861)](n[s(794)],4)),0),p=e[s(687)](n[s(794)],24),w=e[s(1158)](0,p)?f===0?e[s(824)](d,16384)?e[s(844)](d,128)?1:2:e.elCwP(d,2097152)?3:4:e[s(1827)](f,16384)?e.packk(f,128)?5:6:e.OulqD(f,2097152)?7:8:e.OulqD(p,128)?9:10,v=e.NFjwD(ee,a,w),g=a[s(813)];switch(w){case 10:g[v+9]=e.LuWwK(e[s(479)](p,7),1);case 9:g[v+8]=e[s(1189)](9,w)?e[s(1729)](128,p):e.sHWgp(127,p);case 8:g[v+7]=e[s(525)](8,w)?e[s(479)](f,21)|128:e[s(1005)](e[s(1143)](f,21),127);case 7:g[e.RoDej(v,6)]=w!==7?e[s(971)](e.LYTEL(f,14),128):e.sOqLk(e[s(1782)](f,14),127);case 6:g[v+5]=e[s(1189)](6,w)?e[s(1299)](f>>>7,128):e[s(1439)](e[s(1446)](f,7),127);case 5:g[v+4]=e.ZJEhM(5,w)?e[s(1299)](128,f):127&f;case 4:g[v+3]=e[s(939)](4,w)?e.kALcN(e[s(897)](d,21),128):e[s(1433)](e.FwkVa(d,21),127);case 3:g[v+2]=e.hkKtL(3,w)?e[s(1820)](d>>>14,128):d>>>14&127;case 2:g[e[s(1887)](v,1)]=w!==2?e[s(883)](d,7)|128:e.aaOQM(d,7)&127;case 1:g[v]=e.uWaPe(1,w)?e[s(1814)](128,d):127&d}}function Xt(a){return e[t(871)](b,a)}function Bt(a){return e[t(1377)](S,a)}let Qt=65536,Wr=e[t(849)],me=e[t(1744)](Qt,Qt),Ie=e.AIsYq(me,me),Jn=e.dFDIS(Ie,2),ke=String[t(483)+"e"][t(1657)+"At"];class ue{constructor(n,s,d){let f=t;this[f(1606)]=!0,this[f(1693)]=e[f(668)](0,n),this[f(794)]=e[f(1471)](0,s),this[f(1790)]=!!d}static[t(1606)](n){let s=t;return n&&e.aSoWW(!0,n[s(1606)])}static[t(1316)](n,s,d){return new ue(n,s,d)}static[t(928)+"s"](n,s,d){let f=t;return d?ue["fromByte"+f(873)](n,s):ue[f(928)+f(481)](n,s)}static[t(928)+t(873)](n,s){let d=t;return new ue(e[d(1518)](e[d(825)](e[d(891)](n[0],e.AbxbK(n[1],8)),e[d(914)](n[2],16)),n[3]<<24),e[d(1202)](n[4]|e.fxucG(n[5],8),e[d(1455)](n[6],16))|e[d(1668)](n[7],24),s)}static fromBytesBE(n,s){let d=t;return new ue(e[d(1695)](e[d(868)](n[4],24)|e[d(1315)](n[5],16),n[6]<<8)|n[7],e[d(668)](e.ykfoB(e[d(1695)](e[d(459)](n[0],24),e[d(467)](n[1],16)),n[2]<<8),n[3]),s)}static[t(683)](n){let s=t;return e.HamRZ(n,Wr)?Wd:new ue(e[s(491)](e[s(1097)](e[s(1820)](ke[s(1125)](n,0),ke.call(n,1)<<8),e[s(1455)](ke[s(1125)](n,2),16)),e.vdWWZ(ke[s(1125)](n,3),24))>>>0,e[s(1446)](e[s(1438)](e[s(974)](e[s(891)](ke[s(1125)](n,4),ke[s(1125)](n,5)<<8),ke[s(1125)](n,6)<<16),e[s(1502)](ke[s(1125)](n,7),24)),0),!0)}toHash(){let n=t;return String[n(1501)+n(1639)](e[n(1139)](255,this.low),e.odmZE(this.low>>>8,255),e[n(848)](e.qaopY(this[n(1693)],16),255),e[n(1782)](this[n(1693)],24),e.wpARN(255,this[n(794)]),e[n(1763)](e[n(1625)](this[n(794)],8),255),e[n(1339)](this[n(794)],16)&255,e[n(1326)](this[n(794)],24))}static fromNumber(n,s=!0){let d=t;if(e.xKogI(isNaN,n))return s?up:Wd;if(s){if(n>=Ie)return hp}else{if(n<=-Jn)return xp;if(e[d(1044)](e.PhqcI(n,1),Jn))return fp}return ue.fromBits(e[d(1062)](e.NfzQI(n,me),0),n/me|0,s)}[t(1090)](){let n=t;return this[n(1790)]?e[n(801)](e[n(984)](e.LYTEL(this[n(794)],0),me),this[n(1693)]>>>0):e[n(556)](e[n(943)](this[n(794)],me),e[n(1143)](this[n(1693)],0))}[t(1064)](){let n=t;if(e.oAtHQ==="kwolR"){this[n(977)+"ngTimer"](),this[n(1165)+"gTimeoutId"]=e[n(1561)](_0x3afe63,this[n(575)][n(1571)](this),this[n(1526)][n(1774)+n(1783)]);return}else return e[n(1856)](0,this[n(794)])&&e[n(592)](0,this.low)}[t(501)](n){let s=t;ue.isLong(n)||(n=ue[s(1499)+"er"](n));let d=this[s(794)]>>>16,f=e[s(477)](65535,this[s(794)]),p=e[s(743)](this[s(1693)],16),w=65535&this[s(1693)],v=e[s(667)](n.high,16),g=e.IPwRQ(65535,n.high),O=n[s(1693)]>>>16,L=e[s(1805)](65535,n[s(1693)]),U=0,$=0,K=0,fe=0;return fe+=e.vAyxh(w,L),K+=e[s(1023)](fe,16),fe&=65535,K+=e.bMZOb(p,O),$+=K>>>16,K&=65535,$+=e[s(1298)](f,g),U+=e.vGdgQ($,16),$&=65535,U+=e[s(1342)](d,v),U&=65535,ue[s(1316)](e[s(419)](e[s(868)](K,16),fe),e[s(608)](e[s(1886)](U,16),$),this[s(1790)])}[t(1232)](n){let s=t;return ue[s(1606)](n)||(n=ue.fromNumber(n)),e[s(505)](this[s(1790)],n[s(1790)])&&e.nBeVF(e[s(1451)](this[s(794)],31),1)&&e[s(1793)](n.high>>>31,1)?!1:this[s(794)]===n[s(794)]&&e.xmcRF(this.low,n[s(1693)])}[t(672)](){let n=t;if(e[n(517)](e[n(1602)],e.JoeAQ)){let s=e[n(1353)][n(1761)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(e[n(582)](_0x17cfd7,_0x105fd1)&&e[n(633)](e[n(439)],typeof _0x1d3fba)&&_0x40594c)return!0;continue;case"1":if(_0x411c43&&_0x427aff[n(866)+n(1755)])return!0;continue;case"2":return!1;case"3":if(_0x3b886a)return!0;continue;case"4":if(_0x342266&&_0xa0f1f[n(866)+n(1755)])return!0;continue}break}}else return this.low===-1&&this[n(794)]===-1?ue[n(1316)](0,0,this[n(1790)]):this.low===-1?ue[n(1316)](0,e[n(1317)](this[n(794)],1),this[n(1790)]):ue.fromBits(e[n(528)](this[n(1693)],1),this[n(794)],this[n(1790)])}[t(780)](n){let s=t;return n?this[s(1182)+"E"]():this[s(1555)+"E"]()}[t(1182)+"E"](){let n=t,s=this[n(794)],d=this.low;return[e[n(1187)](255,d),e[n(1005)](e[n(624)](d,8),255),e[n(1139)](d>>>16,255),d>>>24,e[n(1249)](255,s),e.egtHf(e[n(609)](s,8),255),e[n(1407)](s>>>16,255),s>>>24]}toBytesBE(){let n=t,s=this[n(794)],d=this[n(1693)];return[e[n(865)](s,24),e[n(1123)](s,16)&255,e[n(1446)](s,8)&255,e[n(568)](255,s),e[n(852)](d,24),e[n(1092)](d,16)&255,e.rnurd(e[n(1885)](d,8),255),e[n(1848)](255,d)]}}let Wd=new ue(0,0,!1),up=new ue(0,0,!0),fp=ue[t(1316)](-1,2147483647,!1),hp=ue[t(1316)](-1,-1,!0),xp=ue[t(1316)](0,-2147483648,!1);var en=(function(a){let n=t;return a[a[e[n(511)]]=5001]=e[n(511)],a[a[n(1229)+"NG_ERROR"]=5002]=n(1229)+"NG_ERROR",a[a[n(767)+n(1633)+"R"]=5003]=e.czoNa,a[a[e[n(806)]]=5004]=n(802)+n(1442),a[a[e.YGRQT]=5005]=e[n(1019)],a})({});class Zn{constructor(n){let s=t;this[s(1327)]=n,this[s(1771)]=null}}class Kd extends Zn{constructor(n,s){let d=t;super(n),this[d(830)]=s&&s[d(830)]||null}}class $d extends Zn{constructor(n,s){let d=t,f=e.bIpIo.split("|"),p=0;for(;;){switch(f[p++]){case"0":super(n);continue;case"1":this.colno=s&&s[d(922)]||0;continue;case"2":this[d(1883)]=s&&s[d(1883)]||5001;continue;case"3":this[d(1410)]=s&&s[d(1410)]||"";continue;case"4":this.message=s&&s[d(830)]||"";continue;case"5":this.lineno=s&&s[d(1461)]||0;continue;case"6":this[d(1697)]=s&&s[d(1697)]||null;continue}break}}}class Vd extends Zn{constructor(n,s){let d=t,f=e.GXxRD[d(1761)]("|"),p=0;for(;;){switch(f[p++]){case"0":this[d(833)]=s&&s.wasClean||!1;continue;case"1":this[d(1609)]=s&&s[d(1609)]||"";continue;case"2":this["willReco"+d(1424)]=s&&s[d(1640)+d(1424)]||!1;continue;case"3":this[d(1883)]=s&&s[d(1883)]||0;continue;case"4":super(n);continue}break}}}class Jd extends Zn{constructor(n,s){let d=t;super(n),this[d(396)]=s&&s.data||null}}class Zd extends Jd{constructor(n,s){let d=t;if(e[d(812)](d(504),e.yPOuw))try{return e.UiFcK!=typeof _0x614387&&(e[d(1496)](_0x16a36c,_0x2d48c3)||_0x3d005a[d(841)]&&_0xb1fec1[d(841)]instanceof _0x3bc636)||e[d(633)](e[d(1368)],typeof _0x2f7efc)?"":(_0x5c12d7[d(476)](_0x229be7),e[d(653)])}catch{return e[d(1368)]==typeof _0x484512?e.eiBJp:""}else super(n),this.data=s&&s[d(396)]||null,this[d(830)]=s&&s[d(830)]||null}}class Yd extends Zn{constructor(n,s){let d=t;super(n),this[d(396)]=s&&s[d(396)]||null}}function at(a,{message:n,code:s,error:d}){let f=t;if(e[f(1089)](e[f(585)],e.hUZZx))this[f(1631)]=!1,e[f(1037)](_0x3b72eb,this[f(1676)+f(561)+f(637)]),e[f(1690)](_0x14069f);else return new $d(a,{message:n,code:s,error:d})}function ht(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Vd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Xd(a,{data:n,message:s}){return new Zd(a,{data:n,message:s})}function Qd(a,{data:n}){return new Yd(a,{data:n})}function oa(a,{message:n}){return new Kd(a,{message:n})}class el{constructor(n,s){let d=t;this[d(1306)+"s"]=n,this[d(1239)+"es"]=s,this["currentI"+d(1876)]=0,this[d(966)+d(1791)+d(1868)+"t"]=0}[t(1764)+t(1835)+t(1893)](){let n=t;this[n(1818)+n(1876)]=0,this[n(966)+n(1791)+n(1868)+"t"]=0}[t(529)+"es"](){let n=t;this[n(966)+n(1791)+n(1868)+"t"]=0}getCurrentEndpoint(){let n=t;return this[n(1306)+"s"][this[n(1818)+n(1876)]]}[t(1757)+"ntEndpoi"+t(765)+t(1088)](){let n=t,s={glCJC:function(d,f){return e.HYgCt(d,f)},RyfPg:function(d,f){return d===f},dNNWR:function(d,f){return d&f},OCzhv:function(d,f){return d&f}};if(e[n(918)]===e[n(607)])_0x1df886=_0x327ed9[n(1657)+"At"](_0x1eae54),_0x497175<128?_0x21244b+=1:s[n(462)](_0x1d1cc8,2048)?_0x358076+=2:s[n(1547)](s.dNNWR(64512,_0x480333),55296)&&s.RyfPg(s[n(700)](64512,_0x41dab6.charCodeAt(_0x3050c0+1)),56320)?(++_0x4fd67c,_0x155e16+=4):_0x589ee3+=3;else return this[n(966)+n(1791)+n(1868)+"t"]}[t(1743)+t(1075)+"es"](){let n=t;return!!(e[n(1044)](this[n(1818)+"ndex"],this.endpoints[n(1120)])||e[n(734)](this[n(1818)+"ndex"],e.aJEwG(this[n(1306)+"s"].length,1))&&e[n(1425)](this[n(966)+n(1791)+n(1868)+"t"],this.maxRetries))}[t(845)+t(1750)+t(1847)+"hedMaxRe"+t(1012)](){let n=t;return e.LphjF(this["currentI"+n(1876)],this[n(1306)+"s"][n(1120)])?!0:e.qvTqB(this.currentEndpointTriesCount,this.maxRetries)}["replaceBackupEndpointAnd"+t(433)+"unt"](){let n=t;if(n(1038)===e[n(1164)])this._qosDB?.[n(908)](),this[n(397)]=void 0;else return this[n(966)+"ndpointTriesCount"]=1,this[n(1818)+n(1876)]++,this[n(1306)+"s"][this[n(1818)+n(1876)]]}["getCurre"+t(628)+t(1891)+"ateCount"](){let n=t;return this["currentE"+n(1791)+"riesCount"]++,this[n(1757)+n(628)+"nt"]()}}let Yn=(e[t(439)]!=typeof globalThis&&e[t(570)](e[t(724)],globalThis[t(924)+"tor"][t(889)])||e.PqAEp(e[t(439)],typeof window)&&e[t(1065)](e.BiSkR,window[t(924)+t(1645)][t(889)]))&&e[t(633)](e[t(439)],typeof document),An=e[t(439)]!=typeof globalThis&&(e[t(539)]===globalThis[t(924)+t(1645)].name||e[t(1784)](e[t(1576)],globalThis[t(924)+"tor"][t(889)]))&&e[t(580)](e[t(439)],typeof tt),Kr=(e[t(1014)](e[t(439)],typeof globalThis)&&e[t(665)](e[t(539)],globalThis[t(924)+t(1645)][t(889)])||e[t(1531)](e[t(439)],typeof globalThis)||e.WHxvL("undefined",typeof globalThis)&&!!globalThis["WeixinJS"+t(757)])&&e[t(580)](e[t(439)],typeof wx),$r=t(704)+"d"!=typeof globalThis&&(e[t(1158)](e.rPypK,globalThis[t(924)+t(1645)][t(889)])||e[t(482)](t(675)+t(647)+"alScope",globalThis[t(924)+t(1645)][t(889)])||e[t(1793)](e[t(471)],globalThis[t(924)+t(1645)][t(889)]))&&e.kfSIM(e[t(439)],typeof self),pp=e[t(580)](e[t(439)],typeof globalThis)&&e[t(1103)](e[t(539)],globalThis[t(924)+t(1645)][t(889)])&&e[t(884)](e[t(439)],typeof global)&&e[t(539)]===global[t(924)+t(1645)][t(889)]&&e[t(884)](e[t(439)],typeof process)&&!!process.version;class aa{constructor(){this._listeners={}}emit(n,...s){let d=t,f=this[d(712)+"rs"][n];if(f)f[d(1844)]()[d(1198)](p=>p.fn[d(1738)](p[d(1797)],s));else if(e[d(742)](e[d(542)],n)&&!this[d(1022)]){let p=s[d(1120)]&&s[0];if(e[d(1496)](p,Error))throw p;let w=new Error(e[d(983)](e[d(881)],p?e[d(1013)](e[d(1360)](" (",p[d(830)]),")"):""));throw w[d(1519)]=p,p}return this}[t(893)](n,s){let d=t;if(e.PEPHx(void 0,n))this._listeners={};else if(e[d(1856)](void 0,s))this[d(712)+"rs"][n]=null;else{let f=this[d(712)+"rs"][n];if(f)for(let p=0;p<f[d(1120)];)f[p].fn===s?f[d(1591)](p,1):++p}return this}on(n,s,d){let f=t;return(this[f(712)+"rs"][n]||(this[f(712)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this}}class gp extends aa{["_formatE"+t(586)+"age"](n){let s=t;if(e[s(666)](e[s(458)],e[s(458)])){let d=this[s(921)+s(760)]?.[s(1757)+s(628)+"nt"]();this["_dispatchCloseEv"+s(1017)](_0x548d5f(s(908),{code:1006,reason:"connect "+d+(" timeout, max re"+s(1402)+s(1330)),wasClean:!0}))}else return n[s(1007)]||n.errNo?(s(1029)+" "+(n.errMsg||"")+s(696)+(n[s(1802)]||""))[s(970)]():JSON.stringify(n)}constructor(n,s,d){let f=t;super(),this._socket=null,Kr&&wx["connectS"+f(1755)]&&(this[f(1408)]=wx[f(866)+"ocket"]({url:n,protocols:s,header:d,fail:this[f(895)+f(1599)+f(1290)][f(1571)](this),success:this[f(895)+"ocketSuc"+f(1352)+"ler"].bind(this)})),An&&tt.connectSocket&&(this._socket=tt.connectSocket({url:n,protocols:s,header:d,fail:this[f(895)+"ocketFai"+f(1290)][f(1571)](this),success:this[f(895)+f(1826)+f(1352)+f(727)][f(1571)](this)}))}["_createS"+t(1826)+t(1352)+t(727)](){let n=t;Promise[n(587)]()[n(1872)](()=>{let s=n;this[s(965)+s(1283)]()})}[t(895)+"ocketFai"+t(1290)](n){let s=t;Promise[s(587)]()[s(1872)](()=>{let d=s,f=at("error",{message:this["_formatE"+d(586)+d(1001)](n)});this[d(1293)](e[d(542)],f);let p=ht(e[d(1153)],{reason:this[d(1898)+d(586)+d(1001)](n)});this[d(1293)](e[d(1153)],p)})}[t(965)+t(1283)](){let n=t,s={WGoMQ:function(d,f,p){return e.NumaW(d,f,p)},YfhTZ:e.kGXfE,EfneA:e[n(1153)],VEkGi:function(d,f){return e[n(1715)](d,f)},djUyT:e[n(1845)],svjvJ:e[n(542)]};this[n(1408)][n(1117)](d=>{let f=n;this[f(1293)]("open",s[f(642)](Qd,s[f(768)],{...d,data:d[f(1007)]||""}))}),this[n(1408)][n(1842)](d=>{let f=n;this[f(1293)](s[f(1155)],ht(s[f(1155)],{...d}))}),this[n(1408)][n(748)+"e"](d=>{let f=n;this[f(1293)](e[f(1195)],e[f(1610)](Xd,e[f(1195)],{...d}))}),this._socket[n(554)](d=>{let f=n;if(s.VEkGi(f(735),s[f(885)]))try{this[f(397)]?.close(),this[f(397)]=void 0}catch(p){_0x32e4b7[f(890)](p)}else this[f(1293)](s[f(1549)],at(f(1697),{...d,message:d.errMsg||""}))})}[t(1890)](n){let s=t,d={SrmaB:e.tvZMI,nnLzt:function(f,p,w){return e.RgYYW(f,p,w)},bzCAO:function(f,p){return e[F(1386)](f,p)},bIMlk:e[s(1762)]};if(n instanceof Uint8Array){let f=n[s(841)][s(1844)](n[s(1193)+"et"],n[s(509)+"th"]+n[s(1193)+"et"]);this[s(1408)]&&this[s(1408)][s(1890)]({data:f,fail:p=>{let w=s;this[w(1293)](d[w(955)],d[w(1247)](at,d[w(955)],{message:this["_formatE"+w(586)+w(1001)](p)}))}})}else this[s(1408)]&&this[s(1408)][s(1890)]({data:n,fail:f=>{let p=s,w={tndOr:d.SrmaB,KBUzI:function(v,g,O){return d[F(1247)](v,g,O)},DydFc:function(v,g){return d.bzCAO(v,g)}};if(p(1204)===d.bIMlk)this.emit(d[p(955)],d[p(1247)](at,d[p(955)],{message:this[p(1898)+"rrorMess"+p(1001)](f)}));else{let v=_0x420bc1[p(841)][p(1844)](_0x2b13b3[p(1193)+"et"],oAaUBJ[p(430)](_0x531af6[p(509)+"th"],_0x535c6b[p(1193)+"et"]));this._socket&&this._socket[p(1890)]({data:v,fail:g=>{let O=p;this[O(1293)](oAaUBJ[O(594)],oAaUBJ.KBUzI(_0x1ac659,"error",{message:this[O(1898)+O(586)+O(1001)](g)}))}})}}})}[t(908)](n,s){let d=t;this[d(1408)]&&this[d(1408)].close({code:n,reason:s})}[t(1079)+"Listener"](n,s){let d=t,f={sSQbc:function(p,w){return e[F(897)](p,w)},cFNef:function(p,w){return p&w},jtbja:function(p,w){return e[F(1834)](p,w)},SXoVI:function(p,w){return e[F(1786)](p,w)},QoDCt:function(p,w){return p|w},VtTGn:function(p,w){return e[F(1315)](p,w)},XFhoa:function(p,w){return p|w}};if(e[d(1121)](e[d(721)],"ArkEE")){_0x504037[d(1606)](_0x2be85c)||(_0x5cf999=_0x2e6ba4[d(1499)+"er"](_0x5ac537));let p=EoChMj.sSQbc(this[d(794)],16),w=EoChMj[d(1459)](65535,this.high),v=EoChMj[d(1278)](this[d(1693)],16),g=65535&this[d(1693)],O=_0x57eea0.high>>>16,L=EoChMj[d(560)](65535,_0x3fcd97[d(794)]),U=EoChMj[d(1278)](_0x444add.low,16),$=EoChMj[d(1459)](65535,_0x136b6e[d(1693)]),K=0,fe=0,Ze=0,je=0;return je+=EoChMj[d(590)](g,$),Ze+=EoChMj[d(1278)](je,16),je&=65535,Ze+=EoChMj[d(590)](v,U),fe+=EoChMj[d(1278)](Ze,16),Ze&=65535,fe+=w+L,K+=EoChMj.sSQbc(fe,16),fe&=65535,K+=EoChMj[d(590)](p,O),K&=65535,_0x9ecf7.fromBits(EoChMj[d(1033)](EoChMj.VtTGn(Ze,16),je),EoChMj.XFhoa(K<<16,fe),this.unsigned)}else this.on(n,s)}["removeEventListe"+t(538)](n,s){this.off(n,s)}get readyState(){let n=t;return this[n(1408)][n(464)+"te"]}get binaryType(){let n=t;return this[n(1408)][n(1418)+"pe"]}set[t(1418)+"pe"](n){}get[t(1416)](){let n=t;return this[n(1408)][n(1416)]}get[t(1034)](){let n=t;return this[n(1408)][n(1034)]}get[t(1364)+"ns"](){let n=t;if(e[n(880)]!==e[n(880)])this[n(1293)](e.uJpxV,_0x53ceb4(e[n(1153)],{..._0x2aa89d}));else return this._socket[n(1364)+"ns"]}get["buffered"+t(1098)](){return 0}}function mp(a,n){let s=t;if(e.wEFlv(e[s(1556)],e[s(1405)])){if(n)return new n(a[s(1416)],a.protocol);if(Kr||An)return new gp(a[s(1416)],a[s(1034)],a[s(792)]);if(e[s(582)](Yn,$r)&&e[s(633)](e.Zynlj,typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1034)+"s"])}else _0x413af3=e[s(1377)](_0x40fceb,_0x41b5e8),_0x1cd01b|=e.UVrmB(e[s(870)](127,_0x20160e),21),e[s(725)](128,_0x53b929)&&(_0x548626=e[s(1594)](_0x1768d4,_0x522854),_0x3e3f4a=127&_0x2b29b2,128&_0x4620f2&&(_0x3c9974=e.hHmeu(_0x398004,_0x123497),_0x4aff47|=e[s(1668)](e[s(1795)](127,_0x5ba16b),7)))}function wp(a){let n=t,s=e[n(1636)][n(1761)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(Kr&&wx[n(866)+"ocket"])return!0;continue;case"1":if(a)return!0;continue;case"2":if(An&&tt[n(866)+n(1755)])return!0;continue;case"3":if(e[n(470)](Yn,$r)&&e[n(633)](e[n(439)],typeof WebSocket)&&WebSocket)return!0;continue;case"4":return!1}break}}function tl(a,n,s){let d=t,f=-1;async function p(w){let v=F;return e.zUkUl(w,f)?Promise[v(1285)](new Error(e.kBSIf)):(f=w,e[v(1265)](w,s[v(1120)])?Promise.resolve():s[w][v(1571)](a)(n,p.bind(null,e[v(1395)](w,1))))}e[d(1559)](p,0)}function nl(a){let n=t,s=0,d=0;for(let f=0;f<a[n(1120)];++f)d=a[n(1657)+"At"](f),e[n(844)](d,128)?s+=1:e[n(1095)](d,2048)?s+=2:e[n(1406)](64512&d,55296)&&e[n(604)](64512,a[n(1657)+"At"](f+1))===56320?(++f,s+=4):s+=3;return s}function rl(a,n,s){let d=t;if(e[d(998)](e[d(909)](s,n),1))return"";let f="";for(let p=n;e[d(876)](p,s);){let w=a[p++];if(e[d(503)](w,127))f+=String[d(1501)+d(1639)](w);else if(w>=192&&e[d(1192)](w,224))f+=String[d(1501)+d(1639)](e.FlvEC(e[d(673)](31,w)<<6,e.sHWgp(63,a[p++])));else if(e.zbugS(w,224)&&w<240)f+=String[d(1501)+d(1639)](e.ATSXY(e[d(1097)](e[d(1849)](e[d(1249)](15,w),12),e[d(562)](63&a[p++],6)),e[d(1714)](63,a[p++])));else if(e.diZzb(w,240)){let v=e.MjnRX(e.MjnRX(e[d(668)](e[d(848)](7,w)<<18,e[d(1242)](e[d(622)](63,a[p++]),12)),e[d(827)](63,a[p++])<<6),e.nRkMV(63,a[p++]))-65536;f+=String[d(1501)+d(1639)](e.XwwhM(55296,e[d(1878)](v,10))),f+=String[d(1501)+d(1639)](e[d(1380)](56320,1023&v))}}return f}function ca(a,n,s){let d=t,f=s,p,w;for(let v=0;e[d(1192)](v,a.length);++v)if(e[d(1678)]!==e[d(394)])if(p=a[d(1657)+"At"](v),e.HYgCt(p,128))n[s++]=p;else if(e.oVyES(p,2048))n[s++]=e[d(716)](e[d(1878)](p,6),192),n[s++]=e[d(1789)](63,p)|128;else if(e[d(482)](64512&p,55296)&&e.xmcRF(e[d(1297)](64512,w=a[d(1657)+"At"](v+1)),56320))if(e[d(1199)](e[d(751)],e[d(1251)])){let g=e[d(452)][d(1761)]("|"),O=0;for(;;){switch(g[O++]){case"0":n[s++]=e.mmdcm(e[d(1227)](e[d(535)](p,6),63),128);continue;case"1":n[s++]=e[d(1109)](63&p,128);continue;case"2":n[s++]=e[d(1814)](p>>18,240);continue;case"3":p=e.TFEES(e[d(1626)](65536,(1023&p)<<10),e.wpARN(1023,w));continue;case"4":++v;continue;case"5":n[s++]=e[d(1729)](e[d(446)](e[d(1878)](p,12),63),128);continue}break}}else{let g=new _0x4cfe56(e[d(1830)](2,_0x55e60e));g[d(588)](_0x1c0b7f),_0x3b1824[d(813)]=g}else n[s++]=p>>12|224,n[s++]=e[d(1843)](e[d(995)](p>>6,63),128),n[s++]=e.ePwOx(63&p,128);else return new _0x44715a(_0x208aae,{message:_0x3cefe2});return e.aJEwG(s,f)}async function il(a){let n=t,s={YzZQR:function(d,f){return d>>>f},bSJUU:function(d,f){return e[F(477)](d,f)},hEbgM:function(d,f){return d&f},WmPbn:function(d,f){return d&f}};if(e[n(1730)](e[n(1613)],n(1383))){if(e[n(1368)]==typeof a)if(e[n(917)](n(398),"LbzZl")){let d=new Uint8Array(nl(a));return e[n(401)](ca,a,d,0),d}else{let d=this[n(794)],f=this[n(1693)];return[IFZsAy.YzZQR(d,24),IFZsAy[n(1552)](IFZsAy.YzZQR(d,16),255),IFZsAy[n(513)](IFZsAy[n(981)](d,8),255),IFZsAy.bSJUU(255,d),IFZsAy[n(981)](f,24),IFZsAy.hEbgM(f>>>16,255),IFZsAy.WmPbn(f>>>8,255),255&f]}return e[n(1496)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(841)],a[n(1193)+"et"],a[n(509)+"th"])}else _0x4e1d60[n(1004)]=_0x3531eb[n(587)]()[n(1872)](()=>(_0x43e1ea(),_0x43707d))[n(1872)](function(d){return d})}function _p(a){let n=t;try{return e.UiFcK!=typeof a&&(e.aEPRo(a,ArrayBuffer)||a.buffer&&a[n(841)]instanceof ArrayBuffer)||e[n(633)](e[n(1368)],typeof a)?"":(JSON[n(476)](a),e[n(653)])}catch{return e[n(1043)](e[n(1368)],typeof a)?e.eiBJp:""}}let yp=(a,n)=>{let s=t;if(e[s(1730)](s(1792),e[s(702)]))_0x3d6d15(CEvnkD[s(938)](_0x26c52f,_0x268e29[s(678)])),_0x5c6797();else switch(a){case e[s(1507)]:case e[s(1548)]:return{[s(1681)+a]:1,"x-tt-env":n};default:return{}}};class Ep{constructor(n){let s=t;this[s(1349)+"ount"]=n,this[s(1028)]=0}[t(1340)](){let n=t;this[n(1028)]++}[t(1743)+t(1516)+"nt"](){let n=t;return e[n(1044)](this[n(1028)],this[n(1349)+n(1088)])}[t(1375)+"nter"](n=0){let s=t;this[s(1349)+s(1088)]=n,this.count=0}}async function bp(a){return new Promise(n=>{let s=F,d={NxPZR:function(f,p){return e[F(515)](f,p)},wsmkb:"unknown reason"};if(!Yn)return n(e[s(1881)]);try{let f=document[s(703)+"ement"](s(1801));window.frontierJSONP=p=>{let w=s;document.body[w(1170)+w(612)](f),window[w(1304)+w(1047)]=void 0,d[w(1667)](n,p&&p[w(1832)]||d[w(1888)])},f.type=e.XnVHB,f[s(1181)]=e.FySus(a.replace(/^ws/,e[s(1840)]),e[s(1141)]);try{document.body[s(1264)+"ild"](f)}catch{document[s(705)][s(1170)+s(612)](f)}}catch{window[s(1304)+"JSONP"]=void 0,e[s(711)](n,e[s(1881)])}})}function tn(a,n,s){let d=t;return!!a?.find(f=>f[d(1376)]===n&&f[d(814)]===s)}function Xn(a,n){let s=t;return a?.[s(1145)](d=>d[s(1376)]===n)?.[s(814)]}let da=null;async function vp(){let a=t;return da||(da=Promise[a(587)]()[a(1872)](Nt.bind(Nt,e[a(1544)]))),da}class Sp extends aa{constructor(n,s){let d=t;super(),this[d(599)]=n,this._keyPath=s,this[d(397)]=void 0,this[d(1905)+d(1002)]=null}async openDB(){await this._init()}async[t(947)](){let n=t,s={FIPwi:function(d,f,p,w){return d(f,p,w)}};if(!this[n(397)]){if(this["_initPro"+n(1002)])return this["_initPro"+n(1002)];try{let d=this[n(599)],f=this[n(1650)];this[n(1905)+n(1002)]=(async()=>{let p=n,{openDB:w}=await vp();this[p(397)]=await s[p(428)](w,p(1304)+"_"+d,1,{upgrade(v){let g=p;v[g(1694)+g(1735)+"e"](d,{keyPath:f})}})})(),await this[n(1905)+n(1002)]}catch(d){console[n(890)](d)}finally{this["_initPro"+n(1002)]=null}}}async[t(1040)](n){let s=t;try{return await this._init(),this._qosDB?.[s(1040)](this._dbName,n)}catch(d){console[s(890)](d)}}async set(n,s){let d=t;return await this[d(947)](),this._qosDB?.[d(615)](this[d(599)],n)}async[t(506)](n){let s=t;try{return await this[s(947)](),this._qosDB?.[s(916)](this[s(599)],n)}catch(d){console[s(890)](d)}}async[t(526)](){let n=t;try{return await this[n(947)](),this[n(397)]?.[n(526)](this[n(599)])}catch(s){console[n(890)](s)}}async[t(566)](){let n=t;return await this[n(947)](),this[n(397)]?.[n(536)+"ys"](this[n(599)])}async[t(1032)](){let n=t;return await this._init(),this[n(397)]?.[n(1032)](this[n(599)])}async[t(1209)](){let n=t;if(e[n(1749)]!==e[n(1281)])try{e.HamRZ(e[n(1154)],e[n(1373)])?(this[n(1758)+n(777)+n(1456)](_0x52c3eb),_0x3e2319[n(588)](_0xd67d90,_0x346aa8,_0x2a5498[n(830)][n(1620)])):(this[n(397)]?.[n(908)](),this[n(397)]=void 0)}catch(s){console[n(890)](s)}else{let s=_0x438495(_0x4b1a89,1);_0x3ad705.bytes[s]=_0x45df8a}}get isReady(){let n=t;if(e[n(1769)](e[n(616)],n(714)))_0xf5f742=_0x5068e2(_0x118a62),e.hCSPw(_0x52d7a2,32)&&(_0x55de40|=e[n(1502)](e[n(507)](127,_0x154c64),_0x533c3e)),_0xa53120+=7;else try{return!!this[n(397)]}catch(s){return console[n(890)](s),!1}}}class Ip{constructor(n,s){let d=t;this[d(693)]=n,this[d(1194)]=s,this[d(397)]=localStorage}async openDB(){}get[t(559)](){return"frontier_"+this[t(693)]}async[t(1040)](n){let s=t,d=this._qosDB[s(1787)](this[s(559)]);return JSON[s(476)](e[s(470)](d,"{}"))[n]}async[t(588)](n,s){let d=t;if(d(975)===e[d(1863)]){let f=this[d(397)][d(1787)](this[d(559)]),p=JSON[d(476)](e[d(558)](f,"{}"));return p[s||n[this[d(1194)]]]=n,this[d(397)].setItem(this[d(559)],JSON[d(840)+"y"](p)),s||n[this[d(1194)]]}else this[d(643)+d(1171)]=_0x4633a0}async[t(506)](n){let s=t,d={WrKoW:function(f,p){return f instanceof p},hsUEv:s(759)+"in;chars"+s(875),zEgto:"application/json",GrOME:e[s(1288)],zXPjc:e[s(1362)],JzCqR:e.QXuGE,dCqwc:function(f,p,w,v){return e[s(401)](f,p,w,v)}};if(e[s(1010)](e[s(1869)],e[s(662)])){let f=d[s(1481)](this._options[s(1453)+"ncoding"],_0x4c8d07)?{force:!!this[s(1526)][s(1453)+s(1156)][s(1483)],encoding:this[s(1526)][s(1453)+s(1156)][s(1634)]?this[s(1526)].payloadEncoding[s(1634)][s(1669)](/\s/g,"")["toLowerC"+s(416)]():""}:{force:!1,encoding:this[s(1526)][s(1453)+"ncoding"]?this[s(1526)]["payloadE"+s(1156)][s(1669)](/\s/g,"")["toLowerC"+s(416)]():""},p=_0x5701eb[s(1453)+s(1156)]?_0x1ab66e["payloadE"+s(1156)][s(1669)](/\s/g,"")[s(898)+"ase"]():"",w=d[s(1481)](this._options[s(442)+s(1768)],_0xa16c16)?{force:!!this[s(1526)][s(442)+s(1768)][s(1483)],type:this[s(1526)]["payloadT"+s(1768)][s(1327)]?this[s(1526)].payloadType[s(1327)].replace(/\s/g,"")[s(898)+s(416)]():""}:{force:!1,type:this[s(1526)][s(442)+"ype"]?this[s(1526)][s(442)+"ype"][s(1669)](/\s/g,"")["toLowerC"+s(416)]():""},v=_0x2e9625["payloadT"+s(1768)]?_0x6274d1[s(442)+"ype"][s(1669)](/\s/g,"")[s(898)+s(416)]():"",g=w[s(1483)]?w[s(1327)]:v||w[s(1327)],O=f.force?f.encoding:p||f[s(1634)],L=[d[s(1284)],d[s(1799)],d[s(537)],"string"],U=[d.zXPjc,d.JzCqR];this[s(1526)][s(1825)+s(919)+s(1042)+"ad"]&&L.includes(g)&&(!O||U[s(1206)](O))?_0x558609[s(1226)+s(1563)]=d[s(1831)](_0x451fa6,_0x28c60d[s(694)],0,_0xcdb723[s(694)].byteLength):_0x170daf[s(1226)+"oad"]=""}else{let f=this[s(397)][s(1787)](this[s(559)]),p=JSON[s(476)](e[s(1819)](f,"{}"));return p[n]=void 0,this[s(397)][s(741)](this[s(559)],JSON.stringify(p))}}async[t(526)](){return this._qosDB.clear()}async[t(566)](){let n=t,s=this[n(397)][n(1787)](this[n(559)]),d=JSON[n(476)](e[n(1670)](s,"{}"));return Object[n(566)](d)}async getAll(){let n=t,s=this[n(397)][n(1787)](this[n(559)]),d=JSON[n(476)](s||"{}");return Object[n(1197)](d)}[t(1209)](){let n=t,s={qWDJs:function(d,f,p){return e[F(1163)](d,f,p)},zfTkd:function(d,f){return e[F(1009)](d,f)},AEZtS:function(d,f){return e[F(1249)](d,f)}};if(e[n(1769)](e[n(789)],e.gGJKc))_0x298aa5-=65536,_0x2b1d67+=oNFOXO.qWDJs(_0x47f384,oNFOXO[n(1477)](_0x5393de>>10,55296),oNFOXO[n(1355)](1023,_0xe5de53)+56320),_0x4efc36+=3;else return Promise[n(587)]()}get[t(420)](){return!!this._qosDB}}class Ap{constructor(n,s){let d=t;this[d(693)]=n,this[d(1194)]=s,this._qosDB=An?tt:Kr?wx:null}async[t(854)](){}get[t(559)](){let n=t;if(e[n(525)](e.xeBCZ,e[n(1379)]))try{_0x3cb3b0(this,_0x19c2b0,[_0x29a820,_0xcc6fc4,_0x16a490])}catch(s){let d=e.gKRUF(_0xebe0bb,n(1697),{message:s[n(830)],code:_0x4b17f8[n(1829)+"OR"],error:s});this["_dispatc"+n(1660)+"ent"](d)}else return n(1304)+"_"+this._DBName}async get(n){let s=t,d={VurgY:function(f,p){return e[F(708)](f,p)},affyh:function(f,p){return e.ZDtPD(f,p)}};if(e[s(809)](s(417),e.LGVTV)){let f=this[s(397)][s(664)+"geSync"](this[s(559)]);return JSON[s(476)](e[s(1679)](f,"{}"))[n]}else{let f=0,p=0,w;do w=hcXQKh.VurgY(_0x31201c,_0x76a66e),hcXQKh[s(1128)](f,32)&&(p|=(127&w)<<f),f+=7;while(128&w);return p}}async[t(588)](n,s){let d=t,f=this._qosDB[d(664)+d(441)](this._prefix),p=JSON.parse(e[d(582)](f,"{}"));return p[s||n[this[d(1194)]]]=n,this[d(397)]["setStora"+d(441)](this[d(559)],JSON[d(840)+"y"](p)),s||n[this[d(1194)]]}async[t(506)](n){let s=t,d=this[s(397)][s(664)+s(441)](this[s(559)]),f=JSON[s(476)](e[s(558)](d,"{}"));return f[n]=void 0,this._qosDB.setStorageSync(this[s(559)],JSON[s(840)+"y"](f))}async[t(526)](){let n=t;return this[n(397)][n(1655)+n(1081)]()}async[t(566)](){let n=t,s=this._qosDB[n(664)+n(733)+"nc"](this._prefix),d=JSON[n(476)](e[n(1351)](s,"{}"));return Object.keys(d)}async[t(1032)](){let n=t,s=this[n(397)][n(664)+n(733)+"nc"](this[n(559)]),d=JSON[n(476)](e[n(1708)](s,"{}"));return Object.values(d)}[t(1209)](){let n=t;if(e[n(1691)]!==e[n(1753)])return Promise[n(587)]();this[n(397)]?.del(_0x25e1be.message_id)}get[t(420)](){return!!this[t(397)]}}function sl(a,n){let s=t;if(e[s(1010)](e[s(1491)],e.maTWw))return!0;if(e[s(1679)](An,An))return new Ap(a,n);if(e[s(692)](Yn,$r)&&e.kfSIM(e[s(439)],typeof indexedDB))return new Sp(a,n);if(e.hXdhl(Yn,$r)&&e[s(633)](e[s(439)],typeof localStorage))return new Ip(a,n);throw new Error(e.siYJG)}class Tp{constructor(){let n=t;this._intervalTimeoutId=null,this[n(1728)+"l"]=36e5,this[n(397)]=e.RgYYW(sl,e[n(1513)],e[n(1322)])}async[t(1728)+"lFlush"](){let n=t;e[n(497)](clearInterval,this[n(1728)+"lTimeoutId"]),this[n(1728)+n(766)+"Id"]=setInterval(()=>{let s=n;if(s(1346)!=="TnvmE")return _0x41d050[s(640)+s(1712)]||_0x31d0ef[s(1040)](_0x33d763);this[s(842)+"ired"]()},this._interval)}async[t(854)](){let n=t;await this[n(397)].openDB()[n(1872)](()=>{let s=n;this[s(1728)+s(892)]()})}async[t(842)+t(435)](){let n=t;(await this[n(397)]?.[n(1032)]()||[])[n(1545)](({timestamp:f})=>f<Date[n(1666)]())[n(1198)](f=>{let p=n;this._qosDB?.[p(506)](f[p(1871)+"id"])})}async[t(506)](n){let s=t;return this[s(397)]?.[s(506)](n)}async[t(588)](n,s){let d=t;return this[d(397)]?.[d(588)]({message_id:n,timestamp:s})}async[t(1040)](n){let s=t;return this._qosDB?.[s(1040)](n)}async[t(1209)](){let n=t,s={ufZVd:function(d,f){return d(f)},QsOlx:function(d,f){return e.areFw(d,f)}};if(e[n(525)](e[n(1709)],e[n(1904)]))e[n(1291)](clearInterval,this[n(1728)+"lTimeoutId"]),await this._qosDB?.[n(1209)]();else{let f=""+_0x584056[n(1666)](),p=_0x3b9072||(_0x254e83=FfFuoI.ufZVd(_0x20c3de,_0x47c8d8)),w=_0x4c4a42.random()[n(532)](16).slice(-6);return FfFuoI[n(1509)](FfFuoI[n(1509)]("02"+f,p),w)}}get[t(420)](){return this[t(397)]?.isReady}}function la(a){let n=t,s=!!this[n(1526)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(964)](tn,a.message[n(792)],e.zZkVt,"2"),f=d&&e[n(964)](tn,a[n(830)][n(792)],e[n(1775)],"1"),p=d&&tn(a.message.headers,e[n(1359)],"1"),w=p?e[n(1e3)](Xn,a[n(830)].headers,e.oDpPp)?.[n(1761)](",")[n(1545)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:p,ackMsgIds:w}}async function ol(){let a=t,n={mTcQY:function(s,d,f){return e.IfCBZ(s,d,f)}};if(e[a(592)](e[a(1748)],e.eKxqs))return this[a(1485)+"ger"]||(this[a(1485)+a(949)]=new Tp),this[a(1485)+"ger"][a(420)]||await this[a(1485)+"ger"].openDB(),this[a(1485)+a(949)];{let s=a(1274)+_0x40c1ba+(a(882)+a(874)+a(1402)+"ached");this[a(1055)](s),this[a(1758)+a(1660)+a(1017)](n[a(1067)](_0x4308ef,a(1697),{message:s,code:_0x4d42ff.MAX_RETRIES_ERROR}));return}}async function Rp(a,n){let s=t,{enableAutoAck:d}=this[s(1526)],f=e.rzOQe(tn,a[s(830)].headers,e.rtCTF,"1"),p=tn(a[s(830)][s(792)],e.uNzWQ,"1"),w=la[s(1125)](this,a);if(e[s(1157)](d,f)){let{SeqID:v,LogID:g,service:O,LogIDNew:L,method:U}=a[s(830)];this[s(1777)]({SeqID:v,LogID:g,LogIDNew:L,service:O,method:U,headers:[{key:e.uNzWQ,value:"1"},{key:e[s(1437)],value:e[s(1351)](L,"")},{key:e[s(1686)],value:"0"}]})}p&&!w[s(912)]&&this["_dispatc"+s(1575)+s(1683)](a),e[s(1411)](n)}async function Cp(a,n){let s=t,d={PxTsY:e[s(1565)],yCYaf:e[s(542)],kKZzg:"abort"};e[s(1751)](e[s(985)],e[s(495)])?(this[s(1055)](e[s(1336)],a.message),n()):(_0x146093["removeEv"+s(1717)+s(538)](gNzTYI.PxTsY,_0x1a75c1),_0x3b5efe[s(839)+s(1717)+s(538)](gNzTYI[s(1100)],_0x3f6ab4),_0x3405dd["removeEv"+s(1717)+s(538)](gNzTYI.kKZzg,_0xdd36f3))}async function kp(a,n){let s=t,d={BEcou:e[s(542)],tKhvo:function(p,w,v){return p(w,v)},dPuQY:e[s(1153)]},f=Xt(await e[s(732)](il,a[s(396)]));try{if(e.TZEmi(e[s(1401)],s(837)))_0x549f1e[s(587)]()[s(1872)](()=>{let p=s,w=_0x482ed7(ScVvjo[p(1747)],{message:this["_formatE"+p(586)+p(1001)](_0x10699a)});this.emit(ScVvjo[p(1747)],w);let v=ScVvjo[p(1440)](_0x2806fd,"close",{reason:this["_formatE"+p(586)+p(1001)](_0x58550a)});this[p(1293)](ScVvjo.dPuQY,v)});else if(f[s(694)]instanceof Uint8Array){let p=e[s(1272)](this[s(1526)][s(1453)+"ncoding"],Object)?{force:!!this._options["payloadE"+s(1156)].force,encoding:this._options[s(1453)+"ncoding"][s(1634)]?this[s(1526)][s(1453)+s(1156)].encoding.replace(/\s/g,"").toLowerCase():""}:{force:!1,encoding:this[s(1526)][s(1453)+"ncoding"]?this[s(1526)][s(1453)+s(1156)][s(1669)](/\s/g,"")[s(898)+s(416)]():""},w=f[s(1453)+s(1156)]?f[s(1453)+"ncoding"][s(1669)](/\s/g,"")[s(898)+s(416)]():"",v=e.xnGMf(this[s(1526)][s(442)+"ype"],Object)?{force:!!this[s(1526)][s(442)+s(1768)][s(1483)],type:this[s(1526)]["payloadT"+s(1768)][s(1327)]?this[s(1526)][s(442)+s(1768)].type[s(1669)](/\s/g,"")["toLowerC"+s(416)]():""}:{force:!1,type:this[s(1526)][s(442)+s(1768)]?this[s(1526)][s(442)+s(1768)][s(1669)](/\s/g,"")[s(898)+s(416)]():""},g=f[s(442)+s(1768)]?f[s(442)+s(1768)].replace(/\s/g,"")["toLowerC"+s(416)]():"",O=v.force?v[s(1327)]:g||v[s(1327)],L=p[s(1483)]?p[s(1634)]:w||p[s(1634)],U=[e[s(1021)],e[s(653)],e.mqKQX,e.UiFcK],$=[e[s(1362)],e[s(1781)]];this[s(1526)][s(1825)+s(919)+s(1042)+"ad"]&&U.includes(O)&&(!L||$[s(1206)](L))?f[s(1226)+s(1563)]=rl(f[s(694)],0,f[s(694)][s(509)+"th"]):f[s(1226)+s(1563)]=""}else f.textPayload=""}catch(p){f[s(1226)+"oad"]="",console.log(p)}a[s(830)]=f,e[s(1411)](n)}function Dp(a,n,s){let d=t,f=s||8192,p=e[d(1328)](f,1),w=null,v=f;return function(g){let O=d;if(g<1||e.lPfze(g,p))return e[O(1037)](a,g);e[O(817)](e[O(963)](v,g),f)&&(w=a(f),v=0);let L=n.call(w,v,v+=g);return e.ZaTZt(7,v)&&(v=e.YFKVV(e[O(1843)](7,v),1)),L}}let Pp=4294967295;function Op(a,n,s){let d=t;return e.ndgIg(RangeError,e[d(528)](e[d(1317)](e[d(466)](e[d(1135)](e[d(1313)],a),e[d(1113)]),n||1)+d(627),s))}function Lp(a,n,s){let d=t,f={GuxBL:function(p,w){return e[F(674)](p,w)},LwNYO:e.kBSIf};if(e[d(1089)](e[d(750)],d(625))){if(e[d(817)](s,Pp))throw new Error(e[d(903)]);let p=3;for(;e[d(1200)](p,0);)if(e.AIrlE!==e[d(1776)]){let w=255&s;e[d(964)](fa,w,a,e[d(963)](n,p)),s>>>=8,p--}else return e[d(423)](this[d(1028)],this["maxLossC"+d(1088)]);return e[d(1360)](n,4)}else return JFSdYv[d(936)](_0x2bb66b,_0x2e8d01)?_0x54dbc5[d(1285)](new _0xcb58f3(JFSdYv[d(1464)])):(_0x362be5=_0x20c1e4,_0x62ca28===_0x214464[d(1120)]?_0x3f31c3[d(587)]():_0x205b0b[_0x386b01][d(1571)](_0x361044)(_0x540fb9,_0x47dd4d.bind(null,_0x5d3377+1)))}function Np(a,n){let s=t,d={SyvyF:function(f,p){return e[F(468)](f,p)},HZSyV:function(f,p){return e[F(1695)](f,p)},NmrZS:function(f,p){return e[F(1614)](f,p)},upZpv:function(f,p){return e[F(467)](f,p)},EEBft:function(f,p){return f<<p},yHJSc:function(f,p){return f|p}};if(e[s(1065)](e[s(1815)],e[s(1815)])){let f=0,p=n,w=n+4;for(;e[s(547)](p,w);)if(s(540)===e.hActY){let{value:v,offset:g}=e.ARUKp(ua,a,p);p=g,f=e[s(530)](e[s(1303)](f,8),0),f+=v}else return new _0x165055(byVzJi[s(1295)](byVzJi.HZSyV(byVzJi.NmrZS(_0x354ddb[0],byVzJi[s(472)](_0x50272c[1],8)),_0x10a123[2]<<16),byVzJi[s(1605)](_0x382867[3],24)),byVzJi[s(1292)](byVzJi.yHJSc(byVzJi[s(422)](_0x47d247[4],_0x471574[5]<<8),_0xad877d[6]<<16),_0x4c3b37[7]<<24),_0x4896c8);return{value:f,offset:w}}else _0x1c3d3c["createOb"+s(1735)+"e"](_0x523062,{keyPath:_0x404df9})}function Mp(a,n,s){let d=t;return a?e[d(1827)](a[d(1120)],40)?e.IrXRO(ca,a,n,s)+s:n.utf8Write?e[d(1593)](n.utf8Write(a,s),s):n[d(886)]?e[d(565)](n.write(a,s),s):e[d(1321)](e[d(1542)](ca,a,n,s),s):s}function Bp(a,n){let s=t,d=new ue(e[s(974)](e[s(644)](e[s(1778)](a[n+4],24),a[e[s(1317)](n,5)]<<16)|e.swZCR(a[e[s(1184)](n,6)],8),a[e.YFKVV(n,7)]),e.UhYwM(e[s(1729)](a[e[s(1817)](n,0)]<<24|a[e.lALrN(n,1)]<<16,a[e.LgLlU(n,2)]<<8),a[n+3]),!0);return n+=8,{value:d,offset:n+8}}function Fp(a,n,s){let d=t,f=a[d(1693)],p=a[d(794)];return n[s]=e[d(1446)](p,24),n[s+1]=e[d(1632)](e[d(743)](p,16),255),n[e[d(1360)](s,2)]=e[d(1834)](e[d(667)](p,8),255),n[e[d(434)](s,3)]=255&p,n[e[d(1025)](s,4)]=e.NEnSW(f,24),n[e[d(755)](s,5)]=e[d(576)](e[d(1554)](f,16),255),n[e[d(1236)](s,6)]=e[d(865)](f,8)&255,n[e[d(1211)](s,7)]=e[d(1152)](255,f),s+=8,s}function ua(a,n){let s=t;return a.readUInt8?{value:a.readUInt8(n),offset:e[s(1013)](n,1)}:{value:e[s(717)](255,a[n]),offset:e[s(1211)](n,1)}}function fa(a,n,s){let d=t;if(e[d(1811)](e[d(1589)],e.UGEpT))_0x2458b2=_0x208041&&e.RPRgi(e[d(1838)],_0x140fcc[d(1034)])?e.llXCM:e[d(756)],_0x1914cf=_0x17af32[d(1669)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x4be3a4=/^wss(.*:\/\/)/.test(_0x7fbbd4)?_0xe20ba4:""+_0x4f9b21+_0x5eebda;else return n[d(1329)+"t8"]?n.writeUint8(a,s):n[s]=e[d(568)](255,a),e.MvYfA(s,1)}let zp=function(a){return new Uint8Array(a)},Up=e[t(831)](e.Zynlj,typeof Buffer)?Buffer["allocUns"+t(1450)]:Dp(zp,Uint8Array[t(483)+"e"][t(1800)]);(()=>{let a=t,n={zRDVt:function(s,d){return s>>>d},NyuDf:function(s,d){return s<<d},RsnlL:function(s,d){return e[F(764)](s,d)},gKOPn:function(s,d){return e[F(547)](s,d)},VURRz:function(s,d){return e[F(1884)](s,d)},NVrgA:function(s,d){return e[F(1146)](s,d)},KHGkE:function(s,d){return s|d},rbFWa:function(s,d){return e[F(844)](s,d)},ISHxh:function(s,d){return e[F(1003)](s,d)},UkZXn:function(s,d){return e[F(1023)](s,d)},gCjdz:function(s,d){return e.YTZEy(s,d)},yfwgZ:function(s,d){return s&d},VbaDa:function(s,d){return s>>>d},vivaj:function(s,d){return s&d},btJXV:function(s,d){return e[F(1390)](s,d)},uPymd:function(s,d,f,p){return e[F(969)](s,d,f,p)},EkCqz:function(s,d){return e[F(825)](s,d)},wQzJR:function(s,d){return e[F(440)](s,d)}};if(e[a(522)](a(1497),a(418))){let s=4294967295;return function(d,f,p=!0){let w=a,v=(w(829)+w(1796)+w(1505)+"0")[w(1761)]("|"),g=0;for(;;){switch(v[g++]){case"0":s=n[w(706)](s|n[w(931)](n[w(437)](15,d[f]),28),0);continue;case"1":if(n.gKOPn(d[f++],128))return{value:p?s:n[w(577)](0,s),offset:f};continue;case"2":s=n[w(1052)](n[w(808)](s,n[w(931)](n[w(437)](127,d[f]),21)),0);continue;case"3":if(n[w(1263)](d[f++],128))return{value:p?s:0|s,offset:f};continue;case"4":if(n.gKOPn(d[f++],128))return{value:p?s:n[w(577)](0,s),offset:f};continue;case"5":s=n.zRDVt(s|n[w(1506)](n.RsnlL(127,d[f]),14),0);continue;case"6":s=n[w(1535)](n[w(1494)](s,n[w(1419)](127,d[f])<<7),0);continue;case"7":s=n[w(1903)](n[w(784)](127,d[f]),0);continue;case"8":if(n[w(581)](f+=5,d.length))throw f=d[w(1120)],n[w(1479)](Op,f,10,d.length);continue;case"9":if(d[f++]<128)return{value:p?s:0|s,offset:f};continue;case"10":return{value:p?s:n[w(1045)](0,s),offset:f};case"11":if(n.rbFWa(d[f++],128))return{value:p?s:0|s,offset:f};continue}break}}}else return ETtQfz[a(1252)](_0x57153a,_0x48d533)})();let Gp=16,ha=32;function qp(a){let n=t,s={ywHAG:n(1697),sQpns:function(p,w,v){return e[n(1517)](p,w,v)},CbTZW:function(p,w){return e[n(1467)](p,w)}},d=0,f={};for(let p=0;e[n(824)](p,a[n(1120)]);p++)if(e[n(996)](n(1875),e[n(1463)]))f[a[p][n(1596)+n(426)]]=e.gFZAq(nl,a[p][n(1596)+n(426)]),d+=14+f[a[p][n(1596)+"ame"]];else{let w={DPKpe:OxPFFB.ywHAG,xDPKt:function(v,g,O){let L=n;return OxPFFB[L(1584)](v,g,O)}};if(_0x2b5bd0 instanceof _0x252336){let v=_0x2d649b[n(841)][n(1844)](_0x3f3996[n(1193)+"et"],OxPFFB.CbTZW(_0x5e4e46[n(509)+"th"],_0x30fe3d.byteOffset));this[n(1408)]&&this[n(1408)][n(1890)]({data:v,fail:g=>{let O=n;this[O(1293)](w[O(1654)],w[O(857)](_0x41d2b4,w[O(1654)],{message:this["_formatE"+O(586)+O(1001)](g)}))}})}else this[n(1408)]&&this._socket.send({data:_0x410aa3,fail:v=>{let g=n;this.emit(w.DPKpe,w[g(857)](_0x29f3dd,w.DPKpe,{message:this[g(1898)+"rrorMess"+g(1001)](v)}))}})}return[d,f]}function al(a,n,s){let d=t,f={dQtZZ:function(O,L,U,$){return e[F(1514)](O,L,U,$)},mRwRP:d(923)+d(1880),Bfxwf:function(O,L,U,$){return e.ASVGn(O,L,U,$)},DrhLA:e[d(1178)],ZJrVx:e.qSVro,VZkWM:e.bZMAP,hjeeL:d(1620)},[p,w]=e.tatlg(qp,a),v=e[d(1046)](Up,p),g=0;return a[d(1198)](O=>{let L=d,U=("1|0|10|2|8|9|6|3"+L(520))[L(1761)]("|"),$=0;for(;;){switch(U[$++]){case"0":g=f[L(688)](fa,0,v,g);continue;case"1":console[L(890)](f[L(769)],O,O.service);continue;case"2":g=Lp(v,g,O[L(1620)]||0);continue;case"3":g=f.Bfxwf(Mp,O[L(1596)+L(426)],v,g);continue;case"4":console.log(f.DrhLA,g);continue;case"5":console[L(890)](f[L(409)],g);continue;case"6":console[L(890)](f[L(1208)],g);continue;case"7":g=f[L(688)](Fp,ue.fromNumber(O[L(1071)]||n),v,g);continue;case"8":console.log(f[L(1084)],g);continue;case"9":g=fa(w[O[L(1596)+L(426)]],v,g);continue;case"10":console[L(890)](L(567),g);continue}break}}),{frameType:ha,headers:[{key:d(1512)+"ile_name",value:s}],payload:v}}function jp(a){let n=t,s=0,d=[];for(;e[n(826)](s,a.byteLength);){let{offset:f}=ua(a,s);s=f;let p={cursor_name:"",cursor:0,service:0},{value:w,offset:v}=Np(a,s);p[n(1620)]=w,s=v;let{value:g,offset:O}=e.OlYPr(ua,a,s);s=O,p[n(1596)+"ame"]=e[n(1422)](rl,a,s,e.TFEES(s,g)),s+=g;let{value:L,offset:U}=Bp(a,s);p[n(1071)]=L[n(1090)](),s=U,d.push(p)}return d}function Hp(){let a=t;return{frameType:ha,headers:[{key:e[a(1225)],value:e[a(410)]}],payload:void 0}}class Wp{constructor(n,s,d){let f=t;this[f(1572)+"ameSpace"]=n,this[f(643)+"ileName"]=s,this[f(432)+f(595)]=d,this[f(397)]=sl(this[f(1572)+f(1551)],e[f(745)])}async[t(854)](){await this._qosDB.openDB()}async getCursors(){let n=t,s={MSmNd:e[n(410)]};if(e[n(1366)](e[n(1016)],n(1592))){if(!this[n(397)][n(420)])return;let d=this["_message"+n(595)],f=await this[n(397)][n(1032)]();switch(console[n(890)](e[n(1105)],f),d){case e.JYtfM:return f&&f[n(1120)]?e[n(1273)](al,f,0,this._cursorFileName):void 0;case e.bpcMC:return;case e.IqPOq:return f&&f[n(1120)]?e[n(969)](al,f,0,this[n(643)+"ileName"]):e[n(1690)](Hp)}}else return{frameType:_0x58f544,headers:[{key:n(1512)+n(494),value:gIGlZJ.MSmNd}],payload:void 0}}async[t(588)](n,s,d){let f=t;return console[f(890)](e.bfCEh,n,s,d),this[f(397)][f(588)]({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d=e.pDTVJ(jp,n);for(let f of d)console[s(890)](e[s(1862)],d),await this[s(397)][s(588)](f)}async[t(1040)](n){let s=t;return(await this[s(397)].get(n))?.[s(1071)]}async[t(1209)](){await this[t(397)].closeDB()}[t(1174)+t(1133)+t(1101)](n){let s=t;this["_cursorF"+s(1171)]=n}get[t(420)](){let n=t;return this[n(397)][n(420)]}}let Kp=e[t(791)];async function cl(a){let n=t;if(!this[n(1526)][n(1266)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(1526)],p=e.YKcZn(a,Kp);try{if(this[n(1254)+n(457)])if(e[n(917)](e[n(933)],n(657)))a&&this["_cursorM"+n(457)][n(1174)+n(1133)+n(1101)](a);else{let w=_0x3fe040.bytes,v=_0x45517c[n(973)];return e[n(1265)](w[n(1120)],v)?w:w[n(1800)](0,v)}else this[n(1254)+n(457)]=new Wp(d+"_"+s+"_"+p,p,f);return this[n(1254)+n(457)].isReady||await this[n(1254)+n(457)][n(854)](),this[n(1254)+"anager"]}catch{return e[n(888)](e[n(1841)],e[n(1841)])?null:this._ws?this[n(634)][n(1364)+"ns"]:""}}async function $p(a,n){let s=t,d={OoFJy:function(f,p){return e[F(1027)](f,p)},BClBh:function(f,p){return e[F(466)](f,p)}};if(e[s(1312)](s(1490),e[s(455)])){let f=tn(a[s(830)].headers,s(1883),"-1"),p=e[s(1070)](tn,a[s(830)][s(792)],e[s(1018)],"1"),w=e.cuQzg(Xn,a[s(830)].headers,e[s(762)]),v=e[s(440)](Number,e[s(1752)](Xn,a[s(830)][s(792)],e[s(1319)]))||0,g=la[s(1125)](this,a),O=e[s(1273)](tn,a[s(830)].headers,e.vidIW,"2"),L=e[s(1798)](Xn,a.message.headers,s(1682)+s(682)+"e"),U=Number(e[s(1779)](Xn,a[s(830)].headers,e.cHhNX));if(g[s(912)])return e[s(1230)](n);let $=g[s(552)+s(1063)]?await ol[s(1125)](this):null;if(a[s(830)].service>0&&p&&!f||e[s(465)](a.message.service,0)){if(w&&g["isQoSMes"+s(1063)]&&$)return!!!await $[s(1040)](w)&&(this[s(1758)+s(777)+s(1456)](a),await $.set(w,Date.now()+v)),e[s(838)](n);if(O){let K=await cl.call(this);if(!K)return this[s(1758)+s(777)+s(1456)](a),n();let fe=await K.get(L)??-1;if(e[s(654)](fe,U))this[s(1758)+s(777)+s(1456)](a),K[s(588)](L,U,a[s(830)][s(1620)]);else throw new Error(s(1570)+s(1220)+s(1607)+U+(s(843)+s(1687)+s(729)+"r ")+fe);return n()}return this[s(1758)+s(777)+s(1456)](a),e[s(1524)](n)}}else _0x2a2171[_0x1d9807[_0xcc1a43][s(1596)+"ame"]]=dOaydd[s(847)](_0x29e602,_0xcad8e4[_0x1a9e96]["cursor_n"+s(426)]),_0x4a7857+=dOaydd.BClBh(14,_0x42d424[_0x1a763f[_0x2304bc][s(1596)+s(426)]])}async function Vp(a,n){let s=t;if(e[s(785)]===e[s(1879)]){let d=_0x534b9c(e[s(542)],{message:_0x3d8b62[s(830)],code:_0x3876c7[s(1829)+"OR"],error:_0xe8219a});this[s(1758)+"hErrorEv"+s(1017)](d)}else{let d=la[s(1125)](this,a);if(!d["isQoSMes"+s(1063)])return e[s(1411)](n);let f=await ol[s(1125)](this);if(d[s(1480)+s(549)+"age"]&&d[s(1724)+"s"][s(1120)])for(let p of d[s(1724)+"s"])await f[s(506)](p);e[s(1690)](n)}}async function Jp(a,n){let s=t,d=e[s(570)](a[s(830)].frameType,Gp),f=a[s(830)][s(1478)+"e"]===ha;if(e[s(414)](!d,!f))return e.Gxrtp(n);let p=Xn(a[s(830)][s(792)],e[s(1225)]);if(!p)return e[s(1586)](n);let w=await cl[s(1125)](this,p);if(!w)return e[s(838)](n);if(d){let v=await w[s(450)+"rs"](),g={frameType:v?.[s(1478)+"e"],SeqID:ue[s(1499)+"er"](this._seqId++),LogID:ue[s(1499)+"er"](this._options[s(1520)+s(488)]()),service:9e3,method:5,headers:v?.[s(792)],payload:v?.payload},O=S(g);this[s(634)]&&this[s(634)][s(464)+"te"]&&this[s(634)].send(O)}if(f){let v=a[s(830)][s(694)];v&&w[s(1370)+"rs"](v)}}let Zp=async function(a,n){let s=t;this[s(1631)]=!1,e[s(1069)](clearTimeout,this[s(1676)+s(561)+"utId"]),n()},Yp=async function(a,n){let s=t;if(e.caGsT(s(1618),s(1427))){if(!this._ws||e[s(1811)](this[s(634)][s(464)+"te"],this[s(1527)]))return e[s(838)](n);let{pingInterval:d}=this[s(1526)];this["_endpoin"+s(760)]?.[s(1764)+s(1835)+"fig"]();for(let p=0;e[s(632)](p,this["_message"+s(524)][s(1120)]);p++){let w=this[s(432)+s(524)][p];if(e[s(1265)](this[s(634)][s(464)+"te"],this[s(1527)])&&e[s(1623)](null,w))this[s(634)]&&this[s(634)][s(1890)](w),this._messageQueue[p]=null;else break}this["_message"+s(524)]=this["_message"+s(524)].filter(p=>!!p),this._pingPongTimeoutId=e[s(1432)](setTimeout,()=>this._ping(),d),this[s(1758)+s(614)+"nt"](a),this[s(1332)+"er"]&&this._ws&&(this[s(634)].binaryType=this[s(521)+"ype"]);let f=this[s(921)+"tManager"]?.[s(1757)+s(628)+"nt"]();this[s(1055)](s(1169)+f+s(1546)),e[s(838)](n)}else e[s(1276)](_0x14a9b3,e.elJek),this[s(893)](e.ELLFe,_0x60a130),this[s(893)](s(962)+s(730)+"t",_0xf29577)},Xp=async function(a,n){let s=t,d=this[s(921)+s(760)]?.[s(1757)+s(628)+"nt"]();this[s(1055)](s(1169)+d),e[s(1557)](n)};class Qp extends aa{constructor(n){let s=t,d={jiMSI:function(v,g){return e[F(1583)](v,g)},lalBH:e.MXOwj,SrTKM:function(v,g){return e[F(1037)](v,g)},Pmirq:function(v,g,O){return v(g,O)},tJSMC:e.qkUyU,PKKtQ:e[s(542)]};super(),this[s(815)+s(1347)+"line"]=!0,this[s(1332)+"er"]=Yn,this[s(728)]=pp,this[s(1260)+"T"]=An,this._isMiniWX=Kr,this[s(1684)+"r"]=$r,this[s(432)+"Queue"]=[],this["_endpoin"+s(760)]=null,this["_readyCl"+s(1112)]=!1,this[s(521)+s(1768)]=e[s(1824)],this["_connect"+s(1812)]=!1,this["_connect"+s(561)+s(637)]=null,this[s(1116)+s(954)+s(1374)]=null,this["_pingPon"+s(698)+"Id"]=null,this._seqId=0,this._isInit=!1,this[s(1104)]="",this["_QoSMana"+s(949)]=null,this[s(1254)+s(457)]=null,this[s(527)+s(695)]=null,this[s(1604)+"ls"]=e[s(1644)],this[s(1385)]=3,this[s(1229)+"NG"]=0,this[s(1527)]=1,this[s(555)]=2,this[s(1030)]=v=>{let g=s;try{e[g(709)](tl,this,v,[Zp,Yp,Xp])}catch(O){let L=e[g(935)](at,e[g(542)],{message:O.message,code:en[g(1829)+"OR"],error:O});this[g(1758)+g(1660)+"ent"](L)}},this[s(1387)+"ge"]=async v=>{let g=s,O={nJiuH:e[g(1622)]},{pingInterval:L,pingFrequency:U}=this[g(1526)];if((e.mnTMz("hi",v[g(396)])&&e.vrEmk===U||e[g(1406)](g(514),U))&&(this[g(977)+g(1511)](),this.emit(e.ELLFe,e[g(798)]),this[g(1165)+g(698)+"Id"]=e[g(1523)](setTimeout,this[g(575)][g(1571)](this),L)),!e.kpUMV("hi",v[g(396)]))try{if(e[g(505)](g(1788),e[g(1689)])){if(!this["_navigat"+g(652)]()||this["_readyCl"+g(1112)])return;this[g(921)+g(760)]?.["resetEnd"+g(1835)+g(1893)](),this[g(527)+g(695)]?.[g(1375)+g(697)](),this._ws?this[g(618)+"ect"](1001,O[g(720)],!0):this[g(1676)]()}else e.HitDs(tl,this,v,[kp,Rp,Vp,Jp,$p,Cp])}catch($){let K=e[g(1269)](at,e[g(542)],{message:$[g(830)],code:en[g(802)+g(1442)],error:$});this[g(1758)+"hErrorEv"+g(1017)](K)}},this[s(1638)]=v=>{let g=s,O=this[g(921)+g(760)]?.[g(1743)+g(1075)+"es"](),L=this["_endpoin"+g(760)]?.[g(1757)+g(628)+"nt"]();if(O&&!v[g(830)])if(d[g(778)]!==g(1085)){let U=g(1274)+L+(g(1577)+g(913)+g(1466)+"ed");this[g(1758)+g(1660)+"ent"](at(g(1697),{message:U,code:en["MAX_RETR"+g(1633)+"R"],error:v}));return}else return ZMfTjm[g(1569)](typeof _0x57b1cf,ZMfTjm[g(1510)])?ZMfTjm.SrTKM(_0x21b862,_0xa5545c):(_0x6cd97a instanceof _0x4f3760&&_0x649d75(_0x18fd26),ZMfTjm.Pmirq(_0x2cfa04,_0x59378c,_0x24f225())?new _0x38476b(_0x912865,_0x42aaa4):_0x23b321);this._ws&&this._ws.readyState===this.OPEN&&this[g(618)+g(1207)](),this[g(1758)+"hErrorEv"+g(1017)](d.Pmirq(at,d[g(1601)],{message:v[g(830)],code:en.NATIVE_ERROR,error:v}))},this._onClose=async v=>{let g=s;this[g(1183)+g(1399)](),this[g(977)+g(1511)](),this[g(1114)+g(1537)+"rs"](),this[g(634)]=null,this["_connect"+g(1812)]=!1;let O=this[g(921)+g(760)]?.[g(1743)+g(1075)+"es"]();if(!O&&this[g(1091)+g(652)]()&&!this["_readyCl"+g(1112)]){let L=this._endpointManager?.[g(1757)+"ntEndpoint"](),U=this[g(1526)][g(1431)+g(648)+g(1726)](v[g(1883)],v.reason);this[g(1758)+g(1853)+g(1017)](e[g(797)](ht,e.uJpxV,{code:1006,reason:v[g(1609)]||g(1020)+g(1448)+g(1420)+g(1127)+g(413)+"ame: "+L,willReconnect:U})),U&&this[g(1676)]();return}if(e[g(939)](1e3,v[g(1883)])&&this[g(658)+g(1112)]){this[g(1758)+g(1853)+"ent"](e.iVLEf(ht,"close",{code:1e3,reason:e[g(1369)]})),this[g(921)+"tManager"]?.["resetEnd"+g(1835)+g(1893)](),this[g(527)+g(695)]?.[g(1375)+"nter"]();return}if(e[g(522)](1e3,v[g(1883)])&&O){let L=this[g(921)+"tManager"]?.[g(1757)+g(628)+"nt"](),U=v[g(1609)];U||(U=await bp(this[g(1104)])),U=g(1020)+g(1448)+g(925)+U+(g(1099)+g(572))+L+(g(874)+g(1402)+g(1330)),this[g(1758)+"hCloseEv"+g(1017)](e[g(1723)](ht,e[g(1153)],{code:v.code,reason:U}));let $=g(1274)+L+(g(1577)+"ax retri"+g(1466)+"ed");this[g(1758)+g(1660)+"ent"](at(e.tvZMI,{message:$,code:en[g(767)+g(1633)+"R"]})),this[g(921)+g(760)]?.[g(1764)+g(1835)+g(1893)](),this["_pingLos"+g(695)]?.[g(1375)+g(697)]();return}if(e[g(1528)](1e3,v[g(1883)])&&!v[g(1609)]){let L=this["_endpoin"+g(760)]?.[g(1757)+g(628)+"nt"]();this[g(1758)+"hCloseEv"+g(1017)](e.KcaqL(ht,e[g(1153)],{code:v[g(1883)],reason:"connecti"+g(1448)+g(1420)+"wn reaso"+g(413)+g(492)+L})),this[g(921)+g(760)]?.[g(1764)+g(1835)+g(1893)](),this[g(527)+g(695)]?.[g(1375)+"nter"]();return}this[g(1758)+g(1853)+g(1017)](v),this[g(921)+g(760)]?.["resetEnd"+g(1835)+"fig"](),this[g(527)+"sCounter"]?.[g(1375)+g(697)]()},this.onclose=null,this[s(1022)]=null,this[s(610)+"e"]=null,this.onopen=null,this[s(1144)+s(1412)]=null,this[s(1429)+s(1595)]=null,this["onStopIm"+s(834)+"yReconnect"]=null,this[s(1630)+s(1590)]=this[s(1630)+s(1590)][s(1571)](this),this[s(1630)+"ffLine"]=this._handleOffLine[s(1571)](this),this[s(1534)+s(1624)]=this["_handleP"+s(1624)].bind(this),this[s(1534)+s(1151)]=this[s(1534)+s(1151)][s(1571)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1048)](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(514),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1641)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=n,w=Array[s(818)](f)?f:e[s(1043)](e[s(1368)],typeof f)?[f]:[];if(!w||e.uoEAO(0,w.length))throw new Error(e[s(1210)]);if(!e.ILkPo(wp,p))throw new Error(s(1094)+s(1130)+s(1397)+", WebSoc"+s(1759)+s(927)+"is undef"+s(453));Object[s(761)](this[s(1526)],n),this[s(921)+s(760)]=new el(w,this[s(1526)][s(1239)+"es"]),this["_pingLos"+s(695)]=new Ep(this[s(1526)][s(1394)+s(1766)]),this[s(1526)][s(1421)+s(805)]&&(this[s(1631)]=!0,this[s(1676)]()),this[s(1526)][s(1646)+"tworkChanged"]&&(this._isMiniTT||this._isMiniWX?this[s(1051)+s(911)+s(763)]():this[s(1332)+"er"]&&this["_initGlo"+s(1166)+s(1222)]())}[t(1630)+t(1590)](){let n=t,s={isJTj:function(d,f,p){return e[F(906)](d,f,p)},fefyN:n(1596)+n(426)};if(n(1900)===n(1900)){if(this[n(1526)]["disableA"+n(707)+n(793)]||this[n(658)+n(1112)])return;this[n(1705)+n(1412)]()}else this[n(1572)+n(1551)]=_0x39b75c,this[n(643)+n(1171)]=_0x14dff2,this[n(432)+n(595)]=_0x20c908,this[n(397)]=VxquRB.isJTj(_0x1bcc12,this[n(1572)+n(1551)],VxquRB[n(1107)])}[t(1630)+t(1078)](){let n=t,s={KJAOw:e.elJek};if(e.uJYgH(e[n(1503)],e.yhgWh)){this[n(534)+n(1441)+"t"]();let d=e.GhraM(oa,e[n(951)],{message:n(1257)+n(1118)+" reconnect"});this["onStopIm"+n(834)+n(855)+"ct"]&&this.onStopImmediatelyReconnect(d)}else this[n(527)+n(695)]?.[n(1340)](),this[n(1293)](n(962)+n(730)+"t",s.KJAOw),this[n(527)+"sCounter"]?.checkReachMaxCount()?this[n(1705)+n(1412)]():this[n(575)]()}[t(1050)+"balEvent"+t(1222)](){let n=t;this[n(1332)+"er"]&&window[n(1079)+"Listener"](e[n(1093)],this[n(1630)+"nLine"]),this._isBrowser&&window[n(1079)+"Listener"](e[n(1701)],this._handleOffLine),this[n(1332)+"er"]&&window["addEvent"+n(1222)]("pagehide",this[n(1534)+"ageHide"]),this._isBrowser&&window[n(1079)+n(1222)](n(1345),this._handlePageShow)}[t(1011)+t(1166)+t(1222)](){let n=t;this[n(1332)+"er"]&&window["removeEv"+n(1717)+n(538)](e[n(1093)],this[n(1630)+n(1590)]),this[n(1332)+"er"]&&window[n(839)+n(1717)+"ner"](e.pwvfa,this[n(1630)+n(1078)]),this[n(1332)+"er"]&&window["removeEv"+n(1717)+n(538)](n(796),this[n(1534)+n(1624)]),this[n(1332)+"er"]&&window[n(839)+n(1717)+"ner"](e[n(1588)],this["_handleP"+n(1151)])}[t(1534)+t(1624)](n){let s=t;!n[s(1271)+"d"]&&(this[s(1332)+"er"]&&window["removeEv"+s(1717)+s(538)](s(796),this["_handleP"+s(1624)]),this[s(1332)+"er"]&&window["removeEv"+s(1717)+s(538)](s(1345),this[s(1534)+"ageShow"]),this[s(908)]()),this[s(1332)+"er"]&&window[s(839)+s(1717)+s(538)](e[s(1093)],this[s(1630)+s(1590)]),this._isBrowser&&window[s(839)+"entListe"+s(538)](e[s(1701)],this[s(1630)+"ffLine"])}["_handleP"+t(1151)](n){let s=t;n[s(1271)+"d"]&&(this[s(1091)+s(652)]()&&(!this._ws||e[s(937)](this[s(634)][s(464)+"te"],this[s(1527)])||e[s(1189)](this[s(634)][s(464)+"te"],this[s(1229)+"NG"]))&&this[s(1630)+s(1590)](),this[s(1332)+"er"]&&window["addEvent"+s(1222)](e[s(1093)],this[s(1630)+s(1590)]),this[s(1332)+"er"]&&window[s(1079)+s(1222)](e[s(1701)],this[s(1630)+s(1078)]))}async[t(758)+t(1538)](n){let s=t,d={SxTEz:function(f,p){return e.nJxAo(f,p)},sRklB:function(f,p){return e[F(649)](f,p)},CiWCb:function(f,p){return e[F(1623)](f,p)}};if(e[s(1205)](e[s(976)],"RxoXq")){if(jXKIaD[s(1061)](_0x29243d,_0x337819))return jXKIaD[s(1810)](_0x17b5bd,_0x4e6577);if(_0x57f66a[s(753)](_0x516d87))return _0x165613[s(1040)](_0x3f3a3f);let f=_0x29242f(_0x42e07a);return jXKIaD[s(408)](f,_0x549f3e)&&(_0x2289af[s(588)](_0x2ca08a,f),_0x30a7a8.set(f,_0x25f5cf)),f}else{let{fpID:f,deviceID:p,bddID:w,ttwID:v,accessKey:g,aID:O,customParams:L={},enableAutoAck:U,enableQoS:$,QoSLevel:K,env:fe}=this[s(1526)],Ze,je,xa;this[s(1332)+"er"]||this._isMiniWX||this._isMiniTT?(Ze=location&&e[s(978)](s(613),location[s(1034)])?s(1132):e.vyZBt,je=n[s(1669)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),xa=/^wss(.*:\/\/)/.test(n)?n:""+Ze+je):e[s(850)]===e[s(850)]?(Ze=e.llXCM,je=n[s(1669)](/(^http)((?:[s]*:\/\/))/,""),xa=/(^ws)((?:[s]*:\/\/))/[s(1119)](je)?je:""+Ze+je):this.on(_0x3ca784,_0x1bb0e0);let dl=w?e.DSsSM:v?e.wtyal:"device_id",ll=w||v||p;if(e[s(1489)](!ll,!dl))throw new Error(e[s(1036)]);let eg=e[s(1754)](e[s(1734)],typeof L)?await L():L,tg=fe?yp(fe[s(1246)],fe[s(1462)]):{},pa=Object[s(761)]({device_platform:e[s(1159)],version_code:e.UgDNx,access_key:g,fpid:f,aid:O,[dl]:ll,xsack:U?1:0,xaack:U?1:0,xsqos:$?1:0,qos_level:$?K:void 0,qos_sdk_version:2,...tg},eg),ng=Object[s(566)](pa)[s(772)]((ga,ma)=>pa[ma]!==void 0?""+ga+(ga?"&":"?")+ma+"="+pa[ma]:ga,"");return xa+s(980)+ng}}async[t(1676)](){let n=t,s={ynrJF:function(d,f){return e[F(1219)](d,f)},ELxJX:function(d,f){return d<f},lPyCd:function(d,f){return e.AQCuj(d,f)},Nsrkj:function(d,f){return e[F(1406)](d,f)},LDqiG:function(d,f){return e[F(576)](d,f)},nNtTH:function(d,f){return e[F(629)](d,f)},BaKCC:function(d,f){return e[F(631)](d,f)},UnQuJ:e[n(905)],hjqVd:function(d,f){return e[n(1344)](d,f)},SnJob:function(d,f){return e[n(930)](d,f)},kzRjQ:function(d,f){return d<<f},FCsDT:function(d,f){return d&f},BBqCe:function(d,f){return e[n(1878)](d,f)},lgIRQ:function(d,f){return e[n(1341)](d,f)},zRoRi:function(d,f){return d|f},Oebud:function(d,f){return d|f},yYiOI:function(d,f){return e[n(997)](d,f)},EUHQG:function(d,f){return e[n(596)](d,f)},YxQVn:function(d,f,p){return d(f,p)},uAyfQ:e[n(1513)],oYLNn:e[n(1322)],oqDoY:function(d,f,p){return e[n(523)](d,f,p)},KIVmT:function(d,f){return e[n(518)](d,f)}};if(!(this[n(1676)+n(1812)]||this[n(658)+"osed"])){this[n(1676)+n(1812)]=!0;try{if(e[n(1486)]==="gIPzD")if(_0x3ccdc0=_0x43cfd6[n(1657)+"At"](_0x245ed7),aWdSFI[n(474)](_0x3fe71d,128))_0x281cab[_0x54ba62++]=_0x466ac6;else if(aWdSFI[n(1053)](_0x371a31,2048))_0x2d8985[_0x28989c++]=aWdSFI[n(1443)](_0x2e87fa,6)|192,_0x3062f6[_0x23b39a++]=63&_0x20546f|128;else if(aWdSFI[n(557)](aWdSFI[n(684)](64512,_0x30bd9d),55296)&&aWdSFI[n(787)](64512,_0x4a4678=_0x4470ac[n(1657)+"At"](aWdSFI[n(645)](_0x398f65,1)))===56320){let d=aWdSFI[n(774)][n(1761)]("|"),f=0;for(;;){switch(d[f++]){case"0":_0xabeb90=aWdSFI[n(1245)](aWdSFI[n(1072)](65536,aWdSFI[n(989)](1023&_0x56a454,10)),aWdSFI[n(920)](1023,_0x1c9578));continue;case"1":_0x234521[_0x345b40++]=aWdSFI.BBqCe(_0x3e9284,18)|240;continue;case"2":++_0x2cb658;continue;case"3":_0x46955c[_0x5ce179++]=aWdSFI[n(787)](aWdSFI[n(421)](_0x31d2f4,12),63)|128;continue;case"4":_0x1e21c0[_0x285ac5++]=aWdSFI[n(431)](aWdSFI[n(421)](_0x41f074,6)&63,128);continue;case"5":_0x2320e5[_0x21dc89++]=aWdSFI[n(920)](63,_0x442859)|128;continue}break}}else _0xb27efc[_0x5e1ec2++]=aWdSFI[n(431)](_0x470182>>12,224),_0x5187a8[_0x2b43f8++]=aWdSFI[n(508)](aWdSFI[n(684)](aWdSFI[n(1550)](_0x5ea096,6),63),128),_0x508388[_0x1c2523++]=aWdSFI[n(1562)](aWdSFI.LDqiG(63,_0x1e232f),128);else{let d=this[n(921)+n(760)]?.[n(845)+n(1750)+"ointReac"+n(1191)+"tries"](),{timeoutInterval:f}=this[n(1526)];if(d){let w=this["_endpoin"+n(760)]?.getCurrentEndpoint(),v=this["_endpoin"+n(760)]?.[n(1428)+n(1172)+n(1259)+n(433)+"unt"](),g=this["_endpoin"+n(760)]?.["getCurre"+n(628)+n(765)+n(1088)]();if(v)if(e.uoEAO(e[n(1179)],e[n(1454)]))this._intervalTimeoutId=null,this[n(1728)+"l"]=36e5,this[n(397)]=aWdSFI[n(1564)](_0x3bdd78,aWdSFI[n(1860)],aWdSFI[n(1173)]);else{let O=n(1274)+w+(n(882)+n(874)+"tries reached, w"+n(646)+n(1855)+n(1233))+v+(n(1039)+"y"),L=e.arlMX(at,e[n(542)],{message:O,code:en["MAX_RETR"+n(1633)+"R"]});this._debug(O),this["_dispatc"+n(1660)+n(1017)](L),this[n(1104)]=await this[n(758)+n(1538)](v),this[n(1055)](n(1274)+v+" "+g+n(427)),this[n(1114)+n(1537)+"rs"]()}else{let O=n(1274)+w+(n(882)+n(874)+"tries re"+n(1330));this[n(1055)](O),this[n(1758)+n(1660)+n(1017)](e.eDgtO(at,e[n(542)],{message:O,code:en.MAX_RETRIES_ERROR}));return}}else{let w=this[n(921)+n(760)]?.[n(1757)+n(628)+"ntAndUpd"+n(1706)](),v=this["_endpoin"+n(760)]?.[n(1757)+n(628)+n(765)+n(1088)]();this[n(1104)]=await this[n(758)+n(1538)](e[n(496)](w,"")),this[n(1055)](n(1274)+w+" "+v+n(427)),this[n(1114)+n(1537)+"rs"]()}if(this[n(1631)])this[n(1631)]=!1;else{let w=e[n(797)](oa,e[n(951)],{message:e[n(992)]});this[n(1144)+n(1412)]&&this["onStartR"+n(1412)](w)}let p=this[n(921)+n(760)]?.[n(1757)+"ntEndpoi"+n(765)+"ount"]()||0;e[n(1482)](p,1)&&await this[n(1371)](e.rlWxp(p,1)),this._debug("connecti"+n(1833)+this._url+(n(754)+n(1150))+this[n(1604)+"ls"]),this[n(634)]=mp({url:this[n(1104)],protocols:[this[n(1604)+"ls"]],headers:this._options[n(1816)+n(1616)+"s"][n(1185)+n(1147)]},this[n(1526)].ws),(this._isBrowser||this[n(1684)+"r"])&&this[n(634)]&&(this[n(634)][n(1418)+"pe"]=this[n(521)+n(1768)]),this[n(965)+n(1283)](),this[n(1676)+"ionTimeo"+n(637)]=setTimeout(this._onTimeout[n(1571)](this),f)}}catch(d){if(e[n(611)](e[n(1126)],e[n(1126)]))aWdSFI[n(1564)](_0x4dac70,_0x4e3975,96),aWdSFI[n(1218)](_0x24f812,_0x1711a3,aWdSFI[n(1026)](_0x3e5445,_0x2328fa));else throw this[n(1676)+"Lock"]=!1,d}}}[t(1183)+t(1399)](){let n=t,s={RgUPs:function(d,f){return e[F(1358)](d,f)},fpufu:function(d,f){return e[F(770)](d,f)},HXLJb:function(d,f){return e[F(1211)](d,f)}};if(e.BbZRz("LYFlz",n(1258)))return mVTzvS[n(1780)](-1,this.low)&&this.high===-1?_0x576284.fromBits(0,0,this[n(1790)]):this[n(1693)]===-1?_0x1f7212[n(1316)](0,mVTzvS.fpufu(this[n(794)],1),this[n(1790)]):_0x289664[n(1316)](mVTzvS[n(1365)](this[n(1693)],1),this[n(794)],this[n(1790)]);clearTimeout(this[n(1676)+n(561)+n(637)]),this[n(1676)+n(561)+n(637)]=null}[t(977)+"ngTimer"](){let n=t;e.sOGza(clearTimeout,this[n(1165)+n(698)+"Id"]),e[n(1389)](clearTimeout,this[n(1116)+n(954)+n(1374)]),this._pingPongTimeoutId=null,this[n(1116)+n(954)+"tId"]=null}_debug(...n){let s=t;e[s(1015)](e[s(573)],s(832))?this[s(1526)][s(553)]&&console[s(890)][s(1738)](console,[e[s(1597)],...n]):(_0x51a0bf&&_0x4589e1[s(1079)+"Listener"]("close",()=>_0x130c62()),_0x3a17cd&&_0x1c20a2[s(1079)+s(1222)](CEvnkD.QiPyW,()=>_0x3877e3()))}[t(1224)+t(480)+"e"](n){let s=t,d={XfktH:function(f,p){return e.aTsiD(f,p)}};if(e[s(1837)](s(429),e[s(979)])){let{initReconnectInterval:f,maxReconnectInterval:p,reconnectIntervalGrowFactor:w}=this[s(1526)],v=f*Math[s(1536)](w,e[s(800)](n,1));return e[s(1396)](v,p)?p:v}else{let f=_0x2a2db2[_0x5c0cbd];if(_0x149c19[_0x20d93b][s(1120)]!==4){let p=_0x1cbb4b[s(862)+"g"](0,rFhsCG.XfktH(4,_0x376964[_0x4b46f2][s(1120)])),w=p[s(1901)](f);_0x2d4b49=_0x59b360[s(1901)](w)}else _0x28c253=_0xfbc49b.concat(f)}}[t(575)](){let n=t;if(this._ws&&e[n(1203)](this[n(634)][n(464)+"te"],this[n(1229)+"NG"])){this[n(977)+n(1511)](),this[n(1165)+n(698)+"Id"]=setTimeout(this[n(575)][n(1571)](this),this[n(1526)][n(1774)+n(1783)]);return}if(!this[n(634)]||e.jAbWQ(this._ws[n(464)+"te"],this[n(1527)]))return void this[n(1705)+"econnect"]();this._ws&&this[n(634)][n(1890)]("hi"),this[n(1116)+n(954)+n(1374)]=e.jIZDg(setTimeout,this[n(1705)+n(1412)+n(960)][n(1571)](this),this._options[n(1024)+n(811)+n(1129)])}[t(1705)+"econnect"+t(960)](){let n=t,s={RgSGv:function(d,f){return e.UIkLN(d,f)},xuAym:function(d,f,p,w){return d(f,p,w)}};if(e.zbtVX(e.NOvHa,e[n(715)])){let d=new _0x182dfc(PZAUeA.RgSGv(_0x39a906,_0x534f62));return PZAUeA[n(1398)](_0x4f034c,_0x45710d,d,0),d}else this._pingLossCounter?.[n(1340)](),this[n(1293)](e[n(1074)],n(1138)),this["_pingLos"+n(695)]?.[n(1743)+n(1516)+"nt"]()?this[n(1705)+n(1412)]():this[n(575)]()}[t(1091)+t(652)](){let n=t;return this._isMiniTT||this[n(1131)+"X"]?this["_miniNav"+n(1347)+n(1854)]:(this._isBrowser||this[n(1684)+"r"])&&this[n(1526)][n(1646)+n(959)+"nged"]?navigator[n(807)]:!0}[t(1705)+"econnect"](){let n=t;!this[n(1091)+n(652)]()||this[n(658)+"osed"]||(this["_endpoin"+n(760)]?.[n(1764)+n(1835)+n(1893)](),this._pingLossCounter?.[n(1375)+n(697)](),this._ws?this[n(618)+n(1207)](1001,e[n(1622)],!0):this[n(1676)]())}[t(1051)+t(911)+t(763)](){let n=t;this._isMiniTT?tt[n(823)+"kStatusC"+n(940)](({isConnected:s})=>{let d=n;this["_miniNav"+d(1347)+d(1854)]=s,s?this[d(1630)+"nLine"]():this[d(1630)+"ffLine"]()}):this[n(1131)+"X"]&&wx[n(823)+"kStatusC"+n(940)](({isConnected:s})=>{let d=n;this[d(815)+d(1347)+d(1854)]=s,s?this["_handleO"+d(1590)]():this._handleOffLine()})}[t(1371)](n){let s={XjeeL:function(d,f,p){return d(f,p)}};return new Promise(d=>{let f=F;s[f(1201)](setTimeout,d,this[f(1224)+f(480)+"e"](n))})}[t(618)+t(1207)](n=1e3,s="",d=!1){let f=t;if(e.zFBKE(f(710),e[f(563)])){if(!this[f(634)])return;this[f(534)+f(1441)+"t"](n,s,d)}else _0x1fdaa1[f(689)](_0x100a44)}[t(1068)+"ut"](){let n=t,s=this[n(921)+"tManager"]?.[n(1757)+n(628)+"nt"]();this[n(1055)](n(1274)+s+n(882)),this[n(618)+"ect"](1001,e[n(1248)],!0)}[t(1777)](n){let s=t,d=e[s(1190)](Bt,n);if(this[s(634)]&&e[s(1720)](this._ws.readyState,this[s(1527)]))if(e[s(939)]("Safiu","eaNBC"))this._ws&&this[s(634)][s(1890)](d),this[s(1055)](e[s(1727)],n);else{let f=this[s(397)][s(1787)](this[s(559)]),p=_0x31ddeb.parse(f||"{}");return p[_0x3a7655]=void 0,this[s(397)][s(741)](this[s(559)],_0x1b3c0a[s(840)+"y"](p))}}["_removeW"+t(1537)+"rs"](){let n=t,s=e.rdbZc[n(1761)]("|"),d=0;for(;;){switch(s[d++]){case"0":this._ws[n(839)+n(1717)+"ner"](e[n(1195)],this[n(1387)+"ge"]);continue;case"1":this[n(634)]["removeEventListe"+n(538)](e[n(1153)],this[n(1874)]);continue;case"2":this[n(634)][n(839)+n(1717)+n(538)]("open",this._onOpen);continue;case"3":this._ws[n(839)+n(1717)+n(538)](e[n(542)],this[n(1638)]);continue;case"4":if(!this[n(634)])return;continue}break}}_addWsListeners(){let n=t,s={zdTXr:function(d,f){return e[F(744)](d,f)},zmgmg:function(d,f){return e[F(1637)](d,f)},yFsPl:function(d,f){return e[F(956)](d,f)},FAtOF:function(d,f){return e.VgxeK(d,f)},UacMd:function(d,f){return e[F(485)](d,f)},LSizh:function(d,f){return d<<f},cdqum:function(d,f){return e[F(1740)](d,f)},NbIpo:function(d,f){return d&f},ZAWRZ:function(d,f){return e[F(621)](d,f)},gNlPd:function(d,f){return d>=f},OkuLo:function(d,f){return e[F(825)](d,f)},FacUE:function(d,f){return d|f},wqHBu:function(d,f){return e[F(1455)](d,f)},DXkuP:function(d,f){return e[F(1135)](d,f)},sduzd:function(d,f){return e[F(1301)](d,f)},apjRf:function(d,f){return e[F(1135)](d,f)}};if(e.eTMOm(e[n(1006)],e.ltkfG)){let d=(n(1149)+"2")[n(1761)]("|"),f=0;for(;;){switch(d[f++]){case"0":if(!this[n(634)])return;continue;case"1":this[n(634)][n(1079)+n(1222)](e[n(1195)],this._onMessage);continue;case"2":this[n(634)][n(1079)+n(1222)](e[n(542)],this[n(1638)]);continue;case"3":this[n(634)][n(1079)+n(1222)](n(776),this._onOpen);continue;case"4":this[n(634)][n(1079)+"Listener"](e[n(1153)],this[n(1874)]);continue}break}}else{if(sGwdTM[n(1465)](_0x3b4ff0,_0x3c709b)<1)return"";let d="";for(let f=_0x491b7a;f<_0x5ddbf7;){let p=_0x2da75e[f++];if(sGwdTM[n(602)](p,127))d+=_0x1ca0c8[n(1501)+n(1639)](p);else if(sGwdTM[n(738)](p,192)&&sGwdTM.FAtOF(p,224))d+=_0x470404[n(1501)+n(1639)](sGwdTM[n(1087)](sGwdTM.LSizh(sGwdTM.cdqum(31,p),6),63&_0x52e7cc[f++]));else if(sGwdTM.yFsPl(p,224)&&sGwdTM[n(1241)](p,240))d+=_0x8e3e5[n(1501)+"Code"](sGwdTM.UacMd(sGwdTM[n(1617)](15,p)<<12|sGwdTM[n(1286)](63&_0x17c2a0[f++],6),63&_0x5ab57f[f++]));else if(sGwdTM[n(661)](p,240)){let w=sGwdTM[n(1087)](sGwdTM[n(1262)](sGwdTM.FacUE(sGwdTM[n(771)](7,p)<<18,sGwdTM[n(1664)](sGwdTM[n(1617)](63,_0x1d8d13[f++]),12)),sGwdTM[n(929)](63&_0x2ebf3a[f++],6)),sGwdTM[n(771)](63,_0x1ceecf[f++]))-65536;d+=_0x356a52[n(1501)+n(1639)](sGwdTM[n(1253)](55296,sGwdTM[n(1698)](w,10))),d+=_0x2a9897["fromChar"+n(1639)](sGwdTM[n(869)](56320,sGwdTM.NbIpo(1023,w)))}}return d}}[t(1484)+t(456)](n=1e3,s=""){let d=t;try{if(e[d(399)]!==d(1309))this._ws&&this[d(634)][d(908)](n,s);else return this[d(397)][d(1655)+"rageSync"]()}catch{}}[t(534)+"WebSocket"](n=1e3,s="",d=!1){let f=t;if(this["_clearPi"+f(1511)](),this[f(1183)+f(1399)](),this[f(1114)+f(1537)+"rs"](),this[f(1484)+f(456)](1e3,s),this[f(1676)+f(1812)]=!1,d&&this[f(1091)+f(652)]()&&!this[f(658)+f(1112)])if(e[f(1809)]!==e.fwztF)this[f(521)+f(1768)]=_0x5b7126,this[f(634)]&&(this[f(634)].binaryType=_0x3e3e95);else{if(this[f(921)+f(760)]?.[f(1743)+"chMaxTries"]()){let w=this[f(921)+"tManager"]?.[f(1757)+f(628)+"nt"]();this["_dispatchCloseEv"+f(1017)](e.NFjwD(ht,e.uJpxV,{code:1006,reason:f(1274)+w+(f(882)+f(874)+f(1402)+"ached"),wasClean:!0}))}else{let w=this[f(1526)][f(1431)+f(648)+"ptor"](n,s);this[f(1758)+f(1853)+f(1017)](e[f(636)](ht,e[f(1153)],{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this[f(1676)]()}return}this[f(1091)+"orOnline"]()||this[f(658)+f(1112)]?this[f(1758)+"hCloseEv"+f(1017)](e[f(584)](ht,f(908),{code:n,reason:e.HeeFM})):this[f(1758)+f(1853)+f(1017)](ht(e.uJpxV,{code:1006,reason:e[f(412)]})),this[f(634)]=null,this[f(921)+"tManager"]?.["resetEndpointCon"+f(1893)](),this[f(527)+f(695)]?.[f(1375)+f(697)]()}["_dispatc"+t(614)+"nt"](n){let s=t;this[s(1293)](e.kGXfE,n),this[s(489)]&&this[s(489)](n)}[t(1758)+"hMessage"+t(1456)](n){let s=t;this[s(1293)](e[s(1195)],n),this[s(610)+"e"]&&this[s(610)+"e"](n)}[t(1758)+"hAckMess"+t(1683)](n){let s=t;this[s(1293)](e[s(972)],n),this[s(1429)+s(1595)]&&this[s(1429)+s(1595)](n)}[t(1758)+t(1660)+t(1017)](n){let s=t,d={lMqPF:e[s(439)],AQGxi:e[s(605)]};if(e[s(1469)]!=="YRjkf")this[s(1293)](s(1697),n),this[s(1022)]&&this[s(1022)](n);else{let f={RAhIP:rWDZIj[s(926)],Jqnkm:rWDZIj[s(1238)]};_0x2277ee.r=p=>{let w=s;f[w(1136)]!=typeof _0x5d91d7&&_0x17d436[w(532)+w(461)]&&_0x3f1faf[w(1378)+w(1794)](p,_0x2a9471["toString"+w(461)],{value:w(1415)}),_0x1b59f8["definePr"+w(1794)](p,f[w(1675)],{value:!0})}}}[t(1758)+t(1853)+"ent"](n){let s=t;this[s(1293)](e[s(1153)],n),this[s(1707)]&&this[s(1707)](n)}get binaryType(){let n=t;return e[n(1231)](e[n(1543)],e[n(1543)])?this[n(1306)+"s"][this[n(1818)+n(1876)]]:this[n(634)]?this._ws.binaryType:this._binaryType}set binaryType(n){let s=t;this[s(521)+"ype"]=n,this[s(634)]&&(this._ws[s(1418)+"pe"]=n)}get[t(1294)+"nt"](){let n=t;if(e[n(786)](e[n(1711)],e.TWtkq))return this[n(921)+n(760)]?.[n(1757)+"ntEndpoi"+n(765)+n(1088)]()||0;this[n(1332)+"er"]&&_0x13a8e1[n(839)+"entListe"+n(538)](e[n(498)],this[n(1534)+n(1624)]),this[n(1332)+"er"]&&_0x4a2e3b[n(839)+n(1717)+n(538)](e[n(1588)],this[n(1534)+n(1151)]),this[n(908)]()}get[t(779)+t(1098)](){let n=t,s=this["_message"+n(524)].reduce((d,f)=>(d+=f&&f[n(509)+"th"]||0,d),0);return e[n(1395)](s,this[n(634)]?this[n(634)][n(779)+n(1098)]:0)}get[t(1364)+"ns"](){let n=t;return this[n(634)]?this[n(634)].extensions:""}get[t(1034)](){return this[t(634)]?this._ws.protocol:""}get[t(464)+"te"](){let n=t;return this[n(634)]?this._ws[n(464)+"te"]:this[n(1526)]["automati"+n(805)]?this[n(1229)+"NG"]:this[n(1385)]}get url(){let n=t;return this[n(634)]?this[n(634)][n(1416)]:this[n(1104)]}[t(908)](n=1e3,s){let d=t,f={BanCp:function(p,w){return p(w)},MZOHz:e[d(798)],PDTrb:e[d(1035)],HuoQj:d(962)+"e_timeout",SeoIZ:d(1138)};if(e[d(775)]===e[d(1680)]){this[d(977)+"ngTimer"](),this[d(1165)+"gTimeoutId"]=e.BBJov(_0x3d8d71,this[d(575)][d(1571)](this),this[d(1526)][d(1774)+d(1783)]);let p=()=>{let v=d;f[v(1331)](_0x31f89f,f[v(1600)]),this.off(f[v(746)],p),this[v(893)](f[v(548)],w)},w=()=>{let v=d;_0x3ca288(f[v(449)]),this[v(893)](f[v(746)],p),this[v(893)](f[v(548)],w)};this.on("ping_onc"+d(1612)+"s",p),this.on(e[d(1074)],w),this._ping()}else{let p=e[d(1363)][d(1761)]("|"),w=0;for(;;){switch(p[w++]){case"0":this["_QoSMana"+d(949)]?.[d(1209)]();continue;case"1":this[d(534)+"WebSocket"](n,s);continue;case"2":this[d(1183)+d(1399)]();continue;case"3":if(!this[d(634)])return void this[d(1055)](e.VjlEn);continue;case"4":this[d(658)+d(1112)]=!0;continue;case"5":this[d(1011)+d(1166)+d(1222)]();continue;case"6":this[d(977)+d(1511)]();continue;case"7":if(e[d(944)](this[d(634)].readyState,this[d(1385)])||e.MqeAg(this[d(634)][d(464)+"te"],this.CLOSING))return void this[d(1055)](e[d(1314)]);continue}break}}}async[t(1890)](n,s){let d=t;if(e[d(1134)](null,n))throw new Error(e[d(1585)]);e[d(1435)](e.aevpz,typeof n)&&(n=JSON[d(840)+"y"](n)),e[d(831)](e.UiFcK,typeof n)&&!e[d(1356)](n,ArrayBuffer)&&!(n[d(841)]&&e[d(1496)](n[d(841)],ArrayBuffer))&&(n=JSON[d(840)+"y"](n));let f=await il(n),p=e[d(1291)](_p,n),{method:w=0,service:v=this[d(1526)][d(1620)],logID:g=this[d(1526)]["logIDGen"+d(488)](),headers:O=this[d(1526)][d(792)],payloadEncoding:L=this[d(1526)][d(1453)+d(1156)],payloadType:U=this[d(1526)][d(442)+d(1768)],logIDNew:$=this._options[d(953)+"Config"][d(1305)+"toGenera"+d(1334)+"ew"]?e.cEyLT(i,this[d(1526)][d(953)+d(1846)][d(1476)]):""}=e[d(470)](s,{});if(!v)throw new Error(e[d(1223)]);let K={SeqID:ue[d(1499)+"er"](this[d(404)]++),LogID:ue[d(1499)+"er"](g),service:v,method:w,headers:O,payloadEncoding:e[d(1272)](L,Object)?L[d(1634)]?L[d(1634)]:"":L,payloadType:e.xikSQ(U,Object)?U.type?U.type:p:U||p,payload:f,LogIDNew:$},fe=e[d(1337)](Bt,K);return this[d(634)]&&this[d(634)][d(464)+"te"]===this.OPEN?(this[d(634)]&&this._ws[d(1890)](fe),this[d(1055)](d(1560),K)):e[d(1219)](this["_message"+d(524)].length,this[d(1526)][d(1532)+d(1873)+d(1255)])?(this["_message"+d(524)][d(689)](fe),this._debug(e[d(564)],K)):(this["_message"+d(524)][d(752)](),this[d(432)+d(524)][d(689)](fe)),{seqID:this[d(404)],logID:g,logIDNew:$}}async[t(1431)+"t"](n){let s=t,{url:d}=e[s(670)](n,{}),f=Array[s(818)](d)?d:e[s(1368)]==typeof d?[d]:[];n&&Object.assign(this._options,n),f&&f[s(1120)]?this[s(921)+s(760)]=new el(f,this[s(1526)][s(1239)+"es"]):this[s(921)+s(760)]?.[s(1764)+s(1835)+s(1893)](),this["_pingLos"+s(695)]?.[s(1375)+s(697)](this._options[s(1394)+s(1766)]),this["_readyCl"+s(1112)]=!1,this._ws&&e[s(713)](this[s(634)].readyState,this[s(1385)])?this._disconnect(1e3,e.tjLxp,!0):(this[s(1631)]=!0,this._connect())}async[t(1054)](){let n=t;if(!this[n(1676)+"Lock"]){let s=e[n(1603)][n(1761)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(658)+n(1112)]=!1;continue;case"1":this[n(527)+n(695)]?.[n(1375)+n(697)]();continue;case"2":this._isInit=!0;continue;case"3":this[n(921)+"tManager"]?.[n(1764)+n(1835)+n(1893)]();continue;case"4":this[n(1676)]();continue}break}}}[t(1079)+t(1222)](n,s){this.on(n,s)}[t(1049)+"Event"](n){let{type:s}=n;this.emit(s,n)}[t(839)+t(1717)+t(538)](n,s){this.off(n,s)}[t(1357)](){let n=t,s={VTFVh:function(d,f){return e[F(620)](d,f)},IjGJa:e[n(798)],fgLKW:n(962)+"e_success"};return new Promise((d,f)=>{let p=n,w={WVGeO:function(O,L){return O(L)},BXKXn:e[p(583)],TlMRA:p(962)+"e_success",eSrKR:p(962)+p(730)+"t"};this[p(977)+p(1511)](),this["_pingPon"+p(698)+"Id"]=e[p(859)](setTimeout,this[p(575)].bind(this),this[p(1526)].pingInterval);let v=()=>{let O=p;s[O(1300)](d,s[O(1772)]),this[O(893)](s[O(1235)],v),this.off(O(962)+O(730)+"t",g)},g=()=>{let O=p;w.WVGeO(f,w[O(1470)]),this.off(w[O(454)],v),this[O(893)](w.eSrKR,g)};this.on(p(962)+p(1612)+"s",v),this.on(p(962)+p(730)+"t",g),this[p(575)]()})}}})(),Le[N(651)+N(1282)]=Re[N(651)+N(1282)],Le[N(1504)+N(1267)]=Re[N(1504)+N(1267)],Le[N(447)+"e"]=Re[N(447)+"e"],Le[N(1456)]=Re.Event,Le[N(691)]=Re[N(691)],Le[N(1228)+N(686)+N(600)]=Re["Frontier"+N(686)+N(600)],Le[N(686)+N(600)]=Re[N(686)+N(600)],Le[N(638)+"t"]=Re[N(638)+"t"],Le["Reconnec"+N(1533)]=Re[N(1672)+"tEvent"],Le.createCloseEvent=Re["createCl"+N(1282)],Le[N(958)+N(1267)]=Re["createEr"+N(1267)],Le[N(1413)+N(1525)+"nt"]=Re[N(1413)+"ssageEvent"],Le.createOpenEvent=Re[N(1457)+N(788)],Le[N(781)+N(1217)+N(600)]=Re[N(781)+N(1217)+"vent"],Le.decodedFrame=Re[N(486)+N(690)],Le["encodeFr"+N(426)]=Re[N(1268)+N(426)];for(Mo in Re)["CustomCloseEvent","CustomErrorEvent","ErrorCode",N(1456),"FWS",N(1228)+N(686)+N(600),"MessageE"+N(600),N(638)+"t",N(1672)+N(1533),N(1372)+N(1282),N(958)+N(1267),N(1413)+N(1525)+"nt",N(1457)+N(788),N(781)+N(1217)+N(600),N(486)+N(690),N(1268)+N(426)].indexOf(Mo)===-1&&(Le[Mo]=Re[Mo]);var Mo;Object["definePr"+N(1794)](Le,N(749)+"le",{value:!0})});import{existsSync as cS,openSync as dS}from"node:fs";import{mkdir as lS}from"node:fs/promises";import{dirname as uS}from"node:path";import{fileURLToPath as fS}from"node:url";function xS(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Pd(t=X()){return cS(t.libEntry)?t.libEntry:fS(new URL("../index.ts",import.meta.url))}async function kx(t={}){let e=t.paths??X(),r=t.entryOverride??Pd(e),i=xS(e,process.env.COZE_BRIDGE_LOG_MODE);await lS(uS(i),{recursive:!0});let o=dS(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=nt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Xi]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return hS.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var hS,Xi,$o=Ye(()=>{"use strict";Wt();te();De();hS=G("spawn-daemon"),Xi="COZE_BRIDGE_DAEMON"});import{spawn as a1}from"node:child_process";import{mkdir as c1,unlink as d1,writeFile as l1}from"node:fs/promises";import{dirname as u1,join as f1}from"node:path";function jr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function h1(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${jr(r)}</key>
|
|
21
|
+
<string>${jr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function x1(t,e){return new Promise((r,i)=>{let o=a1(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 qr,es,ea,Gd,Zx=Ye(()=>{"use strict";te();qr=G("supervisor.launchd"),es="ai.coze.bridge",ea=x1,Gd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
27
27
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
28
28
|
<plist version="1.0">
|
|
29
29
|
<dict>
|
|
30
30
|
<key>Label</key>
|
|
31
|
-
<string>${
|
|
31
|
+
<string>${es}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${jr(t.nodeBin)}</string>
|
|
35
|
+
<string>${jr(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>${jr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${jr(t.logFile)}</string>${h1(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return f1(t.homeDir,"Library","LaunchAgents",`${es}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await c1(u1(i),{recursive:!0}),await l1(i,this.renderConfig(t),"utf8"),qr.info("plist written",{plistPath:i,activate:r}),!r)return;await ea("launchctl",["unload","-w",i]).catch(c=>qr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ea("launchctl",["load","-w",i]),qr.info("launchd job loaded",{label:es});let o=process.getuid?.()??0;await ea("launchctl",["kickstart","-k",`gui/${o}/${es}`]),qr.info("launchd job kickstarted",{label:es,uid:o})},async uninstall(t){let e=this.configPath(t);await ea("launchctl",["unload","-w",e]).catch(r=>qr.warn("launchctl unload failed (ignored)",{err:String(r)})),await d1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),qr.info("launchd job removed",{plistPath:e})}}});import{spawn as p1}from"node:child_process";import{mkdir as g1,unlink as m1,writeFile as w1}from"node:fs/promises";import{dirname as _1,join as Yx}from"node:path";function na(t,e){return t.isRoot?e:["--user",...e]}function E1(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function ra(t,e){return new Promise((r,i)=>{let o=p1(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 ta,Hr,y1,qd,Xx=Ye(()=>{"use strict";te();ta=G("supervisor.systemd"),Hr="coze-bridge.service",y1="/etc/systemd/system";qd={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
|
+
${E1(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Yx(y1,Hr):Yx(t.homeDir,".config","systemd","user",Hr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await g1(_1(i),{recursive:!0}),await w1(i,this.renderConfig(t),"utf8"),ta.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await ra("systemctl",na(t,["daemon-reload"])),await ra("systemctl",na(t,r?["enable","--now",Hr]:["enable",Hr])),ta.info("systemd unit enabled",{unitName:Hr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await ra("systemctl",na(t,["disable","--now",Hr])).catch(r=>ta.warn("systemctl disable failed (ignored)",{err:String(r)})),await m1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ra("systemctl",na(t,["daemon-reload"])).catch(()=>{}),ta.info("systemd unit removed",{unitPath:e})}}});import{spawn as b1}from"node:child_process";import{join as v1}from"node:path";function Qx(t,e){return new Promise((r,i)=>{let o=b1(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 jd,ia,Hd,ep=Ye(()=>{"use strict";te();jd=G("supervisor.taskscheduler"),ia="CozeBridge",Hd={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,48 +86,48 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return bS(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await ep("schtasks",["/Create","/SC","ONLOGON","/TN",aa,"/TR",r,"/RU",t.userName,"/F"]),Wd.info("task scheduler entry created",{task:aa,logFile:t.logFile})},async uninstall(t){await ep("schtasks",["/Delete","/TN",aa,"/F"]).catch(e=>Wd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Wd.info("task scheduler entry removed",{task:aa})}}});var np={};Ea(np,{buildContext:()=>CS,getSupervisor:()=>IS,launchdSupervisor:()=>jd,systemdSupervisor:()=>qd,taskSchedulerSupervisor:()=>Kd});import{homedir as vS,userInfo as SS}from"node:os";function IS(t=process.platform){switch(t){case"darwin":return jd;case"linux":return qd;case"win32":return Kd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function TS(){let t={};for(let e of AS){let r=process.env[e];r&&(t[e]=r)}return t}function CS(){let t=X();return{nodeBin:process.execPath,entry:Ld(t),logFile:t.logFile,homeDir:vS(),userName:SS().username,isRoot:process.getuid?.()===0,env:TS()}}var AS,rp=Ye(()=>{"use strict";ke();Zo();Yh();Qh();tp();AS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();on();var vl=G("acp-installer-warmup"),Cg=["claude-code","codex"];async function Sl(t={}){let e=t.ensure??sr,i=(await Promise.allSettled(Cg.map(async o=>{let c=await e(o);vl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&vl.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))})}an();te();import{readdir as Gg}from"node:fs/promises";import{mkdir as kl,readFile as zg,writeFile as Dl}from"node:fs/promises";import{join as Ca}from"node:path";var Ug={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function cr(t,e,r){await kl(t,{recursive:!0});let i=Ug[e],o=Ca(t,i);return await Dl(o,r??"","utf8"),o}async function Ra(t,e,r){let i=Ca(t,".claude");await kl(i,{recursive:!0});let o=Ca(i,"settings.local.json"),c={};try{let u=await zg(o,"utf8"),x=JSON.parse(u);typeof x=="object"&&x!==null&&!Array.isArray(x)&&(c=x)}catch{}let d=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")d.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");d.defaultMode===void 0&&(d.defaultMode=r)}return c.permissions=d,await Dl(o,JSON.stringify(c,null,2),"utf8"),o}var $e=G("agent-detail-sync"),Hg=6e4,jg=5*6e4,hs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Gg(r)}catch(o){$e.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}$e.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ne(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){$e.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){$e.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),$e.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){$e.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){$e.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ne(e,this.opts.paths);if(!i){$e.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(x){$e.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let p=this.retryQueue.get(e),g=p?Math.min(p.currentDelay*2,jg):Hg;this.retryQueue.set(e,{dueAt:Date.now()+g,currentDelay:g});return}if(o.agentId&&o.agentId!==e){$e.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!1;o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,d=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?($e.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&$e.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){$e.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),$e.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),$e.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):d&&(await cr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Xf=Gt(lu(),1);import{lstat as jc,mkdir as qc,readFile as Vf,readdir as v_,rm as S_,stat as I_,writeFile as Wc}from"node:fs/promises";import{dirname as A_,join as Ot,normalize as T_,relative as Vc,resolve as Kc,sep as Jf}from"node:path";import{Readable as Zf}from"node:stream";import{pipeline as Yf}from"node:stream/promises";import um from"events";import et from"fs";import{EventEmitter as Cc}from"node:events";import Wu from"node:stream";import{StringDecoder as fm}from"node:string_decoder";import Vu from"node:path";import yr from"node:fs";import{dirname as Im,parse as Am}from"path";import{EventEmitter as Lm}from"events";import dc from"assert";import{Buffer as Gn}from"buffer";import*as pu from"zlib";import Nm from"zlib";import{posix as xr}from"node:path";import{basename as cw}from"node:path";import Ks from"fs";import kt from"fs";import bu from"path";import{win32 as yw}from"node:path";import Ru from"path";import lf from"node:fs";import Bw from"node:assert";import{randomBytes as uf}from"node:crypto";import ne from"node:fs";import Pe from"node:path";import ff from"fs";import to from"node:fs";import bi from"node:path";import st from"node:fs";import qw from"node:fs/promises";import Js from"node:path";import{join as vf}from"node:path";import it from"node:fs";import Af from"node:path";var dm=Object.defineProperty,lm=(t,e)=>{for(var r in e)dm(t,r,{get:e[r],enumerable:!0})},uu=typeof process=="object"&&process?process:{stdout:null,stderr:null},xm=t=>!!t&&typeof t=="object"&&(t instanceof qn||t instanceof Wu||hm(t)||pm(t)),hm=t=>!!t&&typeof t=="object"&&t instanceof Cc&&typeof t.pipe=="function"&&t.pipe!==Wu.Writable.prototype.pipe,pm=t=>!!t&&typeof t=="object"&&t instanceof Cc&&typeof t.write=="function"&&typeof t.end=="function",Ht=Symbol("EOF"),jt=Symbol("maybeEmitEnd"),dn=Symbol("emittedEnd"),_s=Symbol("emittingEnd"),si=Symbol("emittedError"),ys=Symbol("closed"),fu=Symbol("read"),Es=Symbol("flush"),xu=Symbol("flushChunk"),gt=Symbol("encoding"),fr=Symbol("decoder"),Me=Symbol("flowing"),oi=Symbol("paused"),mr=Symbol("resume"),Be=Symbol("buffer"),Ve=Symbol("pipes"),Fe=Symbol("bufferLength"),Na=Symbol("bufferPush"),bs=Symbol("bufferShift"),Ke=Symbol("objectMode"),be=Symbol("destroyed"),Ma=Symbol("error"),Ba=Symbol("emitData"),hu=Symbol("emitEnd"),Fa=Symbol("emitEnd2"),Tt=Symbol("async"),za=Symbol("abort"),vs=Symbol("aborted"),ai=Symbol("signal"),Pn=Symbol("dataListeners"),rt=Symbol("discarded"),ci=t=>Promise.resolve().then(t),gm=t=>t(),mm=t=>t==="end"||t==="finish"||t==="prefinish",wm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,_m=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Ku=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[mr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ym=class extends Ku{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)}},Em=t=>!!t.objectMode,bm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",qn=class extends Cc{[Me]=!1;[oi]=!1;[Ve]=[];[Be]=[];[Ke];[gt];[Tt];[fr];[Ht]=!1;[dn]=!1;[_s]=!1;[ys]=!1;[si]=null;[Fe]=0;[be]=!1;[ai];[vs]=!1;[Pn]=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");Em(e)?(this[Ke]=!0,this[gt]=null):bm(e)?(this[gt]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[gt]=null),this[Tt]=!!e.async,this[fr]=this[gt]?new fm(this[gt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Be]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ve]});let{signal:r}=e;r&&(this[ai]=r,r.aborted?this[za]():r.addEventListener("abort",()=>this[za]()))}get bufferLength(){return this[Fe]}get encoding(){return this[gt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Tt]}set async(t){this[Tt]=this[Tt]||!!t}[za](){this[vs]=!0,this.emit("abort",this[ai]?.reason),this.destroy(this[ai]?.reason)}get aborted(){return this[vs]}set aborted(t){}write(t,e,r){if(this[vs])return!1;if(this[Ht])throw new Error("write after end");if(this[be])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[Tt]?ci:gm;if(!this[Ke]&&!Buffer.isBuffer(t)){if(_m(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(wm(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[Me]&&this[Fe]!==0&&this[Es](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):t.length?(typeof t=="string"&&!(e===this[gt]&&!this[fr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[gt]&&(t=this[fr].write(t)),this[Me]&&this[Fe]!==0&&this[Es](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):(this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me])}read(t){if(this[be])return null;if(this[rt]=!1,this[Fe]===0||t===0||t&&t>this[Fe])return this[jt](),null;this[Ke]&&(t=null),this[Be].length>1&&!this[Ke]&&(this[Be]=[this[gt]?this[Be].join(""):Buffer.concat(this[Be],this[Fe])]);let e=this[fu](t||null,this[Be][0]);return this[jt](),e}[fu](t,e){if(this[Ke])this[bs]();else{let r=e;t===r.length||t===null?this[bs]():typeof r=="string"?(this[Be][0]=r.slice(t),e=r.slice(0,t),this[Fe]-=t):(this[Be][0]=r.subarray(t),e=r.subarray(0,t),this[Fe]-=t)}return this.emit("data",e),!this[Be].length&&!this[Ht]&&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[Ht]=!0,this.writable=!1,(this[Me]||!this[oi])&&this[jt](),this}[mr](){this[be]||(!this[Pn]&&!this[Ve].length&&(this[rt]=!0),this[oi]=!1,this[Me]=!0,this.emit("resume"),this[Be].length?this[Es]():this[Ht]?this[jt]():this.emit("drain"))}resume(){return this[mr]()}pause(){this[Me]=!1,this[oi]=!0,this[rt]=!1}get destroyed(){return this[be]}get flowing(){return this[Me]}get paused(){return this[oi]}[Na](t){this[Ke]?this[Fe]+=1:this[Fe]+=t.length,this[Be].push(t)}[bs](){return this[Ke]?this[Fe]-=1:this[Fe]-=this[Be][0].length,this[Be].shift()}[Es](t=!1){do;while(this[xu](this[bs]())&&this[Be].length);!t&&!this[Be].length&&!this[Ht]&&this.emit("drain")}[xu](t){return this.emit("data",t),this[Me]}pipe(t,e){if(this[be])return t;this[rt]=!1;let r=this[dn];return e=e||{},t===uu.stdout||t===uu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ve].push(e.proxyErrors?new ym(this,t,e):new Ku(this,t,e)),this[Tt]?ci(()=>this[mr]()):this[mr]()),t}unpipe(t){let e=this[Ve].find(r=>r.dest===t);e&&(this[Ve].length===1?(this[Me]&&this[Pn]===0&&(this[Me]=!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[Pn]++,!this[Ve].length&&!this[Me]&&this[mr]();else if(t==="readable"&&this[Fe]!==0)super.emit("readable");else if(mm(t)&&this[dn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[si]){let i=e;this[Tt]?ci(()=>i.call(this,this[si])):i.call(this,this[si])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Pn]=this.listeners("data").length,this[Pn]===0&&!this[rt]&&!this[Ve].length&&(this[Me]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Pn]=0,!this[rt]&&!this[Ve].length&&(this[Me]=!1)),e}get emittedEnd(){return this[dn]}[jt](){!this[_s]&&!this[dn]&&!this[be]&&this[Be].length===0&&this[Ht]&&(this[_s]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ys]&&this.emit("close"),this[_s]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==be&&this[be])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[Tt]?(ci(()=>this[Ba](r)),!0):this[Ba](r);if(t==="end")return this[hu]();if(t==="close"){if(this[ys]=!0,!this[dn]&&!this[be])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[si]=r,super.emit(Ma,r);let o=!this[ai]||this.listeners("error").length?super.emit("error",r):!1;return this[jt](),o}else if(t==="resume"){let o=super.emit("resume");return this[jt](),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[jt](),i}[Ba](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[jt](),e}[hu](){return this[dn]?!1:(this[dn]=!0,this.readable=!1,this[Tt]?(ci(()=>this[Fa]()),!0):this[Fa]())}[Fa](){if(this[fr]){let e=this[fr].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[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[gt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(be,()=>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[Ht])return e();let i,o,c=p=>{this.off("data",d),this.off("end",u),this.off(be,x),e(),o(p)},d=p=>{this.off("error",c),this.off("end",u),this.off(be,x),this.pause(),i({value:p,done:!!this[Ht]})},u=()=>{this.off("error",c),this.off("data",d),this.off(be,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,g)=>{o=g,i=p,this.once(be,x),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ma,e),this.off(be,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(Ma,e),this.once(be,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[be])return t?this.emit("error",t):this.emit(be),this;this[be]=!0,this[rt]=!0,this[Be].length=0,this[Fe]=0;let e=this;return typeof e.close=="function"&&!this[ys]&&e.close(),t?this.emit("error",t):this.emit(be),this}static get isStream(){return xm}},vm=et.writev,_n=Symbol("_autoClose"),yt=Symbol("_close"),di=Symbol("_ended"),ce=Symbol("_fd"),Ua=Symbol("_finished"),$t=Symbol("_flags"),Ga=Symbol("_flush"),ac=Symbol("_handleChunk"),cc=Symbol("_makeBuf"),yi=Symbol("_mode"),Ss=Symbol("_needDrain"),br=Symbol("_onerror"),vr=Symbol("_onopen"),Ha=Symbol("_onread"),wr=Symbol("_onwrite"),yn=Symbol("_open"),_t=Symbol("_path"),hn=Symbol("_pos"),Ct=Symbol("_queue"),_r=Symbol("_read"),ja=Symbol("_readSize"),Kt=Symbol("_reading"),li=Symbol("_remain"),qa=Symbol("_size"),Ls=Symbol("_write"),On=Symbol("_writing"),Ns=Symbol("_defaultFlag"),Un=Symbol("_errored"),Rc=class extends qn{[Un]=!1;[ce];[_t];[ja];[Kt]=!1;[qa];[li];[_n];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[Un]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[_t]=t,this[ja]=e.readSize||16*1024*1024,this[Kt]=!1,this[qa]=typeof e.size=="number"?e.size:1/0,this[li]=this[qa],this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[_r]():this[yn]()}get fd(){return this[ce]}get path(){return this[_t]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[yn](){et.open(this[_t],"r",(t,e)=>this[vr](t,e))}[vr](t,e){t?this[br](t):(this[ce]=e,this.emit("open",e),this[_r]())}[cc](){return Buffer.allocUnsafe(Math.min(this[ja],this[li]))}[_r](){if(!this[Kt]){this[Kt]=!0;let t=this[cc]();if(t.length===0)return process.nextTick(()=>this[Ha](null,0,t));et.read(this[ce],t,0,t.length,null,(e,r,i)=>this[Ha](e,r,i))}}[Ha](t,e,r){this[Kt]=!1,t?this[br](t):this[ac](e,r)&&this[_r]()}[yt](){if(this[_n]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[br](t){this[Kt]=!0,this[yt](),this.emit("error",t)}[ac](t,e){let r=!1;return this[li]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[li]<=0)&&(r=!1,this[yt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[_r](),!1;case"error":return this[Un]?!1:(this[Un]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Sm=class extends Rc{[yn](){let t=!0;try{this[vr](null,et.openSync(this[_t],"r")),t=!1}finally{t&&this[yt]()}}[_r](){let t=!0;try{if(!this[Kt]){this[Kt]=!0;do{let e=this[cc](),r=e.length===0?0:et.readSync(this[ce],e,0,e.length,null);if(!this[ac](r,e))break}while(!0);this[Kt]=!1}t=!1}finally{t&&this[yt]()}}[yt](){if(this[_n]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.closeSync(t),this.emit("close")}}},Zs=class extends um{readable=!1;writable=!0;[Un]=!1;[On]=!1;[di]=!1;[Ct]=[];[Ss]=!1;[_t];[yi];[_n];[ce];[Ns];[$t];[Ua]=!1;[hn];constructor(t,e){e=e||{},super(e),this[_t]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[yi]=e.mode===void 0?438:e.mode,this[hn]=typeof e.start=="number"?e.start:void 0,this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[hn]!==void 0?"r+":"w";this[Ns]=e.flags===void 0,this[$t]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[yn]()}emit(t,...e){if(t==="error"){if(this[Un])return!1;this[Un]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[_t]}[br](t){this[yt](),this[On]=!0,this.emit("error",t)}[yn](){et.open(this[_t],this[$t],this[yi],(t,e)=>this[vr](t,e))}[vr](t,e){this[Ns]&&this[$t]==="r+"&&t&&t.code==="ENOENT"?(this[$t]="w",this[yn]()):t?this[br](t):(this[ce]=e,this.emit("open",e),this[On]||this[Ga]())}end(t,e){return t&&this.write(t,e),this[di]=!0,!this[On]&&!this[Ct].length&&typeof this[ce]=="number"&&this[wr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[di]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[On]||this[Ct].length?(this[Ct].push(t),this[Ss]=!0,!1):(this[On]=!0,this[Ls](t),!0)}[Ls](t){et.write(this[ce],t,0,t.length,this[hn],(e,r)=>this[wr](e,r))}[wr](t,e){t?this[br](t):(this[hn]!==void 0&&typeof e=="number"&&(this[hn]+=e),this[Ct].length?this[Ga]():(this[On]=!1,this[di]&&!this[Ua]?(this[Ua]=!0,this[yt](),this.emit("finish")):this[Ss]&&(this[Ss]=!1,this.emit("drain"))))}[Ga](){if(this[Ct].length===0)this[di]&&this[wr](null,0);else if(this[Ct].length===1)this[Ls](this[Ct].pop());else{let t=this[Ct];this[Ct]=[],vm(this[ce],t,this[hn],(e,r)=>this[wr](e,r))}}[yt](){if(this[_n]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},$u=class extends Zs{[yn](){let t;if(this[Ns]&&this[$t]==="r+")try{t=et.openSync(this[_t],this[$t],this[yi])}catch(e){if(e?.code==="ENOENT")return this[$t]="w",this[yn]();throw e}else t=et.openSync(this[_t],this[$t],this[yi]);this[vr](null,t)}[yt](){if(this[_n]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.closeSync(t),this.emit("close")}}[Ls](t){let e=!0;try{this[wr](null,et.writeSync(this[ce],t,0,t.length,this[hn])),e=!1}finally{if(e)try{this[yt]()}catch{}}}},Tm=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"]]),Cm=t=>!!t.sync&&!!t.file,Rm=t=>!t.sync&&!!t.file,km=t=>!!t.sync&&!t.file,Dm=t=>!t.sync&&!t.file,Pm=t=>!!t.file,Om=t=>Tm.get(t)||t,kc=(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},Ri=(t,e,r,i,o)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let x=kc(c);if(o?.(x,d),Cm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,d)}else if(Rm(x)){let p=e(x,d);return u?p.then(()=>u(),u):p}else if(km(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,d)}else if(Dm(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Mm=Nm.constants||{ZLIB_VERNUM:4736},Pt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Mm)),Bm=Gn.concat,gu=Object.getOwnPropertyDescriptor(Gn,"concat"),Fm=t=>t,Wa=gu?.writable===!0||gu?.set!==void 0?t=>{Gn.concat=t?Fm:Bm}:t=>{},Hn=Symbol("_superWrite"),Is=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"}},Ka=Symbol("flushFlag"),Dc=class extends qn{#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 pu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new pu[e](t)}catch(r){throw new Is(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 Is(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return dc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Gn.alloc(0),{[Ka]: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}[Hn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Gn.from(t,e)),this.#e)return;dc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Wa(!0);let d;try{let x=typeof t[Ka]=="number"?t[Ka]:this.#r;d=this.#t._processChunk(t,x),Wa(!1)}catch(x){Wa(!1),this.#o(new Is(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 Is(x,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let x=d[0];u=this[Hn](Gn.from(x));for(let p=1;p<d.length;p++)u=this[Hn](d[p])}else u=this[Hn](Gn.from(d));return r&&r(),u}},Ju=class extends Dc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Pt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Pt.Z_FINISH,t.fullFlushFlag=Pt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Pt.Z_SYNC_FLUSH),dc(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)}}}},zm=class extends Ju{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Hn](t){return this.#e?(this.#e=!1,t[9]=255,super[Hn](t)):super[Hn](t)}},Um=class extends Ju{constructor(t){super(t,"Unzip")}},Zu=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Pt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Pt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Pt.BROTLI_OPERATION_FLUSH,super(t,e)}},Gm=class extends Zu{constructor(t){super(t,"BrotliCompress")}},Hm=class extends Zu{constructor(t){super(t,"BrotliDecompress")}},Yu=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Pt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Pt.ZSTD_e_end,t.fullFlushFlag=Pt.ZSTD_e_flush,super(t,e)}},jm=class extends Yu{constructor(t){super(t,"ZstdCompress")}},qm=class extends Yu{constructor(t){super(t,"ZstdDecompress")}},Wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?$m(t,e):Km(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Km=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},$m=(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]=Xu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Qu(o))}},Vm=t=>{let e=t[0],r=e===128?Zm(t.subarray(1,t.length)):e===255?Jm(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},Jm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=Xu(c):c===0?d=c:(i=!0,d=Qu(c)),d!==0&&(r-=d*Math.pow(256,e-o-1))}return r},Zm=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},Xu=t=>(255^t)&255,Qu=t=>(255^t)+1&255,Ym={};lm(Ym,{code:()=>Pc,isCode:()=>Ms,isName:()=>Xm,name:()=>Ys,normalFsTypes:()=>ef});var Ms=t=>Ys.has(t),Xm=t=>Pc.has(t),ef=new Set(["0","","1","2","3","4","5","6","7","D"]),Ys=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"]]),Pc=new Map(Array.from(Ys).map(t=>[t[1],t[0]])),jn=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");let o=Ln(t,e+156,1),c=ef.has(o),d=c?r:void 0,u=c?i:void 0;if(this.path=d?.path??Ln(t,e,100),this.mode=d?.mode??u?.mode??pn(t,e+100,8),this.uid=d?.uid??u?.uid??pn(t,e+108,8),this.gid=d?.gid??u?.gid??pn(t,e+116,8),this.size=d?.size??u?.size??pn(t,e+124,12),this.mtime=d?.mtime??u?.mtime??$a(t,e+136,12),this.cksum=pn(t,e+148,12),u&&this.#n(u,!0),d&&this.#n(d),Ms(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Ln(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=d?.uname??u?.uname??Ln(t,e+265,32),this.gname=d?.gname??u?.gname??Ln(t,e+297,32),this.devmaj=d?.devmaj??u?.devmaj??pn(t,e+329,8)??0,this.devmin=d?.devmin??u?.devmin??pn(t,e+337,8)??0,t[e+475]!==0){let p=Ln(t,e+345,155);this.path=p+"/"+this.path}else{let p=Ln(t,e+345,130);p&&(this.path=p+"/"+this.path),this.atime=r?.atime??i?.atime??$a(t,e+476,12),this.ctime=r?.ctime??i?.ctime??$a(t,e+488,12)}let x=256;for(let p=e;p<e+148;p++)x+=t[p];for(let p=e+156;p<e+512;p++)x+=t[p];this.cksumValid=x===this.cksum,this.cksum===void 0&&x===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=Qm(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Nn(t,e,100,o)||this.needPax,this.needPax=gn(t,e+100,8,this.mode)||this.needPax,this.needPax=gn(t,e+108,8,this.uid)||this.needPax,this.needPax=gn(t,e+116,8,this.gid)||this.needPax,this.needPax=gn(t,e+124,12,this.size)||this.needPax,this.needPax=Va(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Nn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Nn(t,e+265,32,this.uname)||this.needPax,this.needPax=Nn(t,e+297,32,this.gname)||this.needPax,this.needPax=gn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=gn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Nn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Nn(t,e+345,155,c)||this.needPax:(this.needPax=Nn(t,e+345,130,c)||this.needPax,this.needPax=Va(t,e+476,12,this.atime)||this.needPax,this.needPax=Va(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,gn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ys.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Pc.get(t));if(Ms(e)||e==="Unsupported")this.#e=e;else if(Ms(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Qm=(t,e)=>{let r=t,i="",o,c=xr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=xr.dirname(r),r=xr.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=xr.join(xr.basename(i),r),i=xr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Ln=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),$a=(t,e,r)=>ew(pn(t,e,r)),ew=t=>t===void 0?void 0:new Date(t*1e3),pn=(t,e,r)=>Number(t[e])&128?Vm(t.subarray(e,e+r)):nw(t,e,r),tw=t=>isNaN(t)?void 0:t,nw=(t,e,r)=>tw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),rw={12:8589934591,8:2097151},gn=(t,e,r,i)=>i===void 0?!1:i>rw[r]||i<0?(Wm(i,t.subarray(e,e+r)),!0):(iw(t,e,r,i),!1),iw=(t,e,r,i)=>t.write(sw(i,r),e,r,"ascii"),sw=(t,e)=>ow(Math.floor(t).toString(8),e),ow=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Va=(t,e,r,i)=>i===void 0?!1:gn(t,e,r,i.getTime()/1e3),aw=new Array(156).join("\0"),Nn=(t,e,r,i)=>i===void 0?!1:(t.write(i+aw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Ws=class tf{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 jn({path:("PaxHeader/"+cw(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),
|
|
91
|
-
`).reduce(uw,Object.create(null)),uw=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),d=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},fw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=fw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),xw=class extends qn{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))))}},Xs=(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))},hw=1024*1024,lc=Buffer.from([31,139]),uc=Buffer.from([40,181,47,253]),pw=Math.max(lc.length,uc.length),ct=Symbol("state"),Mn=Symbol("writeEntry"),qt=Symbol("readEntry"),Ja=Symbol("nextEntry"),mu=Symbol("processEntry"),Rt=Symbol("extendedHeader"),ui=Symbol("globalExtendedHeader"),ln=Symbol("meta"),wu=Symbol("emitMeta"),he=Symbol("buffer"),Wt=Symbol("queue"),un=Symbol("ended"),Za=Symbol("emittedEnd"),Bn=Symbol("emit"),Ae=Symbol("unzip"),As=Symbol("consumeChunk"),Ts=Symbol("consumeChunkSub"),Ya=Symbol("consumeBody"),_u=Symbol("consumeMeta"),yu=Symbol("consumeHeader"),fi=Symbol("consuming"),Xa=Symbol("bufferConcat"),Cs=Symbol("maybeEnd"),hr=Symbol("writing"),fn=Symbol("aborted"),Rs=Symbol("onDone"),Fn=Symbol("sawValidEntry"),ks=Symbol("sawNullBlock"),Ds=Symbol("sawEOF"),Eu=Symbol("closeStream"),gw=()=>!0,Ci=class extends Lm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[he];[qt];[Mn];[ct]="begin";[ln]="";[Rt];[ui];[un]=!1;[Ae];[fn]=!1;[Fn];[ks]=!1;[Ds]=!1;[hr]=!1;[fi]=!1;[Za]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Rs,()=>{(this[ct]==="begin"||this[Fn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Rs,t.ondone):this.on(Rs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||hw,this.filter=typeof t.filter=="function"?t.filter:gw;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[Eu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Xs(this,t,e,r)}[yu](t,e){this[Fn]===void 0&&(this[Fn]=!1);let r;try{r=new jn(t,e,this[Rt],this[ui])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[ks]?(this[Ds]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Bn]("eof")):(this[ks]=!0,this[Bn]("nullBlock"));else if(this[ks]=!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[Mn]=new xw(r,this[Rt],this[ui]);if(!this[Fn])if(o.remain){let c=()=>{o.invalid||(this[Fn]=!0)};o.on("end",c)}else this[Fn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Bn]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[ln]="",o.on("data",c=>this[ln]+=c),this[ct]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Bn]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[qt]?this[Wt].push(o):(this[Wt].push(o),this[Ja]())))}}}[Eu](){queueMicrotask(()=>this.emit("close"))}[mu](t){let e=!0;if(!t)this[qt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[qt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ja]()),e=!1);return e}[Ja](){do;while(this[mu](this[Wt].shift()));if(this[Wt].length===0){let t=this[qt];!t||t.flowing||t.size===t.remain?this[hr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ya](t,e){let r=this[Mn];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[Mn]=void 0,r.end()),o.length}[_u](t,e){let r=this[Mn],i=this[Ya](t,e);return!this[Mn]&&r&&this[wu](r),i}[Bn](t,e,r){this[Wt].length===0&&!this[qt]?this.emit(t,e,r):this[Wt].push([t,e,r])}[wu](t){switch(this[Bn]("meta",this[ln]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=Ws.parse(this[ln],this[Rt],!1);break;case"GlobalExtendedHeader":this[ui]=Ws.parse(this[ln],this[ui],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[ln].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[ln].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[fn])return r?.(),!1;if((this[Ae]===void 0||this.brotli===void 0&&this[Ae]===!1)&&t){if(this[he]&&(t=Buffer.concat([this[he],t]),this[he]=void 0),t.length<pw)return this[he]=t,r?.(),!0;for(let d=0;this[Ae]===void 0&&d<lc.length;d++)t[d]!==lc[d]&&(this[Ae]=!1);let o=!1;if(this[Ae]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<uc.length;d++)if(t[d]!==uc[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ae]===!1&&c)if(t.length<512)if(this[un])this.brotli=!0;else return this[he]=t,r?.(),!0;else try{new jn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ae]===void 0||this[Ae]===!1&&(this.brotli||o)){let d=this[un];this[un]=!1,this[Ae]=this[Ae]===void 0?new Um({}):o?new qm({}):new Hm({}),this[Ae].on("data",x=>this[As](x)),this[Ae].on("error",x=>this.abort(x)),this[Ae].on("end",()=>{this[un]=!0,this[As]()}),this[hr]=!0;let u=!!this[Ae][d?"end":"write"](t);return this[hr]=!1,r?.(),u}}this[hr]=!0,this[Ae]?this[Ae].write(t):this[As](t),this[hr]=!1;let i=this[Wt].length>0?!1:this[qt]?this[qt].flowing:!0;return!i&&this[Wt].length===0&&this[qt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Xa](t){t&&!this[fn]&&(this[he]=this[he]?Buffer.concat([this[he],t]):t)}[Cs](){if(this[un]&&!this[Za]&&!this[fn]&&!this[fi]){this[Za]=!0;let t=this[Mn];if(t&&t.blockRemain){let e=this[he]?this[he].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[he]&&t.write(this[he]),t.end()}this[Bn](Rs)}}[As](t){if(this[fi]&&t)this[Xa](t);else if(!t&&!this[he])this[Cs]();else if(t){if(this[fi]=!0,this[he]){this[Xa](t);let e=this[he];this[he]=void 0,this[Ts](e)}else this[Ts](t);for(;this[he]&&this[he]?.length>=512&&!this[fn]&&!this[Ds];){let e=this[he];this[he]=void 0,this[Ts](e)}this[fi]=!1}(!this[he]||this[un])&&this[Cs]()}[Ts](t){let e=0,r=t.length;for(;e+512<=r&&!this[fn]&&!this[Ds];)switch(this[ct]){case"begin":case"header":this[yu](t,e),e+=512;break;case"ignore":case"body":e+=this[Ya](t,e);break;case"meta":e+=this[_u](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[he]=this[he]?Buffer.concat([t.subarray(e),this[he]]):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[fn]||(this[Ae]?(t&&this[Ae].write(t),this[Ae].end()):(this[un]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Cs]())),this}},Ei=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)},mw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},nf=(t,e)=>{let r=new Map(e.map(c=>[Ei(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||Am(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(Im(c),u)}return r.set(c,x),x};t.filter=i?(c,d)=>i(c,d)&&o(Ei(c)):c=>o(Ei(c))},ww=t=>{let e=new Ci(t),r=t.file,i;try{i=yr.openSync(r,"r");let o=yr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let d=Buffer.allocUnsafe(o.size),u=yr.readSync(i,d,0,o.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<o.size;){let x=yr.readSync(i,u,0,c,d);if(x===0)break;d+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{yr.closeSync(i)}catch{}}},_w=(t,e)=>{let r=new Ci(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),yr.stat(o,(u,x)=>{if(u)d(u);else{let p=new Rc(o,{readSize:i,size:x.size});p.on("error",d),p.pipe(r)}})})},Sr=Ri(ww,_w,t=>new Ci(t),t=>new Ci(t),(t,e)=>{e?.length&&nf(t,e),t.noResume||mw(t)}),rf=(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:Ew,parse:vu}=yw,Oc=t=>{let e="",r=vu(t);for(;Ew(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=vu(t)}return[e,t]},Qs=["|","<",">","?",":"],Lc=Qs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),bw=new Map(Qs.map((t,e)=>[t,Lc[e]])),vw=new Map(Lc.map((t,e)=>[t,Qs[e]])),Su=t=>Qs.reduce((e,r)=>e.split(r).join(bw.get(r)),t),Sw=t=>Lc.reduce((e,r)=>e.split(r).join(vw.get(r)),t),sf=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),Ei(e)+"/"+t):Y(t),Iw=16*1024*1024,Iu=Symbol("process"),Au=Symbol("file"),Tu=Symbol("directory"),fc=Symbol("symlink"),Cu=Symbol("hardlink"),xi=Symbol("header"),Bs=Symbol("read"),xc=Symbol("lstat"),Fs=Symbol("onlstat"),hc=Symbol("onread"),pc=Symbol("onreadlink"),gc=Symbol("openfile"),mc=Symbol("onopenfile"),mn=Symbol("close"),$s=Symbol("mode"),wc=Symbol("awaitDrain"),Qa=Symbol("ondrain"),Dt=Symbol("prefix"),of=class extends qn{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=kc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Iw,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,d]=Oc(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Sw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||bu.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[Fs](o):this[xc]()}warn(t,e,r={}){return Xs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[xc](){kt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Fs](e)})}[Fs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Cw(t),this.emit("stat",t),this[Iu]()}[Iu](){switch(this.type){case"File":return this[Au]();case"Directory":return this[Tu]();case"SymbolicLink":return this[fc]();default:return this.end()}}[$s](t){return rf(t,this.type==="Directory",this.portable)}[Dt](t){return sf(t,this.prefix)}[xi](){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 jn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this[$s](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 Ws({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)}[Tu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[xi](),this.end()}[fc](){kt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[pc](e)})}[pc](t){this.linkpath=Y(t),this[xi](),this.end()}[Cu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(bu.relative(this.cwd,t)),this.stat.size=0,this[xi](),this.end()}[Au](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Cu](e);this.linkCache.set(t,this.absolute)}if(this[xi](),this.stat.size===0)return this.end();this[gc]()}[gc](){kt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[mc](e)})}[mc](t){if(this.fd=t,this.#e)return this[mn]();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[Bs]()}[Bs](){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");kt.read(t,e,r,i,o,(c,d)=>{if(c)return this[mn](()=>this.emit("error",c));this[hc](d)})}[mn](t=()=>{}){this.fd!==void 0&&kt.close(this.fd,t)}[hc](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[mn](()=>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[mn](()=>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[Qa]():this[wc](()=>this[Qa]())}[wc](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)}[Qa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[mn](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[Bs]()}},Aw=class extends of{sync=!0;[xc](){this[Fs](kt.lstatSync(this.absolute))}[fc](){this[pc](kt.readlinkSync(this.absolute))}[gc](){this[mc](kt.openSync(this.absolute,"r"))}[Bs](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let d=kt.readSync(e,r,i,o,c);this[hc](d),t=!1}finally{if(t)try{this[mn](()=>{})}catch{}}}[wc](t){t()}[mn](t=()=>{}){this.fd!==void 0&&kt.closeSync(this.fd),t()}},Tw=class extends qn{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 Xs(this,t,e,r)}constructor(t,e={}){let r=kc(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[$s](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[d,u]=Oc(this.path);d&&typeof u=="string"&&(this.path=u,o=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new jn({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 Ws({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 sf(t,this.prefix)}[$s](t){return rf(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}},Cw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Rw=class Er{tail;head;length=0;static create(e=[]){return new Er(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++)Dw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)Pw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new Er;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 Er;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 Er;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 Er;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let d=0;o&&d<e;d++)o=o.next;let c=[];for(let d=0;o&&d<r;d++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let d of i)o=kw(this,o,d);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function kw(t,e,r){let i=e,o=e?e.next:t.head,c=new Nc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Dw(t,e){t.tail=new Nc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Pw(t,e){t.head=new Nc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Nc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},ku=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Du=Buffer.alloc(1024),zs=Symbol("onStat"),hi=Symbol("ended"),mt=Symbol("queue"),pi=Symbol("pendingLinks"),xn=Symbol("current"),zn=Symbol("process"),gi=Symbol("processing"),Ps=Symbol("processJob"),wt=Symbol("jobs"),ec=Symbol("jobDone"),Us=Symbol("addFSEntry"),Pu=Symbol("addTarEntry"),_c=Symbol("stat"),yc=Symbol("readdir"),Gs=Symbol("onreaddir"),Hs=Symbol("pipe"),Ou=Symbol("entry"),tc=Symbol("entryOpt"),js=Symbol("writeEntryClass"),af=Symbol("write"),nc=Symbol("ondrain"),eo=class extends qn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[js];onWriteEntry;[mt];[pi]=new Map;[wt]=0;[gi]=!1;[hi]=!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[js]=of,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 zm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Gm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new jm(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[nc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[nc]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[mt]=new Rw,this[wt]=0,this.jobs=Number(t.jobs)||4,this[gi]=!1,this[hi]=!1}[af](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[hi]=!0,this[zn](),r&&r(),this}write(t){if(this[hi])throw new Error("write after end");return typeof t=="string"?this[Us](t):this[Pu](t),this.flowing}[Pu](t){let e=Y(Ru.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new ku(t.path,e);r.entry=new Tw(t,this[tc](r)),r.entry.on("end",()=>this[ec](r)),this[wt]+=1,this[mt].push(r)}this[zn]()}[Us](t){let e=Y(Ru.resolve(this.cwd,t));this[mt].push(new ku(t,e)),this[zn]()}[_c](t){t.pending=!0,this[wt]+=1;let e=this.follow?"stat":"lstat";Ks[e](t.absolute,(r,i)=>{t.pending=!1,this[wt]-=1,r?this.emit("error",r):this[zs](t,i)})}[zs](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[xn])this[Ps](t);else{let r=`${e.dev}:${e.ino}`,i=this[pi].get(r);i?i.push(t):this[pi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[zn]()}[yc](t){t.pending=!0,this[wt]+=1,Ks.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[wt]-=1,e)return this.emit("error",e);this[Gs](t,r)})}[Gs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[zn]()}[zn](){if(!this[gi]){this[gi]=!0;for(let t=this[mt].head;t&&this[wt]<this.jobs;t=t.next)if(this[Ps](t.value),t.value.ignore){let e=t.next;this[mt].removeNode(t),t.next=e}this[gi]=!1,this[hi]&&this[mt].length===0&&this[wt]===0&&(this.zip?this.zip.end(Du):(super.write(Du),super.end()))}}get[xn](){return this[mt]&&this[mt].head&&this[mt].head.value}[ec](t){this[mt].shift(),this[wt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[pi].get(r);if(i){this[pi].delete(r);for(let o of i)o.pending=!1,this[Ps](o)}}this[zn]()}[Ps](t){if(t.pending&&t.pendingLink&&t===this[xn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[xn]&&!t.piped&&this[Hs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[zs](t,e):this[_c](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Gs](t,e):this[yc](t),!t.readdir)return}if(t.entry=this[Ou](t),!t.entry){t.ignore=!0;return}t===this[xn]&&!t.piped&&this[Hs](t)}}}[tc](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}}[Ou](t){this[wt]+=1;try{return new this[js](t.path,this[tc](t)).on("end",()=>this[ec](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[nc](){this[xn]&&this[xn].entry&&this[xn].entry.resume()}[Hs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Us](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={}){Xs(this,t,e,r)}},Mc=class extends eo{sync=!0;constructor(t){super(t),this[js]=Aw}pause(){}resume(){}[_c](t){let e=this.follow?"statSync":"lstatSync";this[zs](t,Ks[e](t.absolute))}[yc](t){this[Gs](t,Ks.readdirSync(t.absolute))}[Hs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Us](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[af](i)})}},Ow=(t,e)=>{let r=new Mc(t),i=new $u(t.file,{mode:t.mode||438});r.pipe(i),cf(r,e)},Lw=(t,e)=>{let r=new eo(t),i=new Zs(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,d)=>{i.on("error",d),i.on("close",c),r.on("error",d)});return df(r,e).catch(c=>r.emit("error",c)),o},cf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Sr({file:Vu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},df=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Sr({file:Vu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Nw=(t,e)=>{let r=new Mc(t);return cf(r,e),r},Mw=(t,e)=>{let r=new eo(t);return df(r,e).catch(i=>r.emit("error",i)),r},lI=Ri(Ow,Lw,Nw,Mw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Fw=process.env.__FAKE_PLATFORM__||process.platform,xf=Fw==="win32",{O_CREAT:hf,O_NOFOLLOW:Lu,O_TRUNC:pf,O_WRONLY:gf}=ff.constants,mf=Number(process.env.__FAKE_FS_O_FILENAME__)||ff.constants.UV_FS_O_FILEMAP||0,zw=xf&&!!mf,Uw=512*1024,Gw=mf|pf|hf|gf,Nu=!xf&&typeof Lu=="number"?Lu|pf|hf|gf:null,wf=Nu!==null?()=>Nu:zw?t=>t<Uw?Gw:"w":()=>"w",Ec=(t,e,r)=>{try{return to.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Vs=(t,e,r,i)=>{to.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Hw=(t,e,r,i,o)=>{if(e.isDirectory())_f(bi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let d=bi.resolve(t,e.name);Vs(d,r,i,o)});else{let c=bi.resolve(t,e.name);Vs(c,r,i,o)}},_f=(t,e,r,i)=>{to.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 Vs(t,e,r,i);let d=c.length,u=null,x=p=>{if(!u){if(p)return i(u=p);if(--d===0)return Vs(t,e,r,i)}};for(let p of c)Hw(t,p,e,r,x)})},jw=(t,e,r,i)=>{e.isDirectory()&&yf(bi.resolve(t,e.name),r,i),Ec(bi.resolve(t,e.name),r,i)},yf=(t,e,r)=>{let i;try{i=to.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ec(t,e,r);throw c}for(let o of i)jw(t,o,e,r);return Ec(t,e,r)},Ef=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"}},no=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"}},Ww=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Ef(t,r?.code||"ENOTDIR")),e(r)})},Kw=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,d=e.uid,u=e.gid,x=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),p=e.preserve,g=e.unlink,_=Y(e.cwd),S=(v,I)=>{v?r(v):I&&x?_f(I,d,u,T=>S(T)):c?st.chmod(t,o,r):r()};if(t===_)return Ww(t,S);if(p)return qw.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let w=Y(Js.relative(_,t)).split("/");bc(_,w,o,g,_,void 0,S)},bc=(t,e,r,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),x=Y(Js.resolve(t+"/"+u));st.mkdir(x,r,bf(x,e,r,i,o,c,d))},bf=(t,e,r,i,o,c,d)=>u=>{u?st.lstat(t,(x,p)=>{if(x)x.path=x.path&&Y(x.path),d(x);else if(p.isDirectory())bc(t,e,r,i,o,c,d);else if(i)st.unlink(t,g=>{if(g)return d(g);st.mkdir(t,r,bf(t,e,r,i,o,c,d))});else{if(p.isSymbolicLink())return d(new no(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,bc(t,e,r,i,o,c,d))},$w=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Ef(t,r??"ENOTDIR")}},Vw=(t,e)=>{t=Y(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),x=e.preserve,p=e.unlink,g=Y(e.cwd),_=v=>{v&&u&&yf(v,c,d),o&&st.chmodSync(t,i)};if(t===g)return $w(g),_();if(x)return _(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Y(Js.relative(g,t)).split("/"),w;for(let v=S.shift(),I=g;v&&(I+="/"+v);v=S.shift()){I=Y(Js.resolve(I));try{st.mkdirSync(I,i),w=w||I}catch{let T=st.lstatSync(I);if(T.isDirectory())continue;if(p){st.unlinkSync(I),st.mkdirSync(I,i),w=w||I;continue}else if(T.isSymbolicLink())return new no(I,I+"/"+S.join("/"))}}return _(w)},rc=Object.create(null),Mu=1e4,pr=new Set,Jw=t=>{pr.has(t)?pr.delete(t):rc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),pr.add(t);let e=rc[t],r=pr.size-Mu;if(r>Mu/10){for(let i of pr)if(pr.delete(i),delete rc[i],--r<=0)break}return e},Zw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Yw=Zw==="win32",Xw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=vf(i,r)),e.push(r||"/"),e},[]),Qw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Yw?["win32 parallelization disabled"]:t.map(i=>Ei(vf(Jw(i))));let r=new Set(t.map(i=>Xw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")o.add(u);else for(let x of u)o.add(x)}for(let c of i){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let x=d[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},e_=()=>process.umask(),Bu=Symbol("onEntry"),vc=Symbol("checkFs"),Fu=Symbol("checkFs2"),Sc=Symbol("isReusable"),dt=Symbol("makeFs"),Ic=Symbol("file"),Ac=Symbol("directory"),qs=Symbol("link"),zu=Symbol("symlink"),Uu=Symbol("hardlink"),_i=Symbol("ensureNoSymlink"),Gu=Symbol("unsupported"),Hu=Symbol("checkPath"),ic=Symbol("stripAbsolutePath"),wn=Symbol("mkdir"),ze=Symbol("onError"),Os=Symbol("pending"),ju=Symbol("pend"),gr=Symbol("unpend"),sc=Symbol("ended"),oc=Symbol("maybeClose"),Tc=Symbol("skip"),vi=Symbol("doChown"),Si=Symbol("uid"),Ii=Symbol("gid"),Ai=Symbol("checkedCwd"),t_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ti=t_==="win32",n_=1024,r_=(t,e)=>{if(!Ti)return ne.unlink(t,e);let r=t+".DELETE."+uf(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},i_=t=>{if(!Ti)return ne.unlinkSync(t);let e=t+".DELETE."+uf(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},qu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Bc=class extends Ci{[sc]=!1;[Ai]=!1;[Os]=0;reservations=new Qw;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[sc]=!0,this[oc]()},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:n_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ti,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Pe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:e_():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[Bu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[oc](){this[sc]&&this[Os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ic](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Oc(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||Ti&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Pe.posix.dirname(t.path),x=Pe.posix.normalize(Pe.posix.join(u,d.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Hu](t){let e=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[ic](t,"path")||!this[ic](t,"linkpath"))return!1;if(t.absolute=Pe.isAbsolute(t.path)?Y(Pe.resolve(t.path)):Y(Pe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path: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}=Pe.win32.parse(String(t.absolute));t.absolute=i+Su(String(t.absolute).slice(i.length));let{root:o}=Pe.win32.parse(t.path);t.path=o+Su(t.path.slice(o.length))}return!0}[Bu](t){if(!this[Hu](t))return t.resume();switch(Bw.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[vc](t);default:return this[Gu](t)}}[ze](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[gr](),e.resume())}[wn](t,e,r){Kw(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)}[vi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Si](t){return qu(this.uid,t.uid,this.processUid)}[Ii](t){return qu(this.gid,t.gid,this.processGid)}[Ic](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Zs(String(t.absolute),{flags:wf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[ze](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ne.close(i.fd,()=>{}),this[ze](u,t),e();return}--o===0&&i.fd!==void 0&&ne.close(i.fd,x=>{x?this[ze](x,t):this[gr](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,g=t.mtime;ne.futimes(x,p,g,_=>_?ne.utimes(u,p,g,S=>c(S&&_)):c())}if(typeof x=="number"&&this[vi](t)){o++;let p=this[Si](t),g=this[Ii](t);typeof p=="number"&&typeof g=="number"&&ne.fchown(x,p,g,_=>_?ne.chown(u,p,g,S=>c(S&&_)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[ze](u,t),e()}),t.pipe(d)),d.pipe(i)}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[wn](String(t.absolute),r,i=>{if(i){this[ze](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[gr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[vi](t)&&(o++,ne.chown(String(t.absolute),Number(this[Si](t)),Number(this[Ii](t)),c)),c()})}[Gu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[zu](t,e){let r=Y(Pe.relative(this.cwd,Pe.resolve(Pe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[_i](t,this.cwd,r,()=>this[qs](t,String(t.linkpath),"symlink",e),i=>{this[ze](i,t),e()})}[Uu](t,e){let r=Y(Pe.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[_i](t,this.cwd,i,()=>this[qs](t,r,"link",e),o=>{this[ze](o,t),e()})}[_i](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let d=Pe.resolve(e,c);ne.lstat(d,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new no(d,Pe.resolve(d,r.join("/"))));this[_i](t,d,r,i,o)})}[ju](){this[Os]++}[gr](){this[Os]--,this[oc]()}[Tc](t){this[gr](),t.resume()}[Sc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ti}[vc](t){this[ju]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Fu](t,r))}[Fu](t,e){let r=d=>{e(d)},i=()=>{this[wn](this.cwd,this.dmode,d=>{if(d){this[ze](d,t),r();return}this[Ai]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=Y(Pe.dirname(String(t.absolute)));if(d!==this.cwd)return this[wn](d,this.dmode,u=>{if(u){this[ze](u,t),r();return}c()})}c()},c=()=>{ne.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Tc](t),r();return}if(d||this[Sc](t,u))return this[dt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=g=>this[dt](g??null,t,r);return x?ne.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ne.rmdir(String(t.absolute),x=>this[dt](x??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);r_(String(t.absolute),x=>this[dt](x??null,t,r))})};this[Ai]?o():i()}[dt](t,e,r){if(t){this[ze](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ic](e,r);case"Link":return this[Uu](e,r);case"SymbolicLink":return this[zu](e,r);case"Directory":case"GNUDumpDir":return this[Ac](e,r)}}[qs](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[ze](o,t):(this[gr](),t.resume()),i()})}},mi=t=>{try{return[null,t()]}catch(e){return[e,null]}},Sf=class extends Bc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[vc](t){if(!this[Ai]){let o=this[wn](this.cwd,this.dmode);if(o)return this[ze](o,t);this[Ai]=!0}if(t.absolute!==this.cwd){let o=Y(Pe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[wn](o,this.dmode);if(c)return this[ze](c,t)}}let[e,r]=mi(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Tc](t);if(e||this[Sc](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,[d]=c?mi(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](d,t)}let[o]=mi(()=>ne.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:mi(()=>i_(String(t.absolute)));this[dt](i,t)}[Ic](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{ne.closeSync(o)}catch(x){u=x}(d||u)&&this[ze](d||u,t),e()},o;try{o=ne.openSync(String(t.absolute),wf(t.size),r)}catch(d){return i(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[ze](d,t)),t.pipe(c)),c.on("data",d=>{try{ne.writeSync(o,d,0,d.length)}catch(u){i(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{ne.futimesSync(o,u,x)}catch(p){try{ne.utimesSync(String(t.absolute),u,x)}catch{d=p}}}if(this[vi](t)){let u=this[Si](t),x=this[Ii](t);try{ne.fchownSync(o,Number(u),Number(x))}catch(p){try{ne.chownSync(String(t.absolute),Number(u),Number(x))}catch{d=d||p}}}i(d)})}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[wn](String(t.absolute),r);if(i){this[ze](i,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[vi](t))try{ne.chownSync(String(t.absolute),Number(this[Si](t)),Number(this[Ii](t)))}catch{}e(),t.resume()}[wn](t,e){try{return Vw(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}}[_i](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let d of r){c=Pe.resolve(c,d);let[u,x]=mi(()=>ne.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new no(c,Pe.resolve(e,r.join("/"))))}i()}[qs](t,e,r,i){let o=`${r}Sync`;try{ne[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ze](c,t)}}},s_=t=>{let e=new Sf(t),r=t.file,i=lf.statSync(r),o=t.maxReadSize||16*1024*1024;new Sm(r,{readSize:o,size:i.size}).pipe(e)},o_=(t,e)=>{let r=new Bc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),lf.stat(o,(u,x)=>{if(u)d(u);else{let p=new Rc(o,{readSize:i,size:x.size});p.on("error",d),p.pipe(r)}})})},If=Ri(s_,o_,t=>new Sf(t),t=>new Bc(t),(t,e)=>{e?.length&&nf(t,e)}),a_=(t,e)=>{let r=new Mc(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 d=it.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let g=0,_=0;g<512;g+=_){if(_=it.readSync(o,u,g,u.length-g,c+g),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!_)break e}let x=new jn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>d.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,c_(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},c_=(t,e,r,i,o)=>{let c=new $u(t.file,{fd:i,start:r});e.pipe(c),l_(e,o)},d_=(t,e)=>{e=Array.from(e);let r=new eo(t),i=(o,c,d)=>{let u=(S,w)=>{S?it.close(o,v=>d(S)):d(null,w)},x=0;if(c===0)return u(null,0);let p=0,g=Buffer.alloc(512),_=(S,w)=>{if(S||w===void 0)return u(S);if(p+=w,p<512&&w)return it.read(o,g,p,g.length-p,x+p,_);if(x===0&&g[0]===31&&g[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let v=new jn(g);if(!v.cksumValid)return u(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,it.read(o,g,0,512,x,_)};it.read(o,g,0,512,x,_)};return new Promise((o,c)=>{r.on("error",c);let d="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&d==="r+")return d="w+",it.open(t.file,d,u);if(x||!p)return c(x);it.fstat(p,(g,_)=>{if(g)return it.close(p,()=>c(g));i(p,_.size,(S,w)=>{if(S)return c(S);let v=new Zs(t.file,{fd:p,start:w});r.pipe(v),v.on("error",c),v.on("close",o),u_(r,e)})})};it.open(t.file,d,u)})},l_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Sr({file:Af.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},u_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Sr({file:Af.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},wi=Ri(a_,d_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Pm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),II=Ri(wi.syncFile,wi.asyncFile,wi.syncNoFile,wi.asyncNoFile,(t,e=[])=>{wi.validate?.(t,e),f_(t)}),f_=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))};an();var Et={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete"};function ro(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Tf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function io(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Cf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Rf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Ir(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Vt();We();te();ke();We();function En(t,e){if(ro(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function ki(t){return t.startsWith("http://")||t.startsWith("https://")}function so(t){return t.endsWith("/")?t.slice(0,-1):t}We();te();var oo="1008033",Of="1289";var Lf="pbbp2",Nf="https://www.coze.cn",Mf="/api/coze_claw/resource/get_frontier_key",y_="https://www.coze.cn",E_="wss://frontier.coze.cn";function ao(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??y_}function Bf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??E_}function Ar(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 Pi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Di=G("handshake");async function Fc(t){let e=ao(t.endpoint),r=t.timeoutMs??1e4,i=`${so(e)}${Mf}?aid=${encodeURIComponent(oo)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Ar(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),r);Di.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let g=await u.json();if(g.code!==void 0&&g.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${g.code} msg=${g.msg??"-"} logid=${x}`);let _=g.data??{},S=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(!S||!w){let v=JSON.stringify(g).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Di.info("handshake ok",{remoteDeviceId:w,logid:x,traceId:p}),{accessKey:S,deviceId:w}}catch(u){if(u instanceof C)throw Di.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Di.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw Di.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new C("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var zc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",bt="auto",Ff=15e4;function zf(t){return{model:Uc(t.model)??bt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Uf(t){return!t||t===bt}var b_=new Set(["auto","\u81EA\u52A8"]);function Uc(t){let e=t?.trim();if(e)return b_.has(e.toLowerCase())?bt:e}function Gf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=zc,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,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Uf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Hf(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||bt}"`):Uf(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${zc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Ff;e.push("-c",`model_context_window=${r}`)}return e}function jf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Gc(t,e){let{ttEnv:r,usePpe:i}=Pi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function qf(t,e,r){if(!t.modelToken)return{};let i=Gc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,d])=>`${c}:${d}`).join(`
|
|
92
|
-
`)}}function Hc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Wf(t,e,r){if(!t.modelToken)return null;let i=t.model||bt,o=Gc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${zc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Ff,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Kf(t,e,r){if(!t.modelToken)return[];let i=Gc(e,r),o=[];for(let[c,d]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ve=G("agent-handlers"),$f=5*1024*1024,C_=1,R_=6,k_=new Set(["node_modules",".git",".coze","dist","build",".next"]),D_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,P_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,O_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function L_(t){let e=t?.trim();return e?O_.test(e)||P_.test(e)?e:(ve.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function N_(t){return new Promise((e,r)=>{let i=nt("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=d=>{o||(o=!0,d?r(d):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",d=>c(d))})}var co=class{constructor(e){this.opts=e}opts;async listSkills(e){En(e._meta,"_agent/listSkills");let r=Ir(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],d=[];for(let u of c){let x=Ot(o,u.relPath,"SKILL.md");await I_(x).then(g=>g.isFile()).catch(()=>!1)&&d.push(U_(u))}return{skills:d}}async addSkills(e){let r=Ir(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],d=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of o){let p=await Jc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Zc(c,d,p),u.push(x)}return await fs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){En(e._meta,"_agent/removeSkills");let r=Ir(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],d=[];for(let u of c){if(!o.has(u.skillId)){d.push(u);continue}let x=Ot(i.workspace,u.relPath);await S_(x,{recursive:!0,force:!0}),ve.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await fs(r,d),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let d=c.acpSessionId;if(d&&i.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ve.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d});continue}let x=c.downstream;c.downstream=void 0,ve.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d}),x.stop(r).catch(p=>ve.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 ve.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ne(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return ve.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await cr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw ve.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),ve.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Ne(r))throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&ki(e.registry)&&o.push(`--registry=${e.registry}`);let c=L_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let d=e._meta?.cozeEnv;d&&D_.test(d)&&o.push("--env",d);let u=await N_(o);return ve.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ne(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),ve.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}):(ve.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(En(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Uc(e.model)??bt,i=await Ne(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),ve.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return ve.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(d=>ve.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(d);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),ve.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(En(e._meta,Et.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${Et.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,Et.RESET),await this.runDetailSync(e.agentId,Et.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),ve.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,d]of i.sessions)o.set(c,{modelToken:d.modelToken,tokenGeneratedAt:d.tokenGeneratedAt});await ri(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ne(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(En(e._meta,Et.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${Et.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${Et.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){ve.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,Et.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){ve.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){ve.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){En(e._meta,"_agent/getFileTree");let r=e._meta,i=Ir(r),o=await this.resolveWorkspace(i),c=e.filePath??"",d=this.safeJoin(o,c),u=await jc(d).catch(()=>null);if(!u)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ni(d,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=Y_(e.depth);return u.isDirectory()?{tree:await Z_(o,d,c,x)}:{tree:[{name:X_(c),path:e0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){En(e._meta,"_agent/getFileContent");let r=Ir(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await jc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ni(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>$f)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${$f})`);let d=await Vf(o);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ne(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Kc(e,r||"."),o=Vc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Jf}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ne(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function M_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function B_(t){return t==="claude-code"?Ot(".claude","skills"):Ot(".agents","skills")}var F_=3e4,z_=50*1024*1024,Tr=3e4;async function Jc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,d=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!d)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=M_(o.skillName),x=B_(i),p=Ot(x,u),g=Ot(r,p);if(await qc(g,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");Oi(S.length),await Wc(Ot(g,"SKILL.md"),S,"utf8")}else{let S=await G_(o.downloadUrl);j_(S)?await $_(S,g):q_(S)?await W_(S,g):await Wc(Ot(g,"SKILL.md"),S.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 ve.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),_}function Zc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function U_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function G_(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Oi(e);let r=H_(t);return Oi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Vf(e);return Oi(r.length),r}if(ki(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),F_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Oi(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Oi(t){if(t>z_)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function H_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function j_(t){return t.length>=2&&t[0]===31&&t[1]===139}function q_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function $c(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function W_(t,e){let r,i;try{r=new Xf.default(t),i=r.getEntries()}catch(d){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of i){let u=d.entryName;if(!u||$c(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=d.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=K_(i),c=Kc(e);for(let d of i){if($c(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Kc(e,u),p=Vc(c,x);if(p.startsWith("..")||p==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await qc(x,{recursive:!0});continue}await qc(A_(x),{recursive:!0});let g;try{g=d.getData()}catch(_){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${_.message}`,{cause:_})}await Wc(x,g)}}function K_(t){let e;for(let r of t){let i=r.entryName;if(!i||$c(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function $_(t,e){await V_(t);let r=If({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${Tr}ms)`))},Tr);try{await Yf(Zf.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${Tr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function V_(t){let e=[],r=Sr({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${Tr}ms)`))},Tr);try{await Yf(Zf.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${Tr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var J_=5e3;async function Z_(t,e,r,i){return Qf(t,e,r,i,{count:0})}async function Qf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await v_(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(k_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=J_){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ot(e,u.name),p=T_(Ot(r,u.name)),g=null;try{g=await jc(x)}catch{continue}if(g.isSymbolicLink())continue;o.count++;let _={name:u.name,path:e0(Vc(t,x)),isDir:g.isDirectory(),size:g.size,modifiedAt:Math.floor(g.mtimeMs)};g.isDirectory()&&i>1&&(_.children=await Qf(t,x,p,i-1,o)),d.push(_)}return d.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),d}function Y_(t){return!t||t<=0?C_:Math.min(t,R_)}function X_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function e0(t){return t.split(Jf).join("/")}te();import{readFileSync as UA}from"node:fs";import{dirname as HA,join as jA}from"node:path";import{fileURLToPath as WA}from"node:url";var Cr="0.2.0-alpha.7";var bn=G("agent-health-reporter"),Q_=1e4,Li=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Q_}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()}),bn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),bn.info("heartbeat stopped"))}async tick(){if(this.inFlight){bn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){bn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let d of this.opts.core.agents.values()){let u=ey(d);if(!u)continue;let x={agentId:d.agentId,status:u};d.patToken&&(x.patToken=d.patToken),d.accountId&&(x.accountId=d.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:Cr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(d){bn.warn("heartbeat batch send failed",{count:r.length,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(bn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){bn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){bn.warn("onTickEnd hook failed",{err:String(r)})}}};function ey(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}an();import{chmod as Wy,mkdir as wo,rm as Ky,stat as $y,writeFile as Vy}from"node:fs/promises";import{homedir as Jy}from"node:os";import{join as C0}from"node:path";on();import{existsSync as xy}from"node:fs";import{release as hy}from"node:os";import{basename as py,isAbsolute as gy}from"node:path";function Ni(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Rr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function kr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function vn(t,e){return{jsonrpc:"2.0",id:t,error:e}}We();var lo=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,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32022};function t0(t){return"method"in t&&"id"in t&&t.id!==void 0}function n0(t){return"method"in t&&!("id"in t)}function uo(t){return!("method"in t)&&"id"in t}var ty={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,METHOD_NOT_FOUND:Q.METHOD_NOT_FOUND,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,OPERATION_NOT_ALLOWED_FOR_CLOUD:Q.OPERATION_NOT_ALLOWED_FOR_CLOUD,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 ny(t){if(t!=null)return t instanceof Error?{name:t.name,message:Mi(t.message)}:typeof t=="string"?Mi(t):typeof t=="object"?iy(t):t}var ry=[[/\/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 Mi(t){let e=t;for(let[r,i]of ry)e=e.replace(r,i);return e}function iy(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Mi(i):e[r]=i;return e}function Bi(t){if(t instanceof C){let e=ny(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:ty[t.code]??Q.INTERNAL_ERROR,message:Mi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Mi(t instanceof Error?t.message:String(t))}}function r0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:d,...u}=e;c=u}return new C(r,o,{retriable:e?.retriable??!1,cause:c})}function s0(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(
|
|
95
|
-
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function x0(t,e){if(t.length===0)return;let r=e?.killFn??zi,i=e?.isAliveFn??Fi,o=e?.sleepFn??(u=>new Promise(x=>setTimeout(x,u))),c=e?.graceMs??3e3,d=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(x=>i(x));u+=d)await o(Math.min(d,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var fy=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/]claude-agent-acp|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function h0(t,e){if(!e)return null;for(let r of fy)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function p0(t,e){return h0(t,e)}function g0(t,e){return h0(t,e)}function Or(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function m0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let p=t.suspendedMs+o,g=r-t.startedAt-p;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Or(g,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,d=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=d?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Or(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Or(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Or(c,!1,e)}}var w0=qe("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),my=200,wy=40,_y=qe("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),yy=qe("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),Ey=qe("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),by=qe("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),vy=qe("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),Sy=qe("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),_0=500;function Iy(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=_0?t:`${e.slice(0,_0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Ay(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function y0(t){try{return xy(t)}catch{return}}function Ty(t,e){return{platform:process.platform,osRelease:hy(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:gy(e.command)?y0(e.command):void 0,cwd:e.cwd,cwdExists:y0(e.cwd),envKeys:e.envKeys}}function Cy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${py(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Lt=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new fo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Dr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=c0(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=nt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,d0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>my&&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,l0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,d=Ty(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:d}),this.failAllPending(new C("AGENT_SPAWN_FAILED",Cy(c,d),{cause:d}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));zi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||zi(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:vy,phase2GateMs:_y,livenessWindowMs:yy,absoluteMaxMs:Ey,approvalMaxMs:Sy,suspendThresholdMs:by,...r};return this.call("session/prompt",e,w0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Rr("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",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(kr(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(vn(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=w0,o){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Ni(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,p)=>{let g={resolve:x,reject:p,timer:null,method:e,promptTimeout:null};if(o){let _=this.now(),S={cfg:o,startedAt:_,lastActivityAt:_,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:_,expectedIntervalMs:Or(0,!1,o),sessionId:u};g.promptTimeout=S;let w=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},I=this.now(),T=m0(v,S.cfg,I),R=P=>{S.armedAt=I,S.expectedIntervalMs=P,g.timer=setTimeout(w,P)};if(T.action==="suspend"){S.suspendedMs+=T.suspendedDeltaMs,S.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:T.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),R(T.rearmMs);return}if(T.action==="continue"){R(T.rearmMs);return}this.pending.delete(c),T.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:T.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),p(T.awaitingApproval?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),p(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};g.timer=setTimeout(w,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(g.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),p(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,g);try{this.writeFrame(d)}catch(_){g.timer&&clearTimeout(g.timer),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(s0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(uo(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Iy(e.result)}),r.resolve(e.result));return}if(n0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(t0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let d=typeof i.status=="string"?i.status:void 0,u=d==="completed"||d==="failed"||d==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(vn(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(vn(e.id,Bi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=r0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=g0(this.framework,Ay(e));return i?new C(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(wy).join(`
|
|
96
|
-
`),o=p0(this.framework,i);return o?new C(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function Ry(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var xo=class extends Lt{framework="claude-code";constructor(e){let{command:r,args:i}=ei("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 Ry(e)}};on();import{mkdtempSync as ky,rmSync as Dy}from"node:fs";import{tmpdir as Py}from"node:os";import{join as Oy}from"node:path";var ho=class extends Lt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ei("codex",e.command,i),d=e.isolateCodexHome?ky(Oy(Py(),"coze-bridge-codex-home-")):void 0,u=d?{...e.env??{},CODEX_HOME:d}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=d}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{Dy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};We();var Ly=3e4,Lr=class extends Lt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Ly))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new C("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var E0=["default","acceptEdits","plan","auto","bypassPermissions"],b0=["read-only","auto","full-access"];function Sn(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return E0.includes(e);case"codex":return b0.includes(e);case"openclaw":return!1}}function ed(t){switch(t){case"claude-code":return E0.join("/");case"codex":return b0.join("/");case"openclaw":return""}}We();te();ke();function td(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}on();var In=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var po=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new In,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)Ui(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 Ui(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Jt(t){return t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Vt();te();import{constants as v0}from"node:fs";import{access as Ny}from"node:fs/promises";import{delimiter as My,join as By}from"node:path";var vt=G("framework-detector"),S0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Fy=[".exe",".cmd",".bat",".ps1"],Wn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??nt,access:e.access??Ny}}async detect(e){let r=S0[e],i=await this.which(r);if(!i)return vt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(S0).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(My).filter(Boolean),i=this.env.platform==="win32"?["",...Fy]:[""];for(let o of r)for(let c of i){let d=By(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?v0.F_OK:v0.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return vt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return vt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return vt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return vt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(vt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(vt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return vt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return vt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||vt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let d=JSON.parse(c[0]);typeof d.gateway?.port=="number"&&(o.port=d.gateway.port),typeof d.service?.runtime?.status=="string"&&(o.runtime=d.service.runtime.status),!i&&typeof d.rpc?.error=="string"&&(o.detail=d.rpc.error)}catch(d){vt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(d)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(Uy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,d,u=x=>{c||(c=!0,d&&clearTimeout(d),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",p=>u({code:p,stdout:o}))}catch{u(null)}})}},zy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Uy(t){return t.replace(zy,"")}import{homedir as Gy}from"node:os";import{join as Hy}from"node:path";Vt();nr();We();ti();te();async function T0(){let t=Hy(Gy(),".openclaw/openclaw.json");return(await or(t))?.gateway?.auth?.token??""}var I0=G("openclaw.config"),jy=[0,5e3,5e3],qy=qe("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),A0="models.providers.",go="agents.defaults.models",mo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new In;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??jy,this.cliTimeoutMs=e.cliTimeoutMs??qy}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(d=>setTimeout(d,c));try{return await r()}catch(d){i=d,I0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(d)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=nt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",d=!1,u=p=>{d||(d=!0,clearTimeout(x),p())};o.stderr?.on("data",p=>{c+=p.toString("utf8")});let x=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",p=>u(()=>i(p))),o.on("close",p=>u(()=>{p===0?r():i(new Error(`exit ${p}: ${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){I0.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",`${A0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${A0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${go}[${e}]`,()=>this.runCli(["config","set",go,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${go}[${e}]`,`${go}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var de=G("agent-manager"),rd="acceptEdits",D0="full-access",P0="read-only";function Zy(t){switch(t){case"read-only":return["-c",'sandbox_mode="read-only"',"-c",'approval_policy="on-request"'];case"auto":return["-c",'sandbox_mode="workspace-write"',"-c",'approval_policy="on-failure"'];case"full-access":return["-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']}}var Yy=(t,e,r,i,o,c,d,u,x,p)=>{switch(t){case"claude-code":{let g={...o?{...Gf(o),...qf(o,d,u)}:{},...x??{},IS_SANDBOX:"1"};return new xo({cwd:r,env:g,agentId:i})}case"codex":{let g=o?[...Hf(o),...Kf(o,d,u)]:[],_=D0;p!==void 0&&(Sn("codex",p)?_=p:de.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:p}));let S=[...g,...Zy(_)],w={...o?jf(o):{},...x??{}},v=!!o;return new ho({cwd:r,agentId:i,...S.length>0?{extraArgs:S}:{},...Object.keys(w).length>0?{env:w}:{},...v?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Lr({command:e,cwd:r,agentId:i,...c?{sessionName:td(c)}:{}})}};function nd(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&&(Qy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return v1(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Qx("schtasks",["/Create","/SC","ONLOGON","/TN",ia,"/TR",r,"/RU",t.userName,"/F"]),jd.info("task scheduler entry created",{task:ia,logFile:t.logFile})},async uninstall(t){await Qx("schtasks",["/Delete","/TN",ia,"/F"]).catch(e=>jd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),jd.info("task scheduler entry removed",{task:ia})}}});var tp={};_a(tp,{buildContext:()=>C1,getSupervisor:()=>A1,launchdSupervisor:()=>Gd,systemdSupervisor:()=>qd,taskSchedulerSupervisor:()=>Hd});import{homedir as S1,userInfo as I1}from"node:os";function A1(t=process.platform){switch(t){case"darwin":return Gd;case"linux":return qd;case"win32":return Hd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function R1(){let t={};for(let e of T1){let r=process.env[e];r&&(t[e]=r)}return t}function C1(){let t=X();return{nodeBin:process.execPath,entry:Pd(t),logFile:t.logFile,homeDir:S1(),userName:I1().username,isRoot:process.getuid?.()===0,env:R1()}}var T1,np=Ye(()=>{"use strict";De();$o();Zx();Xx();ep();T1=["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 bl=G("acp-installer-warmup"),Cg=["claude-code","codex"];async function vl(t={}){let e=t.ensure??nr,i=(await Promise.allSettled(Cg.map(async o=>{let c=await e(o);bl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&bl.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 qg}from"node:fs/promises";import{mkdir as Cl,readFile as Ug,writeFile as kl}from"node:fs/promises";import{join as Aa}from"node:path";var Gg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function sr(t,e,r){await Cl(t,{recursive:!0});let i=Gg[e],o=Aa(t,i);return await kl(o,r??"","utf8"),o}async function Ta(t,e,r){let i=Aa(t,".claude");await Cl(i,{recursive:!0});let o=Aa(i,"settings.local.json"),c={};try{let u=await Ug(o,"utf8"),h=JSON.parse(u);typeof h=="object"&&h!==null&&!Array.isArray(h)&&(c=h)}catch{}let l=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")l.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");l.defaultMode===void 0&&(l.defaultMode=r)}return c.permissions=l,await kl(o,JSON.stringify(c,null,2),"utf8"),o}var $e=G("agent-detail-sync"),jg=6e4,Hg=5*6e4,us=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await qg(r)}catch(o){$e.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}$e.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ne(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){$e.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){$e.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),$e.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){$e.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){$e.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ne(e,this.opts.paths);if(!i){$e.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(h){$e.warn("detail RPC failed, using local data",{agentId:e,err:String(h)});let x=this.retryQueue.get(e),m=x?Math.min(x.currentDelay*2,Hg):jg;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(o.agentId&&o.agentId!==e){$e.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;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);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?($e.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&$e.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){$e.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),$e.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),$e.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):l&&(await sr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Yf=Ft(du(),1);import{lstat as Gc,mkdir as qc,readFile as $f,readdir as S_,rm as I_,stat as A_,writeFile as jc}from"node:fs/promises";import{dirname as T_,join as Dt,normalize as R_,relative as Kc,resolve as Hc,sep as Vf}from"node:path";import{Readable as Jf}from"node:stream";import{pipeline as Zf}from"node:stream/promises";import fm from"events";import et from"fs";import{EventEmitter as Ac}from"node:events";import Hu from"node:stream";import{StringDecoder as hm}from"node:string_decoder";import $u from"node:path";import mr from"node:fs";import{dirname as Am,parse as Tm}from"path";import{EventEmitter as Nm}from"events";import ac from"assert";import{Buffer as Fn}from"buffer";import*as xu from"zlib";import Mm from"zlib";import{posix as lr}from"node:path";import{basename as dw}from"node:path";import js from"fs";import Rt from"fs";import Eu from"path";import{win32 as Ew}from"node:path";import Ru from"path";import df from"node:fs";import Fw from"node:assert";import{randomBytes as lf}from"node:crypto";import ne from"node:fs";import Oe from"node:path";import uf from"fs";import Xs from"node:fs";import _i from"node:path";import st from"node:fs";import Ww from"node:fs/promises";import Ks from"node:path";import{join as bf}from"node:path";import it from"node:fs";import If from"node:path";var lm=Object.defineProperty,um=(t,e)=>{for(var r in e)lm(t,r,{get:e[r],enumerable:!0})},lu=typeof process=="object"&&process?process:{stdout:null,stderr:null},xm=t=>!!t&&typeof t=="object"&&(t instanceof Gn||t instanceof Hu||pm(t)||gm(t)),pm=t=>!!t&&typeof t=="object"&&t instanceof Ac&&typeof t.pipe=="function"&&t.pipe!==Hu.Writable.prototype.pipe,gm=t=>!!t&&typeof t=="object"&&t instanceof Ac&&typeof t.write=="function"&&typeof t.end=="function",zt=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),gs=Symbol("emittingEnd"),ni=Symbol("emittedError"),ms=Symbol("closed"),uu=Symbol("read"),ws=Symbol("flush"),fu=Symbol("flushChunk"),xt=Symbol("encoding"),dr=Symbol("decoder"),Me=Symbol("flowing"),ri=Symbol("paused"),xr=Symbol("resume"),Be=Symbol("buffer"),Ve=Symbol("pipes"),Fe=Symbol("bufferLength"),Oa=Symbol("bufferPush"),_s=Symbol("bufferShift"),Ke=Symbol("objectMode"),ve=Symbol("destroyed"),La=Symbol("error"),Na=Symbol("emitData"),hu=Symbol("emitEnd"),Ma=Symbol("emitEnd2"),It=Symbol("async"),Ba=Symbol("abort"),ys=Symbol("aborted"),ii=Symbol("signal"),Cn=Symbol("dataListeners"),rt=Symbol("discarded"),si=t=>Promise.resolve().then(t),mm=t=>t(),wm=t=>t==="end"||t==="finish"||t==="prefinish",_m=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ym=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Wu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[xr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Em=class extends Wu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},bm=t=>!!t.objectMode,vm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Gn=class extends Ac{[Me]=!1;[ri]=!1;[Ve]=[];[Be]=[];[Ke];[xt];[It];[dr];[zt]=!1;[on]=!1;[gs]=!1;[ms]=!1;[ni]=null;[Fe]=0;[ve]=!1;[ii];[ys]=!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");bm(e)?(this[Ke]=!0,this[xt]=null):vm(e)?(this[xt]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[xt]=null),this[It]=!!e.async,this[dr]=this[xt]?new hm(this[xt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Be]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ve]});let{signal:r}=e;r&&(this[ii]=r,r.aborted?this[Ba]():r.addEventListener("abort",()=>this[Ba]()))}get bufferLength(){return this[Fe]}get encoding(){return this[xt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[It]}set async(t){this[It]=this[It]||!!t}[Ba](){this[ys]=!0,this.emit("abort",this[ii]?.reason),this.destroy(this[ii]?.reason)}get aborted(){return this[ys]}set aborted(t){}write(t,e,r){if(this[ys])return!1;if(this[zt])throw new Error("write after end");if(this[ve])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[It]?si:mm;if(!this[Ke]&&!Buffer.isBuffer(t)){if(ym(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(_m(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[Me]&&this[Fe]!==0&&this[ws](!0),this[Me]?this.emit("data",t):this[Oa](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):t.length?(typeof t=="string"&&!(e===this[xt]&&!this[dr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[xt]&&(t=this[dr].write(t)),this[Me]&&this[Fe]!==0&&this[ws](!0),this[Me]?this.emit("data",t):this[Oa](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):(this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me])}read(t){if(this[ve])return null;if(this[rt]=!1,this[Fe]===0||t===0||t&&t>this[Fe])return this[Ut](),null;this[Ke]&&(t=null),this[Be].length>1&&!this[Ke]&&(this[Be]=[this[xt]?this[Be].join(""):Buffer.concat(this[Be],this[Fe])]);let e=this[uu](t||null,this[Be][0]);return this[Ut](),e}[uu](t,e){if(this[Ke])this[_s]();else{let r=e;t===r.length||t===null?this[_s]():typeof r=="string"?(this[Be][0]=r.slice(t),e=r.slice(0,t),this[Fe]-=t):(this[Be][0]=r.subarray(t),e=r.subarray(0,t),this[Fe]-=t)}return this.emit("data",e),!this[Be].length&&!this[zt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[zt]=!0,this.writable=!1,(this[Me]||!this[ri])&&this[Ut](),this}[xr](){this[ve]||(!this[Cn]&&!this[Ve].length&&(this[rt]=!0),this[ri]=!1,this[Me]=!0,this.emit("resume"),this[Be].length?this[ws]():this[zt]?this[Ut]():this.emit("drain"))}resume(){return this[xr]()}pause(){this[Me]=!1,this[ri]=!0,this[rt]=!1}get destroyed(){return this[ve]}get flowing(){return this[Me]}get paused(){return this[ri]}[Oa](t){this[Ke]?this[Fe]+=1:this[Fe]+=t.length,this[Be].push(t)}[_s](){return this[Ke]?this[Fe]-=1:this[Fe]-=this[Be][0].length,this[Be].shift()}[ws](t=!1){do;while(this[fu](this[_s]())&&this[Be].length);!t&&!this[Be].length&&!this[zt]&&this.emit("drain")}[fu](t){return this.emit("data",t),this[Me]}pipe(t,e){if(this[ve])return t;this[rt]=!1;let r=this[on];return e=e||{},t===lu.stdout||t===lu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ve].push(e.proxyErrors?new Em(this,t,e):new Wu(this,t,e)),this[It]?si(()=>this[xr]()):this[xr]()),t}unpipe(t){let e=this[Ve].find(r=>r.dest===t);e&&(this[Ve].length===1?(this[Me]&&this[Cn]===0&&(this[Me]=!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[Me]&&this[xr]();else if(t==="readable"&&this[Fe]!==0)super.emit("readable");else if(wm(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ni]){let i=e;this[It]?si(()=>i.call(this,this[ni])):i.call(this,this[ni])}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[Me]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[rt]&&!this[Ve].length&&(this[Me]=!1)),e}get emittedEnd(){return this[on]}[Ut](){!this[gs]&&!this[on]&&!this[ve]&&this[Be].length===0&&this[zt]&&(this[gs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ms]&&this.emit("close"),this[gs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ve&&this[ve])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[It]?(si(()=>this[Na](r)),!0):this[Na](r);if(t==="end")return this[hu]();if(t==="close"){if(this[ms]=!0,!this[on]&&!this[ve])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ni]=r,super.emit(La,r);let o=!this[ii]||this.listeners("error").length?super.emit("error",r):!1;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Ut](),i}[Na](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[Ut](),e}[hu](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[It]?(si(()=>this[Ma]()),!0):this[Ma]())}[Ma](){if(this[dr]){let e=this[dr].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[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[xt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ve,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[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[zt])return e();let i,o,c=x=>{this.off("data",l),this.off("end",u),this.off(ve,h),e(),o(x)},l=x=>{this.off("error",c),this.off("end",u),this.off(ve,h),this.pause(),i({value:x,done:!!this[zt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(ve,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((x,m)=>{o=m,i=x,this.once(ve,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(La,e),this.off(ve,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(La,e),this.once(ve,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ve])return t?this.emit("error",t):this.emit(ve),this;this[ve]=!0,this[rt]=!0,this[Be].length=0,this[Fe]=0;let e=this;return typeof e.close=="function"&&!this[ms]&&e.close(),t?this.emit("error",t):this.emit(ve),this}static get isStream(){return xm}},Sm=et.writev,gn=Symbol("_autoClose"),wt=Symbol("_close"),oi=Symbol("_ended"),ce=Symbol("_fd"),Fa=Symbol("_finished"),Ht=Symbol("_flags"),za=Symbol("_flush"),sc=Symbol("_handleChunk"),oc=Symbol("_makeBuf"),mi=Symbol("_mode"),Es=Symbol("_needDrain"),_r=Symbol("_onerror"),yr=Symbol("_onopen"),Ua=Symbol("_onread"),pr=Symbol("_onwrite"),mn=Symbol("_open"),mt=Symbol("_path"),un=Symbol("_pos"),At=Symbol("_queue"),gr=Symbol("_read"),Ga=Symbol("_readSize"),jt=Symbol("_reading"),ai=Symbol("_remain"),qa=Symbol("_size"),Ds=Symbol("_write"),kn=Symbol("_writing"),Ps=Symbol("_defaultFlag"),Bn=Symbol("_errored"),Tc=class extends Gn{[Bn]=!1;[ce];[mt];[Ga];[jt]=!1;[qa];[ai];[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[Bn]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[Ga]=e.readSize||16*1024*1024,this[jt]=!1,this[qa]=typeof e.size=="number"?e.size:1/0,this[ai]=this[qa],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[gr]():this[mn]()}get fd(){return this[ce]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){et.open(this[mt],"r",(t,e)=>this[yr](t,e))}[yr](t,e){t?this[_r](t):(this[ce]=e,this.emit("open",e),this[gr]())}[oc](){return Buffer.allocUnsafe(Math.min(this[Ga],this[ai]))}[gr](){if(!this[jt]){this[jt]=!0;let t=this[oc]();if(t.length===0)return process.nextTick(()=>this[Ua](null,0,t));et.read(this[ce],t,0,t.length,null,(e,r,i)=>this[Ua](e,r,i))}}[Ua](t,e,r){this[jt]=!1,t?this[_r](t):this[sc](e,r)&&this[gr]()}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[_r](t){this[jt]=!0,this[wt](),this.emit("error",t)}[sc](t,e){let r=!1;return this[ai]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ai]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[gr](),!1;case"error":return this[Bn]?!1:(this[Bn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Im=class extends Tc{[mn](){let t=!0;try{this[yr](null,et.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[gr](){let t=!0;try{if(!this[jt]){this[jt]=!0;do{let e=this[oc](),r=e.length===0?0:et.readSync(this[ce],e,0,e.length,null);if(!this[sc](r,e))break}while(!0);this[jt]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.closeSync(t),this.emit("close")}}},$s=class extends fm{readable=!1;writable=!0;[Bn]=!1;[kn]=!1;[oi]=!1;[At]=[];[Es]=!1;[mt];[mi];[gn];[ce];[Ps];[Ht];[Fa]=!1;[un];constructor(t,e){e=e||{},super(e),this[mt]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[mi]=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[Ps]=e.flags===void 0,this[Ht]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Bn])return!1;this[Bn]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[mt]}[_r](t){this[wt](),this[kn]=!0,this.emit("error",t)}[mn](){et.open(this[mt],this[Ht],this[mi],(t,e)=>this[yr](t,e))}[yr](t,e){this[Ps]&&this[Ht]==="r+"&&t&&t.code==="ENOENT"?(this[Ht]="w",this[mn]()):t?this[_r](t):(this[ce]=e,this.emit("open",e),this[kn]||this[za]())}end(t,e){return t&&this.write(t,e),this[oi]=!0,!this[kn]&&!this[At].length&&typeof this[ce]=="number"&&this[pr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[oi]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[kn]||this[At].length?(this[At].push(t),this[Es]=!0,!1):(this[kn]=!0,this[Ds](t),!0)}[Ds](t){et.write(this[ce],t,0,t.length,this[un],(e,r)=>this[pr](e,r))}[pr](t,e){t?this[_r](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[At].length?this[za]():(this[kn]=!1,this[oi]&&!this[Fa]?(this[Fa]=!0,this[wt](),this.emit("finish")):this[Es]&&(this[Es]=!1,this.emit("drain"))))}[za](){if(this[At].length===0)this[oi]&&this[pr](null,0);else if(this[At].length===1)this[Ds](this[At].pop());else{let t=this[At];this[At]=[],Sm(this[ce],t,this[un],(e,r)=>this[pr](e,r))}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ku=class extends $s{[mn](){let t;if(this[Ps]&&this[Ht]==="r+")try{t=et.openSync(this[mt],this[Ht],this[mi])}catch(e){if(e?.code==="ENOENT")return this[Ht]="w",this[mn]();throw e}else t=et.openSync(this[mt],this[Ht],this[mi]);this[yr](null,t)}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,et.closeSync(t),this.emit("close")}}[Ds](t){let e=!0;try{this[pr](null,et.writeSync(this[ce],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[wt]()}catch{}}}},Rm=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"]]),Cm=t=>!!t.sync&&!!t.file,km=t=>!t.sync&&!!t.file,Dm=t=>!!t.sync&&!t.file,Pm=t=>!t.sync&&!t.file,Om=t=>!!t.file,Lm=t=>Rm.get(t)||t,Rc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Lm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ai=(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=Rc(c);if(o?.(h,l),Cm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(km(h)){let x=e(h,l);return u?x.then(()=>u(),u):x}else if(Dm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(Pm(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}),Bm=Mm.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},Bm)),Fm=Fn.concat,pu=Object.getOwnPropertyDescriptor(Fn,"concat"),zm=t=>t,ja=pu?.writable===!0||pu?.set!==void 0?t=>{Fn.concat=t?zm:Fm}:t=>{},zn=Symbol("_superWrite"),bs=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Ha=Symbol("flushFlag"),Cc=class extends Gn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof xu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new xu[e](t)}catch(r){throw new bs(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 bs(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ac(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Fn.alloc(0),{[Ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[zn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Fn.from(t,e)),this.#e)return;ac(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ja(!0);let l;try{let h=typeof t[Ha]=="number"?t[Ha]:this.#r;l=this.#t._processChunk(t,h),ja(!1)}catch(h){ja(!1),this.#o(new bs(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 bs(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[zn](Fn.from(h));for(let x=1;x<l.length;x++)u=this[zn](l[x])}else u=this[zn](Fn.from(l));return r&&r(),u}},Vu=class extends Cc{#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),ac(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Um=class extends Vu{#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)}},Gm=class extends Vu{constructor(t){super(t,"Unzip")}},Ju=class extends Cc{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)}},qm=class extends Ju{constructor(t){super(t,"BrotliCompress")}},jm=class extends Ju{constructor(t){super(t,"BrotliDecompress")}},Zu=class extends Cc{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)}},Hm=class extends Zu{constructor(t){super(t,"ZstdCompress")}},Wm=class extends Zu{constructor(t){super(t,"ZstdDecompress")}},Km=(t,e)=>{if(Number.isSafeInteger(t))t<0?Vm(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)},Vm=(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]=Yu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Xu(o))}},Jm=t=>{let e=t[0],r=e===128?Ym(t.subarray(1,t.length)):e===255?Zm(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},Zm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Yu(c):c===0?l=c:(i=!0,l=Xu(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Ym=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},Yu=t=>(255^t)&255,Xu=t=>(255^t)+1&255,Xm={};um(Xm,{code:()=>kc,isCode:()=>Os,isName:()=>Qm,name:()=>Vs,normalFsTypes:()=>Qu});var Os=t=>Vs.has(t),Qm=t=>kc.has(t),Qu=new Set(["0","","1","2","3","4","5","6","7","D"]),Vs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),kc=new Map(Array.from(Vs).map(t=>[t[1],t[0]])),Un=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");let o=Dn(t,e+156,1),c=Qu.has(o),l=c?r:void 0,u=c?i:void 0;if(this.path=l?.path??Dn(t,e,100),this.mode=l?.mode??u?.mode??fn(t,e+100,8),this.uid=l?.uid??u?.uid??fn(t,e+108,8),this.gid=l?.gid??u?.gid??fn(t,e+116,8),this.size=l?.size??u?.size??fn(t,e+124,12),this.mtime=l?.mtime??u?.mtime??Wa(t,e+136,12),this.cksum=fn(t,e+148,12),u&&this.#n(u,!0),l&&this.#n(l),Os(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=l?.uname??u?.uname??Dn(t,e+265,32),this.gname=l?.gname??u?.gname??Dn(t,e+297,32),this.devmaj=l?.devmaj??u?.devmaj??fn(t,e+329,8)??0,this.devmin=l?.devmin??u?.devmin??fn(t,e+337,8)??0,t[e+475]!==0){let x=Dn(t,e+345,155);this.path=x+"/"+this.path}else{let x=Dn(t,e+345,130);x&&(this.path=x+"/"+this.path),this.atime=r?.atime??i?.atime??Wa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Wa(t,e+488,12)}let h=256;for(let x=e;x<e+148;x++)h+=t[x];for(let x=e+156;x<e+512;x++)h+=t[x];this.cksumValid=h===this.cksum,this.cksum===void 0&&h===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=ew(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Pn(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=Ka(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Pn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Pn(t,e+265,32,this.uname)||this.needPax,this.needPax=Pn(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=Pn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Pn(t,e+345,155,c)||this.needPax:(this.needPax=Pn(t,e+345,130,c)||this.needPax,this.needPax=Ka(t,e+476,12,this.atime)||this.needPax,this.needPax=Ka(t,e+488,12,this.ctime)||this.needPax);let 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:Vs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(kc.get(t));if(Os(e)||e==="Unsupported")this.#e=e;else if(Os(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},ew=(t,e)=>{let r=t,i="",o,c=lr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=lr.dirname(r),r=lr.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=lr.join(lr.basename(i),r),i=lr.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.*/,""),Wa=(t,e,r)=>tw(fn(t,e,r)),tw=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?Jm(t.subarray(e,e+r)):rw(t,e,r),nw=t=>isNaN(t)?void 0:t,rw=(t,e,r)=>nw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),iw={12:8589934591,8:2097151},hn=(t,e,r,i)=>i===void 0?!1:i>iw[r]||i<0?(Km(i,t.subarray(e,e+r)),!0):(sw(t,e,r,i),!1),sw=(t,e,r,i)=>t.write(ow(i,r),e,r,"ascii"),ow=(t,e)=>aw(Math.floor(t).toString(8),e),aw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ka=(t,e,r,i)=>i===void 0?!1:hn(t,e,r,i.getTime()/1e3),cw=new Array(156).join("\0"),Pn=(t,e,r,i)=>i===void 0?!1:(t.write(i+cw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),qs=class ef{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 Un({path:("PaxHeader/"+dw(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 ef(lw(uw(e),r),i)}},lw=(t,e)=>e?Object.assign({},e,t):t,uw=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(fw,Object.create(null)),fw=(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},hw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=hw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),xw=class extends Gn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,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))))}},Js=(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))},pw=1024*1024,cc=Buffer.from([31,139]),dc=Buffer.from([40,181,47,253]),gw=Math.max(cc.length,dc.length),ct=Symbol("state"),On=Symbol("writeEntry"),Gt=Symbol("readEntry"),$a=Symbol("nextEntry"),gu=Symbol("processEntry"),Tt=Symbol("extendedHeader"),ci=Symbol("globalExtendedHeader"),an=Symbol("meta"),mu=Symbol("emitMeta"),pe=Symbol("buffer"),qt=Symbol("queue"),cn=Symbol("ended"),Va=Symbol("emittedEnd"),Ln=Symbol("emit"),Te=Symbol("unzip"),vs=Symbol("consumeChunk"),Ss=Symbol("consumeChunkSub"),Ja=Symbol("consumeBody"),wu=Symbol("consumeMeta"),_u=Symbol("consumeHeader"),di=Symbol("consuming"),Za=Symbol("bufferConcat"),Is=Symbol("maybeEnd"),ur=Symbol("writing"),dn=Symbol("aborted"),As=Symbol("onDone"),Nn=Symbol("sawValidEntry"),Ts=Symbol("sawNullBlock"),Rs=Symbol("sawEOF"),yu=Symbol("closeStream"),mw=()=>!0,Ii=class extends Nm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[qt]=[];[pe];[Gt];[On];[ct]="begin";[an]="";[Tt];[ci];[cn]=!1;[Te];[dn]=!1;[Nn];[Ts]=!1;[Rs]=!1;[ur]=!1;[di]=!1;[Va]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(As,()=>{(this[ct]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(As,t.ondone):this.on(As,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||pw,this.filter=typeof t.filter=="function"?t.filter:mw;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[yu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Js(this,t,e,r)}[_u](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new Un(t,e,this[Tt],this[ci])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ts]?(this[Rs]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Ln]("eof")):(this[Ts]=!0,this[Ln]("nullBlock"));else if(this[Ts]=!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 xw(r,this[Tt],this[ci]);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[Ln]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[ct]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Ln]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[Gt]?this[qt].push(o):(this[qt].push(o),this[$a]())))}}}[yu](){queueMicrotask(()=>this.emit("close"))}[gu](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[$a]()),e=!1);return e}[$a](){do;while(this[gu](this[qt].shift()));if(this[qt].length===0){let t=this[Gt];!t||t.flowing||t.size===t.remain?this[ur]||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}[wu](t,e){let r=this[On],i=this[Ja](t,e);return!this[On]&&r&&this[mu](r),i}[Ln](t,e,r){this[qt].length===0&&!this[Gt]?this.emit(t,e,r):this[qt].push([t,e,r])}[mu](t){switch(this[Ln]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=qs.parse(this[an],this[Tt],!1);break;case"GlobalExtendedHeader":this[ci]=qs.parse(this[an],this[ci],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Tt]??Object.create(null);this[Tt]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Tt]||Object.create(null);this[Tt]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Te]===void 0||this.brotli===void 0&&this[Te]===!1)&&t){if(this[pe]&&(t=Buffer.concat([this[pe],t]),this[pe]=void 0),t.length<gw)return this[pe]=t,r?.(),!0;for(let l=0;this[Te]===void 0&&l<cc.length;l++)t[l]!==cc[l]&&(this[Te]=!1);let o=!1;if(this[Te]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<dc.length;l++)if(t[l]!==dc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Te]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[pe]=t,r?.(),!0;else try{new Un(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Te]===void 0||this[Te]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Te]=this[Te]===void 0?new Gm({}):o?new Wm({}):new jm({}),this[Te].on("data",h=>this[vs](h)),this[Te].on("error",h=>this.abort(h)),this[Te].on("end",()=>{this[cn]=!0,this[vs]()}),this[ur]=!0;let u=!!this[Te][l?"end":"write"](t);return this[ur]=!1,r?.(),u}}this[ur]=!0,this[Te]?this[Te].write(t):this[vs](t),this[ur]=!1;let i=this[qt].length>0?!1:this[Gt]?this[Gt].flowing:!0;return!i&&this[qt].length===0&&this[Gt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Za](t){t&&!this[dn]&&(this[pe]=this[pe]?Buffer.concat([this[pe],t]):t)}[Is](){if(this[cn]&&!this[Va]&&!this[dn]&&!this[di]){this[Va]=!0;let t=this[On];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[Ln](As)}}[vs](t){if(this[di]&&t)this[Za](t);else if(!t&&!this[pe])this[Is]();else if(t){if(this[di]=!0,this[pe]){this[Za](t);let e=this[pe];this[pe]=void 0,this[Ss](e)}else this[Ss](t);for(;this[pe]&&this[pe]?.length>=512&&!this[dn]&&!this[Rs];){let e=this[pe];this[pe]=void 0,this[Ss](e)}this[di]=!1}(!this[pe]||this[cn])&&this[Is]()}[Ss](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Rs];)switch(this[ct]){case"begin":case"header":this[_u](t,e),e+=512;break;case"ignore":case"body":e+=this[Ja](t,e);break;case"meta":e+=this[wu](t,e);break;default:throw new Error("invalid state: "+this[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[Te]?(t&&this[Te].write(t),this[Te].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Is]())),this}},wi=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)},ww=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},tf=(t,e)=>{let r=new Map(e.map(c=>[wi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Tm(c).root||".",h;if(c===u)h=!1;else{let x=r.get(c);h=x!==void 0?x:o(Am(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(wi(c)):c=>o(wi(c))},_w=t=>{let e=new Ii(t),r=t.file,i;try{i=mr.openSync(r,"r");let o=mr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=mr.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=mr.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{mr.closeSync(i)}catch{}}},yw=(t,e)=>{let r=new Ii(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),mr.stat(o,(u,h)=>{if(u)l(u);else{let x=new Tc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},Er=Ai(_w,yw,t=>new Ii(t),t=>new Ii(t),(t,e)=>{e?.length&&tf(t,e),t.noResume||ww(t)}),nf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:bw,parse:bu}=Ew,Dc=t=>{let e="",r=bu(t);for(;bw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=bu(t)}return[e,t]},Zs=["|","<",">","?",":"],Pc=Zs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),vw=new Map(Zs.map((t,e)=>[t,Pc[e]])),Sw=new Map(Pc.map((t,e)=>[t,Zs[e]])),vu=t=>Zs.reduce((e,r)=>e.split(r).join(vw.get(r)),t),Iw=t=>Pc.reduce((e,r)=>e.split(r).join(Sw.get(r)),t),rf=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),wi(e)+"/"+t):Y(t),Aw=16*1024*1024,Su=Symbol("process"),Iu=Symbol("file"),Au=Symbol("directory"),lc=Symbol("symlink"),Tu=Symbol("hardlink"),li=Symbol("header"),Ls=Symbol("read"),uc=Symbol("lstat"),Ns=Symbol("onlstat"),fc=Symbol("onread"),hc=Symbol("onreadlink"),xc=Symbol("openfile"),pc=Symbol("onopenfile"),xn=Symbol("close"),Hs=Symbol("mode"),gc=Symbol("awaitDrain"),Ya=Symbol("ondrain"),Ct=Symbol("prefix"),sf=class extends Gn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Rc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Aw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=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]=Dc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Iw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||Eu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ns](o):this[uc]()}warn(t,e,r={}){return Js(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[uc](){Rt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ns](e)})}[Ns](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Cw(t),this.emit("stat",t),this[Su]()}[Su](){switch(this.type){case"File":return this[Iu]();case"Directory":return this[Au]();case"SymbolicLink":return this[lc]();default:return this.end()}}[Hs](t){return nf(t,this.type==="Directory",this.portable)}[Ct](t){return rf(t,this.prefix)}[li](){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 Un({path:this[Ct](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ct](this.linkpath):this.linkpath,mode:this[Hs](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 qs({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[Ct](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ct](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)}[Au](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[li](),this.end()}[lc](){Rt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hc](e)})}[hc](t){this.linkpath=Y(t),this[li](),this.end()}[Tu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(Eu.relative(this.cwd,t)),this.stat.size=0,this[li](),this.end()}[Iu](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Tu](e);this.linkCache.set(t,this.absolute)}if(this[li](),this.stat.size===0)return this.end();this[xc]()}[xc](){Rt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[pc](e)})}[pc](t){if(this.fd=t,this.#e)return this[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[Ls]()}[Ls](){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");Rt.read(t,e,r,i,o,(c,l)=>{if(c)return this[xn](()=>this.emit("error",c));this[fc](l)})}[xn](t=()=>{}){this.fd!==void 0&&Rt.close(this.fd,t)}[fc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[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[Ya]():this[gc](()=>this[Ya]())}[gc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ya](){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[Ls]()}},Tw=class extends sf{sync=!0;[uc](){this[Ns](Rt.lstatSync(this.absolute))}[lc](){this[hc](Rt.readlinkSync(this.absolute))}[xc](){this[pc](Rt.openSync(this.absolute,"r"))}[Ls](){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=Rt.readSync(e,r,i,o,c);this[fc](l),t=!1}finally{if(t)try{this[xn](()=>{})}catch{}}}[gc](t){t()}[xn](t=()=>{}){this.fd!==void 0&&Rt.closeSync(this.fd),t()}},Rw=class extends Gn{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Js(this,t,e,r)}constructor(t,e={}){let r=Rc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Y(t.path),this.mode=t.mode!==void 0?this[Hs](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]=Dc(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 Un({path:this[Ct](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ct](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 qs({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[Ct](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ct](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)}[Ct](t){return rf(t,this.prefix)}[Hs](t){return nf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},Cw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",kw=class wr{tail;head;length=0;static create(e=[]){return new wr(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++)Pw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)Ow(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 wr;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 wr;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 wr;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 wr;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=Dw(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 Dw(t,e,r){let i=e,o=e?e.next:t.head,c=new Oc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Pw(t,e){t.tail=new Oc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Ow(t,e){t.head=new Oc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Oc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Cu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},ku=Buffer.alloc(1024),Ms=Symbol("onStat"),ui=Symbol("ended"),pt=Symbol("queue"),fi=Symbol("pendingLinks"),ln=Symbol("current"),Mn=Symbol("process"),hi=Symbol("processing"),Cs=Symbol("processJob"),gt=Symbol("jobs"),Xa=Symbol("jobDone"),Bs=Symbol("addFSEntry"),Du=Symbol("addTarEntry"),mc=Symbol("stat"),wc=Symbol("readdir"),Fs=Symbol("onreaddir"),zs=Symbol("pipe"),Pu=Symbol("entry"),Qa=Symbol("entryOpt"),Us=Symbol("writeEntryClass"),of=Symbol("write"),ec=Symbol("ondrain"),Ys=class extends Gn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Us];onWriteEntry;[pt];[fi]=new Map;[gt]=0;[hi]=!1;[ui]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=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[Us]=sf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Um(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new qm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Hm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[ec]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ec]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[pt]=new kw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[hi]=!1,this[ui]=!1}[of](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[ui]=!0,this[Mn](),r&&r(),this}write(t){if(this[ui])throw new Error("write after end");return typeof t=="string"?this[Bs](t):this[Du](t),this.flowing}[Du](t){let e=Y(Ru.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Cu(t.path,e);r.entry=new Rw(t,this[Qa](r)),r.entry.on("end",()=>this[Xa](r)),this[gt]+=1,this[pt].push(r)}this[Mn]()}[Bs](t){let e=Y(Ru.resolve(this.cwd,t));this[pt].push(new Cu(t,e)),this[Mn]()}[mc](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";js[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Ms](t,i)})}[Ms](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Cs](t);else{let r=`${e.dev}:${e.ino}`,i=this[fi].get(r);i?i.push(t):this[fi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Mn]()}[wc](t){t.pending=!0,this[gt]+=1,js.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Fs](t,r)})}[Fs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Mn]()}[Mn](){if(!this[hi]){this[hi]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[Cs](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[hi]=!1,this[ui]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(ku):(super.write(ku),super.end()))}}get[ln](){return this[pt]&&this[pt].head&&this[pt].head.value}[Xa](t){this[pt].shift(),this[gt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[fi].get(r);if(i){this[fi].delete(r);for(let o of i)o.pending=!1,this[Cs](o)}}this[Mn]()}[Cs](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[zs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ms](t,e):this[mc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Fs](t,e):this[wc](t),!t.readdir)return}if(t.entry=this[Pu](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[zs](t)}}}[Qa](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Pu](t){this[gt]+=1;try{return new this[Us](t.path,this[Qa](t)).on("end",()=>this[Xa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ec](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[zs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)});let e=t.entry,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={}){Js(this,t,e,r)}},Lc=class extends Ys{sync=!0;constructor(t){super(t),this[Us]=Tw}pause(){}resume(){}[mc](t){let e=this.follow?"statSync":"lstatSync";this[Ms](t,js[e](t.absolute))}[wc](t){this[Fs](t,js.readdirSync(t.absolute))}[zs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[of](i)})}},Lw=(t,e)=>{let r=new Lc(t),i=new Ku(t.file,{mode:t.mode||438});r.pipe(i),af(r,e)},Nw=(t,e)=>{let r=new Ys(t),i=new $s(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 cf(r,e).catch(c=>r.emit("error",c)),o},af=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Er({file:$u.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},cf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Er({file:$u.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Mw=(t,e)=>{let r=new Lc(t);return af(r,e),r},Bw=(t,e)=>{let r=new Ys(t);return cf(r,e).catch(i=>r.emit("error",i)),r},uI=Ai(Lw,Nw,Mw,Bw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),zw=process.env.__FAKE_PLATFORM__||process.platform,ff=zw==="win32",{O_CREAT:hf,O_NOFOLLOW:Ou,O_TRUNC:xf,O_WRONLY:pf}=uf.constants,gf=Number(process.env.__FAKE_FS_O_FILENAME__)||uf.constants.UV_FS_O_FILEMAP||0,Uw=ff&&!!gf,Gw=512*1024,qw=gf|xf|hf|pf,Lu=!ff&&typeof Ou=="number"?Ou|xf|hf|pf:null,mf=Lu!==null?()=>Lu:Uw?t=>t<Gw?qw:"w":()=>"w",_c=(t,e,r)=>{try{return Xs.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Ws=(t,e,r,i)=>{Xs.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},jw=(t,e,r,i,o)=>{if(e.isDirectory())wf(_i.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=_i.resolve(t,e.name);Ws(l,r,i,o)});else{let c=_i.resolve(t,e.name);Ws(c,r,i,o)}},wf=(t,e,r,i)=>{Xs.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return Ws(t,e,r,i);let l=c.length,u=null,h=x=>{if(!u){if(x)return i(u=x);if(--l===0)return Ws(t,e,r,i)}};for(let x of c)jw(t,x,e,r,h)})},Hw=(t,e,r,i)=>{e.isDirectory()&&_f(_i.resolve(t,e.name),r,i),_c(_i.resolve(t,e.name),r,i)},_f=(t,e,r)=>{let i;try{i=Xs.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return _c(t,e,r);throw c}for(let o of i)Hw(t,o,e,r);return _c(t,e,r)},yf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Qs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Kw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new yf(t,r?.code||"ENOTDIR")),e(r)})},$w=(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),x=e.preserve,m=e.unlink,E=Y(e.cwd),S=(b,I)=>{b?r(b):I&&h?wf(I,l,u,A=>S(A)):c?st.chmod(t,o,r):r()};if(t===E)return Kw(t,S);if(x)return Ww.mkdir(t,{mode:o,recursive:!0}).then(b=>S(null,b??void 0),S);let _=Y(Ks.relative(E,t)).split("/");yc(E,_,o,m,E,void 0,S)},yc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=Y(Ks.resolve(t+"/"+u));st.mkdir(h,r,Ef(h,e,r,i,o,c,l))},Ef=(t,e,r,i,o,c,l)=>u=>{u?st.lstat(t,(h,x)=>{if(h)h.path=h.path&&Y(h.path),l(h);else if(x.isDirectory())yc(t,e,r,i,o,c,l);else if(i)st.unlink(t,m=>{if(m)return l(m);st.mkdir(t,r,Ef(t,e,r,i,o,c,l))});else{if(x.isSymbolicLink())return l(new Qs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,yc(t,e,r,i,o,c,l))},Vw=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new yf(t,r??"ENOTDIR")}},Jw=(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,x=e.unlink,m=Y(e.cwd),E=b=>{b&&u&&_f(b,c,l),o&&st.chmodSync(t,i)};if(t===m)return Vw(m),E();if(h)return E(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Y(Ks.relative(m,t)).split("/"),_;for(let b=S.shift(),I=m;b&&(I+="/"+b);b=S.shift()){I=Y(Ks.resolve(I));try{st.mkdirSync(I,i),_=_||I}catch{let A=st.lstatSync(I);if(A.isDirectory())continue;if(x){st.unlinkSync(I),st.mkdirSync(I,i),_=_||I;continue}else if(A.isSymbolicLink())return new Qs(I,I+"/"+S.join("/"))}}return E(_)},tc=Object.create(null),Nu=1e4,fr=new Set,Zw=t=>{fr.has(t)?fr.delete(t):tc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),fr.add(t);let e=tc[t],r=fr.size-Nu;if(r>Nu/10){for(let i of fr)if(fr.delete(i),delete tc[i],--r<=0)break}return e},Yw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Xw=Yw==="win32",Qw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=bf(i,r)),e.push(r||"/"),e},[]),e_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Xw?["win32 parallelization disabled"]:t.map(i=>wi(bf(Zw(i))));let r=new Set(t.map(i=>Qw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let 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}},t_=()=>process.umask(),Mu=Symbol("onEntry"),Ec=Symbol("checkFs"),Bu=Symbol("checkFs2"),bc=Symbol("isReusable"),dt=Symbol("makeFs"),vc=Symbol("file"),Sc=Symbol("directory"),Gs=Symbol("link"),Fu=Symbol("symlink"),zu=Symbol("hardlink"),gi=Symbol("ensureNoSymlink"),Uu=Symbol("unsupported"),Gu=Symbol("checkPath"),nc=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),ze=Symbol("onError"),ks=Symbol("pending"),qu=Symbol("pend"),hr=Symbol("unpend"),rc=Symbol("ended"),ic=Symbol("maybeClose"),Ic=Symbol("skip"),yi=Symbol("doChown"),Ei=Symbol("uid"),bi=Symbol("gid"),vi=Symbol("checkedCwd"),n_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Si=n_==="win32",r_=1024,i_=(t,e)=>{if(!Si)return ne.unlink(t,e);let r=t+".DELETE."+lf(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},s_=t=>{if(!Si)return ne.unlinkSync(t);let e=t+".DELETE."+lf(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},ju=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Nc=class extends Ii{[rc]=!1;[vi]=!1;[ks]=0;reservations=new e_;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[rc]=!0,this[ic]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:r_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Si,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Oe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:t_():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Mu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ic](){this[rc]&&this[ks]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[nc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Dc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Si&&/^[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=Oe.posix.dirname(t.path),h=Oe.posix.normalize(Oe.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}[Gu](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[nc](t,"path")||!this[nc](t,"linkpath"))return!1;if(t.absolute=Oe.isAbsolute(t.path)?Y(Oe.resolve(t.path)):Y(Oe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path: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}=Oe.win32.parse(String(t.absolute));t.absolute=i+vu(String(t.absolute).slice(i.length));let{root:o}=Oe.win32.parse(t.path);t.path=o+vu(t.path.slice(o.length))}return!0}[Mu](t){if(!this[Gu](t))return t.resume();switch(Fw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ec](t);default:return this[Uu](t)}}[ze](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[hr](),e.resume())}[pn](t,e,r){$w(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)}[yi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ei](t){return ju(this.uid,t.uid,this.processUid)}[bi](t){return ju(this.gid,t.gid,this.processGid)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new $s(String(t.absolute),{flags:mf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[ze](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ne.close(i.fd,()=>{}),this[ze](u,t),e();return}--o===0&&i.fd!==void 0&&ne.close(i.fd,h=>{h?this[ze](h,t):this[hr](),e()})};i.on("finish",()=>{let u=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,m=t.mtime;ne.futimes(h,x,m,E=>E?ne.utimes(u,x,m,S=>c(S&&E)):c())}if(typeof h=="number"&&this[yi](t)){o++;let x=this[Ei](t),m=this[bi](t);typeof x=="number"&&typeof m=="number"&&ne.fchown(h,x,m,E=>E?ne.chown(u,x,m,S=>c(S&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[ze](u,t),e()}),t.pipe(l)),l.pipe(i)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[ze](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[hr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[yi](t)&&(o++,ne.chown(String(t.absolute),Number(this[Ei](t)),Number(this[bi](t)),c)),c()})}[Uu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Fu](t,e){let r=Y(Oe.relative(this.cwd,Oe.resolve(Oe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[gi](t,this.cwd,r,()=>this[Gs](t,String(t.linkpath),"symlink",e),i=>{this[ze](i,t),e()})}[zu](t,e){let r=Y(Oe.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[gi](t,this.cwd,i,()=>this[Gs](t,r,"link",e),o=>{this[ze](o,t),e()})}[gi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Oe.resolve(e,c);ne.lstat(l,(u,h)=>{if(u)return i();if(h?.isSymbolicLink())return o(new Qs(l,Oe.resolve(l,r.join("/"))));this[gi](t,l,r,i,o)})}[qu](){this[ks]++}[hr](){this[ks]--,this[ic]()}[Ic](t){this[hr](),t.resume()}[bc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Si}[Ec](t){this[qu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Bu](t,r))}[Bu](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[ze](l,t),r();return}this[vi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Oe.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,u=>{if(u){this[ze](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[Ic](t),r();return}if(l||this[bc](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,x=m=>this[dt](m??null,t,r);return h?ne.chmod(String(t.absolute),Number(t.mode),x):x()}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);i_(String(t.absolute),h=>this[dt](h??null,t,r))})};this[vi]?o():i()}[dt](t,e,r){if(t){this[ze](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[vc](e,r);case"Link":return this[zu](e,r);case"SymbolicLink":return this[Fu](e,r);case"Directory":case"GNUDumpDir":return this[Sc](e,r)}}[Gs](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[ze](o,t):(this[hr](),t.resume()),i()})}},xi=t=>{try{return[null,t()]}catch(e){return[e,null]}},vf=class extends Nc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[Ec](t){if(!this[vi]){let o=this[pn](this.cwd,this.dmode);if(o)return this[ze](o,t);this[vi]=!0}if(t.absolute!==this.cwd){let o=Y(Oe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[ze](c,t)}}let[e,r]=xi(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ic](t);if(e||this[bc](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?xi(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=xi(()=>ne.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:xi(()=>s_(String(t.absolute)));this[dt](i,t)}[vc](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[ze](l||u,t),e()},o;try{o=ne.openSync(String(t.absolute),mf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[ze](l,t)),t.pipe(c)),c.on("data",l=>{try{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(x){try{ne.utimesSync(String(t.absolute),u,h)}catch{l=x}}}if(this[yi](t)){let u=this[Ei](t),h=this[bi](t);try{ne.fchownSync(o,Number(u),Number(h))}catch(x){try{ne.chownSync(String(t.absolute),Number(u),Number(h))}catch{l=l||x}}}i(l)})}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[ze](i,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[yi](t))try{ne.chownSync(String(t.absolute),Number(this[Ei](t)),Number(this[bi](t)))}catch{}e(),t.resume()}[pn](t,e){try{return Jw(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}}[gi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Oe.resolve(c,l);let[u,h]=xi(()=>ne.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new Qs(c,Oe.resolve(e,r.join("/"))))}i()}[Gs](t,e,r,i){let o=`${r}Sync`;try{ne[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ze](c,t)}}},o_=t=>{let e=new vf(t),r=t.file,i=df.statSync(r),o=t.maxReadSize||16*1024*1024;new Im(r,{readSize:o,size:i.size}).pipe(e)},a_=(t,e)=>{let r=new Nc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),df.stat(o,(u,h)=>{if(u)l(u);else{let x=new Tc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},Sf=Ai(o_,a_,t=>new vf(t),t=>new Nc(t),(t,e)=>{e?.length&&tf(t,e)}),c_=(t,e)=>{let r=new Lc(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 Un(u);if(!h.cksumValid)break;let x=512*Math.ceil((h.size||0)/512);if(c+x+512>l.size)break;c+=x,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,d_(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},d_=(t,e,r,i,o)=>{let c=new Ku(t.file,{fd:i,start:r});e.pipe(c),u_(e,o)},l_=(t,e)=>{e=Array.from(e);let r=new Ys(t),i=(o,c,l)=>{let u=(S,_)=>{S?it.close(o,b=>l(S)):l(null,_)},h=0;if(c===0)return u(null,0);let x=0,m=Buffer.alloc(512),E=(S,_)=>{if(S||_===void 0)return u(S);if(x+=_,x<512&&_)return it.read(o,m,x,m.length-x,h+x,E);if(h===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,h);let b=new Un(m);if(!b.cksumValid)return u(null,h);let I=512*Math.ceil((b.size??0)/512);if(h+I+512>c||(h+=I+512,h>=c))return u(null,h);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),x=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,x)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,u);if(h||!x)return c(h);it.fstat(x,(m,E)=>{if(m)return it.close(x,()=>c(m));i(x,E.size,(S,_)=>{if(S)return c(S);let b=new $s(t.file,{fd:x,start:_});r.pipe(b),b.on("error",c),b.on("close",o),f_(r,e)})})};it.open(t.file,l,u)})},u_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Er({file:If.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},f_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Er({file:If.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},pi=Ai(c_,l_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Om(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")}),AI=Ai(pi.syncFile,pi.asyncFile,pi.syncNoFile,pi.asyncNoFile,(t,e=[])=>{pi.validate?.(t,e),h_(t)}),h_=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var _t={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete"};function eo(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Af(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function to(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Tf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Rf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function br(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Wt();We();te();De();We();function wn(t,e){if(eo(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ti(t){return t.startsWith("http://")||t.startsWith("https://")}function no(t){return t.endsWith("/")?t.slice(0,-1):t}We();te();var ro="1008033",Pf="1289";var Of="pbbp2",Lf="https://www.coze.cn",Nf="/api/coze_claw/resource/get_frontier_key",E_="https://www.coze.cn",b_="wss://frontier.coze.cn";function io(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??E_}function Mf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??b_}function vr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Ci(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ri=G("handshake");async function Mc(t){let e=io(t.endpoint),r=t.timeoutMs??1e4,i=`${no(e)}${Nf}?aid=${encodeURIComponent(ro)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...vr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ri.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",x=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let b=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${b.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${h}`);let E=m.data??{},S=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(!S||!_){let b=JSON.stringify(m).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${b}`)}return Ri.info("handshake ok",{remoteDeviceId:_,logid:h,traceId:x}),{accessKey:S,deviceId:_}}catch(u){if(u instanceof T)throw Ri.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ri.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw Ri.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:h?.code,syscall:h?.syscall,cause:String(u).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Bc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",Bf=15e4;function Ff(t){return{model:Fc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function zf(t){return!t||t===yt}var v_=new Set(["auto","\u81EA\u52A8"]);function Fc(t){let e=t?.trim();if(e)return v_.has(e.toLowerCase())?yt:e}function Uf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Bc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||yt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else zf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Gf(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):zf(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="${Bc}/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??Bf;e.push("-c",`model_context_window=${r}`)}return e}function qf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function zc(t,e){let{ttEnv:r,usePpe:i}=Ci(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function jf(t,e,r){if(!t.modelToken)return{};let i=zc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function Uc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Hf(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=zc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Bc}/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??Bf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Wf(t,e,r){if(!t.modelToken)return[];let i=zc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Se=G("agent-handlers"),Kf=5*1024*1024,C_=1,k_=6,D_=new Set(["node_modules",".git",".coze","dist","build",".next"]),P_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,O_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,L_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function N_(t){let e=t?.trim();return e?L_.test(e)||O_.test(e)?e:(Se.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function M_(t){return new Promise((e,r)=>{let i=nt("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=l=>{o||(o=!0,l?r(l):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",l=>c(l))})}var so=class{constructor(e){this.opts=e}opts;async listSkills(e){wn(e._meta,"_agent/listSkills");let r=br(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=Dt(o,u.relPath,"SKILL.md");await A_(h).then(m=>m.isFile()).catch(()=>!1)&&l.push(G_(u))}return{skills:l}}async addSkills(e){let r=br(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((h,x)=>[h.skillId,x])),u=[];for(let h of o){let x=await $c({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});Vc(c,l,x),u.push(h)}return await ds(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){wn(e._meta,"_agent/removeSkills");let r=br(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=Dt(i.workspace,u.relPath);await I_(h,{recursive:!0,force:!0}),Se.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ds(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,Se.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,Se.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(x=>Se.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(x)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Se.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ne(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Se.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await sr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Se.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),Se.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Ne(r))throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Ti(e.registry)&&o.push(`--registry=${e.registry}`);let c=N_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let l=e._meta?.cozeEnv;l&&P_.test(l)&&o.push("--env",l);let u=await M_(o);return Se.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ne(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Se.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}):(Se.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(wn(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Fc(e.model)??yt,i=await Ne(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),Se.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Se.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=>Se.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),Se.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(wn(e._meta,_t.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,_t.RESET),await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Se.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 ei(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ne(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(wn(e._meta,_t.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${_t.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Se.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,_t.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Se.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Se.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){wn(e._meta,"_agent/getFileTree");let r=e._meta,i=br(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Gc(l).catch(()=>null);if(!u)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Qr(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=X_(e.depth);return u.isDirectory()?{tree:await Y_(o,l,c,h)}:{tree:[{name:Q_(c),path:Qf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){wn(e._meta,"_agent/getFileContent");let r=br(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 Gc(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 Qr(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Kf)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Kf})`);let l=await $f(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 Ne(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Hc(e,r||"."),o=Kc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Vf}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ne(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 B_(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 F_(t){return t==="claude-code"?Dt(".claude","skills"):Dt(".agents","skills")}var z_=3e4,U_=50*1024*1024,Sr=3e4;async function $c(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=B_(o.skillName),h=F_(i),x=Dt(h,u),m=Dt(r,x);if(await qc(m,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");ki(S.length),await jc(Dt(m,"SKILL.md"),S,"utf8")}else{let S=await q_(o.downloadUrl);H_(S)?await V_(S,m):W_(S)?await K_(S,m):await jc(Dt(m,"SKILL.md"),S.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:x,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Se.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:x,source:c?"content":"downloadUrl"}),E}function Vc(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 G_(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 q_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ki(e);let r=j_(t);return ki(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await $f(e);return ki(r.length),r}if(Ti(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),z_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return ki(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ki(t){if(t>U_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function j_(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 H_(t){return t.length>=2&&t[0]===31&&t[1]===139}function W_(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 Wc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function K_(t,e){let r,i;try{r=new Yf.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Wc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(x=>x===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=$_(i),c=Hc(e);for(let l of i){if(Wc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=Hc(e,u),x=Kc(c,h);if(x.startsWith("..")||x==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await qc(h,{recursive:!0});continue}await qc(T_(h),{recursive:!0});let m;try{m=l.getData()}catch(E){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await jc(h,m)}}function $_(t){let e;for(let r of t){let i=r.entryName;if(!i||Wc(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 V_(t,e){await J_(t);let r=Sf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Sr}ms)`))},Sr);try{await Zf(Jf.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Sr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function J_(t){let e=[],r=Er({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Sr}ms)`))},Sr);try{await Zf(Jf.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Sr}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 Z_=5e3;async function Y_(t,e,r,i){return Xf(t,e,r,i,{count:0})}async function Xf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await S_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(D_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=Z_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Dt(e,u.name),x=R_(Dt(r,u.name)),m=null;try{m=await Gc(h)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let E={name:u.name,path:Qf(Kc(t,h)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(E.children=await Xf(t,h,x,i-1,o)),l.push(E)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function X_(t){return!t||t<=0?C_:Math.min(t,k_)}function Q_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Qf(t){return t.split(Vf).join("/")}te();import{readFileSync as GA}from"node:fs";import{dirname as jA,join as HA}from"node:path";import{fileURLToPath as KA}from"node:url";var Ir="0.2.0-alpha.8";var _n=G("agent-health-reporter"),ey=1e4,Di=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??ey}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),_n.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),_n.info("heartbeat stopped"))}async tick(){if(this.inFlight){_n.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){_n.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=ty(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:Ir,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){_n.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(_n.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){_n.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){_n.warn("onTickEnd hook failed",{err:String(r)})}}};function ty(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as Ky,mkdir as po,rm as $y,stat as Vy,writeFile as Jy}from"node:fs/promises";import{homedir as Zy}from"node:os";import{join as T0}from"node:path";nn();import{existsSync as xy}from"node:fs";import{release as py}from"node:os";import{basename as gy,isAbsolute as my}from"node:path";function Pi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Ar(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Tr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function yn(t,e){return{jsonrpc:"2.0",id:t,error:e}}We();var oo=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,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32022};function e0(t){return"method"in t&&"id"in t&&t.id!==void 0}function t0(t){return"method"in t&&!("id"in t)}function ao(t){return!("method"in t)&&"id"in t}var ny={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,METHOD_NOT_FOUND:Q.METHOD_NOT_FOUND,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,OPERATION_NOT_ALLOWED_FOR_CLOUD:Q.OPERATION_NOT_ALLOWED_FOR_CLOUD,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 ry(t){if(t!=null)return t instanceof Error?{name:t.name,message:Oi(t.message)}:typeof t=="string"?Oi(t):typeof t=="object"?sy(t):t}var iy=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Oi(t){let e=t;for(let[r,i]of iy)e=e.replace(r,i);return e}function sy(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Oi(i):e[r]=i;return e}function Li(t){if(t instanceof T){let e=ry(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:ny[t.code]??Q.INTERNAL_ERROR,message:Oi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Oi(t instanceof Error?t.message:String(t))}}function n0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...u}=e;c=u}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function i0(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var r0=10*1024*1024,co=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>r0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${r0} 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 o0={"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","session/set_mode":"session.setMode",initialize:"initialize"},rT=Object.fromEntries(Object.entries(o0).map(([t,e])=>[e,t])),oy={"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"],"session.setMode":["agentId","sessionId"],"agent.pair":[],initialize:[]},Rr=class{seq=0;next(e,r){this.seq+=1;let i=o0[e]??ay(e),o=oy[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>s0(r?.[h]??"")),u=cy(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>s0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function ay(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function s0(t){return t.replace(/[:_\s]+/g,"-")}function cy(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Xr();import{readFileSync as dy}from"node:fs";var ly=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 ir(t.agentEnvFile,r,{mode:ly})}function Zc(t){try{let e=JSON.parse(dy(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function a0(t,e,r={},i=o=>o){return{...i({...t,...Zc(e)}),...r}}Wt();Qn();We();te();De();import{execFileSync as uy,spawnSync as fy}from"node:child_process";function Ni(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Mi(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),fy("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Yc=new Set;function c0(t){typeof t=="number"&&t>0&&Yc.add(t)}function d0(t){typeof t=="number"&&Yc.delete(t)}function l0(){for(let t of Yc)Mi(t,"SIGKILL")}var Cr="coze-bridge-daemon";function u0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return uy("pgrep",["-U",String(o),"-f",Cr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
|
|
95
|
+
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function f0(t,e){if(t.length===0)return;let r=e?.killFn??Mi,i=e?.isAliveFn??Ni,o=e?.sleepFn??(u=>new Promise(h=>setTimeout(h,u))),c=e?.graceMs??3e3,l=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(h=>i(h));u+=l)await o(Math.min(l,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var hy=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/]claude-agent-acp|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function h0(t,e){if(!e)return null;for(let r of hy)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function x0(t,e){return h0(t,e)}function p0(t,e){return h0(t,e)}function kr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function g0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,m=r-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:kr(m,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:kr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:kr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:kr(c,!1,e)}}var m0=He("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),wy=200,_y=40,yy=He("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Ey=He("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),by=He("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),vy=He("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),Sy=He("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),Iy=He("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),w0=500;function Ay(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=w0?t:`${e.slice(0,w0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Ty(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function _0(t){try{return xy(t)}catch{return}}function Ry(t,e){return{platform:process.platform,osRelease:py(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:my(e.command)?_0(e.command):void 0,cwd:e.cwd,cwdExists:_0(e.cwd),envKeys:e.envKeys}}function Cy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${gy(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new co({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Rr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=a0(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=nt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,c0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>wy&&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,d0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=Ry(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",Cy(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()));Mi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Mi(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:Sy,phase2GateMs:yy,livenessWindowMs:Ey,absoluteMaxMs:by,approvalMaxMs:Iy,suspendThresholdMs:vy,...r};return this.call("session/prompt",e,m0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Ar("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",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(Tr(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(yn(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=m0,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Pi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let h=r.sessionId;return typeof h=="string"?h:void 0})();return new Promise((h,x)=>{let m={resolve:h,reject:x,timer:null,method:e,promptTimeout:null};if(o){let E=this.now(),S={cfg:o,startedAt:E,lastActivityAt:E,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:E,expectedIntervalMs:kr(0,!1,o),sessionId:u};m.promptTimeout=S;let _=()=>{let b={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},I=this.now(),A=g0(b,S.cfg,I),R=k=>{S.armedAt=I,S.expectedIntervalMs=k,m.timer=setTimeout(_,k)};if(A.action==="suspend"){S.suspendedMs+=A.suspendedDeltaMs,S.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),R(A.rearmMs);return}if(A.action==="continue"){R(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),x(A.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),x(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};m.timer=setTimeout(_,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(m.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,m);try{this.writeFrame(l)}catch(E){m.timer&&clearTimeout(m.timer),this.pending.delete(c),x(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(i0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(ao(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Ay(e.result)}),r.resolve(e.result));return}if(t0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(e0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(yn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(yn(e.id,Li(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=n0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=p0(this.framework,Ty(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(_y).join(`
|
|
96
|
+
`),o=x0(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function ky(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 lo=class extends Pt{framework="claude-code";constructor(e){let{command:r,args:i}=Yr("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 ky(e)}};nn();import{mkdtempSync as Dy,rmSync as Py}from"node:fs";import{tmpdir as Oy}from"node:os";import{join as Ly}from"node:path";var uo=class extends Pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Yr("codex",e.command,i),l=e.isolateCodexHome?Dy(Ly(Oy(),"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{Py(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};We();var Ny=3e4,Dr=class extends Pt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Ny))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var y0=["default","acceptEdits","plan","auto","bypassPermissions"],E0=["read-only","auto","full-access"];function En(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return y0.includes(e);case"codex":return E0.includes(e);case"openclaw":return!1}}function Xc(t){switch(t){case"claude-code":return y0.join("/");case"codex":return E0.join("/");case"openclaw":return""}}We();te();De();function Qc(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 fo=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let 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)Bi(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 Bi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Kt(t){return t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Wt();te();import{constants as b0}from"node:fs";import{access as My}from"node:fs/promises";import{delimiter as By,join as Fy}from"node:path";var Et=G("framework-detector"),v0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},zy=[".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??nt,access:e.access??My}}async detect(e){let r=v0[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)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(v0).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(By).filter(Boolean),i=this.env.platform==="win32"?["",...zy]:[""];for(let o of r)for(let c of i){let l=Fy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?b0.F_OK:b0.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&&(Gy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),u(null)},15e3),h.stdout?.on("data",x=>{o+=x.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},Uy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Gy(t){return t.replace(Uy,"")}import{homedir as qy}from"node:os";import{join as jy}from"node:path";Wt();Qn();We();Xr();te();async function A0(){let t=jy(qy(),".openclaw/openclaw.json");return(await rr(t))?.gateway?.auth?.token??""}var S0=G("openclaw.config"),Hy=[0,5e3,5e3],Wy=He("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),I0="models.providers.",ho="agents.defaults.models",xo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new bn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Hy,this.cliTimeoutMs=e.cliTimeoutMs??Wy}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,S0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=nt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=x=>{l||(l=!0,clearTimeout(h),x())};o.stderr?.on("data",x=>{c+=x.toString("utf8")});let h=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);h.unref(),o.on("error",x=>u(()=>i(x))),o.on("close",x=>u(()=>{x===0?r():i(new Error(`exit ${x}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){S0.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",`${I0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${I0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ho}[${e}]`,()=>this.runCli(["config","set",ho,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ho}[${e}]`,`${ho}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}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 de=G("agent-manager"),td="acceptEdits",k0="full-access",D0="read-only";function Yy(t){switch(t){case"read-only":return["-c",'sandbox_mode="read-only"',"-c",'approval_policy="on-request"'];case"auto":return["-c",'sandbox_mode="workspace-write"',"-c",'approval_policy="on-failure"'];case"full-access":return["-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']}}var Xy=(t,e,r,i,o,c,l,u,h,x)=>{switch(t){case"claude-code":{let m={...o?{...Uf(o),...jf(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new lo({cwd:r,env:m,agentId:i})}case"codex":{let m=o?[...Gf(o),...Wf(o,l,u)]:[],E=k0;x!==void 0&&(En("codex",x)?E=x:de.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:x}));let S=[...m,...Yy(E)],_={...o?qf(o):{},...h??{}},b=!!o;return new uo({cwd:r,agentId:i,...S.length>0?{extraArgs:S}:{},...Object.keys(_).length>0?{env:_}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Dr({command:e,cwd:r,agentId:i,...c?{sessionName:Qc(c)}:{}})}};function ed(t){return t==="claude-code"||t==="codex"}function Qy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(eE(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
97
97
|
`)}
|
|
98
|
-
`}function
|
|
99
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var eE={path:"",version:"cloud-deployed"},R0="openclaw_gateway_unavailable",tE="openclaw_default_agent_missing";function k0(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 nE={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},rE=6e4,_o=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Yy,this.createTimeoutMs=e.createTimeoutMs??rE,this.detectorFactory=e.detectorFactory??(()=>new Wn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new mo({command:r})),this.openclawConfigDir=e.openclawConfigDir??C0(Jy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{de.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=C0(e,".env");if(await $y(r).then(c=>c.isFile()).catch(()=>!1)){de.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await wo(e,{recursive:!0});let o=Xy({...process.env,...Xc(this.paths.agentEnvFile)});if(await Vy(r,o,"utf8"),process.platform!=="win32")try{await Wy(r,384)}catch(c){de.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}de.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),de.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let i=await Ne(e.agentId,this.paths).catch(()=>null),o=ro(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")de.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(R=>de.warn("dispose stale agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")de.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(R=>de.warn("dispose drifted agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){de.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let R=await Ne(e.agentId,this.paths).catch(()=>null);R&&(R.patToken=e.patToken,await Qe(R,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){de.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let R=await Ne(e.agentId,this.paths).catch(()=>null);R&&(R.modelInfo=e.modelInfo,await Qe(R,this.paths))}return de.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=Xe(e.agentId,this.paths),x=o?"cloud":"local",p=e.framework==="openclaw"&&x==="local",g;p&&!r?.revive&&(g=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=g??(p?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??_??u.workspace,w=new AbortController,v=setTimeout(()=>w.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,T=!1;try{o&&nd(e.framework)&&await sr(e.framework,w.signal);let R=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await wo(u.root,{recursive:!0}),await wo(S,{recursive:!0}),await wo(u.logs,{recursive:!0}),R(),p||await cr(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(x==="cloud"?await Ra(S,"cloud"):await Ra(S,"local",rd)),R();let P=i,y=zf({model:e.model??P?.model}),k=Tf(e._meta)??P?.accountId,O=e.patToken??P?.patToken,F=x==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(I=new po({agentId:e.agentId,framework:e.framework,workspace:S,model:y.model??bt,deployType:x,...k?{accountId:k}:{},...O?{patToken:O}:{},...F?{modelInfo:F}:{}}),I.status="ok",P?.sessions){let K=x==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Z,re]of Object.entries(P.sessions)){let se={acpSessionId:re.acpSessionId,modelToken:re.modelToken,tokenGeneratedAt:re.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};K?re.permissionMode===void 0?(se.permissionMode=e.framework==="claude-code"?"bypassPermissions":"full-access",de.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Z,framework:e.framework,fallback:se.permissionMode})):Sn(e.framework,re.permissionMode)?se.permissionMode=re.permissionMode:de.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Z,framework:e.framework,value:re.permissionMode}):re.permissionMode!==void 0&&de.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Z,framework:e.framework,deployType:x}),re.cozeGroupId&&(se.cozeGroupId=re.cozeGroupId),I.sessions.set(Z,se)}let ee=Object.keys(P.sessions).length;ee>0&&de.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ee})}this.registry.register(I),T=!0;let N={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:y.model};x==="cloud"&&(N.deployType="cloud"),k&&(N.accountId=k),O&&(N.patToken=O),F&&(N.modelInfo=F),P?.skills&&(N.skills=P.skills),P?.agentName&&(N.agentName=P.agentName),P?.description&&(N.description=P.description),e.framework==="openclaw"&&x==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):de.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let J=e.initialSkills??[];if(J.length>0){let K=[...N.skills??[]],ee=new Map(K.map((se,L)=>[se.skillId,L])),Z=await Promise.allSettled(J.map(se=>Jc({agentId:e.agentId,workspace:S,framework:e.framework,skill:se}))),re=0;for(let[se,L]of Z.entries()){let H=J[se];H&&(L.status==="fulfilled"?(Zc(K,ee,L.value),re++):de.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:H.skillId,skillName:H.skillName,err:String(L.reason)}))}re>0&&(N.skills=K,de.info("initialSkills installed",{agentId:e.agentId,installed:re,requested:J.length}))}return await Qe(N,this.paths),de.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:x}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(R){throw de.error("agent create failed, rolling back",{agentId:e.agentId,err:String(R)}),T&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Ky(u.root,{recursive:!0,force:!0}).catch(P=>de.warn("rm agent dir failed (ignored)",{err:String(P)})),R instanceof C?R:new C("AGENT_SPAWN_FAILED",String(R),{cause:R})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&nd(e.framework))u=eE;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);nd(e.framework)&&!ds(e.framework)&&(de.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await sr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;if(e.framework==="openclaw")p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else{let g=e.sessions.get(i),_=Jt(e)?g?.permissionMode??D0:"full-access";p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),_)}try{return await p.start(),await p.initialize(nE),p}catch(g){let _=p instanceof Lt?p.getStderrTail():[];throw _.length>0&&de.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:g instanceof C?g.code:"unknown",recentStderr:_}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,g)}}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 C("AGENT_ENV_NOT_READY",k0(o),{cause:{reason:R0}})}catch(o){de.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof C?i:new C("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};de.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 de.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 C("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:tE}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new C("AGENT_ENV_NOT_READY",k0(r),{cause:{reason:R0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,x=td(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Lr({command:u,cwd:S.workspace,agentId:S.id,sessionName:x})}let p=await T0(),g=i?Wf(i,c,d):null,_;if(g){let S=Hc(o),v=g.models[0]?.id??bt,I=`${S}/${v}`;if(!this.ensuredProviders.has(I)){let T=this.getOpenclawConfig();await T.ensureProvider(S,g),await T.addModelToAllowlist(I),this.ensuredProviders.add(I)}_=I}return new Lr({command:u,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=Hc(i),c=`${o}/${e.model}`,d=!0;try{await r.removeProvider(o)}catch(u){d=!1,de.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){d=!1,de.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as B0}from"node:crypto";import{promises as uE}from"node:fs";import{basename as F0}from"node:path";We();te();import{promises as sE}from"node:fs";import{basename as oE}from"node:path";var O0=G("file-upload"),aE="/api/coze_claw/file/agent_upload",cE=6e4;async function L0(t,e={}){let i=`${so(ao(e.handshakeBase))}${aE}`,o=e.timeoutMs??cE,c=await sE.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Ar(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);O0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let g=await fetch(i,{method:"POST",headers:u,body:d,signal:x.signal}),_=g.headers.get("x-tt-logid")??"";if(!g.ok){let v=await g.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${g.status} logid=${_}: ${v.slice(0,200)}`)}let S=await g.json();if(S.code!==void 0&&S.code!==0)throw new C("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${_}`);let w=S.data?.file?.file_url;if(!w)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(S).slice(0,200)}`);return O0.info("file upload ok",{uri:w,logid:_}),{uri:w}}catch(g){throw g instanceof C?g:g.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${oE(t.path)}`):new C("UPLOAD_FAILED",String(g),{cause:g})}finally{clearTimeout(p)}}We();te();import{extname as dE}from"node:path";var lE={".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 N0(t){let e=dE(t).toLowerCase();return lE[e]??"application/octet-stream"}ke();var yo=G("agent-send"),M0=50*1024*1024;function z0(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function U0(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,x<2&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(g=>setTimeout(g,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function G0(t,e){let{session:r,runtime:i}=z0(e.core,t.agentId,t.sessionId);if(!await ni(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await uE.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>M0)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${M0}`);let c=await N0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??F0(t.path),u;try{u=await L0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw yo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof C?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:B0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await U0(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),yo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function H0(t,e){let{session:r,runtime:i}=z0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??F0(t.path),c={sessionUpdate:"group_file",messageId:B0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await U0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),yo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function j0(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let d=r[c]??0,u=i[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}on();Vt();te();var Nt=G("coze-cli-installer"),q0="@coze/cli@latest",fE="coze",W0="0.1.8",xE=5e3,hE=5e3,pE=9e4,K0=1e4,Gi=null,Eo=!1;async function id(t,e={}){if(Eo)return;if(Gi)return Gi;let r=e.exec??Pf;return Gi=(async()=>{try{let i=await gE(fE,r),o=!1;if(i){let d=await mE(r);if(d===void 0)Nt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(j0(d,W0))Nt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:W0}),o=!0;else{Nt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),Eo=!0;return}}let c=o?"upgrade-only":"full";Nt.info("coze-cli install start",{package:q0,mode:c});try{await r("npm",["i","-g","--prefer-online",q0],{timeout:pE,maxBuffer:10*1024*1024}),Nt.info("coze-cli install ok")}catch(d){Nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(o){Eo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:K0}),Nt.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Nt.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:K0}),Nt.info("coze auth login ok")}catch(d){Nt.warn("coze auth login failed",{err:String(d)});return}Eo=!0}finally{Gi=null}})(),Gi}async function gE(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:xE});return Ta(i)}catch{return}}async function mE(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:hE});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}ti();ke();var wE=10*6e4;function $0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?wE:e}function bo(t){return or(t??X().configFile)}function Hi(t,e){return ar(e??X().configFile,t)}import{randomBytes as FE}from"node:crypto";nr();We();te();import{createReadStream as _E}from"node:fs";import{mkdir as yE,readFile as EE,realpath as bE,stat as vE,writeFile as SE}from"node:fs/promises";import{basename as IE,dirname as sd,isAbsolute as AE,join as TE,relative as CE,resolve as V0,sep as RE}from"node:path";import{createInterface as kE}from"node:readline";var Z0=G("fs-rpc"),ji=qe("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Y0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>ji)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${ji} bytes`);let i=await Q0(t.path,e);return await yE(sd(i),{recursive:!0}),await SE(i,t.content,"utf8"),Z0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function X0(t,e){let r=await Q0(t.path,e),i=await vE(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>ji&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${ji} bytes`);let c;if(o&&i.size>ji)c=await DE(r,t.line??1,t.limit);else{let d=await EE(r,"utf8");if(o){let u=d.split(`
|
|
100
|
-
`),
|
|
101
|
-
`)}else c=
|
|
102
|
-
`)}async function Q0(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([J0(V0(e)),J0(V0(t))]),o=CE(r,i);if(PE(o,RE,AE(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function PE(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function J0(t){let e=[],r=t;for(;r!==sd(r);)try{let i=await bE(r);return e.length?TE(i,...e.reverse()):i}catch{e.push(IE(r)),r=sd(r)}return t}te();var ex=G("prompt-multimodal"),tx=10*1024*1024,OE=15e3,LE=6;async function nx(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await NE(d))}}let o=Array.from({length:Math.min(LE,t.length)},()=>i());return await Promise.all(o),e}function rx(t){return t.some(e=>e.type==="image")}async function NE(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!ki(e.uri))return t;try{let{buf:r,contentType:i}=await BE(e.uri),o=e.mimeType||ME(i)||"application/octet-stream";return ex.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 ex.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ME(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function BE(t){let e=new AbortController,r=setTimeout(()=>e.abort(),OE);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>tx)throw new Error(`image too large: ${o.byteLength} bytes (max ${tx})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}an();We();te();var q=G("core"),zE=3e4,UE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,GE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",HE="\u5BA1\u6279\u5DF2\u8D85\u65F6",jE=3e4,vo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Dr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=$0(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(),q.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){q.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),q.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){q.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)&&q.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,d)=>{q.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),Ui(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){q.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(vn(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>q.debug("send error response to upstream failed (ignored)",{err:String(d)}));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)){q.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 C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(uo(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&&UE.test(i)?this.currentCozeEnv=i:i&&q.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}`):q.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(kr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(kr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(kr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):q.warn("drop unknown notification",{method:e.method})}catch(o){q.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(vn(r,Bi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!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,g=io(r._meta);return q.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,GE,p,g)}}let d=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{q.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Rf(i);switch(r){case"session/new":{let c=qE();return q.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return q.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,d=c.sessionId;if(!d)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Jt(e)?Cf(i._meta):void 0;if(u!==void 0&&!Sn(e.framework,u))throw new C("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${ed(e.framework)}`);let x=await this.ensureRuntime(e,d);if(u!==void 0&&x.permissionMode===void 0&&(x.permissionMode=u,await this.persistSessionMapping(e)),x.replySeq=0,await this.ensureDownstream(e,d,x),!x.downstream||!x.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&x.permissionMode!==void 0&&x.permissionMode!==u){let S=x.permissionMode;x.permissionMode=u,await this.persistSessionMapping(e);try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(w){throw x.permissionMode=S,await this.persistSessionMapping(e).catch(()=>{}),w}}let p=i._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(x.acpSessionId,p):e.activeTriggers.delete(x.acpSessionId);let g=io(i._meta);if(g?e.activeGroupIds.set(x.acpSessionId,g):e.activeGroupIds.delete(x.acpSessionId),g&&x.cozeGroupId!==g&&(x.cozeGroupId=g,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&rx(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await nx(c.prompt);try{let S=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:_});return x.lastActiveAt=Date.now(),S}catch(S){if(S instanceof C&&S.code==="AGENT_APPROVAL_TIMEOUT"){let w=x.pendingPermission;w&&(w.downstream.respondAgentRequest(w.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(w.upstreamId),x.pendingPermission=void 0);let v=x.acpSessionId,I=v?e.activeTriggers.get(v):void 0,T=v?e.activeGroupIds.get(v):void 0;return q.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:d}),await this.synthesizePromptReply(e,x,d,HE,I,T)}throw S}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.pendingPermission=void 0,x.reloadAfterTurn){x.reloadAfterTurn=!1;let S=x.downstream;S&&(x.downstream=void 0,q.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:x.acpSessionId}),S.stop("reload-after-turn").catch(w=>q.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(w)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,d,x)}}case"session/cancel":{let d=o.sessionId;if(!d)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let x=e.getSessionQueue(d);x.size>0&&(q.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:x.size}),x.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,d=c.sessionId,u=c.modeId,x=io(i._meta);if(!d)throw new C("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Jt(e))throw e.framework==="openclaw"?new C("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new C("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Sn(e.framework,u))throw new C("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${ed(e.framework)}`);if(x)return await this.handleGroupSetMode(e,x,u);let p=e.sessions.get(d)??await this.ensureRuntime(e,d);if(p.permissionMode===u)return{};let g=p.permissionMode;if(p.permissionMode=u,await this.persistSessionMapping(e),p.downstream?.isAlive()&&p.acpSessionId)try{await p.downstream.setSessionMode({sessionId:p.acpSessionId,modeId:u})}catch(_){throw p.permissionMode=g,await this.persistSessionMapping(e).catch(()=>{}),_}else q.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:d,modeId:u});return{}}default:throw new C("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[d,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:d,runtime:u,oldMode:u.permissionMode});if(o.length===0)return q.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};q.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let d of o)d.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let d of o){let u=d.runtime.downstream,x=d.runtime.acpSessionId;u?.isAlive()&&x&&c.push({downstream:u,acpSessionId:x,oldMode:d.oldMode,runtime:d.runtime})}for(let d of c)try{await d.downstream.setSessionMode({sessionId:d.acpSessionId,modeId:i})}catch(u){for(let x of o)x.runtime.permissionMode=x.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}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 Jt(e)&&(c.permissionMode=e.framework==="claude-code"?rd:P0),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(Et.GEN_MODEL_TOKEN,i,jE);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Ui(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,d=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(d>=o&&Date.now()-u<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=d+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(q.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),q.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){q.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let g=await x.sessionNew({cwd:e.workspace});i.acpSessionId=g.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)}}catch(p){throw q.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,p}if(x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId),Jt(e)&&i.acpSessionId&&i.permissionMode)try{await x.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(p){q.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(p)})}}armIdleTimer(e,r,i){if(Ui(i),this.isRuntimeBusy(e,i)){q.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)){q.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}q.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=>q.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Rr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,d){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),d&&(u.cozeGroupId=d),await this.upstream.send(Rr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>q.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){q.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){q.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if($E(r)){q.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let d=r.update;if(d&&typeof d=="object"&&d.sessionUpdate==="current_mode_update"&&Jt(e)){let g=d.currentModeId;Sn(e.framework,g)&&c.permissionMode!==g?(c.permissionMode=g,this.persistSessionMapping(e).catch(_=>q.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(_)}))):typeof g=="string"&&!Sn(e.framework,g)&&q.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:g})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(i);x&&(u.cozeTriggerMsgId=x);let p=e.activeGroupIds.get(i);p&&(u.cozeGroupId=p),this.upstream.send(Rr("session/update",{...r,sessionId:o,_meta:u})).catch(g=>q.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}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}q.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??{},d=await Y0(c,o);r.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await X0(c,o);r.respondAgentRequest(i.id,d)}}catch(o){q.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Bi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let g=u?e.activeGroupIds.get(u):void 0;g&&(p.cozeGroupId=g);let _=u?this.reverseSessionId(e,u):void 0,S=_?e.sessions.get(_):void 0;S&&(S.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:_}),q.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:_,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ni(o,"session/request_permission",w)).catch(v=>{this.pendingUpstream.delete(o),q.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?(q.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"&&WE(e.result,o),q.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 lo(e.error)):i.value.resolve(e.result);return}q.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),d=e.get(c);if(d)return q.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,i=zE){let o=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),d(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(Ni(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),d(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Jt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await ri(e.agentId,r,this.paths)}catch(r){q.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(vn(e,{code:r,message:i,data:{bridgeVersion:Cr}}))}};function qE(){return FE(16).toString("hex")}function WE(t,e){if(!t||typeof t!="object"){q.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){q.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"){q.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")&&q.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var KE=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function $E(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return KE.some(c=>o.startsWith(c))}te();ke();import{randomBytes as VE}from"node:crypto";import{chmod as JE,mkdir as ZE,writeFile as ix}from"node:fs/promises";import{createServer as YE}from"node:http";import{dirname as XE}from"node:path";var QE=1e6,od=G("ipc"),So=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??X()}async start(){this.token=VE(32).toString("hex");let e=YE((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),od.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await ZE(XE(this.paths.portFile),{recursive:!0}),await ix(this.paths.portFile,String(this.port),"utf8"),await ix(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await JE(this.paths.tokenFile,384)}catch(e){od.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){qi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){qi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await eb(e)}catch(u){qi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);qi(r,200,u??{ok:!0})}catch(u){od.error("IPC handler failed",{key:o,err:String(u)}),qi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function qi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function eb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>QE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var E1=Gt(eh(),1),b1=Gt(Oo(),1),v1=Gt(Br(),1),S1=Gt(md(),1),I1=Gt(yd(),1),A1=Gt(Ad(),1),dh=Gt(Bo(),1),T1=Gt(ch(),1);var lh=dh.default;We();te();var{FWS:j1}=Eh(),Ce=G("upstream.frontier"),vh="application/json",Sh="none",q1=15e3;function W1(t){class e extends lh{constructor(i){super(i,Lf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Ce.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(gl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let d=Buffer.from(c.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){Ce.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Qi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Nf,...Ar(this.opts.ppeOverride)},r=W1(e),i=Bf(this.opts.urlOverride),o={url:i,ws:r,fpID:Of,aID:oo,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:vh,force:!0},payloadEncoding:{encoding:Sh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new j1(o),d=!1,u=null,x,p,g=new Promise((w,v)=>{x=w,p=v}),_=w=>{d||(d=!0,u&&(clearTimeout(u),u=null),w?p(w):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let w=this.openCount===1;Ce.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=>Ce.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=w=>{this.opened=!1,Ce.info("frontier closed",{code:w.code,reason:w.reason,willReconnect:w.willReconnect})},c.onerror=w=>{Ce.warn("frontier error",{code:w.code,msg:w.message}),_(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${w.code} msg=${w.message??""}`))},c.onmessage=w=>this.handleMessage(w),this.fws=c;let S=this.opts.openTimeoutMs??q1;u=setTimeout(()=>{_(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await g}catch(w){try{c.close(1e3,"open failed")}catch(v){Ce.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){Ce.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ce.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ce.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Ih(c)||Ce.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:vh,payloadEncoding:Sh})}catch(u){throw Ce.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new C("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ce.debug("drop non-adapter frontier frame",{service:r});return}let i=V1(e);if(!i){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(d){Ce.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;Ih(c)||Ce.info("frontier frame in",{logid:$1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:K1(i)}),Promise.resolve(this.handler(o)).catch(d=>Ce.warn("frontier frame handler threw",{err:String(d)}))}};function Ih(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Ah=2e3;function K1(t){return t.length<=Ah?t:`${t.slice(0,Ah)}...<truncated, total ${t.length} chars>`}function $1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function V1(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 kd=G("upstream.switchable"),Ko=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;kd.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 kd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>kd.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 Dd=G("upstream"),jr=class{handler=null;async start(){Dd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Dd.info("NoopUpstream stopped",{reason:e})}async send(e){Dd.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)}};We();te();te();ke();import{promises as Pd}from"node:fs";import{dirname as J1}from"node:path";var Z1=G("pat-token-store");async function $o(t=X()){try{let r=(await Pd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Z1.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function es(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await Pd.mkdir(J1(e.patTokenFile),{recursive:!0}),await Pd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}ke();ke();import{promises as Vo}from"node:fs";import{join as Y1}from"node:path";function X1(t,e){return`#!/bin/sh
|
|
98
|
+
`}function eE(t){if(t.includes(`
|
|
99
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var tE={path:"",version:"cloud-deployed"},R0="openclaw_gateway_unavailable",nE="openclaw_default_agent_missing";function C0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var rE={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},iE=6e4,go=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Xy,this.createTimeoutMs=e.createTimeoutMs??iE,this.detectorFactory=e.detectorFactory??(()=>new qn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new xo({command:r})),this.openclawConfigDir=e.openclawConfigDir??T0(Zy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new 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=>{de.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=T0(e,".env");if(await Vy(r).then(c=>c.isFile()).catch(()=>!1)){de.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await po(e,{recursive:!0});let o=Qy({...process.env,...Zc(this.paths.agentEnvFile)});if(await Jy(r,o,"utf8"),process.platform!=="win32")try{await Ky(r,384)}catch(c){de.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}de.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),de.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=await Ne(e.agentId,this.paths).catch(()=>null),o=eo(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")de.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(R=>de.warn("dispose stale agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")de.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(R=>de.warn("dispose drifted agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){de.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let R=await Ne(e.agentId,this.paths).catch(()=>null);R&&(R.patToken=e.patToken,await Qe(R,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){de.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let R=await Ne(e.agentId,this.paths).catch(()=>null);R&&(R.modelInfo=e.modelInfo,await Qe(R,this.paths))}return de.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!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 u=Xe(e.agentId,this.paths),h=o?"cloud":"local",x=e.framework==="openclaw"&&h==="local",m;x&&!r?.revive&&(m=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let E=m??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??E??u.workspace,_=new AbortController,b=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&ed(e.framework)&&await nr(e.framework,_.signal);let R=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await po(u.root,{recursive:!0}),await po(S,{recursive:!0}),await po(u.logs,{recursive:!0}),R(),x||await sr(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(h==="cloud"?await Ta(S,"cloud"):await Ta(S,"local",td)),R();let k=i,y=Ff({model:e.model??k?.model}),C=Af(e._meta)??k?.accountId,D=e.patToken??k?.patToken,B=h==="cloud"?e.modelInfo??k?.modelInfo:void 0;if(I=new fo({agentId:e.agentId,framework:e.framework,workspace:S,model:y.model??yt,deployType:h,...C?{accountId:C}:{},...D?{patToken:D}:{},...B?{modelInfo:B}:{}}),I.status="ok",k?.sessions){let V=h==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Z,re]of Object.entries(k.sessions)){let se={acpSessionId:re.acpSessionId,modelToken:re.modelToken,tokenGeneratedAt:re.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};V?re.permissionMode===void 0?(se.permissionMode=e.framework==="claude-code"?"bypassPermissions":"full-access",de.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Z,framework:e.framework,fallback:se.permissionMode})):En(e.framework,re.permissionMode)?se.permissionMode=re.permissionMode:de.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Z,framework:e.framework,value:re.permissionMode}):re.permissionMode!==void 0&&de.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Z,framework:e.framework,deployType:h}),re.cozeGroupId&&(se.cozeGroupId=re.cozeGroupId),I.sessions.set(Z,se)}let ee=Object.keys(k.sessions).length;ee>0&&de.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ee})}this.registry.register(I),A=!0;let M={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:k?.createdAt??Date.now(),sessions:k?.sessions??{},model:y.model};h==="cloud"&&(M.deployType="cloud"),C&&(M.accountId=C),D&&(M.patToken=D),B&&(M.modelInfo=B),k?.skills&&(M.skills=k.skills),k?.agentName&&(M.agentName=k.agentName),k?.description&&(M.description=k.description),e.framework==="openclaw"&&h==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):de.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let J=e.initialSkills??[];if(J.length>0){let V=[...M.skills??[]],ee=new Map(V.map((se,P)=>[se.skillId,P])),Z=await Promise.allSettled(J.map(se=>$c({agentId:e.agentId,workspace:S,framework:e.framework,skill:se}))),re=0;for(let[se,P]of Z.entries()){let q=J[se];q&&(P.status==="fulfilled"?(Vc(V,ee,P.value),re++):de.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:q.skillId,skillName:q.skillName,err:String(P.reason)}))}re>0&&(M.skills=V,de.info("initialSkills installed",{agentId:e.agentId,installed:re,requested:J.length}))}return await Qe(M,this.paths),de.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:h}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(R){throw de.error("agent create failed, rolling back",{agentId:e.agentId,err:String(R)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await $y(u.root,{recursive:!0,force:!0}).catch(k=>de.warn("rm agent dir failed (ignored)",{err:String(k)})),R instanceof T?R:new T("AGENT_SPAWN_FAILED",String(R),{cause:R})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&ed(e.framework))u=tE;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);ed(e.framework)&&!os(e.framework)&&(de.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await nr(e.framework));let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;if(e.framework==="openclaw")x=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else{let m=e.sessions.get(i),E=Kt(e)?m?.permissionMode??k0:"full-access";x=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv(),E)}try{return await x.start(),await x.initialize(rE),x}catch(m){let E=x instanceof Pt?x.getStderrTail():[];throw E.length>0&&de.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof T?m.code:"unknown",recentStderr:E}),await x.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 T("AGENT_ENV_NOT_READY",C0(o),{cause:{reason:R0}})}catch(o){de.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?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};de.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 de.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:nE}})}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",C0(r),{cause:{reason:R0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=Qc(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Dr({command:u,cwd:S.workspace,agentId:S.id,sessionName:h})}let x=await A0(),m=i?Hf(i,c,l):null,E;if(m){let S=Uc(o),b=m.models[0]?.id??yt,I=`${S}/${b}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(S,m),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}E=I}return new Dr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...x?{gatewayToken:x}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Uc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,de.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,de.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as M0}from"node:crypto";import{promises as fE}from"node:fs";import{basename as B0}from"node:path";We();te();import{promises as oE}from"node:fs";import{basename as aE}from"node:path";var P0=G("file-upload"),cE="/api/coze_claw/file/agent_upload",dE=6e4;async function O0(t,e={}){let i=`${no(io(e.handshakeBase))}${cE}`,o=e.timeoutMs??dE,c=await oE.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",...vr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,x=setTimeout(()=>h.abort(),o);P0.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 b=await m.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${b.slice(0,200)}`)}let S=await m.json();if(S.code!==void 0&&S.code!==0)throw new T("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${E}`);let _=S.data?.file?.file_url;if(!_)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(S).slice(0,200)}`);return P0.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof T?m:m.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${aE(t.path)}`):new T("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(x)}}We();te();import{extname as lE}from"node:path";var uE={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function L0(t){let e=lE(t).toLowerCase();return uE[e]??"application/octet-stream"}De();var mo=G("agent-send"),N0=50*1024*1024;function F0(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 z0(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){u=x,h<2&&(mo.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(x)}),await new Promise(m=>setTimeout(m,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function U0(t,e){let{session:r,runtime:i}=F0(e.core,t.agentId,t.sessionId);if(!await Qr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await fE.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>N0)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${N0}`);let c=await L0(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??B0(t.path),u;try{u=await O0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw mo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof T?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let h={sessionUpdate:"agent_file",messageId:M0(),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 z0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),mo.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}=F0(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??B0(t.path),c={sessionUpdate:"group_file",messageId:M0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await z0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),mo.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 q0(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();Wt();te();var Ot=G("coze-cli-installer"),j0="@coze/cli@latest",hE="coze",H0="0.1.8",xE=5e3,pE=5e3,gE=9e4,W0=1e4,Fi=null,wo=!1;async function nd(t,e={}){if(wo)return;if(Fi)return Fi;let r=e.exec??Df;return Fi=(async()=>{try{let i=await mE(hE,r),o=!1;if(i){let l=await wE(r);if(l===void 0)Ot.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(q0(l,H0))Ot.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:H0}),o=!0;else{Ot.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),wo=!0;return}}let c=o?"upgrade-only":"full";Ot.info("coze-cli install start",{package:j0,mode:c});try{await r("npm",["i","-g","--prefer-online",j0],{timeout:gE,maxBuffer:10*1024*1024}),Ot.info("coze-cli install ok")}catch(l){Ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){wo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:W0}),Ot.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Ot.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:W0}),Ot.info("coze auth login ok")}catch(l){Ot.warn("coze auth login failed",{err:String(l)});return}wo=!0}finally{Fi=null}})(),Fi}async function mE(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:xE});return Ia(i)}catch{return}}async function wE(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:pE});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Xr();De();var _E=10*6e4;function K0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?_E:e}function _o(t){return rr(t??X().configFile)}function zi(t,e){return ir(e??X().configFile,t)}import{randomBytes as zE}from"node:crypto";Qn();We();te();import{createReadStream as yE}from"node:fs";import{mkdir as EE,readFile as bE,realpath as vE,stat as SE,writeFile as IE}from"node:fs/promises";import{basename as AE,dirname as rd,isAbsolute as TE,join as RE,relative as CE,resolve as $0,sep as kE}from"node:path";import{createInterface as DE}from"node:readline";var J0=G("fs-rpc"),Ui=He("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Z0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ui)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ui} bytes`);let i=await X0(t.path,e);return await EE(rd(i),{recursive:!0}),await IE(i,t.content,"utf8"),J0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Y0(t,e){let r=await X0(t.path,e),i=await SE(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ui&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ui} bytes`);let c;if(o&&i.size>Ui)c=await PE(r,t.line??1,t.limit);else{let l=await bE(r,"utf8");if(o){let u=l.split(`
|
|
100
|
+
`),h=Math.max(0,(t.line??1)-1),x=typeof t.limit=="number"?h+t.limit:void 0;c=u.slice(h,x).join(`
|
|
101
|
+
`)}else c=l}return J0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function PE(t,e,r){let i=DE({input:yE(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(`
|
|
102
|
+
`)}async function X0(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([V0($0(e)),V0($0(t))]),o=CE(r,i);if(OE(o,kE,TE(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function OE(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function V0(t){let e=[],r=t;for(;r!==rd(r);)try{let i=await vE(r);return e.length?RE(i,...e.reverse()):i}catch{e.push(AE(r)),r=rd(r)}return t}te();var Q0=G("prompt-multimodal"),eh=10*1024*1024,LE=15e3,NE=6;async function th(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 ME(l))}}let o=Array.from({length:Math.min(NE,t.length)},()=>i());return await Promise.all(o),e}function nh(t){return t.some(e=>e.type==="image")}async function ME(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ti(e.uri))return t;try{let{buf:r,contentType:i}=await FE(e.uri),o=e.mimeType||BE(i)||"application/octet-stream";return Q0.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 Q0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function BE(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function FE(t){let e=new AbortController,r=setTimeout(()=>e.abort(),LE);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>eh)throw new Error(`image too large: ${o.byteLength} bytes (max ${eh})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();We();te();var H=G("core"),UE=3e4,GE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,qE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",jE="\u5BA1\u6279\u5DF2\u8D85\u65F6",HE=3e4,yo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Rr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=K0(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),H.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){H.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),H.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){H.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)&&H.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)=>{H.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Bi(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){H.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(yn(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>H.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)){H.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(ao(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&&GE.test(i)?this.currentCozeEnv=i:i&&H.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}`):H.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Tr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Tr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Tr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):H.warn("drop unknown notification",{method:e.method})}catch(o){H.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(yn(r,Li(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let h=o.sessions.get(c);if(h?.pendingPermission){let x=r._meta?.cozeTriggerMsgId,m=to(r._meta);return H.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,h,c,qE,x,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{H.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}=Rf(i);switch(r){case"session/new":{let c=WE();return H.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return H.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Kt(e)?Tf(i._meta):void 0;if(u!==void 0&&!En(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${Xc(e.framework)}`);let h=await this.ensureRuntime(e,l);if(u!==void 0&&h.permissionMode===void 0&&(h.permissionMode=u,await this.persistSessionMapping(e)),h.replySeq=0,await this.ensureDownstream(e,l,h),!h.downstream||!h.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&h.permissionMode!==void 0&&h.permissionMode!==u){let S=h.permissionMode;h.permissionMode=u,await this.persistSessionMapping(e);try{await h.downstream.setSessionMode({sessionId:h.acpSessionId,modeId:u})}catch(_){throw h.permissionMode=S,await this.persistSessionMapping(e).catch(()=>{}),_}}let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(h.acpSessionId,x):e.activeTriggers.delete(h.acpSessionId);let m=to(i._meta);if(m?e.activeGroupIds.set(h.acpSessionId,m):e.activeGroupIds.delete(h.acpSessionId),m&&h.cozeGroupId!==m&&(h.cozeGroupId=m,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&nh(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let E=await th(c.prompt);try{let S=await h.downstream.sessionPrompt({...c,sessionId:h.acpSessionId,prompt:E});return h.lastActiveAt=Date.now(),S}catch(S){if(S instanceof T&&S.code==="AGENT_APPROVAL_TIMEOUT"){let _=h.pendingPermission;_&&(_.downstream.respondAgentRequest(_.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(_.upstreamId),h.pendingPermission=void 0);let b=h.acpSessionId,I=b?e.activeTriggers.get(b):void 0,A=b?e.activeGroupIds.get(b):void 0;return H.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,h,l,jE,I,A)}throw S}finally{if(e.activeTriggers.delete(h.acpSessionId),e.activeGroupIds.delete(h.acpSessionId),h.pendingPermission=void 0,h.reloadAfterTurn){h.reloadAfterTurn=!1;let S=h.downstream;S&&(h.downstream=void 0,H.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:h.acpSessionId}),S.stop("reload-after-turn").catch(_=>H.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(_)})))}else h.downstream?.isAlive()&&this.armIdleTimer(e,l,h)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&(H.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,l=c.sessionId,u=c.modeId,h=to(i._meta);if(!l)throw new T("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Kt(e))throw e.framework==="openclaw"?new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new T("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!En(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${Xc(e.framework)}`);if(h)return await this.handleGroupSetMode(e,h,u);let x=e.sessions.get(l)??await this.ensureRuntime(e,l);if(x.permissionMode===u)return{};let m=x.permissionMode;if(x.permissionMode=u,await this.persistSessionMapping(e),x.downstream?.isAlive()&&x.acpSessionId)try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(E){throw x.permissionMode=m,await this.persistSessionMapping(e).catch(()=>{}),E}else H.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:l,modeId:u});return{}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[l,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:l,runtime:u,oldMode:u.permissionMode});if(o.length===0)return H.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};H.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let l of o)l.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let l of o){let u=l.runtime.downstream,h=l.runtime.acpSessionId;u?.isAlive()&&h&&c.push({downstream:u,acpSessionId:h,oldMode:l.oldMode,runtime:l.runtime})}for(let l of c)try{await l.downstream.setSessionMode({sessionId:l.acpSessionId,modeId:i})}catch(u){for(let h of o)h.runtime.permissionMode=h.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}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 Kt(e)&&(c.permissionMode=e.framework==="claude-code"?td:D0),e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(_t.GEN_MODEL_TOKEN,i,HE);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(Bi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(H.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),H.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){H.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),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 x=await h.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}}catch(x){throw H.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),await h.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,x}if(h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId),Kt(e)&&i.acpSessionId&&i.permissionMode)try{await h.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(x){H.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(x)})}}armIdleTimer(e,r,i){if(Bi(i),this.isRuntimeBusy(e,i)){H.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)){H.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}H.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=>H.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(Ar("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(Ar("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(h=>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){H.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){H.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(VE(r)){H.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l=r.update;if(l&&typeof l=="object"&&l.sessionUpdate==="current_mode_update"&&Kt(e)){let m=l.currentModeId;En(e.framework,m)&&c.permissionMode!==m?(c.permissionMode=m,this.persistSessionMapping(e).catch(E=>H.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(E)}))):typeof m=="string"&&!En(e.framework,m)&&H.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:m})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},h=e.activeTriggers.get(i);h&&(u.cozeTriggerMsgId=h);let x=e.activeGroupIds.get(i);x&&(u.cozeGroupId=x),this.upstream.send(Ar("session/update",{...r,sessionId:o,_meta:u})).catch(m=>H.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}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}H.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 Z0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Y0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){H.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Li(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,h=u?e.activeTriggers.get(u):void 0,x={cozeAgentId:e.agentId};h&&(x.cozeTriggerMsgId=h);let m=u?e.activeGroupIds.get(u):void 0;m&&(x.cozeGroupId=m);let E=u?this.reverseSessionId(e,u):void 0,S=E?e.sessions.get(E):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...E?{sessionId:E}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),H.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(Pi(o,"session/request_permission",_)).catch(b=>{this.pendingUpstream.delete(o),H.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(H.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&KE(e.result,o),H.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 oo(e.error)):i.value.resolve(e.result);return}H.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 H.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=UE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Pi(o,e,r)).catch(h=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Kt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await ei(e.agentId,r,this.paths)}catch(r){H.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(yn(e,{code:r,message:i,data:{bridgeVersion:Ir}}))}};function WE(){return zE(16).toString("hex")}function KE(t,e){if(!t||typeof t!="object"){H.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){H.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"){H.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")&&H.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var $E=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function VE(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return $E.some(c=>o.startsWith(c))}te();De();import{randomBytes as JE}from"node:crypto";import{chmod as ZE,mkdir as YE,writeFile as rh}from"node:fs/promises";import{createServer as XE}from"node:http";import{dirname as QE}from"node:path";var eb=1e6,id=G("ipc"),Eo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??X()}async start(){this.token=JE(32).toString("hex");let e=XE((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),id.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await YE(QE(this.paths.portFile),{recursive:!0}),await rh(this.paths.portFile,String(this.port),"utf8"),await rh(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await ZE(this.paths.tokenFile,384)}catch(e){id.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Gi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Gi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await tb(e)}catch(u){Gi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Gi(r,200,u??{ok:!0})}catch(u){id.error("IPC handler failed",{key:o,err:String(u)}),Gi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Gi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function tb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>eb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var bv=Ft(Xh(),1),vv=Ft(ko(),1),Sv=Ft(Lr(),1),Iv=Ft(pd(),1),Av=Ft(wd(),1),Tv=Ft(Sd(),1),ax=Ft(Lo(),1),Rv=Ft(ox(),1);var cx=ax.default;We();te();var{FWS:Hv}=yx(),Ce=G("upstream.frontier"),bx="application/json",vx="none",Wv=15e3;function Kv(t){class e extends cx{constructor(i){super(i,Of,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Ce.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(pl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Ce.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Zi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Lf,...vr(this.opts.ppeOverride)},r=Kv(e),i=Mf(this.opts.urlOverride),o={url:i,ws:r,fpID:Pf,aID:ro,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:bx,force:!0},payloadEncoding:{encoding:vx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Hv(o),l=!1,u=null,h,x,m=new Promise((_,b)=>{h=_,x=b}),E=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?x(_):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Ce.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let b of this.connectHandlers)Promise.resolve(b({initial:_})).catch(I=>Ce.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,Ce.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Ce.warn("frontier error",{code:_.code,msg:_.message}),E(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let S=this.opts.openTimeoutMs??Wv;u=setTimeout(()=>{E(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(b){Ce.warn("fws close during start failure threw (ignored)",{err:String(b)})}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){Ce.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ce.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ce.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new 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;Sx(c)||Ce.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:bx,payloadEncoding:vx})}catch(u){throw Ce.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ce.debug("drop non-adapter frontier frame",{service:r});return}let i=Jv(e);if(!i){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Ce.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Sx(c)||Ce.info("frontier frame in",{logid:Vv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:$v(i)}),Promise.resolve(this.handler(o)).catch(l=>Ce.warn("frontier frame handler threw",{err:String(l)}))}};function Sx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Ix=2e3;function $v(t){return t.length<=Ix?t:`${t.slice(0,Ix)}...<truncated, total ${t.length} chars>`}function Vv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Jv(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 Rd=G("upstream.switchable"),jo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Rd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Rd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Rd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};te();var Cd=G("upstream"),Ur=class{handler=null;async start(){Cd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Cd.info("NoopUpstream stopped",{reason:e})}async send(e){Cd.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)}};We();te();te();De();import{promises as kd}from"node:fs";import{dirname as Zv}from"node:path";var Yv=G("pat-token-store");async function Ho(t=X()){try{let r=(await kd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Yv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Yi(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await kd.mkdir(Zv(e.patTokenFile),{recursive:!0}),await kd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}De();De();import{promises as Wo}from"node:fs";import{join as Xv}from"node:path";function Qv(t,e){return`#!/bin/sh
|
|
103
103
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
104
|
-
`}function
|
|
104
|
+
`}function eS(t,e){return`@echo off\r
|
|
105
105
|
"${e}" "${t}" %*\r
|
|
106
|
-
`}async function
|
|
106
|
+
`}async function Ax(t,e=X()){let r=e.binDir;await Wo.mkdir(r,{recursive:!0});let i=Xv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?eS(t,o):Qv(t,o);return await Wo.readFile(i,"utf8").catch(()=>null)===c||(await Wo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Wo.chmod(i,493)),r}te();De();import{execSync as Tx}from"node:child_process";import{readFileSync as Rx,unlinkSync as tS}from"node:fs";import{mkdir as nS,open as rS,readFile as Cx,unlink as Dd,writeFile as iS}from"node:fs/promises";import{dirname as sS}from"node:path";var oS=G("single-instance"),aS=t=>new Promise(e=>setTimeout(e,t)),Ko=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:r=>Ni(r),isDaemon:r=>this.matchesDaemonTitle(r)},e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();if(e!==null&&e!==this.selfPid&&this.isLiveDaemon(e))return{kind:"already-running",pid:e};let r=await this.withClaimLock(async()=>{let i=await this.readExistingPid();return i!==null&&i!==this.selfPid&&this.isLiveDaemon(i)?{kind:"already-running",pid:i}:(i!==null&&i!==this.selfPid&&oS.warn("removing stale pid file",{stalePid:i}),await iS(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return r.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),r}async release(){if(this.acquired){try{(await Cx(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await Dd(this.pidFile)}catch{}this.acquired=!1}}isLiveDaemon(e){return this.probe.isAlive(e)&&this.probe.isDaemon(e)}async readExistingPid(){return this.readPidFrom(this.pidFile)}async readPidFrom(e){try{let r=await Cx(e,"utf8"),i=Number.parseInt(r.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(r){if(r.code==="ENOENT")return null;throw r}}async withClaimLock(e){let r=`${this.pidFile}.lock`;await nS(sS(r),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await rS(r,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let l=await this.readPidFrom(r);if(l!==null&&l!==this.selfPid&&this.probe.isAlive(l)){await aS(this.claimLockIntervalMs);continue}await Dd(r).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await Dd(r).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${r} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Rx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes(Cr)||r.includes("lib/index.js"))}catch{}try{let r=Tx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes(Cr)||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=Tx(`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(this.selfPid)&&tS(this.pidFile)}catch{}})}};$o();te();var Vn=G("daemon.upstream-watchdog"),pS=12e4,gS=9e5,mS=3e4;function Od(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Vo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",pS),this.hardMs=e.hardMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",gS),this.intervalMs=e.intervalMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",mS),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Vn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Vn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Vn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Vn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Vn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Vn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Vn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=G("daemon");async function Px(){let t=X();if(process.env.COZE_BRIDGE_LOG_MODE!=="legacy"){hl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:P=>Xe(P,t).logs,listAgentIds:()=>as(t)});try{let{writeFileSync:P}=await import("node:fs");P(t.logFile,`\u8FD0\u884C\u65E5\u5FD7\u5DF2\u8FC1\u79FB\u5230 dated \u6587\u4EF6, \u6B64\u6587\u4EF6 (bridge.log) \u4E0D\u518D\u5199\u5165\u8FD0\u884C\u65E5\u5FD7\u3002
|
|
107
107
|
\u8BF7\u67E5\u770B: ${t.bridgeLogsDir}/bridge-<YYYY-MM-DD>.log
|
|
108
108
|
\u6216\u4F7F\u7528: coze-bridge log [-f] [--lines N]
|
|
109
|
-
`)}catch{}}let e=new Jo({processTitle:Pr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await bo(),o=i??{};cs({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");let c=new Ko(new jr),d=null,u=new vo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(L,H,W,ie)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(L,H,W,ie)}}),x=new _o({paths:t,config:o,registry:u});d=x;let p,g,_=null,S={},w,v=null,I=null,T=null,R=new In;function P(L,H){return R.enqueue(()=>k(L,H))}function y(){I||(I=new Yo({isConnected:()=>c.isConnected(),forceReconnect:()=>T?P(T,{force:!0}):void 0,onFatal:L=>{if(process.env[ts]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:L});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:L}),process.exit(1)}})),I.start()}async function k(L,H){let W=L,ie=W?.privatecode;if(!ie)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Je=Pi(W.env),fe=W.handshake_url,xe=W.frontier_url,It=Ph(W.env,fe,xe);if(T=W,!H?.force&&p===ie&&g===It){let ge=await mv(t);return u.agents.size===0&&ge?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Qo(t,x).catch(Se=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Se)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ft=!!p&&p!==ie,tn=g!==void 0&&g!==It,zt=ft||tn,nn=await Fc({privatecode:ie,...fe?{endpoint:fe}:{},ppeOverride:Je});if(zt){j.warn("connect config switched, resetting agents",{pcChanged:ft,envChanged:tn,previousPc:p?Xo(p):"",nextPc:Xo(ie)});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 jr,"connect switch").catch(()=>{})}_=nn.deviceId,cs({deviceId:_,pid:process.pid}),id({patToken:ie,env:W.env}).catch(ge=>j.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Vr=new Qi({handshake:nn,privatecode:ie,...xe?{urlOverride:xe}:{},ppeOverride:Je,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});return await c.swap(Vr,"connect"),p=ie,g=It,S=Je,w=fe,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new Li({core:u,getDeviceId:()=>_??"",onTickEnd:()=>N.retryPending().catch(ge=>j.warn("detailSync.retryPending failed (ignored)",{err:String(ge)})),onAuthFailures:J})),v.start(),y(),zt&&Qo(t,x).catch(ge=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(ge)})),es(ie,t).catch(ge=>j.warn("writePatToken after /connect failed (ignored)",{err:String(ge)})),j.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async L=>x.createAgent(L.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},F=new co({agents:u.agents,disposeAndMarkDisconnected:async(L,H)=>{let W=u.agents.get(L);if(W){await x.cleanupOpenclawSessionProviders(W).catch(Je=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:L,err:String(Je)}));let ie=!0;try{await W.dispose(`disconnect: ${H}`)}catch(Je){ie=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:L,err:String(Je)}),W.status="error"}ie&&(W.status="disconnected",u.unregister(L),u.disconnectedAgents.add(L))}else u.disconnectedAgents.add(L)},detailSyncer:async L=>{if(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(L)},cleanupOpenclawProviders:async L=>{await x.cleanupOpenclawSessionProviders(L)},openclawRepair:async(L,H)=>{await x.openclawRepair(L,H)},isRuntimePendingPermission:L=>u.hasPendingPermissionFor(L)});u.registerExtension("_agent/listSkills",L=>F.listSkills(L.params)),u.registerExtension("_agent/addSkills",L=>F.addSkills(L.params)),u.registerExtension("_agent/removeSkills",L=>F.removeSkills(L.params)),u.registerExtension("_agent/getFileTree",L=>F.getFileTree(L.params)),u.registerExtension("_agent/getFileContent",L=>F.getFileContent(L.params)),u.registerExtension("_agent/update",L=>F.updateAgent(L.params)),u.registerExtension("_agent/disconnect",L=>F.disconnectAgent(L.params)),u.registerExtension("_agent/switchModel",L=>F.switchModel(L.params)),u.registerExtension("_agent/reset",L=>F.resetAgent(L.params)),u.registerExtension("_agent/repair",L=>F.repairAgent(L.params)),u.registerExtension("_agent/upgrade",L=>F.upgradeBridge(L.params));let N=new hs({paths:t,handlers:F,agentManager:x,sendDetail:L=>u.sendRequest("_agent/detail",L)});O.ref=N;let J=async L=>{await Promise.allSettled(L.map(async H=>{try{await F.disconnectAgent({agentId:H.agentId,reason:`auth_failure: code=${H.code} ${H.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:H.agentId,code:H.code,message:H.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:H.agentId,err:String(W)})}}))};c.onConnect(({initial:L})=>{j.info("frontier upstream connected, triggering detail sync",{initial:L}),N.syncAll(L?"initial-connect":"reconnect").catch(H=>j.warn("detail sync top-level error (ignored)",{err:String(H)}))});let K=new So({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let L=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[ts]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{},...L?{mockScenario:L}:{}}}},{method:"POST",path:"/pair",handler:async L=>{let H=L,W=H?.privatecode,ie=H?.pairing_code;if(!W||!ie)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=Pi(H.env),fe=H.handshake_url,xe=H.frontier_url,It=Ph(H.env,fe,xe),ft=!!p&&p!==W,tn=g!==void 0&&g!==It,zt=ft||tn,nn=await Fc({privatecode:W,...fe?{endpoint:fe}:{},ppeOverride:Je});if(zt){j.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:tn,previousPc:p?Xo(p):"",nextPc:Xo(W),previousEnvKey:g??"",nextEnvKey:It});for(let Se of[...u.agents.values()])await Se.dispose("pair config switch").catch(()=>{}),u.agents.delete(Se.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new jr,"pair switch").catch(()=>{})}_=nn.deviceId,cs({deviceId:_,pid:process.pid}),id({patToken:W,env:H.env}).catch(Se=>j.warn("coze-cli setup error (ignored)",{err:String(Se)}));let Vr=new Qi({handshake:nn,privatecode:W,...xe?{urlOverride:xe}:{},ppeOverride:Je,getPatTokenForAgent:Se=>u.agents.get(Se)?.patToken});await c.swap(Vr,"pair");try{let Se=new Wn;o.frameworksCache=await Se.detectAll(),await Hi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Se){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Se)})}let ge=Object.keys(o.frameworksCache??{});try{let Se=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:W,frameworks:ge,_meta:{cozeDeviceId:_}});j.info("_agent/pair ok",{pairResult:Se}),p=W,g=It,S=Je,w=fe,H.mock_scenario!==void 0&&(u.setMockScenario(H.mock_scenario),j.info("mock scenario set",{scenario:H.mock_scenario})),es(W,t).catch(Re=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Re)})),v||(v=new Li({core:u,getDeviceId:()=>_??"",onTickEnd:()=>N.retryPending().catch(Re=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Re)})),onAuthFailures:J})),v.start(),y(),zt&&Qo(t,x).catch(Re=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Re)}));let Xn;return H.agent_id&&(Xn=await _v(H.agent_id,t,x,Re=>u.sendRequest("_agent/detail",Re),W).catch(Re=>(j.error("--agent-id ensureAgent failed",{agentId:H.agent_id,err:String(Re)}),{ok:!1,agentId:H.agent_id??"",note:String(Re)}))),{ok:!0,note:"paired with cloud",...Xn?{agent:Xn}:{}}}catch(Se){return j.error("_agent/pair failed",{err:String(Se)}),{ok:!1,note:`pair failed: ${String(Se)}`}}}},{method:"POST",path:"/connect",handler:L=>P(L)},{method:"POST",path:"/_agent/create",handler:async L=>{let H=L;return{ok:!0,result:await x.createAgent(H)}}},{method:"POST",path:"/agent/send",handler:async L=>{let H=L;if(!H?.agentId||!H?.sessionId||!H?.kind||!H?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=H;return await(W.groupFile?H0:G0)(W,{core:u,patToken:p,handshakeBase:w,ppeOverride:S})}catch(W){if(W instanceof C)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async L=>{let H=L?.agent_id,W=await u.reloadAgents(H);return j.info("IPC /reload: recycled agent subprocesses",{agentId:H??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{se.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:Z}=await K.start();try{await Th(t.libEntry,t)}catch(L){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(L)})}await u.start(),yv({paths:t,core:u,agentManager:x,detectAll:async()=>(o.frameworksCache=await new Wn().detectAll(),await Hi(o),o.frameworksCache)}).catch(L=>j.warn("startup warmup error (ignored)",{err:String(L)})),Sl().then(async()=>{let{probeAcpVersion:L}=await Promise.resolve().then(()=>(on(),bl));for(let H of["claude-code","codex"]){let W=await L(H);W&&j.info("acp wrapper version",{framework:H,version:W})}}).catch(L=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(L)}));let re=null,se={port:ee,token:Z,core:u,ipc:K,shutdown(L){return re||(j.info("daemon shutdown",{reason:L}),re=(async()=>{v?.stop(),I?.stop(),await u.stop(L),await K.stop(),await e.release()})(),re)}};for(let L of["SIGTERM","SIGINT"])process.on(L,()=>{se.shutdown(L).then(()=>process.exit(0))});return process.on("exit",()=>u0()),process.on("unhandledRejection",L=>{j.error("unhandledRejection",{reason:L instanceof Error?L.message:String(L),stack:L instanceof Error?L.stack:void 0})}),process.on("uncaughtException",L=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:L.message,stack:L.stack,name:L.name});try{process.stderr.write(`FATAL uncaughtException: ${L.stack??L.message}
|
|
110
|
-
`)}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"}),
|
|
111
|
-
`)){let u=
|
|
112
|
-
`;await
|
|
113
|
-
`).filter(
|
|
114
|
-
`)}async function
|
|
115
|
-
`),1;for(let
|
|
116
|
-
`);return 0}let o=t.date??
|
|
109
|
+
`)}catch{}}let e=new Ko({processTitle:Cr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await _o(),o=i??{};ss({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");let c=new jo(new Ur),l=null,u=new yo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(P,q,W,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,q,W,ie)}}),h=new go({paths:t,config:o,registry:u});l=h;let x,m,E=null,S={},_,b=null,I=null,A=null,R=new bn;function k(P,q){return R.enqueue(()=>C(P,q))}function y(){I||(I=new Vo({isConnected:()=>c.isConnected(),forceReconnect:()=>A?k(A,{force:!0}):void 0,onFatal:P=>{if(process.env[Xi]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:P});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:P}),process.exit(1)}})),I.start()}async function C(P,q){let W=P,ie=W?.privatecode;if(!ie)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Je=Ci(W.env),he=W.handshake_url,xe=W.frontier_url,vt=Dx(W.env,he,xe);if(A=W,!q?.force&&x===ie&&m===vt){let me=await wS(t);return u.agents.size===0&&me?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Zo(t,h).catch(Ie=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Ie)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ft=!!x&&x!==ie,Xt=m!==void 0&&m!==vt,Bt=ft||Xt,Qt=await Mc({privatecode:ie,...he?{endpoint:he}:{},ppeOverride:Je});if(Bt){j.warn("connect config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:x?Jo(x):"",nextPc:Jo(ie)});for(let me of[...u.agents.values()])await me.dispose("connect config switch").catch(()=>{}),u.agents.delete(me.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 Ur,"connect switch").catch(()=>{})}E=Qt.deviceId,ss({deviceId:E,pid:process.pid}),nd({patToken:ie,env:W.env}).catch(me=>j.warn("coze-cli setup error (ignored)",{err:String(me)}));let Wr=new Zi({handshake:Qt,privatecode:ie,...xe?{urlOverride:xe}:{},ppeOverride:Je,getPatTokenForAgent:me=>u.agents.get(me)?.patToken});return await c.swap(Wr,"connect"),x=ie,m=vt,S=Je,_=he,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),b||(b=new Di({core:u,getDeviceId:()=>E??"",onTickEnd:()=>M.retryPending().catch(me=>j.warn("detailSync.retryPending failed (ignored)",{err:String(me)})),onAuthFailures:J})),b.start(),y(),Bt&&Zo(t,h).catch(me=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(me)})),Yi(ie,t).catch(me=>j.warn("writePatToken after /connect failed (ignored)",{err:String(me)})),j.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async P=>h.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let D={},B=new so({agents:u.agents,disposeAndMarkDisconnected:async(P,q)=>{let W=u.agents.get(P);if(W){await h.cleanupOpenclawSessionProviders(W).catch(Je=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(Je)}));let ie=!0;try{await W.dispose(`disconnect: ${q}`)}catch(Je){ie=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(Je)}),W.status="error"}ie&&(W.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await h.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,q)=>{await h.openclawRepair(P,q)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>B.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>B.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>B.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>B.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>B.getFileContent(P.params)),u.registerExtension("_agent/update",P=>B.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>B.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>B.switchModel(P.params)),u.registerExtension("_agent/reset",P=>B.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>B.repairAgent(P.params)),u.registerExtension("_agent/upgrade",P=>B.upgradeBridge(P.params));let M=new us({paths:t,handlers:B,agentManager:h,sendDetail:P=>u.sendRequest("_agent/detail",P)});D.ref=M;let J=async P=>{await Promise.allSettled(P.map(async q=>{try{await B.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}),M.syncAll(P?"initial-connect":"reconnect").catch(q=>j.warn("detail sync top-level error (ignored)",{err:String(q)}))});let V=new Eo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Xi]==="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,ie=q?.pairing_code;if(!W||!ie)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=Ci(q.env),he=q.handshake_url,xe=q.frontier_url,vt=Dx(q.env,he,xe),ft=!!x&&x!==W,Xt=m!==void 0&&m!==vt,Bt=ft||Xt,Qt=await Mc({privatecode:W,...he?{endpoint:he}:{},ppeOverride:Je});if(Bt){j.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:x?Jo(x):"",nextPc:Jo(W),previousEnvKey:m??"",nextEnvKey:vt});for(let Ie of[...u.agents.values()])await Ie.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ie.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 Ur,"pair switch").catch(()=>{})}E=Qt.deviceId,ss({deviceId:E,pid:process.pid}),nd({patToken:W,env:q.env}).catch(Ie=>j.warn("coze-cli setup error (ignored)",{err:String(Ie)}));let Wr=new Zi({handshake:Qt,privatecode:W,...xe?{urlOverride:xe}:{},ppeOverride:Je,getPatTokenForAgent:Ie=>u.agents.get(Ie)?.patToken});await c.swap(Wr,"pair");try{let Ie=new qn;o.frameworksCache=await Ie.detectAll(),await zi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ie){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ie)})}let me=Object.keys(o.frameworksCache??{});try{let Ie=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:W,frameworks:me,_meta:{cozeDeviceId:E}});j.info("_agent/pair ok",{pairResult:Ie}),x=W,m=vt,S=Je,_=he,q.mock_scenario!==void 0&&(u.setMockScenario(q.mock_scenario),j.info("mock scenario set",{scenario:q.mock_scenario})),Yi(W,t).catch(ke=>j.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),b||(b=new Di({core:u,getDeviceId:()=>E??"",onTickEnd:()=>M.retryPending().catch(ke=>j.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:J})),b.start(),y(),Bt&&Zo(t,h).catch(ke=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let Jn;return q.agent_id&&(Jn=await yS(q.agent_id,t,h,ke=>u.sendRequest("_agent/detail",ke),W).catch(ke=>(j.error("--agent-id ensureAgent failed",{agentId:q.agent_id,err:String(ke)}),{ok:!1,agentId:q.agent_id??"",note:String(ke)}))),{ok:!0,note:"paired with cloud",...Jn?{agent:Jn}:{}}}catch(Ie){return j.error("_agent/pair failed",{err:String(Ie)}),{ok:!1,note:`pair failed: ${String(Ie)}`}}}},{method:"POST",path:"/connect",handler:P=>k(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 T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=q;return await(W.groupFile?G0:U0)(W,{core:u,patToken:x,handshakeBase:_,ppeOverride:S})}catch(W){if(W instanceof T)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async P=>{let 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(()=>{se.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:Z}=await V.start();try{await Ax(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(),ES({paths:t,core:u,agentManager:h,detectAll:async()=>(o.frameworksCache=await new qn().detectAll(),await zi(o),o.frameworksCache)}).catch(P=>j.warn("startup warmup error (ignored)",{err:String(P)})),vl().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(nn(),El));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 re=null,se={port:ee,token:Z,core:u,ipc:V,shutdown(P){return re||(j.info("daemon shutdown",{reason:P}),re=(async()=>{b?.stop(),I?.stop(),await u.stop(P),await V.stop(),await e.release()})(),re)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{se.shutdown(P).then(()=>process.exit(0))});return process.on("exit",()=>l0()),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}
|
|
110
|
+
`)}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"}),bS({cliSpawned:process.env[Xi]==="1",readPatToken:()=>Ho(t),connect:k}).catch(P=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(P)})),se}async function wS(t){return as(t).length>0}function Jo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Dx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function _S(t,e){let r=as(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),ls));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 yS(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),ls)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let m=Ox(l),E={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{},...m?{_meta:m}:{}};return await r.createAgent(E),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new T("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(h);let x=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:x?"cloud agent acknowledged":"created from cloud detail"}}async function ES(t){let e=t.logger??j;try{let r=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(r??{})})}catch(r){e.warn("framework detection failed (using cached)",{err:String(r)})}await _S(t.paths,t.core).catch(r=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(r)})),await Zo(t.paths,t.agentManager).catch(r=>e.warn("auto-revive top-level error (ignored)",{err:String(r)}))}async function Zo(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(),ls));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let h;try{h=await o(u,t)}catch(x){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(x)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:h.framework});let x=Ox(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...x?{_meta:x}:{}},{revive:!0}),c+=1}catch(x){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:h.framework,err:String(x)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function bS(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 Ox(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}$o();De();import{readFile as Lx}from"node:fs/promises";var Yt=class{paths;constructor(e){this.paths=e??X()}async probe(e=1e3){let r=await Yo(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:SS(i)}}}async request(e){let r=await Yo(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:vS(h)}}finally{clearTimeout(l)}}};async function Yo(t){try{let[e,r]=await Promise.all([Lx(t.portFile,"utf8"),Lx(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 vS(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function SS(t){return t instanceof Error?t.message:String(t)}Wt();te();Qn();import{spawn as IS}from"node:child_process";import{userInfo as Mx}from"node:os";var Ld="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",AS=new Set(["bash","zsh","sh","dash","ksh"]),Nx=He("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),TS=2e3;function RS(t,e=Ld){let r=t.indexOf(e);if(r===-1)return null;let i=t.indexOf(e,r+e.length);if(i===-1)return null;let o=t.slice(r+e.length,i),c={};for(let l of o.split(`
|
|
111
|
+
`)){let u=l.indexOf("=");u<=0||(c[l.slice(0,u)]=l.slice(u+1))}return c}function CS(){let t=(process.env.SHELL??"").trim()||(Mx().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return AS.has(e)?t:null}function kS(t){return new Promise(e=>{let r=`printf '%s' '${Ld}'; env; printf '%s' '${Ld}'`,i;try{i=IS(t,["-ilc",r],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??Mx().homedir}})}catch{e(null);return}let o="",c=!1,l=m=>{try{i.pid&&process.kill(-i.pid,m)}catch{}},u=m=>{c||(c=!0,clearTimeout(h),clearTimeout(x),e(m))};i.stdout?.on("data",m=>{o+=m.toString("utf8")}),i.on("error",()=>u(null)),i.on("close",()=>u(o.length>0?o:null));let h=setTimeout(()=>l("SIGTERM"),Nx),x=setTimeout(()=>{l("SIGKILL"),u(o.length>0?o:null)},Nx+TS)})}async function Nd(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let r=CS();if(!r)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??kS)(r);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=RS(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}De();function In(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 DS,copyFile as Bx,mkdir as zx,readFile as Xo,rename as Fx,rm as Md,stat as Ux,writeFile as PS}from"node:fs/promises";import{homedir as AD}from"node:os";import{dirname as OS,join as Gr,resolve as Bd,sep as Qi}from"node:path";import{fileURLToPath as LS}from"node:url";Wt();te();De();var Fd=G("dist-install");function NS(t){let e=LS(t),r=OS(e),i=`${Qi}src${Qi}`;if(r.includes(i)||r.endsWith(`${Qi}src${Qi}cli`))return null;let o=Bd(r,"index.js"),c=Bd(r,"..","package.json");return{dist:o,pkgJson:c}}async function Ud(t={}){let e=t.paths??X(),r=NS(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 S=JSON.parse(await Xo(o,"utf8"));c=S.version??"unknown",l=S.dependencies??{}}catch(S){return Fd.warn("cannot read source package.json,skip dist install",{err:String(S)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(S)}`}}let u=Zr.map(S=>`${S}@${l[S]??"latest"}`),h=await _o(e.configFile)??{},x=h.libVersion,m=await Xo(e.libEntry).then(()=>!0).catch(()=>!1),E=x===c;if(E&&m&&await zd(e))return{kind:"already-current",libVersion:c};if(!E||!m){await zx(e.libDir,{recursive:!0}),await Bx(i,e.libEntry),await Bx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let S=Bd(e.libDir,"package.json"),_=`${JSON.stringify({type:"module"},null,2)}
|
|
112
|
+
`;await Xo(S,"utf8").catch(()=>null)!==_&&await PS(S,_)}return(!E||!await zd(e))&&await(t.installWrappers??MS)(e,u),h.libVersion=c,await zi(h,e.configFile),Fd.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),E&&m?{kind:"already-current",libVersion:c}:x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function zd(t){for(let e of Zr){let r=Gr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Ux(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function MS(t,e){await zS(t.installLock,async()=>{if(await zd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Qi}.staging-${process.pid}-${r}`,o=Gr(i,"node_modules"),c=Gr(t.libDir,"node_modules");try{await zx(i,{recursive:!0}),await BS(e,i),await FS(o);let l=`${c}.trash-${r}`;await Fx(c,l).catch(()=>{}),await Fx(o,c),await Md(l,{recursive:!0,force:!0}).catch(()=>{}),Fd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Md(i,{recursive:!0,force:!0}).catch(()=>{})}})}function BS(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=nt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",h=>{l.length<8192&&(l+=h.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",h=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(h)}`))}),c.once("close",h=>{clearTimeout(u),h===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${h}: ${l.trim().slice(0,2e3)}`))})})}async function FS(t){for(let e of Zr){let r=Gr(t,...e.split("/")),i=JSON.parse(await Xo(Gr(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=Gr(t,".bin",o),l=await Ux(c);process.platform!=="win32"&&!(l.mode&73)&&await DS(c,l.mode|73).catch(()=>{})}}async function zS(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 Md(t,{force:!0}).catch(()=>{})}}Ea();te();De();import{closeSync as qx,fstatSync as jx,openSync as Hx,readFileSync as US,readSync as GS,readdirSync as qS,statSync as jS}from"node:fs";import{join as Qo}from"node:path";var HS=new Set(["debug","info","warn","error"]);function Wx(t){let e=t,r=In(e,"--agent-id");e=r.rest;let i=In(e,"--date");e=i.rest;let o=In(e,"-n","--lines");e=o.rest;let c=In(e,"--level");e=c.rest;let l=In(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),h=Number.isInteger(u)&&u>=0?u:200,x=c.value&&HS.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),x&&(m.level=x),l.value&&(m.grep=l.value),m}function WS(t,e){return t.agentId?Qo(Xe(t.agentId,e).logs,er("agent",t.date)):Qo(e.bridgeLogsDir,er("bridge",t.date))}function KS(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function $S(t,e){let r;try{r=qS(t)}catch{return[]}let i=[];for(let o of r){let c=ya(o,e);if(!c)continue;let l=0;try{l=jS(Qo(t,o)).size}catch{}i.push({file:Qo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function Kx(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"&&!gl(r,e.level))return!1}return!0}var Gx={debug:"90",info:"36",warn:"33",error:"31"},VS=new Set(["ts","level","module","msg"]);function JS(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function $x(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=JS(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&Gx[o]&&(c=`\x1B[${Gx[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",h=Object.entries(r).filter(([x])=>!VS.has(x)).map(([x,m])=>` ${x}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${l} ${u}${h}`}function ZS(t,e,r){let c=US(t,"utf8").split(`
|
|
113
|
+
`).filter(l=>l.length>0).filter(l=>Kx(l,{level:e.level,grep:e.grep}));for(let l of KS(c,e.lines))process.stdout.write(`${$x(l,{raw:e.raw,color:r})}
|
|
114
|
+
`)}async function Vx(t,e){let r=e.paths??X(),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=$S(l,u);if(h.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
115
|
+
`),1;for(let x of h)process.stdout.write(`${x.date} ${(x.size/1024).toFixed(1)}KB ${x.file}
|
|
116
|
+
`);return 0}let o=t.date??Tn(new Date),c=WS({agentId:t.agentId,date:o},r);try{ZS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
117
117
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
118
118
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
119
|
-
`),1}return t.follow&&await
|
|
120
|
-
`);o=
|
|
121
|
-
`)}await new Promise(
|
|
119
|
+
`),1}return t.follow&&await QS(c,t,i),0}var YS=500;function XS(t){try{let e=Hx(t,"r");try{return jx(e).size}finally{qx(e)}}catch{return 0}}async function QS(t,e,r){let i=XS(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let h=Hx(t,"r");try{let x=jx(h).size;if(x>i){let m=Buffer.allocUnsafe(x-i),E=GS(h,m,0,m.length,i);u=m.subarray(0,E).toString("utf8"),i+=E}}finally{qx(h)}}catch{}if(u){let h=(o+u).split(`
|
|
120
|
+
`);o=h.pop()??"";for(let x of h)x.length>0&&Kx(x,{level:e.level,grep:e.grep})&&process.stdout.write(`${$x(x,{raw:e.raw,color:r})}
|
|
121
|
+
`)}await new Promise(h=>setTimeout(h,YS))}}finally{process.off("SIGINT",l)}}import{basename as e1,resolve as t1}from"node:path";De();var n1=9e4,r1={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,OPERATION_NOT_ALLOWED_FOR_CLOUD:1,METHOD_NOT_FOUND:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function i1(t){return r1[t]??1}async function Jx(t,e={}){let r=e.paths??X();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>
|
|
122
122
|
`),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.
|
|
123
|
-
`),3;let i=await
|
|
124
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
123
|
+
`),3;let i=await Yo(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.
|
|
124
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:t1(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 s1(i,"/agent/send",o,n1)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
125
125
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
126
|
-
`),
|
|
127
|
-
`);else{let
|
|
128
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
129
|
-
`)}return 0}async function
|
|
130
|
-
`)}function
|
|
126
|
+
`),i1(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
127
|
+
`);else{let l=t.name??e1(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})
|
|
128
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${o1(c.bytes)})
|
|
129
|
+
`)}return 0}async function s1(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 o1(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var ip=G("cli");function Ge(t,e){let{value:r,rest:i}=In(t,e);return{value:r,rest:i}}function sa(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
130
|
+
`)}function k1(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:k}=Ge(e.slice(1),"--agent-id");return k?{mode:"reload",agentId:k}:{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 D1(e.slice(1));if(e[0]==="log")return{mode:"log",...Wx(e.slice(1))};if(e[0]==="connect")return P1(e.slice(1));if(e.includes("--status"))return sa("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return sa("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return sa("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return sa("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=Ge(r,"--pat-token");r=o;let{value:c,rest:l}=Ge(r,"--pair-code");r=l;let{value:u,rest:h}=Ge(r,"--env");r=h;let{value:x,rest:m}=Ge(r,"--handshake-url");r=m;let{value:E,rest:S}=Ge(r,"--frontier-url");r=S;let{value:_,rest:b}=Ge(r,"--mock-scenario");r=b;let{value:I}=Ge(r,"--agent-id"),A=r.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let R={mode:"pair",privatecode:i,pairingCode:c};return u&&(R.env=u),x&&(R.handshakeUrl=x),E&&(R.frontierUrl=E),_&&(R.mockScenario=_),I&&(R.agentId=I),A&&(R.skipRebuildEnv=!0),R}function D1(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}=Ge(i,"--caption");i=c;let{value:l,rest:u}=Ge(i,"--name");i=u;let{value:h,rest:x}=Ge(i,"--agent-id");i=x;let{value:m,rest:E}=Ge(i,"--session-id");i=E;let{value:S,rest:_}=Ge(i,"--mime");i=_;let b=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:r,json:I};return o&&(A.caption=o),l&&(A.name=l),h&&(A.agentId=h),m&&(A.sessionId=m),b&&(A.groupFile=!0),S&&(A.mimeType=S),A}function P1(t){let e=t,{value:r,rest:i}=Ge(e,"--pat-token");e=i;let{value:o,rest:c}=Ge(e,"--env");e=c;let{value:l,rest:u}=Ge(e,"--handshake-url");e=u;let{value:h,rest:x}=Ge(e,"--frontier-url");e=x;let{value:m,rest:E}=Ge(e,"--mock-scenario");e=E;let S=e.includes("--skip-rebuild-env"),_={mode:"connect"};return r&&(_.privatecode=r),o&&(_.env=o),l&&(_.handshakeUrl=l),h&&(_.frontierUrl=h),m&&(_.mockScenario=m),S&&(_.skipRebuildEnv=!0),_}var O1=`
|
|
131
131
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
132
132
|
|
|
133
133
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -208,57 +208,57 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
208
208
|
|
|
209
209
|
Internal:
|
|
210
210
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
211
|
-
`.trimStart();async function
|
|
212
|
-
`),0;case"daemon":{try{await
|
|
213
|
-
`),1;if(i.kind==="stale")return await
|
|
211
|
+
`.trimStart();async function sp(t=process.argv,e={}){let r=k1(t);switch(r.mode){case"help":return process.stdout.write(O1),0;case"version":return process.stdout.write(`${Ir}
|
|
212
|
+
`),0;case"daemon":{try{await Px()}catch(i){return ip.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return L1(e);case"stop":return ap(e);case"reload":return B1(r.agentId,e);case"log":return Vx(r,e);case"update":return N1(e);case"purge":return F1(e);case"service-install":return z1(e);case"service-uninstall":return U1(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),G1(r.privatecode,r.pairingCode,e,i,r.agentId,r.skipRebuildEnv)}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),q1(r.privatecode,e,i,r.skipRebuildEnv)}case"send":return Jx({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 op(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 L1(t){let e=t.paths??X(),r=new Yt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
213
|
+
`),1;if(i.kind==="stale")return await op(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
214
214
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
215
215
|
${JSON.stringify(o.body,null,2)}
|
|
216
|
-
`),0}async function
|
|
217
|
-
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(
|
|
216
|
+
`),0}async function ap(t){let e=t.paths??X(),r=new Yt(e),i=t.daemonSweep??(async()=>{let h=u0();return await f0(h),h}),o=async()=>{t.skipProcessKill||await i(e)},c=await ts(t),l=!1;if(c)try{await c.uninstall(),l=!0}catch(h){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(h)}
|
|
217
|
+
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(l?`coze-bridge: stopped
|
|
218
218
|
`:`coze-bridge: not running
|
|
219
|
-
`),0;if(u.kind==="stale")return await
|
|
219
|
+
`),0;if(u.kind==="stale")return await op(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
220
220
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),await o(),process.stdout.write(`coze-bridge: stopped
|
|
221
|
-
`),0}catch(
|
|
222
|
-
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(
|
|
223
|
-
`),1)}}async function
|
|
224
|
-
`),e(1)})})}async function
|
|
221
|
+
`),0}catch(h){return(await r.probe()).kind!=="connected"?(await o(),process.stdout.write(`coze-bridge: stopped
|
|
222
|
+
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(h)}
|
|
223
|
+
`),1)}}async function N1(t){return await ap(t),(t.spawnNpx??M1)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function M1(t){return new Promise(e=>{let r=nt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
224
|
+
`),e(1)})})}async function B1(t,e){let r=new Yt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
225
225
|
`),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)
|
|
226
226
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
227
227
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
228
228
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
229
|
-
`),1}}async function
|
|
229
|
+
`),1}}async function ts(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(()=>(np(),tp)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function cp(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??kx,o=t.waitTimeoutMs??15e3,c=t.sleep??H1,l=t.paths??X(),u=await ts(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let h=await rp(e,o,c);if(h.kind==="connected")return h;St(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){St(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(h)})}St(l.bridgeLogsDir,"warn","cli","\u79FB\u9664\u5F00\u673A\u81EA\u542F\u914D\u7F6E (supervisor \u63A5\u7BA1\u672A\u6210\u529F, \u56DE\u9000\u624B\u52A8 spawn; \u4E0B\u6B21\u91CD\u542F\u4E0D\u518D\u81EA\u542F, \u9700\u91CD\u65B0 service install)",{platform:u.platform}),await u.uninstall().catch(()=>{}),await j1(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)}
|
|
230
230
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
231
|
-
`),await i({paths:t.paths}),
|
|
232
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
233
|
-
`)}await new Promise(
|
|
234
|
-
`)}catch(
|
|
231
|
+
`),await i({paths:t.paths}),rp(e,o,c)}async function F1(t){let e=new Yt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
232
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
233
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await ts(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
234
|
+
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
235
235
|
`)}let o=t.paths??X(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
236
|
-
`)}catch(
|
|
236
|
+
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
237
237
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
238
|
-
`),0}async function
|
|
238
|
+
`),0}async function z1(t){let e=await ts(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
239
239
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
240
240
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
241
|
-
`),1}}async function
|
|
241
|
+
`),1}}async function U1(t){let e=await ts(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
242
242
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),
|
|
245
|
-
`),(await
|
|
246
|
-
`)}let
|
|
247
|
-
`),1;let
|
|
243
|
+
`),1}}async function dp(t,e,r){if(e)return St(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await r();return i.kind==="ok"?(St(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(St(t.bridgeLogsDir,"info","cli","agent-env: rebuild not applicable, use process.env",{reason:i.reason}),process.env):(process.stderr.write(`coze-bridge: \u91CD\u5EFA shell \u73AF\u5883\u5931\u8D25, \u56DE\u9000\u5F53\u524D\u8FDB\u7A0B\u73AF\u5883 (\u53EF\u7528 --skip-rebuild-env \u663E\u5F0F\u8DF3\u8FC7)
|
|
244
|
+
`),St(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function G1(t,e,r,i={},o,c){let l=new Yt(r.paths),u=r.paths??X(),h=await dp(u,c,r.reconstructEnv??Nd);if(await Jc(u,h).catch(E=>St(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(E)})),!r.skipDistInstall){let E=await Ud({paths:r.paths});E.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${E.fromVersion} \u2192 ${E.toVersion}
|
|
245
|
+
`),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):E.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${E.libVersion}
|
|
246
|
+
`)}let x=await cp(r,l);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
247
|
+
`),1;let m={privatecode:t,pairing_code:e};i.env&&(m.env=i.env),i.handshakeUrl&&(m.handshake_url=i.handshakeUrl),i.frontierUrl&&(m.frontier_url=i.frontierUrl),i.mockScenario&&(m.mock_scenario=i.mockScenario),o&&(m.agent_id=o);try{let E=await l.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});if(E.status===200&&E.body?.ok){let S=E.body.agent;return S&&!S.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${S.agentId}): ${S.note}
|
|
248
248
|
`),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"
|
|
249
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
250
|
-
`),1}catch(
|
|
251
|
-
`),1}}async function
|
|
252
|
-
`),(await
|
|
253
|
-
`)}let
|
|
254
|
-
`),1;let
|
|
255
|
-
`),await
|
|
256
|
-
`),1)}catch(
|
|
257
|
-
`),1}}async function
|
|
249
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(E.body)}
|
|
250
|
+
`),1}catch(E){return process.stderr.write(`coze-bridge: pair failed: ${String(E)}
|
|
251
|
+
`),1}}async function q1(t,e,r={},i){let o=e.paths??X(),c=t??await Ho(o);if(!c)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 l=new Yt(e.paths),u=await dp(o,i,e.reconstructEnv??Nd);if(await Jc(o,u).catch(m=>St(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(m)})),!e.skipDistInstall){let m=await Ud({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
252
|
+
`),(await l.probe()).kind==="connected"&&(await l.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(S=>setTimeout(S,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
253
|
+
`)}let h=await cp(e,l);if(h.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${h.kind}
|
|
254
|
+
`),1;let x={privatecode:c};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let m=await l.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
|
|
255
|
+
`),await Yi(c,o).catch(E=>ip.warn("writePatToken after connect failed (ignored)",{err:String(E)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
|
|
256
|
+
`),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
|
|
257
|
+
`),1}}async function rp(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 j1(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||!Ni(u))return;await e(i)}}function H1(t){return new Promise(e=>setTimeout(e,t))}te();function W1(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 lp(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=W1(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
|
|
258
258
|
`),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
|
|
259
259
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
260
260
|
npx -y coze-bridge@latest stop
|
|
261
261
|
npx -y coze-bridge@latest connect
|
|
262
262
|
|
|
263
|
-
`)}
|
|
263
|
+
`)}lp();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&xl("warn");sp(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
264
264
|
`),process.exit(1)});
|