coze-bridge 0.1.97 → 0.1.98-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +76 -76
- 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 Rp=Object.create;var ha=Object.defineProperty;var kp=Object.getOwnPropertyDescriptor;var Op=Object.getOwnPropertyNames;var Pp=Object.getPrototypeOf,Lp=Object.prototype.hasOwnProperty;var de=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ze=(t,e)=>()=>(t&&(e=t(t=0)),e);var se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),pa=(t,e)=>{for(var r in e)ha(t,r,{get:e[r],enumerable:!0})},Np=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Op(e))!Lp.call(t,o)&&o!==r&&ha(t,o,{get:()=>e[o],enumerable:!(i=kp(e,o))||i.enumerable});return t};var At=(t,e,r)=>(r=t!=null?Rp(Pp(t)):{},Np(e||!t||!t.__esModule?ha(r,"default",{value:t,enumerable:!0}):r,t));function Ft(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Xi=Ze(()=>{"use strict"});import{createWriteStream as Mp,mkdirSync as Bp,readdirSync as zp,unlinkSync as Fp}from"node:fs";import{join as el}from"node:path";function In(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Xn(t,e){return`${t}-${e}.log`}function ga(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Up(t,e,r){let i=c=>{let[l,u,x]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function Qi(t,e,r,i){let o;try{o=zp(t)}catch{return}for(let c of o){let l=ga(c,e);if(l&&Up(l,r,i))try{Fp(el(t,c))}catch{}}}var jr,ma=Ze(()=>{"use strict";jr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>In(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Bp(this.dir,{recursive:!0});let r=Mp(el(this.dir,Xn(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function Qp(t){let e=
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await fl(o,i,{encoding:"utf8",mode:r.mode}):await fl(o,i,"utf8"),await ul(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await ul(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Vr=$e(()=>{"use strict"});import{promises as hl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as Ie,resolve as xl}from"node:path";function Y(t){let e=t??cg(),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 Ve(t,e=Y()){let r=Ie(e.agentsRoot,t);return{root:r,config:Ie(r,"config.json"),workspace:Ie(r,"workspace"),logs:Ie(r,"logs")}}function ns(t=Y()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Jr(t,e){let r=await hl.realpath(xl(t)).catch(()=>null);if(!r)return!1;let i=await hl.realpath(xl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+dg)}var De=$e(()=>{"use strict"});var ss={};ha(ss,{AGENT_CONFIG_FILE_MODE:()=>rs,enforceAgentConfigMode:()=>fg,loadAgentConfig:()=>Ge,persistAgentSessions:()=>Zr,persistAgentSkills:()=>is,saveAgentConfig:()=>Je});import{chmod as lg,stat as ug}from"node:fs/promises";function Ge(t,e){return Qn(Ve(t,e).config)}function Je(t,e){return er(Ve(t.agentId,e).config,t,{mode:rs})}async function fg(t,e){if(process.platform==="win32")return;let r=Ve(t,e).config;try{let i=await ug(r);if(!i.isFile())return;let o=i.mode&511;o!==rs&&(await lg(r,rs),pl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;pl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Zr(t,e,r){let i=await Ge(t,r);i&&(i.sessions=Object.fromEntries(e),await Je(i,r))}async function is(t,e,r){let i=await Ge(t,r);i&&(i.skills=e,await Je(i,r))}var pl,rs,en=$e(()=>{"use strict";Vr();te();De();pl=U("agent-config"),rs=384});var Ea=ie((LS,_l)=>{_l.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var as=ie(El=>{var yl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function mg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(yl))El[t]=mg(yl[t])});var Al=ie((BS,Il)=>{var wg=ce("fs"),ke=ce("path"),bl=Ea(),_g=as(),yg=typeof process=="object"&&process.platform==="win32",vl=t=>typeof t=="object"&&t!==null,Sl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ee(t){this.sep=ke.sep,this.fs=wg,vl(t)&&vl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Il.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=ke.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=ke.dirname(t);c.fs.exists(x,function(_){_||c.makeDir(x),c.fs.open(t,"w",438,function(m,A){m?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let h=ke.join(i,u),x=e.fs.statSync(h);(!o||o.test(h))&&l.push(ke.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=ke.join(t,u),r.fs.stat(u,function(h,x){if(h)return e(h);x&&(i.push(ke.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(_,m){if(_)return e(_);i=i.concat(m),--l||e(null,i)}):--l||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Sl[(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 bl.STORED:return"STORED ("+t+")";case bl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=ke.posix.normalize("/"+t.split("\\").join("/"));return ke.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=ke.posix.normalize("/"+t.split("\\").join("/"));return ke.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=ke.resolve(ke.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=ke.normalize(ke.join(t,r.slice(i,o).join(ke.sep)));if(c.indexOf(t)===0)return c}return ke.normalize(ke.join(t,ke.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=yg;Ee.crcTable=Sl});var Rl=ie((zS,Tl)=>{var Eg=ce("path");Tl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Eg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Dl=ie((FS,Cl)=>{Cl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var rr=ie((US,nr)=>{nr.exports=Al();nr.exports.Constants=Ea();nr.exports.Errors=as();nr.exports.FileAttr=Rl();nr.exports.decoder=Dl()});var Ol=ie((GS,kl)=>{var tn=rr(),z=tn.Constants;kl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,x=0,_=0,m=0,A=0,y=0,v=0;t|=tn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},S=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,P=w=>Math.max(0,w)&255;return o=tn.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&z.FLG_EFS)>0},set flags_efs(w){w?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(w){w?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(w){switch(w){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=w},get time(){return tn.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=tn.fromDate2DOS(w)},get timeval(){return o},set timeval(w){o=S(w)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(w){c=S(w)},get compressedSize(){return l},set compressedSize(w){l=S(w)},get size(){return u},set size(w){u=S(w)},get fileNameLength(){return h},set fileNameLength(w){h=w},get extraLength(){return x},set extraLength(w){x=w},get extraLocalLength(){return I.extraLen},set extraLocalLength(w){I.extraLen=w},get commentLength(){return _},set commentLength(w){_=w},get diskNumStart(){return m},set diskNumStart(w){m=S(w)},get inAttr(){return A},set inAttr(w){A=S(w)},get attr(){return y},set attr(w){y=S(w)},get fileAttr(){return(y||0)>>16&4095},get offset(){return v},set offset(w){v=S(w)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+h+x+_},get realDataOffset(){return v+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(w){var C=w.slice(v,v+z.LOCHDR);if(C.readUInt32LE(0)!==z.LOCSIG)throw tn.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=v+z.LOCHDR+I.fnameLen,L=D+I.extraLen;return w.slice(D,L)},loadFromBinary:function(w){if(w.length!==z.CENHDR||w.readUInt32LE(0)!==z.CENSIG)throw tn.Errors.INVALID_CEN();t=w.readUInt16LE(z.CENVEM),e=w.readUInt16LE(z.CENVER),r=w.readUInt16LE(z.CENFLG),i=w.readUInt16LE(z.CENHOW),o=w.readUInt32LE(z.CENTIM),c=w.readUInt32LE(z.CENCRC),l=w.readUInt32LE(z.CENSIZ),u=w.readUInt32LE(z.CENLEN),h=w.readUInt16LE(z.CENNAM),x=w.readUInt16LE(z.CENEXT),_=w.readUInt16LE(z.CENCOM),m=w.readUInt16LE(z.CENDSK),A=w.readUInt16LE(z.CENATT),y=w.readUInt32LE(z.CENATX),v=w.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(z.LOCHDR);return w.writeUInt32LE(z.LOCSIG,0),w.writeUInt16LE(e,z.LOCVER),w.writeUInt16LE(r,z.LOCFLG),w.writeUInt16LE(i,z.LOCHOW),w.writeUInt32LE(o,z.LOCTIM),w.writeUInt32LE(c,z.LOCCRC),w.writeUInt32LE(l,z.LOCSIZ),w.writeUInt32LE(u,z.LOCLEN),w.writeUInt16LE(h,z.LOCNAM),w.writeUInt16LE(I.extraLen,z.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(z.CENHDR+h+x+_);return w.writeUInt32LE(z.CENSIG,0),w.writeUInt16LE(t,z.CENVEM),w.writeUInt16LE(e,z.CENVER),w.writeUInt16LE(r,z.CENFLG),w.writeUInt16LE(i,z.CENHOW),w.writeUInt32LE(o,z.CENTIM),w.writeUInt32LE(c,z.CENCRC),w.writeUInt32LE(l,z.CENSIZ),w.writeUInt32LE(u,z.CENLEN),w.writeUInt16LE(h,z.CENNAM),w.writeUInt16LE(x,z.CENEXT),w.writeUInt16LE(_,z.CENCOM),w.writeUInt16LE(m,z.CENDSK),w.writeUInt16LE(A,z.CENATT),w.writeUInt32LE(y,z.CENATX),w.writeUInt32LE(v,z.CENOFF),w},toJSON:function(){let w=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:tn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(l),size:w(u),fileNameLength:w(h),extraLength:w(x),commentLength:w(_),diskNumStart:m,inAttr:A,attr:y,offset:v,centralHeaderSize:w(z.CENHDR+h+x+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Nl=ie((HS,Pl)=>{var ir=rr(),ge=ir.Constants;Pl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return ge.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ge.ENDHDR||c.readUInt32LE(0)!==ge.ENDSIG)&&(c.length<ge.ZIP64HDR||c.readUInt32LE(0)!==ge.ZIP64SIG))throw ir.Errors.INVALID_END();c.readUInt32LE(0)===ge.ENDSIG?(t=c.readUInt16LE(ge.ENDSUB),e=c.readUInt16LE(ge.ENDTOT),r=c.readUInt32LE(ge.ENDSIZ),i=c.readUInt32LE(ge.ENDOFF),o=c.readUInt16LE(ge.ENDCOM)):(t=ir.readBigUInt64LE(c,ge.ZIP64SUB),e=ir.readBigUInt64LE(c,ge.ZIP64TOT),r=ir.readBigUInt64LE(c,ge.ZIP64SIZE),i=ir.readBigUInt64LE(c,ge.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ge.ENDHDR+o);return c.writeUInt32LE(ge.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ge.ENDSUB),c.writeUInt16LE(e,ge.ENDTOT),c.writeUInt32LE(r,ge.ENDSIZ),c.writeUInt32LE(i,ge.ENDOFF),c.writeUInt16LE(o,ge.ENDCOM),c.fill(" ",ge.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 va=ie(ba=>{ba.EntryHeader=Ol();ba.MainHeader=Nl()});var Ml=ie((jS,Ll)=>{Ll.exports=function(t){var e=ce("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var x=0;x<c.length;x++){var _=c[x];_.copy(u,h),h+=_.length}i&&i(u)}),o.end(t)}}}});var zl=ie((WS,Bl)=>{var bg=+(process.versions?process.versions.node:"").split(".")[0]||0;Bl.exports=function(t,e){var r=ce("zlib");let i=bg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),x=0;h.fill(0);for(var _=0;_<l.length;_++){var m=l[_];m.copy(h,x),x+=m.length}o&&o(h)}),c.end(t)}}}});var ql=ie((KS,Hl)=>{"use strict";var{randomFillSync:Fl}=ce("crypto"),vg=as(),Sg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Gl=(t,e)=>Math.imul(t,e)>>>0,Ul=(t,e)=>Sg[(t^e)&255]^t>>>8,Yr=()=>typeof Fl=="function"?Fl(Buffer.alloc(12)):Yr.node();Yr.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 cs={genSalt:Yr};function ds(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])}ds.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ul(e[0],t),e[1]+=e[0]&255,e[1]=Gl(e[1],134775813)+1,e[2]=Ul(e[2],e[1]>>>24),t};ds.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Gl(t,t^1)>>8&255};function Ig(t){let e=new ds(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Ag(t){let e=new ds(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ig(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Rg(t){Buffer.isBuffer(t)&&t.length>=12?cs.genSalt=function(){return t.slice(0,12)}:t==="node"?cs.genSalt=Yr.node:cs.genSalt=Yr}function Cg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ag(r),c=cs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Hl.exports={decrypt:Tg,encrypt:Cg,_salter:Rg}});var jl=ie(ls=>{ls.Deflater=Ml();ls.Inflater=zl();ls.ZipCrypto=ql()});var Ia=ie((VS,Wl)=>{var se=rr(),Dg=va(),be=se.Constants,Sa=jl();Wl.exports=function(t,e){var r=new Dg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),x=!0;let _=t,m=typeof _.decoder=="object"?_.decoder:se.decoder;x=m.hasOwnProperty("efs")?m.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(h=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(se.crc32(w)!==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 se.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 se.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw se.Errors.DESCRIPTOR_FAULTY();if(se.crc32(w)!==C.crc)return!1}return!0}function v(w,C,D){if(typeof C>"u"&&typeof w=="string"&&(D=w,w=void 0),c)return w&&C&&C(Buffer.alloc(0),se.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var L=A();if(L.length===0)return w&&C&&C(L),L;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw se.Errors.INVALID_PASS_PARAM();L=Sa.ZipCrypto.decrypt(L,r,D)}var B=Buffer.alloc(r.size);switch(r.method){case se.Constants.STORED:if(L.copy(B),y(B))return w&&C&&C(B),B;throw w&&C&&C(B,se.Errors.BAD_CRC()),se.Errors.BAD_CRC();case se.Constants.DEFLATED:var V=new Sa.Inflater(L,r.size);if(w)V.inflateAsync(function(J){J.copy(J,0),C&&(y(J)?C(J):C(J,se.Errors.BAD_CRC()))});else{if(V.inflate(B).copy(B,0),!y(B))throw se.Errors.BAD_CRC(`"${m.decode(i)}"`);return B}break;default:throw w&&C&&C(Buffer.alloc(0),se.Errors.UNKNOWN_METHOD()),se.Errors.UNKNOWN_METHOD()}}function I(w,C){if((!l||!l.length)&&Buffer.isBuffer(e))return w&&C&&C(A()),A();if(l.length&&!c){var D;switch(r.method){case se.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(l.length),l.copy(D),w&&C&&C(D),D;default:case se.Constants.DEFLATED:var L=new Sa.Deflater(l);if(w)L.deflateAsync(function(V){D=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(D),C&&C(D)});else{var B=L.deflate();return r.compressedSize=B.length,B}L=null;break}}else if(w&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function S(w,C){return se.readBigUInt64LE(w,C)}function R(w){try{for(var C=0,D,L,B;C+4<w.length;)D=w.readUInt16LE(C),C+=2,L=w.readUInt16LE(C),C+=2,B=w.slice(C,C+L),C+=L,be.ID_ZIP64===D&&P(B)}catch{throw se.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(w){var C,D,L,B;w.length>=be.EF_ZIP64_SCOMP&&(C=S(w,be.EF_ZIP64_SUNCOMP),r.size===be.EF_ZIP64_OR_32&&(r.size=C)),w.length>=be.EF_ZIP64_RHO&&(D=S(w,be.EF_ZIP64_SCOMP),r.compressedSize===be.EF_ZIP64_OR_32&&(r.compressedSize=D)),w.length>=be.EF_ZIP64_DSN&&(L=S(w,be.EF_ZIP64_RHO),r.offset===be.EF_ZIP64_OR_32&&(r.offset=L)),w.length>=be.EF_ZIP64_DSN+4&&(B=w.readUInt32LE(be.EF_ZIP64_DSN),r.diskNumStart===be.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return m.decode(i)},get rawEntryName(){return i},set entryName(w){i=se.toBuffer(w,m.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(w){u=w,r.extraLength=w.length,R(w)},get comment(){return m.decode(o)},set comment(w){if(o=se.toBuffer(w,m.encode),r.commentLength=o.length,o.length>65535)throw se.Errors.COMMENT_TOO_LONG()},get name(){var w=m.decode(i);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(w){I(!0,w)},setData:function(w){l=se.toBuffer(w,se.decoder.encode),!c&&l.length?(r.size=l.length,r.method=se.Constants.DEFLATED,r.crc=se.crc32(w),r.changed=!0):r.method=se.Constants.STORED},getData:function(w){return r.changed?l:v(!1,null,w)},getDataAsync:function(w,C){r.changed?w(l):v(!0,w,C)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var w=r.centralHeaderToBinary(),C=se.Constants.CENHDR;return i.copy(w,C),C+=i.length,u.copy(w,C),C+=r.extraLength,o.copy(w,C),w},packLocalHeader:function(){let w=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,w),w+=C.length,i.copy(D,w),w+=i.length,h.copy(D,w),w+=h.length,D},toJSON:function(){let w=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:w(e),data:w(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Vl=ie((JS,$l)=>{var Kl=Ia(),kg=va(),He=rr();$l.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,u=null;let h=new Set,x=e,{noSort:_,decoder:m}=x;t?v(x.readEntries):l=!0;function A(){let S=new Set;for(let R of Object.keys(i)){let P=R.split("/");if(P.pop(),!!P.length)for(let w=0;w<P.length;w++){let C=P.slice(0,w+1).join("/")+"/";S.add(C)}}for(let R of S)if(!(R in i)){let P=new Kl(x);P.entryName=R,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,h.add(P)}}function y(){if(l=!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 S=c.offset,R=0;R<r.length;R++){var P=S,w=new Kl(x,t);w.header=t.slice(P,P+=He.Constants.CENHDR),w.entryName=t.slice(P,P+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(P,P+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(P,P+w.header.commentLength)),S+=w.header.centralHeaderSize,r[R]=w,i[w.entryName]=w}h.clear(),A()}function v(S){var R=t.length-He.Constants.ENDHDR,P=Math.max(0,R-65535),w=P,C=t.length,D=-1,L=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(P=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===He.Constants.ENDSIG){D=R,L=R,C=R+He.Constants.ENDHDR,w=R-He.Constants.END64HDR;continue}if(t.readUInt32LE(R)===He.Constants.END64SIG){w=P;continue}if(t.readUInt32LE(R)===He.Constants.ZIP64SIG){D=R,C=R+He.readBigUInt64LE(t,R+He.Constants.ZIP64SIZE)+He.Constants.ZIP64LEAD;break}}if(D==-1)throw He.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,C)),c.commentLength&&(o=t.slice(L+He.Constants.ENDHDR)),S&&y()}function I(){r.length>1&&!_&&r.sort((S,R)=>S.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(S=>!h.has(S))},get comment(){return m.decode(o)},set comment(S){o=He.toBuffer(S,m.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||y(),i[S]||null},setEntry:function(S){l||y(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,R=!0){l||y();let P=i[S];this.getEntryChildren(P,R).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||y();let R=i[S],P=r.indexOf(R);P>=0&&(r.splice(P,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,R=!0){if(l||y(),typeof S=="object")if(S.isDirectory&&R){let P=[],w=S.entryName;for(let C of r)C.entryName.startsWith(w)&&P.push(C);return P}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let R=this.getEntryChildren(S);return R.includes(S)?R.length-1:R.length}return 0},compressToBuffer:function(){l||y(),I();let S=[],R=[],P=0,w=0;c.size=0,c.offset=0;let C=0;for(let B of this.entries){let V=B.getCompressedData();B.header.offset=w;let J=B.packLocalHeader(),ee=J.length+V.length;w+=ee,S.push(J),S.push(V);let X=B.packCentralHeader();R.push(X),c.size+=X.length,P+=ee+X.length,C++}P+=c.mainHeaderSize,c.offset=w,c.totalEntries=C,w=0;let D=Buffer.alloc(P);for(let B of S)B.copy(D,w),w+=B.length;for(let B of R)B.copy(D,w),w+=B.length;let L=c.toBinary();return o&&o.copy(L,He.Constants.ENDHDR),L.copy(D,w),t=D,l=!1,D},toAsyncBuffer:function(S,R,P,w){try{l||y(),I();let C=[],D=[],L=0,B=0,V=0;c.size=0,c.offset=0;let J=function(ee){if(ee.length>0){let X=ee.shift(),_e=X.entryName+X.extra.toString();P&&P(_e),X.getCompressedDataAsync(function(fe){w&&w(_e),X.header.offset=B;let k=X.packLocalHeader(),H=k.length+fe.length;B+=H,C.push(k),C.push(fe);let j=X.packCentralHeader();D.push(j),c.size+=j.length,L+=H+j.length,V++,J(ee)})}else{L+=c.mainHeaderSize,c.offset=B,c.totalEntries=V,B=0;let X=Buffer.alloc(L);C.forEach(function(fe){fe.copy(X,B),B+=fe.length}),D.forEach(function(fe){fe.copy(X,B),B+=fe.length});let _e=c.toBinary();o&&o.copy(_e,He.Constants.ENDHDR),_e.copy(X,B),t=X,l=!1,S(X)}};J(Array.from(this.entries))}catch(C){R(C)}}}}});var Yl=ie((ZS,Zl)=>{var we=rr(),me=ce("path"),Og=Ia(),Pg=Vl(),In=(...t)=>we.findLast(t,e=>typeof e=="boolean"),Jl=(...t)=>we.findLast(t,e=>typeof e=="string"),Ng=(...t)=>we.findLast(t,e=>typeof e=="function"),Lg={noSort:!1,readEntries:!1,method:we.Constants.NONE,fs:null};Zl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Lg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=we.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new we(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=we.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=we.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw we.Errors.INVALID_FILENAME();let c=new Pg(r,i),{canonical:l,sanitize:u,zipnamefix:h}=we;function x(y){if(y&&c){var v;if(typeof y=="string"&&(v=c.getEntry(me.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(v=c.getEntry(y.entryName)),v)return v}return null}function _(y){let{join:v,normalize:I,sep:S}=me.posix;return v(me.isAbsolute(y)?"/":".",I(S+y.split("\\").join(S)+S))}function m(y){return y instanceof RegExp?(function(v){return function(I){return v.test(I)}})(y):typeof y!="function"?()=>!0:y}let A=(y,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",me.relative(y,v)+I};return{readFile:function(y,v){var I=x(y);return I&&I.getData(v)||null},childCount:function(y){let v=x(y);if(v)return c.getChildCount(v)},readFileAsync:function(y,v){var I=x(y);I?I.getDataAsync(v):v(null,"getEntry failed for:"+y)},readAsText:function(y,v){var I=x(y);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(y,v,I){var S=x(y);S?S.getDataAsync(function(R,P){if(P){v(R,P);return}R&&R.length?v(R.toString(I||"utf8")):v("")}):v("")},deleteFile:function(y,v=!0){var I=x(y);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(y){var v=x(y);v&&c.deleteEntry(v.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,v){var I=x(y);I&&(I.comment=v)},getZipEntryComment:function(y){var v=x(y);return v&&v.comment||""},updateFile:function(y,v){var I=x(y);I&&I.setData(v)},addLocalFile:function(y,v,I,S){if(o.fs.existsSync(y)){v=v?_(v):"";let R=me.win32.basename(me.win32.normalize(y));v+=I||R;let P=o.fs.statSync(y),w=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,w,S,P)}else throw we.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,v){y=typeof y=="object"?y:{localPath:y};let I=me.resolve(y.localPath),{comment:S}=y,{zipPath:R,zipName:P}=y,w=this;o.fs.stat(I,function(C,D){if(C)return v(C,!1);R=R?_(R):"";let L=me.win32.basename(me.win32.normalize(I));if(R+=P||L,D.isFile())o.fs.readFile(I,function(B,V){return B?v(B,!1):(w.addFile(R,V,S,D),setImmediate(v,void 0,!0))});else if(D.isDirectory())return R+=o.sep,w.addFile(R,Buffer.alloc(0),S,D),setImmediate(v,void 0,!0)})},addLocalFolder:function(y,v,I){if(I=m(I),v=v?_(v):"",y=me.normalize(y),o.fs.existsSync(y)){let S=o.findFiles(y),R=this;if(S.length)for(let P of S){let w=me.join(v,A(y,P));I(w)&&R.addLocalFile(P,me.dirname(w))}}else throw we.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,v,I,S){S=m(S),I=I?_(I):"",y=me.normalize(y);var R=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,we.Errors.FILE_NOT_FOUND(y));else if(P)v(void 0,P);else{var w=o.findFiles(y),C=-1,D=function(){if(C+=1,C<w.length){var L=w[C],B=A(y,L).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(L,function(V,J){V&&v(void 0,V),J.isFile()?o.fs.readFile(L,function(ee,X){ee?v(void 0,ee):(R.addFile(I+B,X,"",J),D())}):(R.addFile(I+B+"/",Buffer.alloc(0),"",J),D())}):process.nextTick(()=>{D()})}else v(!0,void 0)};D()}})},addLocalFolderAsync2:function(y,v){let I=this;y=typeof y=="object"?y:{localPath:y},localPath=me.resolve(_(y.localPath));let{zipPath:S,filter:R,namefix:P}=y;R instanceof RegExp?R=(function(D){return function(L){return D.test(L)}})(R):typeof R!="function"&&(R=function(){return!0}),S=S?_(S):"",P=="latin1"&&(P=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=D=>D);let w=D=>me.join(S,P(A(localPath,D))),C=D=>me.win32.basename(me.win32.normalize(P(D)));o.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?v(void 0,we.Errors.FILE_NOT_FOUND(localPath)):D?v(void 0,D):o.findFilesAsync(localPath,function(L,B){if(L)return v(L);B=B.filter(V=>R(w(V))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(V,J){return function(ee,X){if(ee||X===!1)return setImmediate(V,ee,!1);I.addLocalFileAsync({localPath:J,zipPath:me.dirname(w(J)),zipName:C(J)},V)}},v))})})},addLocalFolderPromise:function(y,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},v),(R,P)=>{R&&S(R),P&&I(this)})})},addFile:function(y,v,I,S){y=h(y);let R=x(y),P=R!=null;P||(R=new Og(i),R.entryName=y),R.comment=I||"";let w=typeof S=="object"&&S instanceof o.fs.Stats;w&&(R.header.time=S.mtime);var C=R.isDirectory?16:0;let D=R.isDirectory?16384:32768;return w?D|=4095&S.mode:typeof S=="number"?D|=4095&S:D|=R.isDirectory?493:420,C=(C|D<<16)>>>0,R.attr=C,R.setData(v),P||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return x(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,v,I,S,R,P){S=In(!1,S),R=In(!1,R),I=In(!0,I),P=Jl(R,P);var w=x(y);if(!w)throw we.Errors.NO_ENTRY();var C=l(w.entryName),D=u(v,P&&!w.isDirectory?P:I?C:me.basename(C));if(w.isDirectory){var L=c.getEntryChildren(w);return L.forEach(function(J){if(J.isDirectory)return;var ee=J.getData();if(!ee)throw we.Errors.CANT_EXTRACT_FILE();var X=l(J.entryName),_e=u(v,I?X:me.basename(X));let fe=R?J.header.fileAttr:void 0;o.writeFileTo(_e,ee,S,fe)}),!0}var B=w.getData(c.password);if(!B)throw we.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(D)&&!S)throw we.Errors.CANT_OVERRIDE();let V=R?y.header.fileAttr:void 0;return o.writeFileTo(D,B,S,V),!0},test:function(y){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(y);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(y,v,I,S){if(I=In(!1,I),S=Jl(I,S),v=In(!1,v),!c)throw we.Errors.NO_ZIP();c.entries.forEach(function(R){var P=u(y,l(R.entryName));if(R.isDirectory){o.makeDir(P);return}var w=R.getData(S);if(!w)throw we.Errors.CANT_EXTRACT_FILE();let C=I?R.header.fileAttr:void 0;o.writeFileTo(P,w,v,C);try{o.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw we.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,v,I,S){if(S=Ng(v,I,S),I=In(!1,I),v=In(!1,v),!S)return new Promise((D,L)=>{this.extractAllToAsync(y,v,I,function(B){B?L(B):D(this)})});if(!c){S(we.Errors.NO_ZIP());return}y=me.resolve(y);let R=D=>u(y,me.normalize(l(D.entryName))),P=(D,L)=>new Error(D+': "'+L+'"'),w=[],C=[];c.entries.forEach(D=>{D.isDirectory?w.push(D):C.push(D)});for(let D of w){let L=R(D),B=I?D.header.fileAttr:void 0;try{o.makeDir(L),B&&o.fs.chmodSync(L,B),o.fs.utimesSync(L,D.header.time,D.header.time)}catch{S(P("Unable to create folder",L))}}C.reverse().reduce(function(D,L){return function(B){if(B)D(B);else{let V=me.normalize(l(L.entryName)),J=u(y,V);L.getDataAsync(function(ee,X){if(X)D(X);else if(!ee)D(we.Errors.CANT_EXTRACT_FILE());else{let _e=I?L.header.fileAttr:void 0;o.writeFileToAsync(J,ee,v,_e,function(fe){fe||D(P("Unable to write file",J)),o.fs.utimes(J,L.header.time,L.header.time,function(k){k?D(P("Unable to set times",J)):D()})})}})}}},S)()},writeZip:function(y,v){if(arguments.length===1&&typeof y=="function"&&(v=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(y,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(y,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((R,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let C=D=>D?R(D):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,w,I,S,C)},P)})},toBufferPromise:function(){return new Promise((y,v)=>{c.toAsyncBuffer(y,v)})},toBuffer:function(y,v,I,S){return typeof y=="function"?(c.toAsyncBuffer(y,v,I,S),null):c.compressToBuffer()}}}});import{execFile as I_,spawn as A_,spawnSync as dA}from"node:child_process";import{promisify as T_}from"node:util";function C_(t){if(process.platform!=="win32")return!1;if(Kf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Kf,"").toLowerCase();return R_.has(r)}function $f(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return C_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function ot(t,e=[],r={}){return A_(t,e,$f(t,r))}function Vf(t,e=[],r={}){return D_(t,e,$f(t,r))}var R_,Kf,D_,mn=$e(()=>{"use strict";R_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Kf=/\.(cmd|bat|ps1)$/i;D_=T_(I_)});var q0=ie(Ne=>{"use strict";var M=K;(function(t,e){let r=K,i=t();for(;;)try{if(-parseInt(r(1285))/1+parseInt(r(1633))/2*(parseInt(r(676))/3)+-parseInt(r(1533))/4+parseInt(r(772))/5*(parseInt(r(1583))/6)+-parseInt(r(569))/7+parseInt(r(1422))/8*(parseInt(r(1010))/9)+-parseInt(r(1657))/10*(-parseInt(r(1564))/11)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(_o,125830);var gE=Object["definePr"+M(908)],mE=Object["getOwnPropertyNa"+M(838)],z0=(t,e)=>function(){return t&&(e=(0,t[{WUYUR:function(c,l){return c(l)}}[M(1205)](mE,t)[0]])(t=0)),e},wE=(t,e)=>{for(var r in e)gE(t,r,{get:e[r],enumerable:!0})};function _o(){let t=["x2LUAxrhBg8","vLPsB28","ywrKrxzLBNq","zw1ivMC","Cg9PBNrbBMq","q09oveLovuu","z1HOwuO","Aw9Ul2PZB24","DhvytMS","AvHnqLi","BwvZC2fNztO","ywrK","Ahr0Chm6","AxmGDw5Kzwy","B25JBg9Zzq","DwjjEMq","zw5KCg9PBNq","zw50tgLZDgu","x2HHBMrSzva","tufyx1jfvfi","Ec1TC2CTCw8","reD0vwu","z3bsCLu","yxvmDey","B25LCNjVCG","C2fNzq","s21Zywq","yLj0z28","svvJwNq","Ae1Yuue","ENnQCvC","mLfTzMTztW","zxvgrxu","y29SBM8","zgvMAw5Luhi","BLnhtxG","tKfusvzfx0u","DgTADvG","DMjIAfq","Aw1LCYbPBIa","uen1Chq","AevcDvy","yMLUyxj5","v3H2sw8","CMvTB3zLq2G","qwjVCNrfCNi","CMfTugfYyw0","z252Dvu","CM92AwrLihy","s2fjtuS","suX0v1y","txD2u0i","y2XLyxjtDg8","D3nZoI8V","q2vrvMq","mZiYmZuXmhPbsfbJqG","B3v0sw50zxi","thrOwuW","AePjuM8","CMvZzxrdB3u","vMXpDge","y3jLyxrLrxi","EfDes0W","y29TCgXLDgu","sLnptLa","wNPurMW","ruzvyNO","u3vwCeW","DND1AeK","y2XVC2u","x3DHAxq","twvfz24","rfHnqu8","B3fKD2G","AwXLx25HBwu","ihn1y2nLC3m","rxjYB3jdB2q","y3vYDMfSDwu","zw5NDgG","r1fsEwy","AeXqwgu","Dgv4Dc9WBge","BMjjB3i","BxnNsuq","wgXjvvy","tun6AMu","ufHIr0G","DMDlEg0","x3bPBMC","rK92v0S","ALLxAg0","EeXtrM4","DgLTzw91DcW","rxfYD1i","y291BNq","Cxb4BeS","rMjgtuK","wvv0CLC","D0LACuG","C3rVCMu","CM92AwrLigi","sMrZB0O","zgvSzxrL","EvbIr2S","BMrWB2LUDca","rNzdEK4","CM95AKC","Aw50zwDLCIa","yMfSrxzLBNq","A0DJtvu","DgLUzYbZzxi","BNrfBMrWB2K","rhrXsNG","CNjVCK1LC3m","yNLL","BMfTzq","qMTdvgW","Cgf5Bg9Hza","yMLUyxj5vhK","sefcvhy","BhDSDwy","yvrvwgG","Ahr0Ca","DvHosfy","q0jNt0S","whDYvxG","DhryqwG","BgLUzq","BuLVsvy","DuzgqK0","x2XPC3rLBMu","yNvMzMvYzwq","ywWGy3vYC28","uwLYBM0","DhjPzxmGCMu","x3jLBw92zvC","B3bLBG","EwDuwee","DxrVuMvJB24","zKzVDw4","DMvUDa","se1tEKW","u3rYyxrLz3K","wunyEw8","y25kswy","y3jLyxrLuMu","uwfvAfq","tKHRzfa","Cw1dzuu","B1HMzNm","u2HHCMvKv28","zsbHihn0CMK","quXuwfK","zcWGDw5RBM8","BKTbzu4","x3bHDgHlzxK","zMLSzw5HBwu","CYbHBhjLywq","DhjHBNnHy3q","seHjuKe","qvrgDKm","zvfwvMK","zMLN","DevftuK","zvHYtwK","vLHeAee","uevlrvq","q2r0qMq","q29UzMLN","AhPcDha","C0nVDw50zxi","CMHsDxy","Cg9PBNrdB24","wwDdzey","Ec1TC2CTy3u","Cw9Zx18","vffqsMO","x2LZsw5PDa","y2HLy2Tszwe","zw5HyMXLuw8","x3jLywr5q2W","C3rHCNq","B25SBxq","rhb5Cve","AKXtrgq","A1POzvO","qvzxs3u","u1HsEgu","Dw50","qLLgzw4","v3v3D1e","C3jJ","AM9PBG","vfjAr3y","DhzjrNO","y29Uy2f0","CgLUz1rPBwu","AeLQsu8","x3DZ","C3vJy2vZCW","wKnxA0O","uvHqEfm","qwXUt2C","AMTJshy","y3vQCMS","sufrtKC","s3bbtM8","BeHHBMrSzxi","C2v0u3rVCMe","ywrKt25L","ENnHrMW","De1HBMfNzxi","zxjFDhrS","C0Xf","nxWY","twLZC2LUzYa","zg51Cxu","Cu5nDMG","EsbJBg9Zzwq","B0HID20","zu1eBM8","CMvJzwL2zwq","BMvY","sM1erwu","Bwf4tg9ZC0m","Agzkwhi","r0L3AMS","zeXJEeO","Dgj3DKC","zxjFCw9Z","zhjwuMW","y0nNzuO","x2LUDgvYDMe","CMvJzxzPzwq","EKfXEge","Cuz5yK4","AxLwtfu","A3fesvO","zKv2zwW","zeH2zui","tg9UwM0","zNjVBuj5Dgu","C2Pxtg0","BxnzDMe","x21PBMLoyxy","t2nZDvm","BfrPBwvVDxq","BwvZC2fNzv8","y2HHCKnVzgu","x2vUzhbVAw4","aaaaaaaaaaa","CMTcCMm","t1bftG","CYbPBNn0yw4","CKXhrha","BwzeDfK","ue56yu4","zcWG","q3vZDg9Tq2W","v1HKDgq","zxrxB3jRq2G","y2fSBa","BMvJDa","y1b4DNK","EvjLy29UBMu","tgrhExa","ign1CNnVCIa","s2LPwem","nhWZFdf8mNW","CM92AwrLige","x194x21Zz18","z2DqrgK","u1vcA2q","vertyuC","igzHAwWSig0","z2vrDwv1zuW","C2XPy2u","EMrTt24","y29qu0u","yxPmqLG","wuTVuNK","yMfJA3vWigu","wwDewLG","y0XYyLm","vKzpBNG","vu1Rze0","ugHqBgC","u3rUAuq","BMv4DcGPigm","yKrIzfK","CNb4qKe","rNzqy3u","CgfYC2u","txbcvuG","zgf0yq","BwDqCM0","EfvbzMK","wfDouxO","q2rAvva","BM5Ly3q","ywr2yw5Jzq","x2LZtwLUAvC","AwTQv0m","y2rAv3C","vK1xDw4","tw9JuKW","DxrMofDYAxq","vK1zBNC","u2X5vKW","yMLUza","x3vYBa","zKLyqM4","yxnL","qNLhsfG","EM54Cxy","r3bHyLm","zw50zwqGDhK","sMX3Be4","AxnrB1nby2S","DMfSDwvZ","q2H2s0C","zLbVteO","A2v5CW","Cgu6ia","AxfeAu0","x3DZsw5ZDge","BNvTyMvY","zM9YrwfJAa","u25dqwS","wfDhBuq","whLguem","yxbWBhK","zufJAW","B25ozxr3B3i","AMfJsve","wg5kB3O","zv9ZDwnJzxm","z2v0sxrLBq","yKPqvMq","DLH0reW","shzNCum","C2PetwS","vhHOtwG","swPWDwK","AefJA01LC3m","yKfezMC","vxbuuuO","DfbZALO","x29Ut3bLBG","sK15ruS","rwrkt3O","tNjRsfC","tKzYu2O","yw1Lu3bHy2u","zvHzyLy","vu5ZqKi","B1LWsxi","uffzv04","tg9JAW","A3b4vuu","zMzLCG","v2vIu29JA2u","D1rxEeq","EKfbzhG","DfvYExq","sgPrEw8","v0zvBLy","yunZDey","wwvzs1m","y3vYC29YlNm","yMXVy2TLza","y2f0y2G","uMTiDhe","BwvrENa","uMD2yvi","C0T3sMK","z2z5zg0","BgvUz3rO","Bg93","qun3reS","vxPergW","r2v1Cem","Cg9W","ugX0uMC","BNrhq0u","Bg1TwNi","ihrYEsbYzwm","y3vYC29Yx24","BMv3vMvYC2K","BvHLsxu","DhPcD0W","AwHewfy","DeTQENu","Axjhrwu","zfPQshq","DhPsCuG","ugTwEfK","z2vY","CMvTB3zLrxy","u3rdDK0","rNPtA20","D2vkvfu","thPpBKW","uMDpCfm","y3vZDg9Tshq","ywT5qLi","Bwu6ia","B2nRzxq","BwzIz2G","zxj2AwnL","zcbLCNjVCI4","vw1oy20","A2v5","CgXLyxnLiha","Ef9MCM9UDgK","yMjUyuO","Dw5KzwzPBMu","tuvtu0fhrv8","x2LZqNjVD3m","C0Hdtfm","AePiAe8","AwXK","u0LNCum","ihrPBwvVDxq","qw1VDw50","tMLHzhC","CMvQzwn0","ysbTDxn0igi","CM9YrxzLBNq","B3nLrxzLBNq","z2v0","u0n5weq","uuzsrNm","thf6u3a","wxPlwKu","EKX0EfG","ywDL","x3bPBMDqB24","B1nqzfa","DwrIr1m","Cg93","C3nHz2vfDMu","CKfLv3m","vfH4vw8","lcbTyxGGCMu","CMv0CNLdB3u","yM9L","Aw9U","Au9cu0i","vgfN","BNHpBeG","DxbNCMfKzw4","z0zXyLa","y2XVC2veqG","mJqYnta4C1DRr21H","rgDIAKK","Eu9cug0","t3bLBKv2zw4","Dwv2r0y","s01fsem","u0LRtMm","BMCGB3iGyw4","rwDYC0W","zxjFywnRx20","EhbrCuS","t3LqDxu","q3zzBxG","uvPjteK","DgLjDhe","igzPzwXKoIa","t1bLB08","C0XPC3rLBMu","uMHTsgK","A1noqMO","rhn1rLC","CMfNzvn5BMm","yxHNr1a","AgvHzgvYCW","x2rYB3bhBg8","t0zWwfq","vNLIBKq","yKPxz0i","tMnpwfC","rLDt","BvbUCgW","Bg9NsurozxC","t1fVrhe","CMvZzxruCMK","whbJCge","s2TXqu4","u0zQAha","vw1bz08","r0nhsxa","zNjVBunOyxi","qwTItuS","BuDpCeC","thj1Dwy","yw5ZzM9YBvq","s2XuwNy","yxGGCMv0CMK","C3rLBMvYCW","t0XMz1i","rvPmy2e","Dg9uv1K","rKXvA2u","ihzHBgLKihm","Dwrtq2W","zNjVBujPDhm","vhL1zwy","rLL3zfC","EfzUrKW","DujnBKS","yM1iDfy","tg9Nsuq","zhrND2S","oxWWFdv8ohW","BMnVzgLUzW","x29UugfNzu4","zxH0zw5ZAw8","Dg9cExrLC0W","tfLmq1K","CMTLCKDSB2i","t3fcCfG","EfvZzuvUDG","zNLgz2m","wxL6wuS","x1fVu01HBMe","BxnN","vNnhvge","B3jLtMfTzxm","s05kzNi","mxWW","yxKSig5LDhC","z2u6ia","x2n1CNnVCK4","rNnxuxK","BwvKAwf0zwW","thDVvuq","Dxrjza","EgPID0m","DNbeEgG","BML0AwfSAxO","CNnVCL9Uyw0","r2Lxz2C","uMvHzcbWyxm","z0ngvfu","DxbYr2m","B25mAw5L","ANfhz1q","C2DPza","qufZD2G","yvz2ExC","EKrmEey","mdaWmdaWmda","zezQzhy","x2fKzfDZtgK","rxntDhK","EK5bsu0","AgfZ","z0zrDLG","B3jL","mZeZntC1ugH0v09d","CNzHBfzHBhu","zNDZxZeUmc4","zxHWB3j0CW","rNrsDuW","s3P4CfC","B3bLBKrc","wMfNBgW","ywrKq291BNq","BhrPCgXLihq","zxjYtxnN","zxjHDg9Y","y2XVC2uSihC","BwvZC2fNzq","thLTzeW","q3Dqv1u","AvP4D1C","CgLUz0XVC3m","yw5Hz2vY","EhrjENq","yxnJCMLWDa","rePuvfG","z2v0qwXS","seHYy1C","CfDVy2y","ELHnBLy","BwnRuLm","DhDVCMTdAge","EMTSDMe","BMfWsxm","ALDOwhi","Eg9qEhy","AxnAzxjV","C2vUza","zLzxDg8","AxnmB25N","uwP1tfK","q1L6vMu","zLzNAfi","yxzlBMq","C0jf","DhLWzq","B25SAw5L","s0fvDeW","DM5Rwe4","BwLUAvbYB2C","D3jky1m","zKPdyve","ywDLu2HVDW","DeLUDgvYy2u","ChLksLO","mNWZFdb8nhW","ihzHBgLKigq","CMvZDwX0","u1HfCLK","B3bLBIa","z2vtEw5J","rMfrsgi","ywnRpwzYB24","uuLrvhe","uvnlDMO","yvLjuey","D2XdrLO","ihbYB3rVy28","qKXAuvq","qMvkv0m","vxf6wxC","zNvUy3rPB24","B2zM","zgrjrcWGzgu","twvZC2fNzuu","B2nRzxrtDwm","z0vtDuW","t0fKs2q","EvbdzMy","A0nYBxC","vvjMu1K","B3jRig9MzMW","o2nOyxjZzxq","BgXxrKC","y0jwEvG","zw1LBNq","wgz0uLm","tvPev3e","zw5fDMvUDa","C2v0y3vYC28","x2LUAxq","wLruCxG","x2HHBMrSzvi","y2vnswS","Bg9IywXty28","A1DNDKO","CNnVCKzPBgu","B3HkDLq","yw10zg8","tNjjEfO","mZqYmtbly3z6zvG","CxjpAw0","EMHWvuq","x3jLy29UBMu","y0PLDui","yxnZAwDU","BfrNA2u","EeDltKm","qKLlqwe","q0nTCeC","y1bcDu4","y29Kzq","sejRq3y","y0flr00","zgjTs3K","C2v0","qKf5Auy","AxzHvxG","tNnwtg0","CMvWBgfJzui","y0nzuLO","CNDtuKq","uvzmwMW","tuXfD0K","B3ziA20","y0jPr3G","zeDkA0m","Cgvizxu","AgvKtwf4uMu","BIWGAg9ZDg4","DcbSAw1PDa","Dg9cExrLC0i","zuf4wLC","r2PdsvC","yMfSu2nVCgu","x3bPBMDmB3m","AxnFywnR","zfPXr2e","zw5HyMXLqxu","BNruCMLLC0m","BMDLza","Aw5JBhvKzxm","Aw5PDcbrB1m","vgTnAKO","ELj3Bxm","CMrft00","tgrZuxi","zMLSDgvY","Dgvbt0q","AwDHDg9Yt24","D214vhG","Cgf5Bg9Hzeu","twvqEve","A2v0ignVBNm","x25HDMLNyxq","DLruDKq","CKfTrvC","zMLUza","DgfYz2v0","mhWXFdr8m3W","jMPZy2fSBgi","ywXPEw4","v2LUzg93","s2PirhO","q0rSrfe","nNWZFdj8mta","BwvZ","Eg9iBKu","l3DZl3yY","uKnJzKe","zv90Aw1LB3u","DhnssLi","y3HHqKq","DK1vENi","B0jsCgG","sLPcyxC","rgfQqvG","AgLNAa","D2XVq08","CMvUDevUzha","vgvzzgO","wvLoreu","EhrAD0e","C2nYAxb0","x2DLBMvYyxq","AgvHzgvY","DKPkuu4","vfzADKK","u0zsD1a","DhjPBq","u1zbwLG","tgLZDgvUzxi","q2r3Bhi","CMvJB25Uzwm","DhjPzxm","Dgflqwm","CMTvyLm","ugTLEe8","BwLUzW","z2jXuNi","yNL0zuXLBMC","D2vI","yuHPBNC","twH5Cxu","sxPczfK","BMCGDxjSoIa","ywnRDxbfBMq","sLryCvK","D2neDhm","C01dzLu","BMfpDK0","DM5hDLy","Dw5RBM93BIa","CgfNzxnOB3C","rMLkDMS","y3jLyxrLt3a","BMrLEa","ywDLsgLKzq","yxfIzfi","vhvVrw0","vvrhENy","D3jPDgu","rhHtAhm","zw5JB2rLrNi","yxv0B21HDgK","y3jLyxrLq2W","DgH1uLi","wgzbBvC","x2n1CNnVCKy","vfzdvM0","BxzRzuW","AKPTrgq","ywnR","C0LmAfG","qu16zwy","whHWDui","B3bLCNr5","A0HyAeG","CvbjEhC","rKXOANC","yLLfugu","id4G","wffhqxy","ywXSq3vYC28","v1vZvNy","D2fZq2XLyw4","BwfUDwfSihi","uuvizvi","y3r4","C3bSAxq","zeDRDMq","t1bftL9fuLi","u1vLugi","yxbWzw5Kq2G","q09oCKm","rwfUvNe","n3W4FdL8mxW","DxbKyxrLq3u","ihjLy29UBMu","BwjsrMK","C1vlEMe","DujOwNq","x3fVC0rc","zLDIsgq","yu51sei","BLPdue4","wuDLAKe","B25pCgvU","ywjVCNq","BK9fCMy","u2HJBMW","zxPhyNi","x2HHBMrSzu8","wMPvDfe","weDjCfC","wMDZDKy","z09Ltfa","q1vbtva","DxjS","y29UDgLUDwu","t2jQzwn0","A1fXzhi","B2Hztuq","q1v3wMy","D24GCMvHC28","qwn6C0C","Dev2zw50","vNHvuKK","EvrRsg4","q0Xpu0ve","vMPmtNO","Aw5KzxGGB3u","y3f3DwW","BezSDxnO","B25TzxnZywC","Dg9oDw1Izxi","ruTkshe","vw1Mrue","Bu92zKG","tKH0vvi","EhDmtvy","tuvqBK8","s1Ddvhm","CMLLC0nVDw4","Dw5ZAwDUzwq","zKP6CvO","BMnLq2XVC2u","B25tDgfYDfi","Bhf0Dgu","rNjVBNrPzxi","Dw1yzfq","vMHdAKu","z0HvB1m","AKv0sLy","vK5xEMG","n3WYFdn8nhW","thPOAe8","D3blqKe","x19LC01Vzhu","DK1Iuxi","DefXy3C","t1Hsyuu","ExLuyuy","sKvlz2S","Dej5Axa","y29UBMvJDca","ruDiwNi","tNPlqNG","q0TqsMq","DKDoA1a","Du91vue","zwvKzwq","yw5Nzq","AevYCM9Yrxy","Beryt3a","sMnRse8","CK9sAfK","vuLnvuG","nta2n295q3zyvq","y3vYCMvUDeu","nhWW","zfnyr3G","x2LUAxrqCM8","lcbOB3n0BMe","t01OzKK","A0rTy3K","sLbgDe8","nxWXFdn8mNW","ChbL","CunHEKe","B1j6v0y","y2vUz0m","yLnhvK4","vM5PDhO","yNvMzMvY","vvn2wgO","AejYvwm","r0jhuhe","yNL0zxm","zhHAzxO","z0HMshe","sKzuww4","zMXVB3i","DKPyvNG","rxHbu3y","tLvoBfG","Cgf5Bg9Hzfq","zw50","B25nzxnZywC","z1rPBwvVDxq","vNfhs3u","B2D4uhq","zKDor0m","rhfgCgS","AenSB3nLrxy","x3bYzwzPEa","y29UBMvJDfm","zxf1ywXZ","yxrLq291BNq","EMjNBLK","twv0wuO","uMvJB25Uzwm","CNnVCL92ywW","x0rctMfTzq","uwrluei","yNviu2W","qvnkzue","ww1uB2e","C2v0sxrLBq","r3HIEe4","Dg9mB3DLCKm","BgLTAxq","vxbKyxrLq28","u2PAv1C","yvjNs2W","Cw9Z","CNzHBa","D2zjBLO","u2vXsuq","tMDtwg8","t0H6zgq","zxjYtM8","wuXOCe0","Aw47y2HHCNm","x2nSzwfYvgK","tNzuz28","seTOtvC","Efrurw52","zKryEgy","AwXLtMfTzq","t0DWCgK","rvjst1i","CMvZzxrfBMq","u1LRqKm","rvfbCva","x29WDgLVBNm","ihrPBwvZ","zLPjr3q","Fdv8nhWXmxW","zhrLrLq","BKXPBMu","x3bYB3rVy28","B2LUDfjLywm","CM5tChq","x2nSzwfYugK","sMrbA3e","C3bSAwnL","zLLLAfK","Dfjmwfy","txrLuK4","Dg9Y","zg9Uzq","u09IwMK","CwXsAK0","vxrntum","qLvZyK4","quToC2i","rwzTzeC","vgLTzw91Da","AhzNALm","q1LlDuu","C0PgB3y","q3vzsMS","zu9Xvgy","BgvY","uMXQAMG","DNz4z0e","y29UC3rYDwm","C2vYDMvYvgK","DMvY","BerRs28","DhDUt0q","B3jpBMXPBMu","uhPJD08","se9nBgm","Afrwy3a","B25Uzwn0Aw4","ENjOtwe","qwnADvi","AhvxC2C","yMvOCfm","rwP5A1a","DgvZDa","BuXSt0q","D2TnChG","x2zVCM1HDeu","ANvdAvC","zMvY","uMTkAvG","Bwv0Ag9K","zfDVCMTLCKC","qurZuwm","C2v0zgi","BNrLCG","ywnOzwqSihC","zxjFBxnNAwq","t1jfCfu","u2LLDLi","yw1LoIa","x2LZtwLUAvq","A2HZCxO","thPwwMq","tfz4DKm","tNvwquO","s1jZq1a","q0DgAeG","De5SveW","Dhj1y3rVCIa","x2rPC2nVBM4","AxnszwfKEq","zvz5s2e","sM5WweO","ALfUr20","BLDqBuW","rKLmrv9ot1q","zgLZCgf0y2G","B2zLAfa","B3nLza","suvtx0vsuK8","tevsyNG","DxP2A00","z3vMr0G","x2nVBM5Ly3q","zfvPue4","vLDxEe8","ywDLrxzLBNq","C0zlu3u","ufj5zxy","zMnxAKC","x21LC3nHz2u","svnLvuO","s0nirK4","uuX6CKG","t211B1q","uKnvtvy","zgvS","qw1zthO","vvH3zgO","vxjut3O","q09otKvdveK","zMzmAw5L","z2v0q3vYCMu","y0TLB1m","ueLLyM4","y1bbvMe","Chv0","CwTzDw0","uejJr00","vgzvChu","Aw5L","yKDeq3e","ALvlz0q","tKTVBwK","v1vzvvi","BwLZzq","zw5JB2rPBMC","DhfdrvG","qxn1teC","zNjVBNrPzxi","zM9Yy2u","tMfTzq","y29UBMvJDeu","y29UBMvJDgK","tLPRqxq","rwfbtgy","CgLUz19VBMm","zM1puui","y0z6uuu","AfzxCxG","vgPOqu0","qKrPDhu","wMj3yvG","Bhm6ia","thDiuvm","B0rMqu0","y3vYCMvUDeK","tevlu1G","x3nVy2TLDa","CMvHzhDYAxq","zxH0ugf5Bg8","DuHAqKW","Eg55A0W","vujwyLe","Eejzv24","EvbZv3i","B25fCNjVCG","qu1Xv2m","DxnLCKLW","vvnTvvG","BM9Uzv9UB24","zwnVBM5Ly3q","qLLIzwO","ug54uhu","rLjQzNK","t3zcyKK","CIb0DhDjra","q1PUy0q","AxnrB1nnzxm","svHAzhK","nhWXFdj8mhW","zwn0","ywnSBhG","ENzPy2e","Aw5Lza","zxjYB3i","tw9KDwXL","v2f0DKq","ywnOzwq","r2L1CeK","Cwz4v3C","Cfn0rfe","z2TVthu","C3vSrhG","t0H2Cfi","Ae5oBLO","z2v0q3vYC28","BvjOvLu","wMfoC2q","BM93","A0j6uhm","AwfeENC","DeLK","zxrIDM8","tMLsuhi","y3rnBfm","zejOwxO","rgvKAwnHDgu","zLvRtvO","CgLUz0LUDgu","nhWYFdb8m3W","u3zyANu","CMfTrNO","D0fWvuy","oduYmdf5zvHkshO","C2XmBgu","Cvvmwwm","BMDuAw1LCG","ugv6ufa","CMvKDwnL","BMrWB2LUDfq","z2v0u3rVCMe","yMfItfe","CMvHzhLtDge","CgjICdi","Dg9iyxnO","z2vjBMzVu3K","rK9MAwK","BwfW","u05tq28","Bwf4uMv0CMK","yxjYyxLIDwy","zgvJB2rLzey","CgLUz09Uy2u","Cevbwva","su5tvefova","x2rItMfTzq","BfbHtNO","BgXoAw4","ExbL","vKvkvfm","CMvZB2X2zq","v1PQqxm","wNjnshK","CKPWAgS","Dgn2rMO","B1vLu1y","x2n1CNnVCK0","rgXjC0q","vK1HEfG","ywnRx2nVzgu","BgLUzw5V","refrEfa","DgfIyxnL","z1PrDw8","y29UDgv4Da","ywnRtxnNswq","tffXvuK","q29Kzq","A093BKq","CLvVswS","Dg9tDhjPBMC","Bwf4twvZC2e","Bxfyq3u","y2uGBM90igK","wgTLB2W","ue5Xre8","t3nrt0S","x2jPBMfYEvq","Ae1LC3nHz2u","x2nYzwf0zvm","qxLxvKe","B2nRzxrgywK","AxzequS","y3ruAw1LB3u","seTVsvO","EhfbBvC","BLbjuNC","nhWXFdn8mhW","sfrPzuW","sujNBuu","y3jLyxrLt2i","vK5nvKy","zgvSvei","B2fK","ywDoCLO","C0DOueS","tgDOtu8","tNDwtKK","z29PBMCGyxC","rvPSuNe","sKXhzw8","yM9KEq","rxzLBNq","uMPhvKG","u0fICha","x29Uq2XVC2u","D1ntu3u","BgrwyNu","nhWYFdb8mxW","B2zMC2v0","z3j5twW","qNzZsvi","zLHyBwe","q3vZDg9Trxi","v0zAD0m","uLjpuG","r2DWAgy","BfHrt3i","CvvXCgi","BwvY","uerkzxq","x2rLC3rYB3K","y2HnyxHuCMK","q291BNq","yNL0zu9MzNm","Aentuge","ugTvELu","Bg55wfC","EwvczfC","Cvbbsxi","Ee5cBwu","t2feuK0","x2LZv29YA2u","C3vIyxjYyxK","zfjwD2S","C3rYAw5N","CfjnqKy","y2HLy2TdDxi","uxvLDwu","B3vUDa","yxDnzgW","zMjpEhy","ywzHs2q","vxPHweS","ue5mz1m","A3DVC1i","u2HgBha","sfrwqLK","qNLXz1e","BNrbBMrvCgq","z2v0s2v5","ig1LC3nHz2u","CgvYC2LZDgu","DMvYC2LVBMm","x3nLCuLK","vgzkrKO","sMjiCKW","CfLqte8","B1rcv00","nhW1Fda","ndq4zMjmBKDA","C2vYDMLJzq","y3jLyxrLtwu","zLrTqwm","ChvZAa","zNjVBu51Bwi","AwXSihvZzsa","ywXty29Wzq","y2XLyxi","suTKCNK","CMfUzg9T","Bg9Nsurhzw4","tLvbsg4","Avf4z1K","qMjUq3u","BMCGzMfPBgu","x29UvgLTzw8","zgzSChy","tw1mr2C","DcbVzIbYyw4","u294C24","zw1PDa","B25VCgvU","ze1Lru4","Dgrmsha","ELPHtuS","quPfrxq","zNjHBwvuExa","B25szwnLAxy","EfHIqxG","zwrPyxrLBhK","zgr2uMK","Ae9Wzw5fDMu","yw1L","AgvirLK","wuLzEwm","C2HPzNq","C2v0q3vYC28","renHzwq","yvPkzgW","Bg9N","AxjLza","t0H1tLm","q0TiB04","yxv0BW","qvD6rhu","Dgv4DfbHEwW","y2TiBvK","txDsseO","D2LSBfjLy28","DMfSDwu","Buvfu08","CMvWBgfJzq","zgvSzxrLrge","x2rPC3bHDgm","seHgt2C","y09Wzw4","EfvwzNC","C3vIC3rYAw4","wKP1DxO","mxWWFdn8nhW","AfLOsxq","vgnJvKy","x2rLyNvN","Be9WDNa","t2Xvsxm","uwTSvwi","x29UtwvZC2e","uM5rsNa","x3nLBMrby2S","sLzHv2i","Dwzptei","tvrbqwq","q1vLrfG","Dg9VigXHCMC","sejrBuK","B25tDg9Wsw0","zxmGCMvHy2G","CMvXDwLYzwq","tMTKCMy","x2TLEvbHDgG","yxbWBgLJyxq","AKXzEvO","EeD0tg0","Bvfzt3a","C3H2yw8","tvPMzfq","tKLMsLe","AMvJDfn0B3i","tKDFrvjst1i","t2z0A1m","C29YDa","Dg9cExrLCW","B2jQzwn0u3q","zgr0wMi","AgfUz2u","Aw5KzxHpzG","ChjVDg9JB2W","Buntq1K","zw5Tuvy","yM5bEMy","zgLZywjSzue","ANrlv1i","uNPJsxK","rwD3y1a","rLrYtwS","rM5Lsw4","BfnYD1G","y3vYC29Y","C1P1Efy","y3jXCuK","otG3nZu2rgPutvjw","uM92Be4","v3fPyKW","y0f1yvm","Dwrnqwu","reiGzMfPBgu","t0fXv24","x29UrxjYB3i","Aw9UvgLTzw8","y2vZC0HHBMq","ywnRx2LK","BgLZDgvUtMu","B2zMBgLUzq","z2v0qwXSs2u","C3rYAw5NAwy","ze10zhm","zxjFAxnFywm","CMvHzg9UBhK","tKfvDeK","rMPTqu4","AxnbCNjHEq","CMfTzq","wwrUze4","uMDVBha","wfLbuK0","ENPsuvC","uMvushG","CMvHzfvjBNq","u1Hgs3y","rNz4AeS","AurpALa","mtfVzNPgAgK","uhjPBwfYEuS","ChrVCG","tNvOyMO","ueT6DfO","m3W1Fdr8mNW","C1rIEhG","ChjVDg90Exa","DgHLBG","ywXSzwqGBxu","zvvYBa","CMzmuNu","tNnhvge","vKrvDhu","CLzHBhvLCW","icSG","tw1jvhC","y0vsuKG","C3rVCcbPBw0","mZbKEKDOrM0","rLjptLrjrvi","v1LUChy","EKnTswS","y3vYC29Yx2y","B1zZANK","y2HnyxHdB3u","wNbSCLK","sxz5ALy","vLf3rvu","twnkt0S","zLrxuuO","tvnRqK0","CMvHC29U","vLjVCNC","D3jPDgvvAw4","Aw5KzxG","rwnhrhK","x2DLDeLUDgu"];return _o=function(){return t},_o()}function _E(){return P0||(P0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function yE(){let t=M;return N0||(N0=[IDBCursor[t(1571)+"e"][t(415)],IDBCursor[t(1571)+"e"][t(951)],IDBCursor[t(1571)+"e"]["continue"+t(1565)+"ey"]])}function EE(t){let e=M,r={HjQyo:e(1256),MePyQ:function(o){return o()},sGhPK:"timeout",NrkHW:e(1217)+e(451)+"s",UXwdj:function(o,c){return o!==c},awMdl:"zVEqd",TVZvI:e(1157),ZCWkJ:e(314),rnSpt:function(o,c){return o!==c},udMAe:e(535)},i=new Promise((o,c)=>{let l=e,u={zIEwD:function(m,A){return m(A)},NZkAt:function(m){return r[K(824)](m)},UBVbQ:function(m,A){return m(A)},yXypm:r[l(1357)],qPszS:r[l(466)],dflpv:function(m,A){return r[l(1189)](m,A)},yZCgS:r[l(1402)],CYzVe:r[l(859)],zfoYK:function(m,A){return m(A)}},h=()=>{let m=l;t[m(513)+"entListe"+m(337)](m(314),x),t[m(513)+m(1619)+"ner"](r[m(480)],_)},x=()=>{let m=l;u.zIEwD(o,Pt(t[m(729)])),u[m(1215)](h)},_=()=>{let m=l,A={tKjzu:function(y,v){return u[K(1234)](y,v)},SlyVL:u.yXypm,Lruuf:u.qPszS};u[m(1439)](u.yZCgS,u[m(713)])?(u.zfoYK(c,t[m(1256)]),u.NZkAt(h)):(A[m(507)](_0x1ff4ac,A[m(423)]),this.off(A[m(611)],_0x2cf4a4),this[m(744)](m(1217)+m(842)+"t",_0x57ee7d))};t[l(1604)+l(863)](r[l(315)],x),t[l(1604)+l(863)](r[l(480)],_)});return i[e(1572)](o=>{let c=e;if(r[c(1095)](r[c(1537)],c(535)))return this["_endpoin"+c(326)]?.getCurrentEndpointTriesCount()||0;o instanceof IDBCursor&&Yc[c(787)](o,t)})[e(486)](()=>{}),Eo[e(787)](i,t),i}function bE(t){let e=M,r={WxvIo:e(1665),blEfk:e(1256),roHVb:function(o){return o()},xwLMV:function(o,c){return o(c)},LERbx:"AbortError",ASJeA:function(o){return o()},kWgvJ:e(940)};if(yo[e(673)](t))return;let i=new Promise((o,c)=>{let l=e,u={URfSY:function(m,A){return r[K(972)](m,A)},TWrrE:r[l(1171)],vpDxh:function(m){return r[l(1058)](m)}},h=()=>{let m=l;t[m(513)+m(1619)+"ner"](r[m(1645)],x),t[m(513)+m(1619)+m(337)](r.blEfk,_),t[m(513)+m(1619)+m(337)]("abort",_)},x=()=>{r.roHVb(o),r.roHVb(h)},_=()=>{let m=l;u[m(752)](c,t.error||new DOMException(m(1647)+"or",u.TWrrE)),u[m(655)](h)};t[l(1604)+l(863)](r.WxvIo,x),t["addEvent"+l(863)](l(1256),_),t[l(1604)+l(863)](r[l(767)],_)});yo.set(t,i)}function vE(t){bo={QSKvj:function(i,o){return i(o)}}[M(736)](t,bo)}function SE(t){let e=M,r={Cdwlr:function(i,o,c){return i(o,c)},MSkBM:function(i,o){return i>>>o},KpANo:function(i,o){return i!==o},OMhfI:e(1552),jUKgD:function(i,o){return i(o)},hDKDl:function(i,o){return i===o},WCSdd:"QkCHn",sILhX:function(i,o){return i(o)},mfbgh:function(i,o){return i in o},NTMKy:e(1515)+e(644),yLzqX:function(i){return i()}};return r.hDKDl(t,IDBDatabase.prototype.transaction)&&!r[e(523)](r.NTMKy,IDBTransaction[e(1571)+"e"])?function(i,...o){let c=e,l={JVaWb:function(u,h,x){return r[K(864)](u,h,x)},fQaFV:function(u,h){return r[K(1595)](u,h)}};if(r[c(321)](r[c(1016)],"GNeQU")){let u=t[c(376)](r[c(1203)](Mi,this),i,...o);return Zc.set(u,i[c(1513)]?i[c(1513)]():[i]),Pt(u)}else{let{value:u,offset:h}=l[c(1492)](_0x5a3e13,_0x218f22,_0x540ef0);_0x32a1f5=h,_0x5498c1=l.fQaFV(_0x5956c8<<8,0),_0x3c20cf+=u}}:r.yLzqX(yE)[e(813)](t)?function(...i){let o=e;if(r.hDKDl(r.WCSdd,"MXDTY"))this[o(313)]&&this[o(313)][o(709)](_0x3d02fc),this[o(1181)+o(1400)][_0x5477cd]=null;else return t[o(446)](Mi(this),i),r[o(1203)](Pt,Yc.get(this))}:function(...i){let o=e;return r[o(905)](Pt,t.apply(r[o(905)](Mi,this),i))}}function IE(t){let e=M,r={IUcZt:function(i,o){return i(o)},FvPcu:function(i,o,c){return i(o,c)},OsQOK:function(i){return i()}};return typeof t=="function"?r[e(1630)](SE,t):(t instanceof IDBTransaction&&r[e(1630)](bE,t),r[e(406)](F0,t,r[e(1338)](_E))?new Proxy(t,bo):t)}function Pt(t){let e=M,r={hfJXr:function(o,c){return o instanceof c},FdIDT:function(o,c){return o(c)}};if(r[e(340)](t,IDBRequest))return r.FdIDT(EE,t);if(mo[e(673)](t))return mo[e(545)](t);let i=IE(t);return i!==t&&(mo[e(787)](t,i),Eo[e(787)](i,t)),i}var F0,P0,N0,Yc,yo,Zc,mo,Eo,bo,Mi,L0=z0({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={IzBdY:function(r,i){return r instanceof i},OXRaE:function(r,i){return r===i},xUVfw:t(1190),qlRjM:function(r,i){return r===i},hVLyw:t(1515)+"oreNames",EFUbz:t(1701),IAQNG:function(r,i){return r(i)},xNBme:function(r,i){return r===i}};F0=(r,i)=>i.some(o=>r instanceof o),Yc=new WeakMap,yo=new WeakMap,Zc=new WeakMap,mo=new WeakMap,Eo=new WeakMap,bo={get(r,i,o){let c=t;if(e[c(876)](r,IDBTransaction))if(e[c(993)](e[c(1479)],c(1190))){if(e[c(993)](i,c(1103)))return yo[c(545)](r);if(e[c(1105)](i,e.hVLyw))return r[c(1515)+c(644)]||Zc[c(545)](r);if(i===e[c(1668)])return o[c(1515)+c(644)][1]?void 0:o[c(1515)+"ore"](o[c(1515)+c(644)][0])}else this._isMiniTT||this[c(416)+"X"]?this[c(632)+c(375)+c(1004)]():this[c(533)+"er"]&&this[c(1602)+c(1710)+c(863)]();return e[c(320)](Pt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e.IzBdY(r,IDBTransaction)&&(i===o(1103)||e[o(1392)](i,e[o(1668)]))?!0:i in r}},Mi=r=>Eo[t(545)](r)}}),U0={};wE(U0,{deleteDB:()=>TE,openDB:()=>AE,unwrap:()=>Mi,wrap:()=>Pt});function AE(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,u={YLhpM:function(_,m){return _(m)},wfInZ:function(_,m){return _(m)},jEtJV:function(_){return _()},CYKuE:function(_,m){return _===m},UmAgO:l(1483),CZncD:l(1415)+"hange",dUiPN:l(566)+l(1003),yQZBZ:l(485)},h=indexedDB[l(251)](t,e),x=Pt(h);return i&&h[l(1604)+l(863)](u[l(1175)],_=>{let m=l;i(u.YLhpM(Pt,h[m(729)]),_.oldVersion,_[m(503)+"on"],u[m(1074)](Pt,h[m(273)+m(562)]))}),r&&h[l(1604)+l(863)](u.yQZBZ,()=>r()),x[l(1572)](_=>{let m=l;u[m(1112)](u[m(606)],m(1380))?(xQWtkS[m(1074)](_0xcbdfad,xQWtkS[m(1069)](_0x2b2068,_0x52818c.result)),xQWtkS[m(985)](_0x254744)):(c&&_[m(1604)+m(863)](m(1671),()=>c()),o&&_[m(1604)+m(863)](u[m(1248)],()=>o()))})[l(486)](()=>{}),x}function TE(t,{blocked:e}={}){let r=M,i={GBGPq:r(485),mLlOD:function(c,l){return c(l)}},o=indexedDB[r(1475)+r(1324)](t);return e&&o[r(1604)+"Listener"](i[r(1029)],()=>e()),i[r(1135)](Pt,o)[r(1572)](()=>{})}function M0(t,e){let r=M,i={RgOpS:r(1230)+"e",QklUb:r(1550),XQGAv:r(1397),MZDWq:function(h,x){return h!==x},fGNGC:function(h,x){return h in x}};if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e===i[r(914)]))return;if(wo.get(e))return wo[r(545)](e);let o=e.replace(/FromIndex$/,""),c=i[r(759)](e,o),l=H0[r(813)](o);if(!i[r(1044)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(l||G0.includes(o)))return;let u=async function(h,...x){let _=r,m=this[_(273)+_(562)](h,l?i[_(518)]:i[_(1488)]),A=m.store;return c&&(A=A[_(1599)](x[_(1458)]())),(await Promise.all([A[o](...x),l&&m.done]))[0]};return wo[r(787)](e,u),u}var G0,H0,wo,RE=z0({"node_modules/idb/build/index.js"(){let t=M,e={delTB:function(o,c){return o(c)},qrOim:t(1197),dpTvD:t(1613),IBgmE:t(1430),VDUtu:function(o){return o()},lDRQs:t(545),UqzYw:t(1412),SYkBC:"getAll",vTTvD:"count",KAWcW:function(o){return o()}},r=(t(1569)+t(646)).split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(1354)](vE,o=>({...o,get:(c,l,u)=>M0(c,l)||o[t(545)](c,l,u),has:(c,l)=>!!M0(c,l)||o[t(673)](c,l)}));continue;case"1":wo=new Map;continue;case"2":H0=[e[t(773)],e.dpTvD,t(1704),e[t(1351)]];continue;case"3":e[t(1577)](L0);continue;case"4":G0=[e.lDRQs,e[t(742)],e[t(1085)],t(1546)+"ys",e[t(827)]];continue;case"5":e.KAWcW(L0);continue}break}}}),CE={idb:function(t){let e=M,r={hEBuV:"mADqj"};t.exports=Promise[e(1312)]()[e(1572)](()=>(RE(),U0)).then(function(i){let o=e;if(r[o(1643)]==="mADqj")return i;this[o(1096)+o(1288)](),this[o(552)+o(1041)+"Id"]=_0x38d612(this._ping[o(424)](this),this._options["pingInte"+o(1068)])})}},B0={};function Ot(t){let e=M,r={fEaVO:"1|4|2|3|0",OHzdd:function(u,h){return u!==h}},i=r.fEaVO[e(921)]("|"),o=0;for(;;){switch(i[o++]){case"0":return l[e(679)];case"1":var c=B0[t];continue;case"2":var l=B0[t]={exports:{}};continue;case"3":CE[t](l,l[e(679)],Ot);continue;case"4":if(r[e(1072)](void 0,c))return c[e(679)];continue}break}}Ot.d=(t,e)=>{let r=K;for(var i in e)Ot.o(e,i)&&!Ot.o(t,i)&&Object[r(1636)+r(908)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Ot.o=(e,r)=>Object[t(1571)+"e"]["hasOwnPr"+t(908)][t(376)](e,r)})(),(()=>{let t=M,e={auLtF:function(r,i){return r<i},eRoVn:t(355),VejYS:t(937),sHCLS:t(531)+"d",uYhBc:t(1257),qmCeE:t(990)+"le"};Ot.r=r=>{let i=t,o={PKztZ:function(c,l){return e[K(1625)](c,l)},cengC:function(c,l){return c-l}};if(e.eRoVn!==e.VejYS)e[i(534)]!=typeof Symbol&&Symbol[i(1332)+"Tag"]&&Object.defineProperty(r,Symbol["toString"+i(564)],{value:e.uYhBc}),Object[i(1636)+"operty"](r,e[i(263)],{value:!0});else{let c=_0x3d9282[i(921)](":");for(let l=0;o[i(1568)](l,c[i(492)]);l++){let u=c[l];if(c[l][i(492)]!==4){let h=_0x1336e1[i(1480)+"g"](0,o[i(1023)](4,c[l][i(492)])),x=h[i(310)](u);_0x37e9f7=_0x28637c[i(310)](x)}else _0x511b6e=_0x5107ae[i(310)](u)}return _0x47d95b}}})();var Te={};function K(t,e){t=t-245;let r=_o(),i=r[t];if(K.UnFaSJ===void 0){var o=function(h){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",m="";for(let A=0,y,v,I=0;v=h.charAt(I++);~v&&(y=A%4?y*64+v:v,A++%4)?_+=String.fromCharCode(255&y>>(-2*A&6)):0)v=x.indexOf(v);for(let A=0,y=_.length;A<y;A++)m+="%"+("00"+_.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(m)};K.fkMLuv=o,K.lUiScY={},K.UnFaSJ=!0}let c=r[0],l=t+c,u=K.lUiScY[l];return u?i=u:(i=K.fkMLuv(i),K.lUiScY[l]=i),i}(()=>{let t=M,e={dtgwk:function(a,n){return a+n},NIfJQ:function(a,n){return a*n},RovlN:"done",dFjdv:function(a,n){return a===n},QIQTq:"objectSt"+t(644),XwrUx:t(1701),HKhMW:function(a,n){return a!==n},OAdKd:t(291),kjeip:"xBdwK",uOuUA:function(a,n){return a+n},NHkdP:function(a,n){return a(n)},NgSXo:function(a,n,s){return a(n,s)},zhpUD:function(a,n){return a(n)},NUNlX:function(a,n,s){return a(n,s)},jQnGm:function(a,n){return a(n)},OmuoT:function(a,n){return a(n)},JPFtO:function(a,n){return a+n},FOvWK:"0000",cCYRZ:"ffff",NHtUR:"ping_onc"+t(451)+"s",QMhPp:function(a,n){return a>n},NuVAJ:function(a,n){return a<n},GiupI:function(a,n){return a-n},cAuaS:function(a,n){return a===n},znxqv:t(1221),teAOD:function(a,n){return a!==n},BIKAa:function(a,n){return a-n},tPsjZ:function(a,n){return a===n},WFZwC:t(1507),xCxwb:t(902),AcZuR:function(a,n){return a<n},ZplrY:function(a,n){return a!==n},XBoHB:function(a,n){return a(n)},gESuL:"juSqw",zZaMK:"itnAD",behpS:function(a,n,s){return a(n,s)},vMbQr:function(a,n){return a(n)},kHXhH:function(a,n,s){return a(n,s)},aZJdl:function(a,n){return a&n},vnGvV:t(330)+t(1500)+t(584)+t(527),QZILI:function(a,n){return a===n},yyTaF:t(330)+"required field: "+t(1472),juCiW:function(a){return a()},PNLgS:function(a,n,s){return a(n,s)},LthYL:"pagehide",dHveB:t(885),eXrMi:function(a,n){return a!==n},FRjfy:function(a,n,s){return a(n,s)},bbnaJ:function(a,n,s){return a(n,s)},YILxz:function(a,n){return a(n)},ZeFlG:function(a,n){return a!==n},XnJoz:function(a,n){return a(n)},qkYum:function(a,n){return a!==n},tzRqH:function(a,n){return a(n)},UIMUH:function(a,n,s){return a(n,s)},xoPxv:function(a,n){return a!==n},twnOD:function(a,n,s){return a(n,s)},KRsCP:function(a,n,s){return a(n,s)},CBgOK:function(a,n){return a!==n},PkUzU:t(1e3),VsGTa:function(a,n,s){return a(n,s)},nOGEP:function(a,n,s){return a(n,s)},HnPSP:function(a,n,s){return a(n,s)},nxOlH:"UtMMC",nbIor:function(a,n,s){return a(n,s)},lDXOp:function(a,n){return a(n)},SNSCo:function(a,n){return a(n)},LwoUD:function(a,n){return a(n)},iZxwW:function(a,n){return a>>>n},gkoLu:function(a,n){return a(n)},bGDCq:function(a,n){return a(n)},IvyjV:function(a,n){return a===n},napIs:"PBoeA",OlUIs:function(a,n){return a(n)},WvyRy:function(a,n,s){return a(n,s)},YUtrW:function(a,n){return a(n)},NsVLm:function(a,n,s){return a(n,s)},SqyXN:function(a,n,s){return a(n,s)},fmOQB:function(a,n){return a(n)},udbGS:function(a,n){return a(n)},VhCjE:function(a,n,s){return a(n,s)},xNbFP:t(330)+"required"+t(584)+"service",zCmIk:function(a,n){return a===n},EaALf:t(330)+t(1500)+" field: method",SXFKv:function(a,n){return a&n},yPCff:function(a,n,s){return a(n,s)},cAKGM:function(a,n,s){return a(n,s)},gbqRr:"GwixY",JOlhW:"KRHdD",zsaFl:function(a,n){return a>>n},ikjWC:function(a,n){return a>=n},Vnitz:function(a,n){return a>n},LEKSX:function(a,n){return a+n},drVRl:function(a,n,s){return a(n,s)},HHIRA:function(a,n,s){return a(n,s)},zzRQW:t(818),bSGVN:t(1486),OyPuu:function(a,n){return a>n},AKNsb:t(659)+t(802),gHfHq:function(a,n){return a+n},oHbwm:function(a,n,s){return a(n,s)},RCcfA:function(a,n){return a!==n},uprGc:function(a,n){return a>>>n},bmHtV:function(a,n,s){return a(n,s)},BvsIR:function(a,n){return a<n},twRuB:function(a,n){return a===n},SBnKP:function(a,n){return a&n},mfDtY:function(a,n){return a!==n},VybnD:function(a,n){return a&n},SvXju:function(a,n){return a|n},rkBrc:function(a,n){return a<<n},MetYJ:function(a,n){return a&n},dGJkC:function(a,n){return a<n},cKeoS:function(a,n){return a==n},SIkNc:function(a,n){return a+n},VjLNz:function(a,n){return a+n},gryMl:function(a,n){return a+n},wmxTx:function(a,n){return a+n},LwHQS:function(a,n){return a!==n},VFOnx:function(a,n){return a|n},VIClR:t(898),zAAdx:function(a,n){return a&n},hNNnZ:function(a,n){return a<=n},dRVwk:function(a,n){return a==n},wloCO:function(a,n){return a|n},FvxhK:function(a,n){return a&n},VMaxX:function(a,n){return a>n},fJzqZ:function(a,n,s){return a(n,s)},BDitu:function(a,n,s){return a(n,s)},vXtDL:t(585),rORhY:function(a,n){return a===n},kSNBj:t(853),yPbGk:function(a,n){return a+n},XGIpW:function(a,n){return a<n},dZjHt:function(a,n,s){return a(n,s)},VNWzh:function(a,n){return a!==n},JmDEe:function(a,n){return a>=n},UeCWP:function(a,n){return a<=n},tUryt:function(a,n){return a+n},zklva:function(a,n){return a<n},XxpuB:function(a,n){return a>>n},ZbwaX:function(a,n){return a|n},LqzSp:function(a,n){return a&n},VQwEU:function(a,n){return a<n},CKHoN:function(a,n){return a+n},bRwBq:function(a,n,s){return a(n,s)},QXPxS:function(a,n,s){return a(n,s)},tByip:function(a,n){return a<n},qULYc:function(a,n){return a<<n},GxbxN:function(a,n){return a&n},crqqI:function(a,n){return a!==n},FyJQG:t(494),naOvM:t(1001),JMyEK:function(a,n){return a<<n},zRwms:function(a,n){return a(n)},cvopU:function(a,n){return a&n},PzcwO:function(a,n){return a(n)},fVWto:function(a,n){return a&n},VXDhA:function(a,n){return a&n},zXMnV:function(a,n){return a(n)},fFoun:function(a,n){return a&n},sJFov:function(a,n){return a!==n},oWPzo:"MJpZX",rhRuv:function(a,n){return a(n)},ByqgQ:function(a,n){return a<<n},HBkCv:function(a,n){return a&n},HTieL:function(a,n){return a&n},zvica:function(a,n){return a===n},StCvM:t(1728),iOBSB:t(769),DajAX:function(a,n){return a&n},irGEe:function(a,n){return a<<n},PRyev:function(a,n){return a&n},JnpXJ:function(a,n){return a|n},Soxsn:function(a,n){return a>>>n},aTUXh:function(a,n){return a<<n},nWPmL:function(a,n){return a&n},OAqWn:function(a,n){return a>>>n},qpxlK:function(a,n){return a>>>n},sFKSu:function(a,n){return a<n},dZqGa:function(a,n){return a<n},bRtgo:function(a,n){return a>>>n},xtIzt:function(a,n){return a+n},UmfEA:function(a,n){return a&n},OHvpR:function(a,n){return a+n},kGcMU:function(a,n){return a|n},fYehY:function(a,n){return a>>>n},ckHmY:function(a,n){return a>>>n},tdLHp:function(a,n){return a>>>n},EGHZr:function(a,n){return a|n},WJvDw:function(a,n){return a&n},MteRN:function(a,n){return a+n},sTWXY:function(a,n){return a|n},yPsWr:function(a,n){return a>>>n},UmNcm:function(a,n){return a|n},fPoLJ:function(a,n){return a>>>n},aCstF:function(a,n){return a&n},tzBwL:function(a,n){return a&n},cCgeJ:function(a){return a()},mqXCu:"YblNM",Szbid:t(394),udSCl:function(a,n){return a(n)},EqrwR:function(a,n){return a(n)},onlmt:function(a,n){return a|n},ZzTFl:t(531)+"d",MapWy:"Module",uQQKu:t(990)+"le",mXeIu:"OvWmi",ctMlS:t(305),LzhhO:function(a,n){return a<<n},hIjIO:function(a,n){return a|n},OftkS:function(a,n){return a|n},SievR:function(a,n,s,d){return a(n,s,d)},tEEMI:function(a,n){return a+n},rdEOM:function(a,n){return a===n},CUAMP:t(1398),fVghR:function(a,n){return a|n},FKxPC:function(a,n){return a|n},OGppi:function(a,n){return a<<n},TldhB:function(a,n){return a<<n},KWCTs:function(a,n){return a<<n},JLGeo:function(a,n){return a<<n},GiWgg:function(a,n){return a<<n},sjDMk:function(a,n){return a|n},BYbej:function(a,n){return a|n},mPnpl:function(a,n){return a<<n},Ijpui:function(a,n){return a&n},Zagll:function(a,n){return a>>>n},zbgnY:function(a,n){return a>>>n},uHZBL:function(a,n){return a&n},JckHO:function(a,n){return a(n)},CvYmx:function(a,n){return a>=n},KNJfr:function(a,n){return a<=n},oBRph:function(a,n){return a>=n},RnQJp:function(a,n){return a+n},xLSFn:function(a,n){return a%n},MOiLp:function(a,n){return a/n},cqwul:function(a,n){return a>>>n},DJTTX:function(a,n){return a>>>n},SObZi:function(a,n){return a&n},FYwdW:function(a,n){return a>>>n},PNqDO:function(a,n){return a+n},ChvKG:function(a,n){return a>>>n},UpTQJ:function(a,n){return a+n},gpoOJ:function(a,n){return a>>>n},MeEgn:function(a,n){return a|n},EZLca:function(a,n){return a>=n},JFTYn:function(a,n,s){return a(n,s)},xnykL:function(a,n){return a|n},fJCaQ:function(a,n){return a===n},MEPnO:t(1404),ZTTqx:function(a,n){return a!==n},QjuLY:function(a,n){return a===n},FsWQy:function(a,n){return a>>>n},MSksC:function(a,n){return a===n},XftRS:function(a,n){return a===n},gFqbP:function(a,n){return a+n},zNAIM:function(a,n){return a-n},iaDzw:function(a,n){return a|n},BAyiF:function(a,n){return a&n},Nkdrf:function(a,n){return a+n},MpBUH:function(a,n){return a>>n},jJmDd:function(a,n){return a+n},acllx:"ZrMHy",AWzDu:function(a,n){return a&n},uFFBM:function(a,n){return a&n},OLfgR:function(a,n){return a>>>n},rpxBA:function(a,n){return a>>>n},FTrMk:function(a,n){return a!==n},ZWkNG:"CXVeS",ZaNsd:t(360),mGOpG:function(a,n){return a>>>n},OwPZc:function(a,n){return a&n},ovHkm:function(a,n){return a&n},WUsVv:function(a,n){return a&n},nOErf:function(a,n){return a>>>n},MTAAd:function(a,n){return a&n},ETdrE:t(1191)+t(1511),qPIxw:"NATIVE_E"+t(1377),HfmQK:t(1621)+t(1170)+"R",ohYMD:t(532)+"ERROR",lmmZr:t(923)+"OR",ZjUtQ:"1|6|3|2|"+t(1421),qCazA:t(1344),tAqcw:"2|4|0|3|1",fTmAc:t(1366),RgvaR:t(901),mCSCY:t(865)+"t",NzKBx:t(296),ALTXY:t(351),NxkOR:"Unhandle"+t(525),oVsjy:function(a,n){return a===n},NrWbk:function(a,n){return a>>>n},DgbjI:t(1671),vbbhT:t(251),hMrQA:function(a,n,s){return a(n,s)},LzOnL:"message",HABTv:t(1256),coPSE:function(a,n,s){return a(n,s)},WFUnV:function(a,n){return a instanceof n},VMYnw:function(a,n){return a||n},ivaUx:t(1251)+"3",mbRFi:function(a,n){return a!=n},rAVVj:t(1140),WSMnE:t(933),yTkHn:function(a,n){return a<=n},wxNhM:t(403)+t(1573)+t(685)+t(1641)+"process",JbHrL:function(a,n){return a===n},RjGVH:t(603),Nchjz:function(a,n){return a&n},OREpU:function(a,n){return a===n},babLQ:function(a,n){return a+n},bDbdY:function(a,n){return a<n},RxYaa:t(667),oSPdP:function(a,n){return a<=n},GeupC:function(a,n){return a<n},PezPP:function(a,n){return a<<n},lqtte:function(a,n){return a&n},ExASv:function(a,n){return a|n},SnCAk:function(a,n){return a|n},XWNQz:function(a,n){return a&n},LzVZd:function(a,n){return a&n},cERRH:"aRGvG",eucxU:t(488),oTBWM:function(a,n){return a|n},uBMnK:function(a,n){return a|n},cBiGx:function(a,n){return a&n},DsuFW:function(a,n){return a<<n},wkMpx:function(a,n){return a+n},rfLRu:function(a,n,s){return a(n,s)},TRZGv:t(718),uXNHV:t(1545),IKdry:function(a,n){return a===n},pNVIx:t(637),DCaed:t(1056),EZlRq:function(a,n){return a<n},FLUke:t(256),cnJIf:"HQDdk",ArdzR:function(a,n){return a<n},aNuHB:t(1184),lwluf:function(a,n){return a|n},gnvuU:function(a,n){return a|n},dnuqu:function(a,n){return a&n},HOMlc:function(a,n){return a+n},PQYWN:function(a,n){return a|n},Mhyqu:function(a,n){return a|n},hBrUc:function(a,n){return a&n},SIgqC:function(a,n){return a+n},sUKza:function(a,n){return a+n},euFEu:function(a,n){return a<<n},SjZWW:function(a,n){return a&n},GIwjk:function(a,n){return a|n},BLZQT:function(a,n){return a-n},hikXR:t(1353),QFRFs:t(1397),TfUpu:function(a,n){return a|n},NcOXW:function(a,n){return a|n},vMUzr:function(a,n){return a|n},agNrZ:function(a,n){return a<<n},kwosR:function(a,n){return a<<n},GRHtq:function(a,n){return a|n},SCyXD:function(a,n){return a<<n},ZJuuz:function(a,n){return a<<n},hLPXe:t(1470),LghMO:function(a,n){return a instanceof n},KkqAN:t(1503)+t(1609),dSXGx:t(1683)+t(1075)+"et=utf-8",buHSl:t(561),PEKET:t(1020),FbFMI:function(a,n){return a>=n},AsuLG:t(884)+t(1596),aliyn:function(a,n){return a(n)},wcDts:t(855),sjWLm:"text/jav"+t(696),SUBkd:t(1724),HyiiX:t(832)+t(734)+"tierJSONP",TirvE:function(a,n){return a(n)},xBYWn:function(a,n){return a in n},oqdwh:t(467),JTXqY:"idb",gZQuo:t(955),TXxUo:function(a,n){return a!==n},LqWoC:t(1111),UTGzv:function(a,n){return a>=n},TDSaG:t(1597),ihDXV:function(a,n){return a<=n},RhmHi:function(a,n){return a>=n},wlCFZ:t(318),mRhVU:"Xofdp",EKJHq:function(a,n){return a===n},mEESO:t(1477),LdGyp:function(a,n){return a||n},CONrC:function(a,n){return a!==n},AyWVA:function(a,n){return a||n},MocRL:function(a,n){return a===n},xqAmW:t(401),cFzQE:function(a,n){return a||n},DXMAO:function(a,n){return a||n},OdAFx:t(1067),NrIxZ:"message_id",NXjXj:"blumB",tkZuX:function(a,n){return a(n)},xWDKL:function(a,n,s){return a(n,s)},hCSPa:t(591),SVAZX:"WJvwJ",VDmHj:function(a,n){return a==n},EsSty:t(383)+"0",cPAVa:function(a,n){return a!==n},MZNEZ:t(1628),cJeuB:function(a,n){return a instanceof n},eOqTf:function(a,n){return a===n},kqDIZ:t(1688),khsqz:function(a,n){return a<n},PkexO:function(a,n){return a>n},KjHDz:function(a,n){return a(n)},GpabS:function(a,n){return a>n},yeBdW:function(a,n){return a|n},GIGxb:t(1464),JRRXS:t(529)+t(344),ShFlp:function(a,n,s,d){return a(n,s,d)},YeYKS:function(a,n,s,d){return a(n,s,d)},JdoYZ:t(529)+t(1549)+"k",hJIRo:function(a,n,s){return a(n,s)},nEGTg:t(529)+t(578)+t(664),ggPDi:"need_ack",lnyXW:function(a,n,s,d){return a(n,s,d)},BUsbN:t(808),CDlDQ:function(a,n){return a&&n},zdmOn:t(1321),pYPLO:function(a){return a()},oDfAM:t(607),hTVcp:t(336),gXhYJ:function(a){return a()},QaUhT:function(a,n){return a(n)},KaIMK:function(a,n){return a(n)},LwKLB:function(a,n){return a instanceof n},gCFTU:function(a,n){return a instanceof n},YIYyc:"application/json"+t(754)+"=utf-8",FhneT:t(1241)+"e",peHeu:t(1644),XWGmD:function(a){return a()},TOnIW:function(a,n){return a>n},AAswh:function(a,n){return a(n)},hKfzC:function(a,n){return a>n},wTWxD:function(a,n){return a(n)},mgPrm:function(a,n){return a&n},sMCfU:function(a,n){return a!==n},zsjqW:"KOMuY",EcGDy:function(a,n){return a+n},jrdFg:function(a,n){return a+n},iXMBR:function(a,n){return a>n},FCViF:t(1709)+t(1496)+"e",aqbdR:function(a,n){return a>=n},KlTZv:function(a,n){return a===n},jYWhm:t(959),WatvD:function(a,n){return a&n},PltRg:function(a,n,s,d){return a(n,s,d)},TkMjJ:function(a,n){return a+n},SUePb:function(a,n){return a<n},GjCIW:function(a,n){return a>>>n},OMIIH:t(831)+"2",oRzWF:function(a,n){return a<n},NyXiH:function(a,n){return a+n},rkUbS:function(a,n){return a|n},ISeUJ:function(a,n){return a|n},huWsg:function(a,n){return a<<n},lOmTg:function(a,n){return a+n},XVrjd:function(a,n){return a&n},aHinw:function(a,n){return a>>>n},vnkXN:function(a,n){return a+n},SMarK:function(a,n){return a>>>n},NsGTa:function(a,n){return a>>>n},taKAc:function(a,n){return a&n},EQAqP:t(304),gHUoS:function(a,n){return a+n},jacIQ:function(a,n){return a&n},uevGF:t(928)+t(837)+t(1090)+"0",WXdtd:function(a,n){return a<n},avKnd:function(a,n){return a|n},fEvel:function(a,n){return a&n},umXdT:function(a,n){return a>>>n},FaQHb:function(a,n){return a<n},eXYbV:function(a,n){return a(n)},cPBuN:function(a,n){return a+n},ScRmm:t(857),AMqWc:"service-"+t(1717),hiVZA:"name",nKAeN:t(1423),uZjWM:t(1679),OaDRM:function(a,n){return a(n)},YGejA:t(1587)+t(1676),EJKZI:function(a,n){return a<n},oOBTo:t(609),AVWKu:"fFRBo",rAmEW:function(a,n,s){return a(n,s)},FiJvk:function(a,n,s,d){return a(n,s,d)},enmQV:function(a,n){return a+n},UMkdM:function(a,n,s){return a(n,s)},QzzOd:t(1166)+"_EXIST",FtRuL:function(a,n,s){return a(n,s)},royjG:"ALL",fIXBn:function(a,n,s,d){return a(n,s,d)},bJWgB:t(1144),mOvfH:function(a,n,s){return a(n,s)},aYIPF:t(1261),RWOZR:function(a,n){return a(n)},rJphk:t(761)+"r",fUkMZ:function(a,n){return a!==n},UzDDl:t(1563),tsRJR:function(a,n,s,d){return a(n,s,d)},vfWYp:function(a,n,s,d){return a(n,s,d)},ufOLB:t(529)+t(1147),JdAkq:t(529)+t(327),lPaNz:function(a,n,s,d){return a(n,s,d)},HKoIZ:t(1622)+"s",LOqCa:function(a,n){return a(n)},CXYhI:t(947),WZjAs:function(a){return a()},lSrwX:function(a,n){return a===n},mQYOp:"llNin",Niadw:function(a){return a()},udOSY:function(a){return a()},SXErY:t(302),LjRxt:function(a){return a()},dlNPP:function(a,n){return a===n},tffBR:function(a,n){return a===n},uLVWI:function(a){return a()},ntGCE:function(a,n,s){return a(n,s)},LgbGK:function(a){return a()},JlwlN:function(a){return a()},JNYJC:function(a,n,s){return a(n,s)},LVxvC:function(a,n){return a!==n},BkCTl:t(690),rAeWs:function(a){return a()},hzBtp:function(a,n,s,d){return a(n,s,d)},DhctW:function(a,n){return a!==n},dbmKy:"tuXNk",NUAHn:function(a,n,s){return a(n,s)},AJEEt:function(a,n,s){return a(n,s)},cpkpY:function(a,n,s){return a(n,s)},PIebn:function(a,n){return a!==n},wlAkn:function(a,n,s){return a(n,s)},qPAIr:function(a,n){return a(n)},PCupt:function(a,n){return a+n},kUXcF:"always",ReTHx:function(a,n){return a===n},kDmcy:t(1466),llWFG:function(a,n,s){return a(n,s)},fZIGt:"QzckF",EZeGl:t(1176),aDpgd:function(a,n,s){return a(n,s)},mXrzk:t(1295),nZGZR:function(a,n){return a/n},CdtBd:"CONTINUE",TtBzq:function(a,n){return a===n},KSQeq:t(528)+t(1650)+"alid url",xGtLm:function(a,n){return a(n)},CwPWU:"LybcM",ogxPt:t(1582)+t(1452)+t(930)+"ct",iqDiM:"OOxFW",Rgolp:t(911),avPOr:function(a,n){return a!==n},xtZwA:t(1614),DpyqQ:t(1655),wrJcS:t(1409),RCUMV:"ttwid",SOCAb:t(743),mjoCj:t(873),NiRPr:function(a,n){return a<n},EdJOz:function(a,n){return a-n},YgCdF:function(a,n){return a<=n},sKwJi:function(a,n){return a<n},wSSSu:function(a,n){return a&n},DqbVV:function(a,n){return a&n},OmTBy:function(a,n){return a>=n},rUoIk:function(a,n){return a<n},ADsQc:function(a,n){return a<<n},DlIsD:function(a,n){return a>=n},vvxgA:function(a,n){return a|n},DGtUe:function(a,n){return a|n},nPIRw:function(a,n){return a&n},SuVpL:function(a,n){return a<<n},vJJQN:function(a,n){return a&n},Shcnl:function(a,n){return a>>n},DAQxP:function(a,n){return a!==n},pStDQ:"adodE",jqGgT:function(a,n,s){return a(n,s)},mIoIV:function(a,n){return a>n},qNMvh:function(a,n){return a-n},hVWqx:function(a,n,s){return a(n,s)},KAUtL:function(a,n){return a(n)},PzGEZ:t(1584)+">",dMeEN:function(a,n){return a*n},JEKgk:function(a,n){return a>n},WqibL:t(1453),fXXma:t(1217)+t(842)+"t",msYva:"timeout",GQRyf:function(a,n){return a!==n},KiiXC:t(1188),cLrbS:function(a,n){return a+n},gSePi:t(804),YzKZE:t(1694)+t(501)+t(1128)+"g",weJTU:t(319),NAsib:t(594),EanVq:t(1349)+"2",GHjOT:t(1281)+"1",Xkeol:function(a,n){return a>=n},imfxa:function(a,n){return a&n},zAqxa:function(a,n){return a+n},OvBbI:function(a,n){return a===n},bWtfJ:function(a,n){return a<<n},heHFY:"pAdXI",NKomi:t(894),dGkvd:t(1716),CeQVd:function(a,n,s){return a(n,s)},aQtbn:"aBTwp",rwSRD:t(904),HHrcW:t(1451),DqFpk:t(1080),sneEC:function(a,n){return a*n},nSGMx:function(a,n){return a>n},fTWQJ:t(457),POgiH:t(688)+t(368)+t(1335)+t(656)+"ed",dMtds:t(688)+t(272)+t(333),IXZdy:function(a,n){return a+n},tcvFj:function(a,n){return a!==n},AMzef:function(a,n){return a|n},lTgke:function(a,n){return a<<n},emHVg:function(a,n){return a|n},EMWsk:function(a,n){return a&n},mFJJa:function(a,n){return a<=n},tRLXV:t(528)+t(384)+t(728)+"ata, dat"+t(542)+t(266)+t(576)+" arraybu"+t(475),amtdo:function(a,n){return a instanceof n},GdsyV:"please provide a"+t(620)+t(524),tiItq:function(a,n){return a(n)},BbnCu:function(a,n){return a===n},VlOta:t(1066),zjWeg:"sent",FzSkm:t(639),Nuhbj:"enqueue",pEAYP:t(470),PNzaN:t(1525),EikTZ:function(a){return a()},kvlLD:function(a,n){return a!==n},CCmpG:t(1714),KCHFN:t(918)+t(1242)+"ing",iQxgY:t(727)+"1",dBhYz:function(a,n){return a!==n},XyFPC:t(275),dIfRa:"grsZv",BzDpm:t(1440),usotR:function(a,n){return a(n)},kOwnD:t(314),DTFZE:t(365),jLSDd:function(a,n){return a===n},PDJet:t(834),FvPvr:function(a,n){return a===n},xoHnE:function(a,n){return a!=n},ramFz:function(a,n){return a===n},xUAfi:t(952),EjykP:function(a,n){return a===n},xpQqK:function(a,n){return a!=n},CwuOl:function(a,n){return a!=n},NvTgo:t(265)+t(636)+t(1429),TeYdj:"ServiceWorkerGlo"+t(806),KMEHC:function(a,n){return a!=n},CUeDX:function(a,n){return a===n},rLGDp:function(a,n,s){return a(n,s)},ofehP:t(385)+t(290)};Ot.r(Te),Ot.d(Te,{FWS:()=>Ap,CustomErrorEvent:()=>Ld,createCloseEvent:()=>lt,ReconnectEvent:()=>Nd,createErrorEvent:()=>rt,decodedFrame:()=>Jt,createOpenEvent:()=>Gd,CustomCloseEvent:()=>Md,createReconnectEvent:()=>ta,FrontierMessageEvent:()=>zd,encodeFrame:()=>Lt,createMessageEvent:()=>Ud,OpenEvent:()=>Fd,ErrorCode:()=>Yt,Event:()=>$n,MessageEvent:()=>Bd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(1270)](),f=r||(r=h(a)),p=Math[n(1432)]()[n(1332)](16)[n(391)](-6);return e[n(629)](e[n(629)](e.dtgwk(s,d),f),p)}function o(){let a=t;return e[a(629)](1e4*Date[a(1270)](),Math[a(1034)](e.NIfJQ(1e4,Math[a(1432)]())))}function c(a){let n=t,s={yJAvd:e[n(1534)],vJXVx:function(d,f){return e[n(669)](d,f)},TccVF:e[n(735)],gwDyS:e[n(1727)]};if(e.HKhMW(e[n(749)],e.kjeip))return e[n(1002)](e[n(262)](Array,8).join("0"),e[n(1071)](parseInt,a,10)[n(1332)](2))[n(391)](-8);if(_0x44151f===hTOdZl.yJAvd)return _0x251adf[n(545)](_0x2f28f6);if(hTOdZl[n(1035)](_0x5af2de,hTOdZl[n(1484)]))return _0x58055a.objectStoreNames||_0x5ae410[n(545)](_0x31727b);if(hTOdZl[n(1035)](_0x586a8f,hTOdZl.gwDyS))return _0x349a2d["objectSt"+n(644)][1]?void 0:_0x1dcf0d[n(1515)+n(675)](_0x497e40[n(1515)+n(644)][0])}function l(a){let n=t;return(e.zhpUD(Array,4)[n(307)]("0")+e.NUNlX(parseInt,a,2)[n(1332)](16))[n(391)](-4)}function u(a){let n=t,s=a[n(921)](/\./)[n(1299)](p=>c(p)),d=[];return d[0]=e[n(1164)](l,e[n(629)](s[0],s[1])),d[1]=e[n(1185)](l,e[n(1018)](s[2],s[3])),[e[n(1691)],e.FOvWK,e[n(1691)],e[n(1691)],e[n(1691)],e[n(792)],d[0],d[1]][n(307)]("")}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}/.test(a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1134)](a);return s?u(a):d?x(a):n(668)+n(668)+n(668)+"00000000"}function x(a){let n=t,s="",d=[],f=0,p=0,E=!0,b="0000";if(e.QMhPp(a[n(1518)]("::"),-1)){let g=a[n(921)]("::");for(let N=0;e.NuVAJ(N,g[n(492)]);N++){let F=g[N];if(F.indexOf(":")>0){let G=F.split(":");E&&(f=G.length),p+=G[n(492)];for(let W=0;e[n(1155)](W,G[n(492)]);W++)if(e[n(1078)](4,G[W].length)){let ye=b[n(1480)+"g"](0,e[n(1260)](4,G[W][n(492)])),ut=ye[n(310)](G[W]);d[n(1426)](ut)}else d[n(1426)](G[W]);E=!1}else if(e[n(1536)](e[n(429)],"TjhAM")){if(e[n(820)](4,F[n(492)])){let G=b[n(1480)+"g"](0,4-F[n(492)]),W=G.concat(F);d.push(W)}else d[n(1426)](F);E&&(f+=1),p+=1,E=!1}else e[n(262)](_0x13f1d6,n(314)),this[n(744)](e.NHtUR,_0x4497f3),this[n(744)](n(1217)+n(842)+"t",_0xd00c6f)}let O="";for(let N=0;N<e[n(780)](8,p);N++)O=O.concat(b);for(let N=0;N<d[n(492)];N++)if(e[n(462)](N,f)){if(e[n(669)](e[n(1376)],e.xCxwb))return _0x150c0a[n(1462)](_0xeeb660),!1;s=s[n(310)](O),s=s[n(310)](d[N])}else s=s.concat(d[N]);return s}{let g=a.split(":");for(let O=0;e.AcZuR(O,g[n(492)]);O++){let N=g[O];if(e.ZplrY(4,g[O][n(492)])){let F=b[n(1480)+"g"](0,e[n(780)](4,g[O][n(492)])),G=F[n(310)](N);s=s[n(310)](G)}else s=s[n(310)](N)}return s}}function _(a,n){let s=t,d={oXffs:function(f,p){return e[K(774)](f,p)},cxaBD:function(f,p){return e.XBoHB(f,p)}};if(e[s(748)]===e[s(1447)]){let f=_0x15c238.call(hCbDMW[s(264)](_0x431ac6,this),_0x7561b6,..._0x30976a);return _0x52d0c8.set(f,_0x16b1c2[s(1513)]?_0x4717a3[s(1513)]():[_0x41a7ea]),hCbDMW[s(844)](_0x46bfec,f)}else{let f=a[s(527)];f!==void 0&&(e[s(1071)](le,n,10),e[s(1071)](H,n,f));let p=a[s(1472)];e[s(1078)](void 0,p)&&(le(n,18),e[s(1132)](H,n,p))}}function m(a){let n=t,s={};e:for(;!e[n(991)](J,a);){let d=de(a);switch(d>>>3){case 0:break e;case 1:s[n(527)]=e[n(909)](k,a,de(a));break;case 2:s[n(1472)]=e.kHXhH(k,a,e[n(1185)](de,a));break;default:e.kHXhH(R,a,e[n(1461)](7,d))}}if(e[n(1536)](void 0,s[n(527)]))throw new Error(e[n(883)]);if(e[n(582)](void 0,s[n(1472)]))throw new Error(e[n(994)]);return s}function A(a){let n=t,s=e[n(1138)](C);return e[n(1406)](y,a,s),B(s)}function y(a,n){let s=t,d={fcWjG:e[s(1659)],LuJvX:e.dHveB},f=a[s(1070)];e.eXrMi(void 0,f)&&(le(n,8),e[s(1037)](dt,n,f));let p=a[s(628)];e[s(820)](void 0,p)&&(e[s(1406)](le,n,16),e[s(1245)](dt,n,p));let E=a[s(1423)];E!==void 0&&(e[s(1406)](le,n,24),e[s(530)](dt,n,e.YILxz(P,E)));let b=a[s(1141)];e.ZeFlG(void 0,b)&&(e[s(1037)](le,n,32),dt(n,e.XnJoz(P,b)));let g=a[s(592)];if(e.qkYum(void 0,g))for(let Hr of g){le(n,42);let vn=e[s(1138)](C);e[s(1245)](_,Hr,vn),le(n,vn[s(1063)]),j(n,vn),e[s(510)](D,vn)}let O=a[s(823)+s(631)];O!==void 0&&(le(n,50),e[s(1009)](H,n,O));let N=a[s(1038)+s(1310)];N!==void 0&&(e.FRjfy(le,n,58),e[s(1071)](H,n,N));let F=a[s(1719)];e.xoPxv(void 0,F)&&(e[s(909)](le,n,66),e[s(1123)](le,n,F[s(492)]),e[s(1156)](fe,n,F));let G=a.LogIDNew;if(e[s(1726)](void 0,G)){if(e[s(462)](s(1244),e[s(1388)]))return _0x351fce[s(1515)+s(644)]||_0x2862eb[s(545)](_0x1af2e8);e[s(643)](le,n,74),H(n,G)}let W=a[s(1120)+"ming"];e[s(820)](void 0,W)&&(e[s(1245)](le,n,82),e.nOGEP(H,n,W));let ye=a.msgID;ye!==void 0&&(e.twnOD(le,n,90),e.HnPSP(H,n,ye));let ut=a[s(1449)+"e"];e[s(820)](void 0,ut)&&(s(1106)===e[s(565)]?(le(n,96),e[s(1684)](dt,n,e[s(1006)](P,ut))):(this[s(533)+"er"]&&_0x5c29d2[s(513)+"entListe"+s(337)](d[s(1180)],this[s(1620)+"ageHide"]),this[s(533)+"er"]&&_0x448fb3[s(513)+s(1619)+s(337)](d.LuJvX,this[s(1620)+"ageShow"]),this[s(1671)]()))}function v(a){return I(e[t(1300)](L,a))}function I(a){let n=t,s={};e:for(;!e[n(1006)](J,a);){let d=e[n(652)](de,a);switch(e[n(692)](d,3)){case 0:break e;case 1:s.SeqID=Et(a,!0);break;case 2:s[n(628)]=Et(a,!0);break;case 3:s.service=e[n(1263)](de,a);break;case 4:s[n(1141)]=e[n(1202)](de,a);break;case 5:if(e.IvyjV(e[n(705)],e.napIs)){let f=S(a);(s[n(592)]||(s[n(592)]=[]))[n(1426)](e[n(1487)](m,a)),a[n(1063)]=f;break}else _0x5a313c+=e.jQnGm(_0xec5af5,_0x192d8a),_0x351c0d++;case 6:s[n(823)+n(631)]=k(a,e[n(1006)](de,a));break;case 7:s[n(1038)+"ype"]=e.WvyRy(k,a,e[n(1699)](de,a));break;case 8:s[n(1719)]=_e(a,de(a));break;case 9:s.LogIDNew=e[n(790)](k,a,de(a));break;case 10:s[n(1120)+n(870)]=e.SqyXN(k,a,e.YUtrW(de,a));break;case 11:s[n(1685)]=k(a,e[n(1218)](de,a));break;case 12:s[n(1449)+"e"]=e[n(554)](de,a);break;default:e[n(983)](R,a,e[n(1461)](7,d))}}if(e[n(669)](void 0,s[n(1070)]))throw new Error(n(330)+"required"+n(584)+n(1070));if(e[n(1591)](void 0,s.LogID))throw new Error("Missing "+n(1500)+n(584)+n(628));if(s.service===void 0)throw new Error(e.xNbFP);if(e[n(1586)](void 0,s[n(1141)]))throw new Error(e[n(1216)]);return s}function S(a){let n=t,s=e[n(510)](de,a),d=a.limit;return a.limit=a[n(1371)]+s,d}function R(a,n){let s=t;switch(n){case 0:for(;e[s(1561)](128,re(a)););break;case 2:e[s(530)](V,a,e.fmOQB(de,a));break;case 5:e[s(750)](V,a,4);break;case 1:e[s(785)](V,a,8);break;default:throw new Error("Unimplem"+s(431)+s(438)+n)}}function P(a){let n=t;return e[n(1536)](e[n(871)],e.JOlhW)?this[n(934)]?.set({message_id:_0x107081,timestamp:_0x326f80}):(a|=0,{low:a,high:e[n(325)](a,31),unsigned:e.ikjWC(a,0)})}let w=[];function C(){let a=t,n=w[a(497)]();return n?(n[a(1371)]=n[a(1063)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function D(a){w[t(1426)](a)}function L(a){return{bytes:a,offset:0,limit:a[t(492)]}}function B(a){let n=t,s=a.bytes,d=a.limit;return e[n(1536)](s.length,d)?s:s.subarray(0,d)}function V(a,n){let s=t;if(e[s(1025)](e.LEKSX(a[s(1371)],n),a[s(1063)]))throw new Error("Skip past limit");a.offset+=n}function J(a){let n=t;if(e[n(1558)]!==e[n(1024)])return a[n(1371)]>=a[n(1063)];{let s=this[n(364)+n(326)]?.[n(293)+"chMaxTries"](),d=this[n(364)+"tManager"]?.[n(1193)+"ntEndpoint"]();if(s&&!_0x48902b[n(689)]){let f=n(997)+d+(" fail, m"+n(614)+n(1499)+"ed");this["_dispatc"+n(1005)+"ent"](e.drVRl(_0x5109da,"error",{message:f,code:_0x3f4817[n(1621)+"IES_ERROR"],error:_0x7d81be}));return}this[n(313)]&&this[n(313)][n(1294)+"te"]===this[n(367)]&&this["_disconn"+n(1252)](),this[n(1476)+n(1005)+n(1039)](e[n(274)](_0x3c0eba,n(1256),{message:_0x2bf441[n(689)],code:_0x4679d2[n(1638)+n(1377)],error:_0x3851fd}))}}function ee(a,n){let s=t,d=a[s(1030)],f=a.offset,p=a.limit,E=e[s(629)](f,n);if(e[s(1025)](E,d.length)){let b=new Uint8Array(e[s(1509)](2,E));b[s(787)](d),a[s(1030)]=b}return a[s(1371)]=E,e[s(580)](E,p)&&(a[s(1063)]=E),f}function X(a,n){let s=t,d=a[s(1371)];if(e[s(1018)](d,n)>a[s(1063)])throw new Error(e[s(1108)]);return a[s(1371)]+=n,d}function _e(a,n){let s=t,d=X(a,n);return a[s(1030)][s(1395)](d,e[s(1032)](d,n))}function fe(a,n){let s=t,d=e[s(334)](ee,a,n.length);a[s(1030)][s(787)](n,d)}function k(a,n){let s=t,d=e.bmHtV(X,a,n),f=String[s(608)+s(1329)],p=a[s(1030)],E="\uFFFD",b="";for(let g=0;e[s(1373)](g,n);g++){let O=p[e.JPFtO(g,d)],N,F,G,W;if(e.cAuaS(128&O,0))b+=e.vMbQr(f,O);else if(e.twRuB(e.SBnKP(224,O),192))e[s(417)](e.JPFtO(g,1),n)?b+=E:(N=p[e[s(629)](g,d)+1],e[s(370)](e[s(595)](192,N),128)?b+=E:(W=e[s(1282)](e.rkBrc(e[s(1052)](31,O),6),e[s(1561)](63,N)),e[s(798)](W,128)?b+=E:(b+=e.YUtrW(f,W),g++)));else if(e[s(1194)](240&O,224))if(e[s(575)](g,2)>=n)b+=E;else if(N=p[e[s(962)](e[s(1372)](g,d),1)],F=p[e[s(822)](e[s(575)](g,d),2)],e[s(1225)](e[s(399)](N,e[s(366)](F,8))&49344,32896))b+=E;else if(e[s(279)](e.VIClR,s(1580)))W=e.rkBrc(e[s(1461)](15,O),12)|e[s(366)](e[s(478)](63,N),6)|e.MetYJ(63,F),e[s(1155)](W,2048)||W>=55296&&e[s(1266)](W,57343)?b+=E:(b+=e[s(1263)](f,W),g+=2);else return _0x8f9649[s(711)](_0x4d841e)||(_0x16e82e=_0x4dd8dd.fromNumber(_0x4f9dd7)),e[s(841)](this.unsigned,_0x1991a9.unsigned)&&e[s(669)](this.high>>>31,1)&&e[s(1536)](e[s(661)](_0x2f9c10[s(849)],31),1)?!1:e[s(1536)](this[s(849)],_0x555a80[s(849)])&&this[s(493)]===_0x4dcb34[s(493)];else e[s(1396)](e[s(1052)](248,O),240)?e[s(1372)](g,3)>=n?b+=E:(N=p[g+d+1],F=p[e.dtgwk(g,d)+2],G=p[e[s(1228)](e[s(822)](g,d),3)],e.SBnKP(e[s(1282)](N|e[s(366)](F,8),G<<16),12632256)!==8421504?b+=E:(W=e[s(1282)](e.wloCO(e[s(366)](e[s(1562)](7,O),18),e[s(366)](e[s(478)](63,N),12)),e.rkBrc(e[s(1562)](63,F),6))|e[s(595)](63,G),e[s(1155)](W,65536)||e[s(1320)](W,1114111)?b+=E:(W-=65536,b+=e[s(977)](f,e.JPFtO(W>>10,55296),e[s(629)](1023&W,56320)),g+=3))):b+=E}return b}function H(a,n){let s=t,d={ldVbu:function(f,p,E){return e[K(1222)](f,p,E)}};if(e[s(454)]!==e[s(454)])return this[s(934)]?.[s(1161)];{let f=n.length,p=0;for(let g=0;e.dGJkC(g,f);g++)if(e[s(1008)](s(666),e[s(588)]))zEEoba[s(1369)](_0x339960,_0x399fb9,10),zEEoba.ldVbu(_0x1aea50,_0x41b09e,_0x478c20);else{let O=n.charCodeAt(g);e[s(417)](O,55296)&&O<=56319&&e.NuVAJ(e[s(1705)](g,1),f)&&(O=(O<<10)+n[s(363)+"At"](++g)-56613888),p+=e.XGIpW(O,128)?1:e[s(1155)](O,2048)?2:e[s(1373)](O,65536)?3:4}e[s(509)](le,a,p);let E=e[s(627)](ee,a,p),b=a[s(1030)];for(let g=0;g<f;g++)if(e.VNWzh(s(460),s(953))){let O=n.charCodeAt(g);e.JmDEe(O,55296)&&e.UeCWP(O,56319)&&e[s(479)](g,1)<f&&(O=e[s(629)](O<<10,n[s(363)+"At"](++g))-56613888),O<128?b[E++]=O:(O<2048?b[E++]=e.wloCO(e[s(1561)](O>>6,31),192):(e.zklva(O,65536)?b[E++]=e.aZJdl(e.zsaFl(O,12),15)|224:(b[E++]=e.VFOnx(e[s(1052)](e.XxpuB(O,18),7),240),b[E++]=e[s(1223)](e[s(907)](O,12)&63,128)),b[E++]=e[s(850)](e[s(907)](O,6)&63,128)),b[E++]=e[s(548)](63,O)|128)}else return this[s(313)]?this[s(313)].readyState:this._options[s(896)+"cOpen"]?this[s(1191)+"NG"]:this[s(961)]}}function j(a,n){let s=t,d=ee(a,n[s(1063)]),f=a.bytes,p=n[s(1030)];for(let E=0,b=n[s(1063)];e[s(1592)](E,b);E++)f[e[s(1465)](E,d)]=p[E]}function re(a){return a[t(1030)][e.bRwBq(X,a,1)]}function Ke(a,n){let s=t,d=e[s(316)](ee,a,1);a[s(1030)][d]=n}function de(a){let n=t,s=0,d=0,f;do f=re(a),e[n(996)](s,32)&&(d|=e[n(1287)](e[n(1061)](127,f),s)),s+=7;while(128&f);return d}function le(a,n){let s=t;for(n>>>=0;e[s(338)](n,128);)if(e[s(1532)](s(1516),e.FyJQG))e[s(983)](Ke,a,e.ZbwaX(127&n,128)),n>>>=7;else return this[s(493)]===-1&&this[s(849)]===-1?_0x5ac40b[s(622)](0,0,this[s(976)]):this[s(493)]===-1?_0x3e7068[s(622)](0,this[s(849)]+1,this[s(976)]):_0x47ac5f.fromBits(this[s(493)]+1,this[s(849)],this.unsigned);e[s(1009)](Ke,a,n)}function Et(a,n){let s=t,d={ubIzd:s(1671),iqkns:function(f,p,E){return f(p,E)}};if(!e[s(582)]("RAxDD",e[s(882)])){let f=0,p=0,E=0,b;if(b=e.jQnGm(re,a),f=e[s(595)](127,b),e[s(1562)](128,b)&&(b=re(a),f|=e[s(464)](e[s(1561)](127,b),7),128&b&&(b=e[s(816)](re,a),f|=e[s(366)](e.cvopU(127,b),14),e[s(1562)](128,b)&&(b=e[s(1125)](re,a),f|=e[s(710)](127,b)<<21,e[s(280)](128,b)&&(b=e[s(701)](re,a),p=e[s(1052)](127,b),e[s(254)](128,b))))))if(e[s(1113)](s(795),e.oWPzo)){if(b=e[s(286)](re,a),p|=e[s(1410)](e[s(595)](127,b),7),128&b&&(b=e.YILxz(re,a),p|=e[s(784)](127,b)<<14,e[s(1562)](128,b)&&(b=re(a),p|=e.rkBrc(e[s(1350)](127,b),21),128&b))){if(e[s(1254)](e[s(514)],e[s(563)]))return new _0x590d64(_0x2e4ee4,_0x22827f,_0x210c8f);b=re(a),E=e.MetYJ(127,b),e[s(848)](128,b)&&(b=e[s(1125)](re,a),E|=e[s(508)](e[s(1179)](127,b),7))}}else this[s(1443)](d[s(1617)],d.iqkns(_0x18c54d,d[s(1617)],{..._0x550fe5}));return{low:e[s(1163)](f,e[s(508)](p,28)),high:e[s(1163)](e[s(1442)](p,4),e[s(1723)](E,24)),unsigned:n}}}function dt(a,n){let s=t;if(e[s(1591)](s(1298),s(779)))e[s(345)](_0x14579c,_0x2ca8b7,e[s(1282)](e[s(1165)](127,_0x13fbf7),128)),_0x36bf18>>>=7;else{let d=e[s(692)](n[s(493)],0),f=(e[s(1539)](n[s(493)],28)|e[s(464)](n[s(849)],4))>>>0,p=e[s(1697)](n[s(849)],24),E=e[s(1536)](0,p)?f===0?d<16384?e[s(1373)](d,128)?1:2:e[s(1178)](d,2097152)?3:4:e[s(946)](f,16384)?e[s(798)](f,128)?5:6:e[s(704)](f,2097152)?7:8:e[s(809)](p,128)?9:10,b=ee(a,E),g=a[s(1030)];switch(E){case 10:g[b+9]=e[s(1629)](p,7)&1;case 9:g[e[s(695)](b,8)]=e.mfDtY(9,E)?128|p:e[s(969)](127,p);case 8:g[e[s(1265)](b,7)]=e.LwHQS(8,E)?e[s(399)](f>>>21,128):e.DajAX(f>>>21,127);case 7:g[b+6]=E!==7?e[s(1711)](e[s(1099)](f,14),128):e[s(1469)](f,14)&127;case 6:g[e[s(962)](b,5)]=e[s(1198)](6,E)?e.uprGc(f,7)|128:e[s(1350)](e[s(1446)](f,7),127);case 5:g[e[s(1265)](b,4)]=e[s(370)](5,E)?e[s(998)](128,f):e.WJvDw(127,f);case 4:g[e[s(1101)](b,3)]=E!==4?e.sTWXY(d>>>21,128):e[s(1236)](d,21)&127;case 3:g[e[s(1465)](b,2)]=E!==3?e[s(526)](e[s(436)](d,14),128):e[s(1052)](e.ckHmY(d,14),127);case 2:g[b+1]=e[s(1590)](2,E)?e.JnpXJ(e.Soxsn(d,7),128):e[s(482)](e[s(1539)](d,7),127);case 1:g[b]=E!==1?e[s(850)](128,d):e[s(505)](127,d)}}}function Jt(a){let n=t;if(e[n(1334)]===e.Szbid){let s=this[n(364)+"tManager"]?.["getCurre"+n(1713)+"nt"]();this._debug(n(731)+s),e[n(346)](_0xcd1972)}else return e[n(621)](v,a)}function Lt(a){return e[t(1695)](A,a)}let Zt=65536,Fr=e.DTFZE,pe=Zt*Zt,Se=e.NIfJQ(pe,pe),Kn=Se/2,Ce=String[t(1571)+"e"][t(363)+"At"];class ae{constructor(n,s,d){let f=t;this.isLong=!0,this[f(493)]=e[f(297)](0,n),this[f(849)]=0|s,this[f(976)]=!!d}static[t(711)](n){let s=t;return n&&e[s(669)](!0,n[s(711)])}static fromBits(n,s,d){let f=t;if(e[f(820)](e[f(504)],e[f(1276)]))return new ae(n,s,d);vamMZT[f(1667)]!=typeof _0x545f84&&_0x1101aa["toString"+f(564)]&&_0x4fd4fa[f(1636)+"operty"](_0x1c28f5,_0x1eebc7[f(1332)+"Tag"],{value:vamMZT.MapWy}),_0x31f96a[f(1636)+"operty"](_0x293837,vamMZT.uQQKu,{value:!0})}static fromBytes(n,s,d){let f=t;return d?ae[f(356)+f(328)](n,s):ae["fromByte"+f(716)](n,s)}static["fromByte"+t(328)](n,s){let d=t;return new ae(e[d(850)](e[d(1163)](n[0],e[d(988)](n[1],8)),n[2]<<16)|e[d(1410)](n[3],24),e[d(1163)](e[d(312)](e[d(1512)](n[4],n[5]<<8),n[6]<<16),e[d(1410)](n[7],24)),s)}static[t(356)+t(716)](n,s){let d=t,f={wApUF:function(p,E,b){return e.QXPxS(p,E,b)},PkVxY:function(p,E,b){return p(E,b)},tNlTL:function(p,E,b,g){return e[K(1149)](p,E,b,g)},bJPVd:function(p,E){return e[K(278)](p,E)}};if(e[d(817)](e[d(949)],e[d(949)]))return new ae(e[d(714)](e.FKxPC(e[d(1082)](n[4],24),e.TldhB(n[5],16)),e[d(974)](n[6],8))|n[7],e[d(366)](n[0],24)|e[d(1362)](n[1],16)|e[d(658)](n[2],8)|n[3],s);{let p=0,E=[];for(;p<_0x3b123c[d(872)+"th"];){let{offset:b}=f[d(1284)](_0x39524d,_0x28e81b,p);p=b;let g={cursor_name:"",cursor:0,service:0},{value:O,offset:N}=f[d(511)](_0x1d3c82,_0x1be873,p);g.service=O,p=N;let{value:F,offset:G}=f.wApUF(_0x594e2b,_0x9800ed,p);p=G,g[d(502)+"ame"]=f[d(1158)](_0x11acef,_0x5f0b8a,p,f[d(453)](p,F)),p+=F;let{value:W,offset:ye}=_0x44e160(_0x3a047f,p);g.cursor=W[d(967)](),p=ye,E[d(1426)](g)}return E}}static fromHash(n){let s=t;return n===Fr?Pd:new ae(e[s(850)](e[s(456)](e[s(1243)](Ce[s(376)](n,0),e[s(508)](Ce[s(376)](n,1),8)),e[s(1287)](Ce[s(376)](n,2),16)),e[s(366)](Ce[s(376)](n,3),24))>>>0,(e.fVghR(Ce[s(376)](n,4)|Ce[s(376)](n,5)<<8,Ce[s(376)](n,6)<<16)|e[s(599)](Ce[s(376)](n,7),24))>>>0,!0)}[t(1296)](){let n=t;return String[n(608)+n(1329)](e[n(458)](255,this[n(493)]),e[n(692)](this.low,8)&255,e[n(478)](e[n(683)](this[n(493)],16),255),this.low>>>24,255&this.high,e[n(1051)](this.high,8)&255,e[n(1232)](e[n(1469)](this[n(849)],16),255),e[n(661)](this[n(849)],24))}static[t(1427)+"er"](n,s=!0){let d=t;if(e[d(1007)](isNaN,n))return s?zx:Pd;if(s){if(e[d(581)](n,Se))return Ux}else{if(e[d(645)](n,-Kn))return Gx;if(e[d(846)](e[d(1490)](n,1),Kn))return Fx}return ae[d(622)](e[d(456)](e[d(1693)](n,pe),0),e[d(456)](e.MOiLp(n,pe),0),s)}[t(967)](){let n=t;return this[n(976)]?e[n(1490)](e[n(964)](this[n(849)],0)*pe,e[n(1697)](this[n(493)],0)):e[n(1490)](e[n(1509)](this[n(849)],pe),e[n(697)](this[n(493)],0))}[t(708)](){let n=t;return this.high===0&&e[n(1586)](0,this[n(493)])}[t(1613)](n){let s=t;ae[s(711)](n)||(n=ae[s(1427)+"er"](n));let d=this[s(849)]>>>16,f=e[s(1104)](65535,this[s(849)]),p=e[s(624)](this[s(493)],16),E=65535&this[s(493)],b=e[s(1051)](n.high,16),g=e[s(482)](65535,n[s(849)]),O=e.qpxlK(n[s(493)],16),N=65535&n[s(493)],F=0,G=0,W=0,ye=0;return ye+=e[s(1337)](E,N),W+=e[s(435)](ye,16),ye&=65535,W+=e[s(461)](p,O),G+=e.gpoOJ(W,16),W&=65535,G+=f+g,F+=e[s(1099)](G,16),G&=65535,F+=d+b,F&=65535,ae[s(622)](e[s(1673)](e[s(1082)](W,16),ye),F<<16|G,this[s(976)])}[t(1049)](n){let s=t,d={BeJWC:function(f,p){return e[K(617)](f,p)},TyYsK:function(f,p,E){return e[K(1033)](f,p,E)},jtKWR:function(f,p){return e[K(1233)](f,p)},SJDhb:function(f,p){return e[K(1165)](f,p)}};if(e[s(723)](s(605),e[s(973)])){for(_0x5b268d>>>=0;wGOklR[s(741)](_0x80c977,128);)wGOklR.TyYsK(_0x1c5258,_0x49226c,wGOklR[s(1524)](wGOklR.SJDhb(127,_0x10959e),128)),_0x5e46c3>>>=7;wGOklR.TyYsK(_0x1b490d,_0x57d64f,_0xfc67ce)}else return ae[s(711)](n)||(n=ae.fromNumber(n)),e[s(763)](this[s(976)],n[s(976)])&&e[s(817)](e.tdLHp(this[s(849)],31),1)&&e[s(712)](e[s(650)](n[s(849)],31),1)?!1:e.MSksC(this[s(849)],n[s(849)])&&e[s(817)](this[s(493)],n.low)}[t(324)](){let n=t;return e[n(758)](-1,this[n(493)])&&e.cAuaS(-1,this[n(849)])?ae.fromBits(0,0,this[n(976)]):this[n(493)]===-1?ae.fromBits(0,this[n(849)]+1,this[n(976)]):ae[n(622)](e[n(567)](this[n(493)],1),this.high,this.unsigned)}[t(1514)](n){let s=t;if(e.ZplrY(s(1314),e[s(1253)])){let d=e[s(672)](e[s(998)](e[s(1272)](e[s(1410)](e[s(788)](7,_0x3059ea),18)|e[s(974)](e[s(1061)](63,_0x43cc4a[_0x2215c9++]),12),e[s(658)](63&_0x3efe89[_0x41d9c4++],6)),63&_0x2dd079[_0x4ae974++]),65536);_0x333489+=_0x28eafe[s(608)+s(1329)](e.Nkdrf(55296,e[s(408)](d,10))),_0x148da9+=_0x80e6fb["fromChar"+s(1329)](e[s(903)](56320,e.PRyev(1023,d)))}else return n?this.toBytesLE():this[s(803)+"E"]()}[t(634)+"E"](){let n=t,s=this[n(849)],d=this[n(493)];return[e[n(1467)](255,d),e[n(788)](e[n(1446)](d,8),255),e[n(1731)](e[n(616)](d,16),255),d>>>24,e[n(1179)](255,s),e[n(1629)](s,8)&255,s>>>16&255,e[n(405)](s,24)]}[t(803)+"E"](){let n=t;if(e[n(1527)](e.ZWkNG,e[n(1269)])){let s=this[n(849)],d=this[n(493)];return[e[n(610)](s,24),e[n(595)](e[n(1099)](s,16),255),e.OwPZc(e[n(610)](s,8),255),e.ovHkm(255,s),e[n(1099)](d,24),e[n(916)](e[n(941)](d,16),255),e.SObZi(e[n(1697)](d,8),255),e[n(1494)](255,d)]}else _0x5c1c4f.push(_0x5ea2a8)}}let Pd=new ae(0,0,!1),zx=new ae(0,0,!0),Fx=ae[t(622)](-1,2147483647,!1),Ux=ae[t(622)](-1,-1,!0),Gx=ae[t(622)](0,-2147483648,!1);var Yt=(function(a){let n=t,s=(n(1482)+n(329)).split("|"),d=0;for(;;){switch(s[d++]){case"0":a[a["CONNECTI"+n(1511)]=5002]=e.ETdrE;continue;case"1":a[a[e[n(910)]]=5001]=n(1638)+n(1377);continue;case"2":return a;case"3":a[a["MAX_RETR"+n(1170)+"R"]=5003]=e.HfmQK;continue;case"4":a[a[e[n(954)]]=5004]=e[n(954)];continue;case"5":a[a[n(923)+"OR"]=5005]=e[n(500)];continue}break}})({});class $n{constructor(n){this.type=n,this.target=null}}class Nd extends $n{constructor(n,s){let d=t;super(n),this.message=s&&s[d(689)]||null}}class Ld extends $n{constructor(n,s){let d=t,f=e[d(945)][d(921)]("|"),p=0;for(;;){switch(f[p++]){case"0":this[d(783)]=s&&s[d(783)]||5001;continue;case"1":super(n);continue;case"2":this[d(271)]=s&&s[d(271)]||"";continue;case"3":this[d(1635)]=s&&s[d(1635)]||0;continue;case"4":this[d(1322)]=s&&s[d(1322)]||0;continue;case"5":this.message=s&&s[d(689)]||"";continue;case"6":this[d(1256)]=s&&s[d(1256)]||null;continue}break}}}class Md extends $n{constructor(n,s){let d=t;if(e.tPsjZ(e.qCazA,e[d(1021)])){let f=e[d(992)].split("|"),p=0;for(;;){switch(f[p++]){case"0":this.reason=s&&s[d(1596)]||"";continue;case"1":this.willReconnect=s&&s[d(1471)+d(414)]||!1;continue;case"2":super(n);continue;case"3":this.wasClean=s&&s[d(917)]||!1;continue;case"4":this.code=s&&s[d(783)]||0;continue}break}}else{let f=this._qosDB[d(1292)+"geSync"](this[d(1047)]),p=_0x5119e0[d(407)](f||"{}");return p[_0x24ec27]=void 0,this[d(934)]["setStora"+d(732)](this[d(1047)],_0x4672f0[d(1547)+"y"](p))}}}class Bd extends $n{constructor(n,s){let d=t;super(n),this.data=s&&s[d(409)]||null}}class zd extends Bd{constructor(n,s){let d=t;super(n),this[d(409)]=s&&s[d(409)]||null,this[d(689)]=s&&s[d(689)]||null}}class Fd extends $n{constructor(n,s){let d=t;super(n),this[d(409)]=s&&s[d(409)]||null}}function rt(a,{message:n,code:s,error:d}){return new Ld(a,{message:n,code:s,error:d})}function lt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){let p=t;return e[p(707)](p(1366),e[p(1425)])?_0x4f85ac.resolve():new Md(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Ud(a,{data:n,message:s}){return new zd(a,{data:n,message:s})}function Gd(a,{data:n}){return new Fd(a,{data:n})}function ta(a,{message:n}){return new Nd(a,{message:n})}class Hd{constructor(n,s){let d=t;this[d(1618)+"s"]=n,this.maxRetries=s,this[d(1227)+d(888)]=0,this[d(1011)+d(1291)+"riesCount"]=0}["resetEnd"+t(287)+"fig"](){let n=t;this[n(1227)+n(888)]=0,this[n(1011)+n(1291)+n(975)+"t"]=0}[t(602)+"es"](){let n=t;this[n(1011)+n(1291)+n(975)+"t"]=0}[t(1193)+"ntEndpoint"](){let n=t;return this[n(1618)+"s"][this[n(1227)+n(888)]]}[t(1193)+t(1713)+"ntTriesC"+t(1401)](){let n=t;return this[n(1011)+n(1291)+n(975)+"t"]}[t(293)+t(1384)+"es"](){let n=t;return!!(e[n(338)](this[n(1227)+n(888)],this.endpoints[n(492)])||this.currentIndex===e[n(672)](this[n(1618)+"s"][n(492)],1)&&e[n(758)](this[n(1011)+n(1291)+n(975)+"t"],this[n(1301)+"es"]))}[t(1399)+t(851)+t(1094)+t(800)+t(866)](){let n=t;return e.dRVwk(this["currentI"+n(888)],this[n(1618)+"s"][n(492)])?!0:this[n(1011)+"ndpointT"+n(975)+"t"]>this[n(1301)+"es"]}[t(791)+t(878)+t(1606)+t(1064)+t(303)](){let n=t;return this[n(1011)+n(1291)+n(975)+"t"]=1,this["currentI"+n(888)]++,this[n(1618)+"s"][this["currentI"+n(888)]]}["getCurre"+t(1713)+t(1411)+t(1050)](){let n=t;if(e.RCcfA(e[n(489)],e[n(489)]))this.off(_0xb7353c,_0x14492b);else return this["currentE"+n(1291)+n(975)+"t"]++,this["getCurre"+n(1713)+"nt"]()}}let Vn=(e[t(931)](e[t(1667)],typeof globalThis)&&e[t(299)](e[t(1382)],globalThis["construc"+t(1102)][t(1717)])||e[t(931)](e[t(1667)],typeof window)&&e.FvPvr(e[t(1382)],window[t(1119)+t(1102)].name))&&e[t(839)](e.ZzTFl,typeof document),bn=e.xoHnE("undefined",typeof globalThis)&&(e[t(1283)](e[t(411)],globalThis[t(1119)+"tor"][t(1717)])||e[t(1133)]("Dedicate"+t(1142)+t(766)+"pe",globalThis["construc"+t(1102)][t(1717)]))&&e[t(579)](e[t(1667)],typeof tt),Ur=(e.xoHnE(e.ZzTFl,typeof globalThis)&&e.xUAfi===globalThis[t(1119)+t(1102)][t(1717)]||e[t(1194)]("undefined",typeof globalThis)||e[t(931)](e[t(1667)],typeof globalThis)&&!!globalThis.WeixinJSBridge)&&e[t(579)](t(531)+"d",typeof wx),Gr=e.CwuOl(e.ZzTFl,typeof globalThis)&&(e[t(1418)](t(1278)+"dWorkerG"+t(766)+"pe",globalThis.constructor[t(1717)])||e[t(1077)]===globalThis[t(1119)+t(1102)][t(1717)]||e[t(852)]===globalThis["construc"+t(1102)][t(1717)])&&t(531)+"d"!=typeof self,Hx=e[t(574)]("undefined",typeof globalThis)&&e[t(1495)]("Object",globalThis[t(1119)+t(1102)].name)&&e[t(1667)]!=typeof global&&e[t(1148)](e[t(411)],global[t(1119)+t(1102)][t(1717)])&&e[t(1667)]!=typeof process&&!!process.version;class na{constructor(){let n=t;this[n(245)+"rs"]={}}emit(n,...s){let d=t,f={ByGHX:function(E,b,g){return e[K(1071)](E,b,g)},wIZqH:e[d(1520)],Ggphf:e[d(999)]},p=this[d(245)+"rs"][n];if(p)p[d(391)]()[d(442)](E=>E.fn[d(446)](E[d(920)],s));else if(e[d(1536)](d(1256),n)&&!this[d(1626)])if(e[d(267)]===e.ALTXY){let E=s[d(492)]&&s[0];if(E instanceof Error)throw E;let b=new Error(e.NxkOR+(E?e[d(1265)](e[d(903)](" (",E[d(689)]),")"):""));throw b[d(1326)]=E,E}else{let E=f[d(428)](_0x30566c,f[d(1700)],{message:f[d(1378)]});this.onStartReconnect&&this[d(979)+d(1242)](E)}return this}[t(744)](n,s){let d=t;if(n===void 0)this[d(245)+"rs"]={};else if(s===void 0)this[d(245)+"rs"][n]=null;else{let f=this._listeners[n];if(f)for(let p=0;p<f.length;)e[d(1588)](f[p].fn,s)?f[d(1098)](p,1):++p}return this}on(n,s,d){let f=t;return(this._listeners[n]||(this._listeners[n]=[]))[f(1426)]({fn:s,ctx:d||this}),this}}class qx extends na{[t(1137)+t(1715)+t(551)](n){let s=t;return n[s(686)]||n[s(1073)]?(s(1612)+" "+(n[s(686)]||"")+" code: "+(n[s(1073)]||""))[s(861)]():JSON[s(1547)+"y"](n)}constructor(n,s,d){let f=t;super(),this._socket=null,Ur&&wx[f(1048)+f(522)]&&(this[f(1229)]=wx[f(1048)+f(522)]({url:n,protocols:s,header:d,fail:this[f(1341)+f(1343)+f(322)][f(424)](this),success:this[f(1341)+"ocketSuccessHand"+f(1116)].bind(this)})),bn&&tt[f(1048)+f(522)]&&(this[f(1229)]=tt.connectSocket({url:n,protocols:s,header:d,fail:this[f(1341)+f(1343)+f(322)][f(424)](this),success:this["_createS"+f(747)+f(1542)+f(1116)][f(424)](this)}))}[t(1341)+t(747)+t(1542)+"ler"](){let n=t;Promise.resolve()[n(1572)](()=>{let s=n;this[s(670)+s(615)]()})}["_createS"+t(1343)+t(322)](n){let s=t;Promise.resolve()[s(1572)](()=>{let d=s,f={fWbHd:function(p,E){return e[K(461)](p,E)},dBizf:function(p,E){return e[K(661)](p,E)},LQqUI:function(p,E){return e.NrWbk(p,E)},sTbxx:function(p,E){return e[K(1509)](p,E)}};if(d(618)!==d(618))return this[d(976)]?FPqOSF[d(935)](FPqOSF.dBizf(this.high,0)*_0x3b0d17,FPqOSF[d(1328)](this.low,0)):FPqOSF[d(1570)](this[d(849)],_0x27d48e)+FPqOSF.LQqUI(this[d(493)],0);{let p=e.fJzqZ(rt,"error",{message:this[d(1137)+d(1715)+d(551)](n)});this[d(1443)](d(1256),p);let E=e[d(983)](lt,e[d(570)],{reason:this[d(1137)+"rrorMess"+d(551)](n)});this[d(1443)](e[d(570)],E)}})}[t(670)+t(615)](){let n=t,s={ezGbr:e[n(1640)],pbGTw:function(d,f,p){return e[n(1631)](d,f,p)},uzvkM:n(1671),YmToa:e.LzOnL,jWhXr:function(d,f,p){return e[n(274)](d,f,p)},bnAzf:e[n(1721)]};this[n(1229)][n(939)](d=>{let f=n;this[f(1443)](s[f(943)],s.pbGTw(Gd,s[f(943)],{...d,data:d[f(686)]||""}))}),this[n(1229)].onClose(d=>{let f=n;this[f(1443)](s[f(1172)],lt(f(1671),{...d}))}),this[n(1229)][n(1040)+"e"](d=>{let f=n;this[f(1443)](s[f(1059)],s[f(706)](Ud,s[f(1059)],{...d}))}),this._socket[n(1237)](d=>{let f=n;this.emit(s[f(1522)],rt(s[f(1522)],{...d,message:d[f(686)]||""}))})}send(n){let s=t,d={XlIUV:function(f,p,E){return f(p,E)}};if(e[s(481)](n,Uint8Array)){let f=n[s(1026)][s(391)](n.byteOffset,e[s(575)](n[s(872)+"th"],n[s(1386)+"et"]));this[s(1229)]&&this[s(1229)][s(709)]({data:f,fail:p=>{let E=s;this.emit(e[E(1721)],e[E(393)](rt,e[E(1721)],{message:this[E(1137)+E(1715)+"age"](p)}))}})}else this[s(1229)]&&this[s(1229)][s(709)]({data:n,fail:f=>{let p=s;this[p(1443)](p(1256),d[p(1686)](rt,p(1256),{message:this[p(1137)+p(1715)+p(551)](f)}))}})}close(n,s){this[t(1229)]&&this._socket.close({code:n,reason:s})}[t(1604)+t(863)](n,s){this.on(n,s)}["removeEv"+t(1619)+t(337)](n,s){this[t(744)](n,s)}get[t(1294)+"te"](){return this._socket.readyState}get[t(1720)+"pe"](){let n=t;return this[n(1229)][n(1720)+"pe"]}set[t(1720)+"pe"](n){}get[t(950)](){let n=t;return this[n(1229)][n(950)]}get[t(1519)](){let n=t;return this._socket[n(1519)]}get extensions(){return this[t(1229)].extensions}get[t(246)+"Amount"](){return 0}}function jx(a,n){let s=t;if(n)return new n(a.url,a.protocol);if(e[s(422)](Ur,bn))return new qx(a[s(950)],a[s(1519)],a[s(592)]);if((Vn||Gr)&&e[s(1667)]!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(950)],a[s(1519)+"s"])}function Wx(a){let n=t,s=e[n(789)][n(921)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(e.VMYnw(Vn,Gr)&&e.mbRFi(e[n(1667)],typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(Ur&&wx[n(1048)+n(522)])return!0;continue;case"2":if(bn&&tt[n(1048)+"ocket"])return!0;continue;case"3":return!1;case"4":if(a)return!0;continue}break}}function qd(a,n,s){let d={eVyKa:function(E,b){return E!==b},MZfdT:function(E,b,g){return e[K(909)](E,b,g)}},f=-1;async function p(E){let b=K;if(e[b(1008)](e.rAVVj,e.WSMnE)){let g=_0x516973[b(527)];g!==void 0&&(_0x4bd4b1(_0x12cd54,10),_0x55b85b(_0x238e98,g));let O=_0x4a49f6[b(1472)];DpCSTS[b(1162)](void 0,O)&&(DpCSTS[b(1508)](_0x3c8936,_0x447964,18),_0x525a51(_0x27db5a,O))}else return e[b(960)](E,f)?Promise[b(541)](new Error(e.wxNhM)):(f=E,e[b(462)](E,s[b(492)])?Promise[b(1312)]():s[E].bind(a)(n,p.bind(null,e[b(461)](E,1))))}p(0)}function jd(a){let n=t,s={VZRoo:function(p,E,b){return e.NgSXo(p,E,b)}},d=0,f=0;for(let p=0;p<a.length;++p)e[n(1418)](e[n(1365)],e[n(1365)])?(f=a[n(363)+"At"](p),e[n(1155)](f,128)?d+=1:f<2048?d+=2:e[n(669)](e.Nchjz(64512,f),55296)&&e[n(1148)](64512&a[n(363)+"At"](e[n(1293)](p,1)),56320)?(++p,d+=4):d+=3):(TVouPX[n(1603)](_0x1c9a7d,_0x33ee9c,18),TVouPX.VZRoo(_0xe29e96,_0x49865f,_0xc2436));return d}function Wd(a,n,s){let d=t,f={TuoEm:function(E,b,g,O){return e[K(1149)](E,b,g,O)}};if(e[d(1373)](s-n,1))return"";let p="";for(let E=n;e[d(404)](E,s);)if(e.RxYaa!=="tIsqt"){let b=a[E++];if(e[d(553)](b,127))p+=String[d(608)+d(1329)](b);else if(b>=192&&e[d(496)](b,224))p+=String["fromChar"+d(1329)](e[d(1289)](e[d(980)](31,b),6)|63&a[E++]);else if(b>=224&&e[d(946)](b,240))p+=String.fromCharCode(e[d(1036)](e.SnCAk(e[d(1287)](15&b,12),e[d(988)](e[d(412)](63,a[E++]),6)),e[d(1153)](63,a[E++])));else if(e.CvYmx(b,240))if(e[d(1581)]!==e.eucxU){let g=e[d(1420)](e[d(626)](e.irGEe(e[d(797)](7,b),18),e[d(589)](e[d(1061)](63,a[E++]),12))|e[d(1362)](e[d(1232)](63,a[E++]),6),e[d(796)](63,a[E++]))-65536;p+=String[d(608)+d(1329)](e[d(1136)](55296,g>>10)),p+=String["fromChar"+d(1329)](e[d(278)](56320,e.fVWto(1023,g)))}else this[d(347)+d(965)]()}else throw _0xcf7144=_0x41336e[d(492)],f[d(891)](_0x3fa6f5,_0x3d0375,10,_0x2b8403[d(492)]);return p}function ra(a,n,s){let d=t;if(e[d(1431)](e.pNVIx,e[d(1460)]))_0x29b394[d(1462)](_0x544800);else{let f=s,p,E;for(let b=0;e[d(1361)](b,a[d(492)]);++b)if(e.QjuLY(e[d(619)],e[d(259)]))_0x18005f(_0x3e06ab,32),e[d(1575)](_0x2df9a2,_0x409e50,_0x36eee0(_0x3d99ab));else if(p=a[d(363)+"At"](b),e.ArdzR(p,128))n[s++]=p;else if(p<2048)e[d(763)](e[d(936)],e[d(936)])?(this._isBrowser&&_0x16c1a8["removeEv"+d(1619)+"ner"](e[d(308)],this[d(944)+d(1092)]),this[d(533)+"er"]&&_0x5d2098["removeEventListe"+d(337)](e[d(1725)],this[d(944)+"ffLine"]),this[d(533)+"er"]&&_0x1693c1["removeEventListe"+d(337)](e[d(1659)],this[d(1620)+d(889)]),this[d(533)+"er"]&&_0x587e27[d(513)+d(1619)+d(337)](e[d(354)],this[d(1620)+d(724)])):(n[s++]=e[d(1722)](e.MpBUH(p,6),192),n[s++]=e[d(1649)](e[d(331)](63,p),128));else if(e.PRyev(64512,p)===55296&&(64512&(E=a[d(363)+"At"](e.HOMlc(b,1))))===56320){let g=(d(1019)+d(1012)).split("|"),O=0;for(;;){switch(g[O++]){case"0":n[s++]=63&p|128;continue;case"1":++b;continue;case"2":n[s++]=e[d(472)](p>>12&63,128);continue;case"3":n[s++]=p>>18|240;continue;case"4":n[s++]=e[d(875)](e.hBrUc(p>>6,63),128);continue;case"5":p=e.SIgqC(e[d(932)](65536,e[d(1634)](e[d(1065)](1023,p),10)),e[d(1461)](1023,E));continue}break}}else n[s++]=e[d(341)](e[d(408)](p,12),224),n[s++]=e[d(443)](e[d(325)](p,6)&63,128),n[s++]=e[d(1649)](63&p,128);return e[d(740)](s,f)}}async function Kd(a){let n=t;if(e.hikXR===n(276)){let s=this[n(934)][n(452)](this[n(1047)]);return _0x1beb33[n(407)](e[n(422)](s,"{}"))[_0xa368a8]}else{if(e[n(1194)](e[n(547)],typeof a)){let s=new Uint8Array(e[n(450)](jd,a));return e.SievR(ra,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a[n(872)+"th"])}}function Kx(a){let n=t;if(e[n(763)](e[n(1682)],e[n(1682)]))return new _0x25735e(e[n(1200)](e[n(597)](e[n(845)](_0x3c38de[0],e.euFEu(_0x4a9cab[1],8)),e[n(1356)](_0x8edb54[2],16)),e[n(1407)](_0x50bb58[3],24)),e[n(1036)](e.GRHtq(_0x7939c0[4],e.SCyXD(_0x45e3fc[5],8))|e[n(1481)](_0xd63e54[6],16),e.aTUXh(_0x2ba82a[7],24)),_0x223ef1);try{return e[n(931)](e[n(547)],typeof a)&&(e[n(1358)](a,ArrayBuffer)||a.buffer&&a[n(1026)]instanceof ArrayBuffer)||e[n(547)]!=typeof a?"":(JSON.parse(a),e[n(604)])}catch{return e[n(547)]==typeof a?e[n(1013)]:""}}let $x=(a,n)=>{let s=t;switch(a){case e[s(1057)]:case e[s(281)]:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class Vx{constructor(n){let s=t;this[s(339)+"ount"]=n,this.count=0}[t(684)](){let n=t;this[n(1696)]++}[t(293)+t(1589)+"nt"](){let n=t;return e[n(1698)](this[n(1696)],this["maxLossC"+n(1401)])}[t(1661)+t(1145)](n=0){let s=t;this[s(339)+s(1401)]=n,this.count=0}}async function Jx(a){return new Promise(n=>{let s=K,d={JSTzG:function(f,p){return f(p)},PUIwx:e.AsuLG};if(!Vn)return e[s(833)](n,e[s(1209)]);try{let f=document["createEl"+s(757)](e[s(880)]);window[s(1210)+s(1666)]=p=>{let E=s;document[E(1363)][E(1646)+E(536)](f),window["frontier"+E(1666)]=void 0,d.JSTzG(n,p&&p[E(642)]||d.PUIwx)},f.type=e[s(357)],f[s(306)]=e.gFqbP(a[s(1474)](/^ws/,e[s(387)]),e.HyiiX);try{document.body[s(925)+s(536)](f)}catch{document[s(1363)][s(1646)+"ild"](f)}}catch{window[s(1210)+s(1666)]=void 0,e.TirvE(n,s(884)+s(1596))}})}function Xt(a,n,s){let d=t;return!!a?.[d(829)](f=>f[d(527)]===n&&f[d(1472)]===s)}function Jn(a,n){let s=t;return a?.[s(829)](d=>d[s(527)]===n)?.[s(1472)]}let ia=null;async function Zx(){let a=t,n={vgKxm:a(1103),LJwwg:function(s,d){return e[a(817)](s,d)},HBQmI:e[a(1727)],xVnFL:function(s,d){return e[a(1235)](s,d)}};return e[a(986)](e[a(1675)],a(467))?_0x3f5224 instanceof _0xe84da0&&(_0x15e952===eZBOQa[a(1689)]||eZBOQa.LJwwg(_0x466dc7,eZBOQa[a(1497)]))?!0:eZBOQa[a(625)](_0x5af5cd,_0x30d8ea):(ia||(ia=Promise.resolve().then(Ot[a(424)](Ot,e[a(879)]))),ia)}class Yx extends na{constructor(n,s){let d=t;super(),this[d(1307)]=n,this[d(1502)]=s,this[d(934)]=void 0,this._initPromise=null}async[t(682)](){await this[t(762)]()}async _init(){let n=t,s={rXkww:function(d,f){return d+f},XfAmW:function(d,f,p){return d(f,p)},EfmdG:function(d,f){return d>>>f},FneIn:function(d,f){return e[K(599)](d,f)}};if(n(955)!==e[n(1325)]){let d=0,f=_0x235fc5,p=s.rXkww(_0x2096a3,4);for(;f<p;){let{value:E,offset:b}=s[n(899)](_0x663f7,_0x2ea89c,f);f=b,d=s[n(1109)](s[n(1528)](d,8),0),d+=E}return{value:d,offset:p}}else{if(this[n(934)])return;if(this[n(1014)+n(1206)])return this[n(1014)+n(1206)];try{let d=this[n(1307)],f=this[n(1502)];this[n(1014)+n(1206)]=(async()=>{let p=n,{openDB:E}=await e[p(1138)](Zx);this[p(934)]=await E("frontier_"+d,1,{upgrade(b){let g=p;b[g(1352)+g(1510)+"e"](d,{keyPath:f})}})})(),await this[n(1014)+n(1206)]}catch(d){console[n(1462)](d)}finally{this[n(1014)+n(1206)]=null}}}async[t(545)](n){let s=t;try{return await this[s(762)](),this[s(934)]?.[s(545)](this[s(1307)],n)}catch(d){console[s(1462)](d)}}async set(n,s){let d=t;return e[d(558)](e.LqWoC,d(1111))?e[d(833)](_0x5a6864,_0x48f524):(await this._init(),this._qosDB?.[d(1197)](this[d(1307)],n))}async[t(1187)](n){let s=t;try{return await this._init(),this._qosDB?.[s(1704)](this._dbName,n)}catch(d){console.log(d)}}async[t(1430)](){let n=t;try{return e[n(388)]==="VRorw"?(await this[n(762)](),this[n(934)]?.[n(1430)](this._dbName)):e[n(892)](this[n(1696)],this[n(339)+n(1401)])}catch(s){console.log(s)}}async[t(437)](){return await this[t(762)](),this._qosDB?.getAllKeys(this._dbName)}async[t(698)](){let n=t;return await this[n(762)](),this._qosDB?.[n(698)](this[n(1307)])}async[t(568)](){let n=t;try{this._qosDB?.close(),this[n(934)]=void 0}catch(s){console.log(s)}}get[t(1161)](){let n=t,s={yOBPm:function(d,f){return e[K(506)](d,f)},slLle:function(d,f){return e[K(587)](d,f)},jLYyZ:function(d,f){return e[K(1032)](d,f)},fbOxv:function(d,f,p){return e[K(1222)](d,f,p)},dxZez:e[n(1721)],kZheZ:"close"};if(e[n(738)]===e[n(1268)]){if(YGtUNg[n(571)](_0x2f3532,-_0x3aeb1f))return _0x5ebe77;if(YGtUNg[n(1286)](YGtUNg[n(1504)](_0x24fcf1,1),_0x143abc))return _0x332f17}else try{return!!this[n(934)]}catch(d){if(e[n(968)](e[n(1473)],e[n(1473)]))return console.log(d),!1;_0x2616bb[n(1312)]()[n(1572)](()=>{let f=n,p=YGtUNg[f(1403)](_0x4a3213,YGtUNg[f(1031)],{message:this["_formatE"+f(1715)+f(551)](_0x2d3d3c)});this[f(1443)](f(1256),p);let E=_0x584bbd(YGtUNg[f(300)],{reason:this[f(1137)+f(1715)+"age"](_0x2c6de7)});this.emit(f(1671),E)})}}}class Xx{constructor(n,s){let d=t;this[d(1055)]=n,this[d(270)]=s,this[d(934)]=localStorage}async[t(682)](){}get[t(1047)](){let n=t;return n(1210)+"_"+this[n(1055)]}async[t(545)](n){let s=t,d=this._qosDB[s(452)](this[s(1047)]);return JSON[s(407)](e[s(422)](d,"{}"))[n]}async[t(787)](n,s){let d=t,f=this._qosDB.getItem(this._prefix),p=JSON[d(407)](f||"{}");return p[s||n[this._pathKey]]=n,this[d(934)][d(1060)](this._prefix,JSON[d(1547)+"y"](p)),s||n[this[d(270)]]}async[t(1187)](n){let s=t,d=this._qosDB[s(452)](this[s(1047)]),f=JSON.parse(e[s(422)](d,"{}"));return f[n]=void 0,this[s(934)].setItem(this[s(1047)],JSON[s(1547)+"y"](f))}async[t(1430)](){return this[t(934)].clear()}async keys(){let n=t,s=this[n(934)].getItem(this[n(1047)]),d=JSON[n(407)](s||"{}");return Object.keys(d)}async[t(698)](){let n=t,s=this[n(934)][n(452)](this._prefix),d=JSON[n(407)](e[n(380)](s,"{}"));return Object[n(434)](d)}closeDB(){return Promise.resolve()}get[t(1161)](){return!!this._qosDB}}class Qx{constructor(n,s){let d=t;if(e.CONrC(d(1208),"ZqJur"))this[d(1055)]=n,this[d(270)]=s,this[d(934)]=bn?tt:Ur?wx:null;else return!!_0x2e1bf9?.[d(829)](f=>f.key===_0x282c03&&f[d(1472)]===_0x1b2cf0)}async openDB(){}get[t(1047)](){let n=t;return n(1210)+"_"+this[n(1055)]}async get(n){let s=t,d=this[s(934)][s(1292)+s(732)](this[s(1047)]);return JSON[s(407)](e.AyWVA(d,"{}"))[n]}async[t(787)](n,s){let d=t,f=this[d(934)][d(1292)+d(732)](this[d(1047)]),p=JSON[d(407)](e[d(380)](f,"{}"));return p[s||n[this[d(270)]]]=n,this._qosDB.setStorageSync(this[d(1047)],JSON.stringify(p)),s||n[this[d(270)]]}async[t(1187)](n){let s=t;if(e[s(420)](s(1405),e[s(1347)]))this[s(339)+s(1401)]=_0x594a0a,this[s(1696)]=0;else{let d=this[s(934)][s(1292)+"geSync"](this[s(1047)]),f=JSON[s(407)](e[s(1219)](d,"{}"));return f[n]=void 0,this[s(934)][s(323)+s(732)](this[s(1047)],JSON[s(1547)+"y"](f))}}async[t(1430)](){let n=t;return this[n(934)][n(1654)+n(590)]()}async keys(){let n=t,s=this[n(934)][n(1292)+n(1297)+"nc"](this[n(1047)]),d=JSON[n(407)](e[n(1342)](s,"{}"));return Object.keys(d)}async[t(698)](){let n=t,s=this._qosDB[n(1292)+n(1297)+"nc"](this[n(1047)]),d=JSON[n(407)](e[n(422)](s,"{}"));return Object[n(434)](d)}[t(568)](){return Promise[t(1312)]()}get isReady(){return!!this[t(934)]}}function $d(a,n){let s=t;if(e[s(1674)](bn,bn))return new Qx(a,n);if(e[s(1674)](Vn,Gr)&&s(531)+"d"!=typeof indexedDB)return new Yx(a,n);if((Vn||Gr)&&e[s(931)]("undefined",typeof localStorage))return new Xx(a,n);throw new Error(s(814)+s(1538)+"d")}class ep{constructor(){let n=t;this[n(347)+n(361)+"Id"]=null,this[n(347)+"l"]=36e5,this[n(934)]=$d(e.OdAFx,e[n(771)])}async["_interva"+t(965)](){let n=t,s={XYARM:e[n(547)],IDBan:e[n(1013)]};if(e.NXjXj===n(395))return VllMwF[n(1557)]==typeof _0x11a62e?VllMwF.IDBan:"";e[n(1639)](clearInterval,this[n(347)+"lTimeoutId"]),this["_interva"+n(361)+"Id"]=e[n(1664)](setInterval,()=>{this["flushExp"+n(1463)]()},this[n(347)+"l"])}async openDB(){let n=t;e[n(1586)](e[n(1387)],e[n(862)])?_0x547cfa&&this[n(1318)+n(694)][n(929)+n(768)+"Name"](_0x1cca7c):await this[n(934)][n(682)]().then(()=>{this[n(347)+"lFlush"]()})}async flushExpired(){let n=t;(await this._qosDB?.[n(698)]()||[])[n(819)](({timestamp:f})=>f<Date[n(1270)]())[n(442)](f=>{let p=n;this[p(934)]?.[p(1187)](f[p(362)+"id"])})}async del(n){let s=t;if(e.twRuB(s(1703),s(1703)))return this[s(934)]?.del(n);if(e.VDmHj(e[s(547)],typeof _0x1b3571)){let d=new _0x218a96(_0x509f36(_0x3ebb84));return e.SievR(_0x122b6d,_0xb4b8af,d,0),d}return _0xc59855 instanceof _0x11f304?new _0x5a1fb9(_0x116710):new _0x2dd225(_0x4e793b[s(1026)],_0x532628[s(1386)+"et"],_0x171adf[s(872)+"th"])}async[t(787)](n,s){let d=t,f={KzxpW:e[d(671)]};if(e[d(1196)](e.MZNEZ,d(487)))return this[d(934)]?.set({message_id:n,timestamp:s});if(!this[d(1174)+d(473)]){let p=f[d(681)][d(921)]("|"),E=0;for(;;){switch(p[E++]){case"0":this[d(1174)]();continue;case"1":this[d(295)+d(1169)]=!1;continue;case"2":this._isInit=!0;continue;case"3":this[d(807)+d(285)]?.["resetCou"+d(1145)]();continue;case"4":this[d(364)+d(326)]?.[d(1084)+d(287)+d(277)]();continue}break}}}async[t(545)](n){let s=t;return this[s(934)]?.[s(545)](n)}async[t(568)](){let n=t;e[n(1185)](clearInterval,this["_interva"+n(361)+"Id"]),await this._qosDB?.[n(568)]()}get[t(1161)](){let n=t;if(e[n(1115)](e[n(352)],e[n(352)]))return this._qosDB?.[n(1161)];{let s=this[n(245)+"rs"][_0x54e1f5];if(s)s[n(391)]().forEach(d=>d.fn[n(446)](d[n(920)],_0x2f8cd9));else if(e.tPsjZ(e[n(1721)],_0x14307d)&&!this[n(1626)]){let d=_0x2582db.length&&_0x2fc7b9[0];if(e[n(776)](d,_0x59f8ad))throw d;let f=new _0x2107cc(e.NxkOR+(d?e[n(1032)](e.Nkdrf(" (",d.message),")"):""));throw f.context=d,d}return this}}}function sa(a){let n=t;if(e[n(558)](n(343),e.GIGxb)){let s=!!this[n(1087)][n(294)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e.SievR(Xt,a.message.headers,e.JRRXS,"2"),f=d&&e[n(1408)](Xt,a[n(689)][n(592)],"x_frontier_qos_ack","1"),p=d&&e[n(483)](Xt,a[n(689)].headers,e.JdoYZ,"1"),E=p?e[n(1660)](Jn,a[n(689)][n(592)],e.nEGTg)?.[n(921)](",")[n(819)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:p,ackMsgIds:E}}else{if(e[n(1152)](_0x305a83,1)||e[n(869)](_0x27fb98,_0xd574e3))return e[n(835)](_0x2d6e8c,_0x1185ad);e[n(430)](e[n(278)](_0x48c431,_0x1f8476),_0x45a9d3)&&(_0xe85e14=e[n(652)](_0x49fa4e,_0x5b1c04),_0x4a18e5=0);let s=_0x3cb8d6[n(376)](_0x379fa5,_0x481884,_0x173a7b+=_0x5b0ffc);return 7&_0xc3abc6&&(_0x42d96a=e[n(1018)](e[n(1390)](7,_0x29527a),1)),s}}async function Vd(){let a=t;return this[a(641)+"ger"]||(this[a(641)+a(512)]=new ep),this["_QoSMana"+a(512)][a(1161)]||await this[a(641)+a(512)].openDB(),this[a(641)+a(512)]}async function tp(a,n){let s=t,{enableAutoAck:d}=this._options,f=e[s(1408)](Xt,a.message[s(592)],e[s(386)],"1"),p=e[s(1389)](Xt,a.message[s(592)],e[s(1107)],"1"),E=sa[s(376)](this,a);if(e[s(836)](d,f)){let{SeqID:b,LogID:g,service:O,LogIDNew:N,method:F}=a[s(689)];this._sendAck({SeqID:b,LogID:g,LogIDNew:N,service:O,method:F,headers:[{key:e.BUsbN,value:"1"},{key:s(1543),value:e[s(422)](N,"")},{key:e[s(392)],value:"0"}]})}p&&!E.isQoSAck&&this[s(1476)+"hAckMess"+s(1177)](a),e[s(1419)](n)}async function np(a,n){let s=t;e[s(723)](e[s(1226)],e[s(1226)])?(this[s(1485)](e[s(1127)],a[s(689)]),e.gXhYJ(n)):this["_initPro"+s(1206)]=null}async function rp(a,n){let s=t,d=e[s(261)](Jt,await e[s(1651)](Kd,a[s(409)]));try{if(e.LwKLB(d[s(1719)],Uint8Array)){let f=e[s(660)](this[s(1087)]["payloadE"+s(631)],Object)?{force:!!this[s(1087)][s(823)+s(631)].force,encoding:this[s(1087)][s(823)+s(631)].encoding?this._options[s(823)+s(631)].encoding[s(1474)](/\s/g,"")[s(1062)+s(427)]():""}:{force:!1,encoding:this[s(1087)][s(823)+s(631)]?this[s(1087)]["payloadE"+s(631)][s(1474)](/\s/g,"")["toLowerC"+s(427)]():""},p=d.payloadEncoding?d[s(823)+s(631)][s(1474)](/\s/g,"")["toLowerC"+s(427)]():"",E=e[s(660)](this[s(1087)][s(1038)+s(1310)],Object)?{force:!!this[s(1087)][s(1038)+s(1310)][s(1211)],type:this._options["payloadT"+s(1310)][s(717)]?this[s(1087)][s(1038)+s(1310)].type[s(1474)](/\s/g,"")[s(1062)+s(427)]():""}:{force:!1,type:this[s(1087)][s(1038)+"ype"]?this._options[s(1038)+s(1310)][s(1474)](/\s/g,"")[s(1062)+"ase"]():""},b=d[s(1038)+s(1310)]?d[s(1038)+s(1310)][s(1474)](/\s/g,"")[s(1062)+s(427)]():"",g=E.force?E.type:b||E.type,O=f.force?f[s(1207)]:p||f.encoding,N=[e.dSXGx,e.KkqAN,e[s(1457)],s(1397)],F=[e.FhneT,e[s(799)]];this._options["enableTr"+s(612)+s(1231)+"ad"]&&N[s(813)](g)&&(!O||F[s(813)](O))?d["textPayl"+s(1355)]=e[s(1389)](Wd,d[s(1719)],0,d[s(1719)][s(872)+"th"]):d[s(1468)+s(1355)]=""}else d[s(1468)+"oad"]=""}catch(f){d[s(1468)+s(1355)]="",console.log(f)}a[s(689)]=d,e[s(444)](n)}function ip(a,n,s){let d=t,f=e[d(1219)](s,8192),p=e[d(1629)](f,1),E=null,b=f;return function(g){let O=d;if(e[O(404)](g,1)||e.TOnIW(g,p))return e[O(665)](a,g);e.hKfzC(e[O(1228)](b,g),f)&&(E=e[O(477)](a,f),b=0);let N=n[O(376)](E,b,b+=g);return e[O(410)](7,b)&&(b=e[O(456)](7,b)+1),N}}let sp=4294967295;function op(a,n,s){let d=t;return e[d(881)](d(1129),e[d(1632)])?e[d(1007)](RangeError,e[d(1600)](e.jrdFg(e[d(1490)](d(963)+d(1441)+d(648)+a,d(1579)),n||1),d(913))+s):vamMZT[d(1185)](_0xb86f40,_0xbd511e[d(446)](vamMZT[d(1007)](_0x3f75ca,this),_0x1a2530))}function ap(a,n,s){let d=t;if(e[d(1611)](s,sp))throw new Error(e.FCViF);let f=3;for(;e[d(890)](f,0);)if(e[d(613)](e.jYWhm,e[d(1692)])){let p=e[d(1258)](255,s);e[d(498)](aa,p,a,e.SIkNc(n,f)),s>>>=8,f--}else{let p=_0x1fed7a[d(497)]();return p?(p[d(1371)]=p[d(1063)]=0,p):{bytes:new _0x1ca62f(64),offset:0,limit:0}}return n+4}function cp(a,n){let s=t,d=0,f=n,p=e.TkMjJ(n,4);for(;e[s(924)](f,p);){let{value:E,offset:b}=e[s(345)](oa,a,f);f=b,d=e[s(805)](d<<8,0),d+=E}return{value:d,offset:p}}function dp(a,n,s){let d=t,f=e.OMIIH[d(921)]("|"),p=0;for(;;){switch(f[p++]){case"0":if(!a)return s;continue;case"1":if(e[d(1022)](a.length,40))return e.NyXiH(e[d(1408)](ra,a,n,s),s);continue;case"2":return e[d(479)](ra(a,n,s),s);case"3":if(n[d(893)])return e[d(1600)](n.write(a,s),s);continue;case"4":if(n[d(421)+"e"])return e[d(461)](n[d(421)+"e"](a,s),s);continue}break}}function lp(a,n){let s=t,d=new ae(e[s(868)](e[s(1182)](a[n+4]<<24,e[s(1634)](a[e.Nkdrf(n,5)],16)),e[s(1131)](a[e[s(567)](n,6)],8))|a[n+7],e.PQYWN(e[s(341)](e[s(845)](e[s(546)](a[e[s(1490)](n,0)],24),a[e.lOmTg(n,1)]<<16),a[e[s(1501)](n,2)]<<8),a[e.babLQ(n,3)]),!0);return n+=8,{value:d,offset:e[s(815)](n,8)}}function up(a,n,s){let d=t,f=a[d(493)],p=a.high;return n[s]=e[d(1697)](p,24),n[e.sUKza(s,1)]=e.XVrjd(e[d(874)](p,16),255),n[e.LEKSX(s,2)]=e[d(692)](p,8)&255,n[e[d(537)](s,3)]=e.LqzSp(255,p),n[e[d(720)](s,4)]=e.SMarK(f,24),n[e[d(903)](s,5)]=f>>>16&255,n[e.yPbGk(s,6)]=e[d(482)](e[d(1576)](f,8),255),n[e[d(1501)](s,7)]=e[d(867)](255,f),s+=8,s}function oa(a,n){let s=t;if(e[s(1086)]!==s(317))return a[s(1560)+"8"]?{value:a[s(1560)+"8"](n),offset:e[s(984)](n,1)}:{value:e[s(1467)](255,a[n]),offset:n+1};this.emit(s(1256),e[s(1660)](_0x2c30f4,e[s(1721)],{message:this[s(1137)+s(1715)+s(551)](_0x31e66d)}))}function aa(a,n,s){let d=t;return n[d(1598)+"t8"]?n[d(1598)+"t8"](a,s):n[s]=e.jacIQ(255,a),e[d(479)](s,1)}let fp=function(a){return new Uint8Array(a)},hp=e[t(931)](e[t(1667)],typeof Buffer)?Buffer.allocUnsafe:e[t(369)](ip,fp,Uint8Array[t(1571)+"e"].subarray);(()=>{let a=t,n={TfJFJ:e[a(573)],kCrmw:function(d,f){return d|f},gfydm:function(d,f){return d>>>f},eMDno:function(d,f){return e.LzhhO(d,f)},gufGH:function(d,f){return e[a(458)](d,f)},cBVyX:function(d,f){return e[a(374)](d,f)},ILtWV:function(d,f){return e[a(715)](d,f)},FvCzN:function(d,f){return d<f},wpKBA:function(d,f){return e[a(472)](d,f)},SFRwP:function(d,f){return d|f},gFQvX:function(d,f){return e[a(353)](d,f)},VMWun:function(d,f){return e[a(850)](d,f)},YdndN:function(d,f){return e[a(1289)](d,f)},DcbvI:function(d,f){return e[a(924)](d,f)},jJXXB:function(d,f){return e[a(982)](d,f)},LYLCY:function(d,f){return e[a(733)](d,f)},dLcxJ:function(d,f){return d>f}},s=4294967295;return function(d,f,p=!0){let E=a,b=n[E(1417)][E(921)]("|"),g=0;for(;;){switch(b[g++]){case"0":return{value:p?s:0|s,offset:f};case"1":if(d[f++]<128)return{value:p?s:n[E(751)](0,s),offset:f};continue;case"2":s=n[E(491)](n[E(751)](s,n.eMDno(n[E(1173)](127,d[f]),21)),0);continue;case"3":if(n[E(756)](d[f++],128))return{value:p?s:n[E(1652)](0,s),offset:f};continue;case"4":if(n[E(1707)](d[f++],128))return{value:p?s:n[E(989)](0,s),offset:f};continue;case"5":s=n[E(491)](n[E(860)](s,n[E(335)](n[E(674)](15,d[f]),28)),0);continue;case"6":s=n[E(491)](n[E(419)](s,n.YdndN(127&d[f],14)),0);continue;case"7":s=n[E(491)](n[E(1173)](127,d[f]),0);continue;case"8":if(n.DcbvI(d[f++],128))return{value:p?s:n[E(1652)](0,s),offset:f};continue;case"9":s=n.jJXXB(n[E(419)](s,n[E(1555)](n.gufGH(127,d[f]),7)),0);continue;case"10":if(n[E(635)](d[f++],128))return{value:p?s:n.wpKBA(0,s),offset:f};continue;case"11":if(n[E(342)](f+=5,d.length))throw f=d[E(492)],op(f,10,d[E(492)]);continue}break}}})();let xp=16,ca=32;function pp(a){let n=t,s=0,d={};for(let f=0;e[n(1130)](f,a[n(492)]);f++)d[a[f][n(502)+n(1455)]]=e[n(469)](jd,a[f][n(502)+n(1455)]),s+=e[n(782)](14,d[a[f].cursor_name]);return[s,d]}function Jd(a,n,s){let d=t,f={nOMtk:d(987)+d(630)+"6|1|10",AczsG:function(O,N,F,G){return e[d(483)](O,N,F,G)},tvIFz:function(O,N,F,G){return O(N,F,G)},gpRrU:e.ScRmm,mckRS:e[d(1238)],USvXj:e.hiVZA,HvgqC:e[d(269)],MwvSB:e.uZjWM},[p,E]=e[d(1393)](pp,a),b=hp(p),g=0;return a[d(442)](O=>{let N=d,F=f.nOMtk[N(921)]("|"),G=0;for(;;){switch(F[G++]){case"0":g=f[N(957)](aa,E[O[N(502)+"ame"]],b,g);continue;case"1":g=f[N(309)](up,ae[N(1427)+"er"](O[N(1530)]||n),b,g);continue;case"2":g=f[N(957)](aa,0,b,g);continue;case"3":console.log(f[N(1624)],g);continue;case"4":g=ap(b,g,O[N(1423)]||0);continue;case"5":console[N(1462)](f[N(702)],g);continue;case"6":console[N(1462)](f[N(1027)],g);continue;case"7":console[N(1462)](N(484)+"ervice",O,O.service);continue;case"8":g=f[N(957)](dp,O[N(502)+"ame"],b,g);continue;case"9":console[N(1462)](f[N(455)],g);continue;case"10":console[N(1462)](f[N(1653)],g);continue}break}}),{frameType:ca,headers:[{key:e[d(938)],value:s}],payload:b}}function gp(a){let n=t,s=0,d=[];for(;e.EJKZI(s,a[n(872)+"th"]);)if(e.oOBTo!==e[n(301)]){let{offset:f}=e[n(977)](oa,a,s);s=f;let p={cursor_name:"",cursor:0,service:0},{value:E,offset:b}=e[n(828)](cp,a,s);p.service=E,s=b;let{value:g,offset:O}=oa(a,s);s=O,p["cursor_n"+n(1455)]=e[n(886)](Wd,a,s,e[n(1521)](s,g)),s+=g;let{value:N,offset:F}=e[n(400)](lp,a,s);p[n(1530)]=N[n(967)](),s=F,d[n(1426)](p)}else try{return!!this[n(934)]}catch(f){return _0x29d255[n(1462)](f),!1}return d}function mp(){return{frameType:ca,headers:[{key:e.YGejA,value:e.QzzOd}],payload:void 0}}class wp{constructor(n,s,d){let f=t;this[f(649)+f(468)]=n,this["_cursorF"+f(1081)]=s,this[f(1181)+f(257)]=d,this[f(934)]=e[f(680)]($d,this[f(649)+"ameSpace"],"cursor_n"+f(1455))}async[t(682)](){let n=t;await this[n(934)][n(682)]()}async[t(1267)+"rs"](){let n=t;if(!this[n(934)][n(1161)])return;let s=this["_message"+n(257)],d=await this[n(934)][n(698)]();switch(console[n(1462)](n(915)+n(1578),d),s){case e[n(1708)]:return d&&d[n(492)]?e[n(426)](Jd,d,0,this[n(900)+n(1081)]):void 0;case n(1306):return;case n(1607):return d&&d[n(492)]?e[n(1149)](Jd,d,0,this["_cursorF"+n(1081)]):e[n(1608)](mp)}}async[t(787)](n,s,d){let f=t;return console[f(1462)](e[f(596)],n,s,d),this[f(934)][f(787)]({cursor_name:n,cursor:s,service:d})}async[t(1459)+"rs"](n){let s=t,d={CdZUP:function(f,p,E,b){return f(p,E,b)},YyzYK:function(f,p,E){return e[K(970)](f,p,E)}};if(e[s(737)]!=="qfxWw")try{d[s(413)](_0x5dc688,this,_0xfb06de,[_0x1b7f0d,_0x1a6d8b,_0xd7d296])}catch(f){let p=d[s(640)](_0x6b8eed,s(1256),{message:f.message,code:_0x3d1a89[s(923)+"OR"],error:f});this["_dispatc"+s(1005)+"ent"](p)}else{let f=e.RWOZR(gp,n);for(let p of f)console[s(1462)](e[s(1315)],f),await this._qosDB[s(787)](p)}}async[t(545)](n){let s=t;return(await this[s(934)][s(545)](n))?.[s(1530)]}async closeDB(){let n=t;await this._qosDB[n(568)]()}[t(929)+t(768)+t(1212)](n){let s=t;this[s(900)+s(1081)]=n}get[t(1161)](){let n=t;return this._qosDB[n(1161)]}}let _p=e[t(1168)];async function Zd(a){let n=t;if(!this[n(1087)][n(294)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(1087)],p=e[n(422)](a,_p);try{if(e[n(1279)](e[n(495)],e.UzDDl))this.type=_0x53eeb6,this[n(830)]=null;else return this[n(1318)+"anager"]?a&&this[n(1318)+"anager"][n(929)+n(768)+n(1212)](a):this[n(1318)+"anager"]=new wp(d+"_"+s+"_"+p,p,f),this[n(1318)+"anager"][n(1161)]||await this[n(1318)+n(694)][n(682)](),this[n(1318)+n(694)]}catch{return null}}async function yp(a,n){let s=t,d=e[s(843)](Xt,a[s(689)][s(592)],"code","-1"),f=e.vfWYp(Xt,a[s(689)][s(592)],e[s(1107)],"1"),p=e.hMrQA(Jn,a[s(689)][s(592)],e[s(1493)]),E=Number(e[s(627)](Jn,a[s(689)][s(592)],e[s(1097)]))||0,b=sa[s(376)](this,a),g=e[s(1308)](Xt,a[s(689)][s(592)],e[s(1346)],"2"),O=e[s(909)](Jn,a.message[s(592)],"x-msg-cu"+s(657)+"e"),N=e.LOqCa(Number,Jn(a[s(689)][s(592)],s(289)+s(1054)+"ue"));if(b[s(433)])return n();let F=b[s(1249)+"sage"]?await Vd[s(376)](this):null;if(e[s(580)](a[s(689)][s(1423)],0)&&f&&!d||e[s(1025)](a[s(689)][s(1423)],0)){if(p&&b["isQoSMes"+s(1627)]&&F)return e.CXYhI===e.CXYhI?(!!!await F[s(545)](p)&&(this[s(1476)+s(1340)+s(1364)](a),await F.set(p,e[s(1705)](Date[s(1270)](),E))),e[s(1313)](n)):(_0x3a6437[_0x1ee2e5]=_0x4a113d,!0);if(g){let G=await Zd.call(this);if(!G){if(e[s(1529)](e[s(1506)],s(1309)))return this["_dispatc"+s(1340)+s(1364)](a),e[s(540)](n);_0x45bbab(_0x249bbf,74),_0x303d5e(_0x18eddc,_0x418452)}let W=await G[s(545)](O)??-1;if(e[s(1178)](W,N))this[s(1476)+"hMessage"+s(1364)](a),G[s(787)](O,N,a[s(689)].service);else throw new Error(s(348)+s(1413)+s(381)+N+(" larger than loc"+s(247)+"r ")+W);return e.udOSY(n)}return this["_dispatchMessage"+s(1364)](a),n()}}async function Ep(a,n){let s=t;if(e.fUkMZ(e[s(730)],s(302))){let d=_0x2c219f[s(1480)+"g"](0,4-_0x59a47e[s(492)]),f=d[s(310)](_0x21e419);_0x5bd509.push(f)}else{let d=sa[s(376)](this,a);if(!d[s(1249)+s(1627)])return e[s(346)](n);let f=await Vd[s(376)](this);if(d["isAckCleanupMess"+s(551)]&&d[s(1327)+"s"].length)for(let p of d[s(1327)+"s"])await f[s(1187)](p);e.LjRxt(n)}}async function bp(a,n){let s=t,d=e.dlNPP(a[s(689)].frameType,xp),f=e.tffBR(a.message.frameType,ca);if(!d&&!f)return e.uLVWI(n);let p=e[s(499)](Jn,a[s(689)][s(592)],e[s(938)]);if(!p)return e[s(346)](n);let E=await Zd[s(376)](this,p);if(!E)return e[s(540)](n);if(d){let b=await E[s(1267)+"rs"](),g={frameType:b?.[s(1449)+"e"],SeqID:ae[s(1427)+"er"](this[s(1416)]++),LogID:ae[s(1427)+"er"](this[s(1087)]["logIDGen"+s(687)]()),service:9e3,method:5,headers:b?.[s(592)],payload:b?.[s(1719)]},O=e.NHkdP(A,g);this[s(313)]&&this[s(313)].readyState&&this[s(313)][s(709)](O)}if(f){let b=a.message[s(1719)];b&&E[s(1459)+"rs"](b)}}let vp=async function(a,n){let s=t;this[s(292)]=!1,e.JckHO(clearTimeout,this["_connect"+s(1541)+"utId"]),e.LgbGK(n)},Sp=async function(a,n){let s=t;if(!this._ws||e[s(1154)](this[s(313)][s(1294)+"te"],this[s(367)]))return e.Niadw(n);let{pingInterval:d}=this[s(1087)];this[s(364)+"tManager"]?.[s(1084)+s(287)+s(277)]();for(let p=0;e[s(496)](p,this[s(1181)+s(1400)][s(492)]);p++){let E=this[s(1181)+s(1400)][p];if(this[s(313)][s(1294)+"te"]===this[s(367)]&&e[s(1527)](null,E))if(e[s(1718)]===s(623)){e[s(1575)](_0x4d4ebf,_0x74a178,42);let b=e[s(432)](_0x5d4598);_0x1220c5(_0x5b5c60,b),e.JNYJC(_0x186809,_0x2d9624,b[s(1063)]),e[s(1156)](_0x406793,_0x1494ae,b),e[s(1263)](_0x481d12,b)}else this._ws&&this[s(313)].send(E),this[s(1181)+s(1400)][p]=null;else break}this[s(1181)+s(1400)]=this[s(1181)+s(1400)][s(819)](p=>!!p),this[s(552)+s(1041)+"Id"]=e[s(970)](setTimeout,()=>this._ping(),d),this[s(1476)+s(1454)+"nt"](a),this[s(533)+"er"]&&this[s(313)]&&(this._ws[s(1720)+"pe"]=this._binaryType);let f=this[s(364)+s(326)]?.[s(1193)+"ntEndpoint"]();this._debug("open "+f+s(1677)),n()},Ip=async function(a,n){let s=t,d=this[s(364)+s(326)]?.[s(1193)+s(1713)+"nt"]();this[s(1485)](s(731)+d),e[s(557)](n)};class Ap extends na{constructor(n){let s=t,d={cdZWw:e.kUXcF,McJOK:function(b,g){return e[K(1559)](b,g)},RPmiH:e[s(1017)],pWocf:e[s(971)],NAUtI:function(b,g){return b===g},kpxUE:function(b,g){return e[s(712)](b,g)},edGrJ:s(577),sZuxV:function(b,g,O){return e[s(755)](b,g,O)},oUeSV:e[s(1721)],WYnpv:e[s(1089)],VqGKu:e.EZeGl,YCXyo:function(b,g,O){return e.aDpgd(b,g,O)}};super(),this[s(359)+s(821)+"line"]=!0,this[s(533)+"er"]=Vn,this._isNode=Hx,this[s(1151)+"T"]=bn,this[s(416)+"X"]=Ur,this._isWorker=Gr,this["_message"+s(1400)]=[],this["_endpoin"+s(326)]=null,this._readyClosed=!1,this[s(1339)+"ype"]=s(1302)+s(1139),this["_connect"+s(473)]=!1,this[s(1174)+"ionTimeo"+s(653)]=null,this[s(775)+s(1345)+s(1273)]=null,this[s(552)+s(1041)+"Id"]=null,this[s(1416)]=0,this[s(292)]=!1,this._url="",this["_QoSMana"+s(512)]=null,this["_cursorM"+s(694)]=null,this[s(807)+s(285)]=null,this[s(1093)+"ls"]=e.mXrzk,this[s(961)]=3,this[s(1191)+"NG"]=0,this.OPEN=1,this.CLOSING=2,this[s(463)]=b=>{let g=s;try{e[g(284)](qd,this,b,[vp,Sp,Ip])}catch(O){let N=rt(e.HABTv,{message:O[g(689)],code:Yt[g(923)+"OR"],error:O});this[g(1476)+g(1005)+g(1039)](N)}},this[s(1489)+"ge"]=async b=>{let g=s,{pingInterval:O,pingFrequency:N}=this[g(1087)];if((b[g(409)]==="hi"&&d[g(418)]===N||d[g(1593)](d.RPmiH,N))&&(this[g(1096)+g(1288)](),this.emit(d[g(700)],"success"),this["_pingPon"+g(1041)+"Id"]=setTimeout(this[g(1690)].bind(this),O)),!d[g(1551)]("hi",b[g(409)]))try{if(d[g(474)](g(520),d.edGrJ))return!!this._qosDB;qd(this,b,[rp,tp,Ep,bp,yp,np])}catch(F){let G=d[g(1531)](rt,d[g(1317)],{message:F[g(689)],code:Yt[g(532)+g(1083)],error:F});this[g(1476)+g(1005)+g(1039)](G)}},this[s(1540)]=b=>{let g=s,O=this["_endpoin"+g(326)]?.[g(293)+g(1384)+"es"](),N=this._endpointManager?.[g(1193)+g(1713)+"nt"]();if(O&&!b[g(689)])if(d[g(1585)]!==d[g(1042)]){let F="connect "+N+(g(389)+g(614)+g(1499)+"ed");this[g(1476)+g(1005)+g(1039)](d[g(258)](rt,d[g(1317)],{message:F,code:Yt["MAX_RETR"+g(1170)+"R"],error:b}));return}else return new _0x1f9af0(F=>{let G=g;_0x82cd70(F,this[G(1601)+"rvalValue"](_0x14381b))});this[g(313)]&&d.kpxUE(this[g(313)][g(1294)+"te"],this[g(367)])&&this[g(1160)+g(1252)](),this[g(1476)+g(1005)+g(1039)](rt(g(1256),{message:b.message,code:Yt[g(1638)+"RROR"],error:b}))},this[s(1367)]=async b=>{let g=s,O={TQkID:function(F,G){return e[K(1126)](F,G)},vwuhI:function(F,G){return e[K(932)](F,G)}};this[g(1076)+g(1381)](),this[g(1096)+g(1288)](),this["_removeW"+g(586)+"rs"](),this[g(313)]=null,this[g(1174)+"Lock"]=!1;let N=this[g(364)+g(326)]?.["checkRea"+g(1384)+"es"]();if(!N&&this[g(826)+"orOnline"]()&&!this[g(295)+g(1169)]){let F=this["_endpoin"+g(326)]?.[g(1193)+g(1713)+"nt"](),G=this[g(1087)]["reconnec"+g(725)+g(1566)](b.code,b[g(1596)]);this[g(1476)+g(1046)+g(1039)](lt(e[g(570)],{code:1006,reason:b[g(1596)]||"connecti"+g(1437)+g(268)+g(956)+g(801)+g(1150)+F,willReconnect:G})),G&&this[g(1174)]();return}if(e[g(986)](1e3,b.code)&&this._readyClosed)if(e.DhctW(g(1610),e[g(786)])){let G=""+_0x50ab6b.now(),W=_0x2d85fc||(_0x44b113=_0x2af91a(_0x2f26c9)),ye=_0x343b0a.random()[g(1332)](16).slice(-6);return bCQZFd.TQkID(bCQZFd[g(1670)]("02",G),W)+ye}else{this["_dispatc"+g(1046)+g(1039)](e[g(1434)](lt,"close",{code:1e3,reason:g(1716)})),this[g(364)+g(326)]?.[g(1084)+g(287)+g(277)](),this[g(807)+"sCounter"]?.[g(1661)+g(1145)]();return}if(e[g(1225)](1e3,b.code)&&N){let F=this[g(364)+g(326)]?.[g(1193)+g(1713)+"nt"](),G=b[g(1596)];G||(G=await Jx(this[g(425)])),G="connecti"+g(1437)+g(372)+G+(g(1015)+g(521))+F+(g(559)+g(249)+g(1259)),this[g(1476)+g(1046)+g(1039)](e[g(1448)](lt,e.DgbjI,{code:b[g(783)],reason:G}));let W=g(997)+F+(g(389)+g(614)+"es reached");this["_dispatc"+g(1005)+"ent"](e.cpkpY(rt,e.HABTv,{message:W,code:Yt[g(1621)+g(1170)+"R"]})),this[g(364)+g(326)]?.[g(1084)+g(287)+g(277)](),this[g(807)+g(285)]?.[g(1661)+g(1145)]();return}if(e[g(1195)](1e3,b.code)&&!b[g(1596)]){let F=this[g(364)+g(326)]?.[g(1193)+g(1713)+"nt"]();this[g(1476)+g(1046)+g(1039)](e.wlAkn(lt,e[g(570)],{code:b[g(783)],reason:g(1214)+"ng failed, unkno"+g(956)+g(801)+g(1150)+F})),this[g(364)+g(326)]?.["resetEnd"+g(287)+g(277)](),this[g(807)+g(285)]?.[g(1661)+g(1145)]();return}this["_dispatc"+g(1046)+g(1039)](b),this[g(364)+g(326)]?.resetEndpointConfig(),this[g(807)+"sCounter"]?.[g(1661)+g(1145)]()},this[s(1616)]=null,this[s(1626)]=null,this[s(966)+"e"]=null,this[s(1444)]=null,this["onStartR"+s(1242)]=null,this[s(1450)+s(447)]=null,this[s(1498)+s(651)+s(379)+"ct"]=null,this["_handleO"+s(1092)]=this._handleOnLine.bind(this),this[s(944)+s(1192)]=this[s(944)+s(1192)][s(424)](this),this[s(1620)+s(889)]=this[s(1620)+s(889)].bind(this),this[s(1620)+s(724)]=this[s(1620)+s(724)].bind(this),this[s(1087)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.nZGZR(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:"auto",pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(282)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=n,E=Array.isArray(f)?f:e[s(1396)](e.QFRFs,typeof f)?[f]:[];if(!E||e.TtBzq(0,E.length))throw new Error(e.KSQeq);if(!e[s(1505)](Wx,p))throw new Error(s(528)+"rovide ws params, WebSoc"+s(825)+s(1159)+s(1615)+s(1255));Object.assign(this._options,n),this[s(364)+s(326)]=new Hd(E,this[s(1087)][s(1301)+"es"]),this[s(807)+"sCounter"]=new Vx(this[s(1087)][s(693)+s(1385)]),this[s(1087)][s(896)+"cOpen"]&&(this._isInit=!0,this[s(1174)]()),this[s(1087)][s(1544)+s(703)+s(812)]&&(s(726)===e[s(691)]?(_0x6a1ae9[_0x38fc79[_0x51b83a]["cursor_n"+s(1455)]]=e[s(1391)](_0x59c021,_0x29daaf[_0x36a94b][s(502)+"ame"]),_0x24ea2d+=e[s(1642)](14,_0x3d5585[_0x1cdc1b[_0x518794][s(502)+"ame"]])):this[s(1151)+"T"]||this[s(416)+"X"]?this[s(632)+s(375)+s(1004)]():this[s(533)+"er"]&&this[s(1602)+s(1710)+s(863)]())}[t(944)+t(1092)](){let n=t;this[n(1087)][n(1523)+n(253)+n(377)]||this._readyClosed||this[n(764)+n(1242)]()}_handleOffLine(){let n=t;this[n(1383)+"WebSocket"]();let s=e[n(1448)](ta,e[n(1520)],{message:e[n(1043)]});this[n(1498)+n(651)+n(379)+"ct"]&&this[n(1498)+n(651)+"yReconnect"](s)}[t(1602)+t(1710)+"Listener"](){let n=t;this[n(533)+"er"]&&window["addEvent"+n(863)](n(718),this["_handleO"+n(1092)]),this[n(533)+"er"]&&window[n(1604)+"Listener"](e[n(1725)],this[n(944)+n(1192)]),this[n(533)+"er"]&&window[n(1604)+n(863)](e[n(1659)],this[n(1620)+"ageHide"]),this._isBrowser&&window[n(1604)+n(863)](e[n(354)],this[n(1620)+n(724)])}[t(593)+"balEvent"+t(863)](){let n=t;this._isBrowser&&window[n(513)+n(1619)+n(337)](e[n(308)],this[n(944)+n(1092)]),this[n(533)+"er"]&&window[n(513)+"entListener"](e.uXNHV,this[n(944)+"ffLine"]),this[n(533)+"er"]&&window[n(513)+n(1619)+n(337)](e[n(1659)],this[n(1620)+n(889)]),this._isBrowser&&window[n(513)+"entListe"+n(337)](e[n(354)],this["_handleP"+n(724)])}[t(1620)+"ageHide"](n){let s=t;!n[s(1414)+"d"]&&(this[s(533)+"er"]&&window["removeEv"+s(1619)+"ner"]("pagehide",this[s(1620)+s(889)]),this[s(533)+"er"]&&window[s(513)+s(1619)+s(337)](e[s(354)],this[s(1620)+s(724)]),this.close()),this._isBrowser&&window[s(513)+s(1619)+s(337)](e[s(308)],this[s(944)+s(1092)]),this[s(533)+"er"]&&window[s(513)+s(1619)+s(337)](e[s(1725)],this[s(944)+"ffLine"])}[t(1620)+t(724)](n){let s=t;e[s(1586)](e[s(439)],e[s(1556)])?(e.JNYJC(_0x2c0177,_0x358700,96),e.VsGTa(_0x378916,_0x4f04e0,e[s(1164)](_0x52ddef,_0x4724a1))):n.persisted&&(this["_navigat"+s(1124)]()&&(!this[s(313)]||e[s(881)](this[s(313)][s(1294)+"te"],this[s(367)])||e.avPOr(this[s(313)][s(1294)+"te"],this.CONNECTING))&&this[s(944)+"nLine"](),this[s(533)+"er"]&&window["addEvent"+s(863)](e[s(308)],this[s(944)+s(1092)]),this[s(533)+"er"]&&window[s(1604)+"Listener"](e[s(1725)],this[s(944)+"ffLine"]))}async[t(856)+t(1574)](n){let s=t,{fpID:d,deviceID:f,bddID:p,ttwID:E,accessKey:b,aID:g,customParams:O={},enableAutoAck:N,enableQoS:F,QoSLevel:G,env:W}=this[s(1087)],ye,ut,Hr;if(this[s(533)+"er"]||this[s(416)+"X"]||this[s(1151)+"T"])ye=location&&e[s(1396)](e[s(854)],location[s(1519)])?e[s(298)]:"ws://",ut=n[s(1474)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Hr=/^wss(.*:\/\/)/[s(1134)](n)?n:""+ye+ut;else{if(e[s(723)](e[s(722)],s(402)))return this[s(1011)+"ndpointT"+s(975)+"t"];ye="wss://",ut=n[s(1474)](/(^http)((?:[s]*:\/\/))/,""),Hr=/(^ws)((?:[s]*:\/\/))/[s(1134)](ut)?ut:""+ye+ut}let vn=p?"bd_did":E?e[s(1186)]:"device_id",Yd=p||E||f;if(!Yd||!vn)throw new Error(s(528)+s(1702)+s(745)+"viceID o"+s(1247));let Tp=e[s(1194)](e.SOCAb,typeof O)?await O():O,Rp=W?$x(W[s(638)],W[s(1079)]):{},da=Object[s(777)]({device_platform:e.mjoCj,version_code:s(678)+"0",access_key:b,fpid:d,aid:g,[vn]:Yd,xsack:N?1:0,xaack:N?1:0,xsqos:F?1:0,qos_level:F?G:void 0,qos_sdk_version:2,...Rp},Tp),Cp=Object[s(437)](da)[s(1290)]((la,ua)=>da[ua]!==void 0?""+la+(la?"&":"?")+ua+"="+da[ua]:la,"");return Hr+s(840)+Cp}async _connect(){let n=t;if(!(this["_connect"+n(473)]||this[n(295)+n(1169)])){this[n(1174)+"Lock"]=!0;try{let s=this["_endpoin"+n(326)]?.["checkCur"+n(851)+"ointReac"+n(800)+n(866)](),{timeoutInterval:d}=this._options;if(s)if(e[n(1323)](e[n(1262)],e[n(1262)])){if(e[n(1275)](e[n(465)](_0x6d56a9,_0x165893),1))return"";let p="";for(let E=_0x4edb91;e[n(924)](E,_0x101748);){let b=_0x22f39d[E++];if(e[n(288)](b,127))p+=_0x1ea3bb[n(608)+n(1329)](b);else if(b>=192&&e[n(490)](b,224))p+=_0x5ccd49[n(608)+n(1329)](e.SCyXD(e[n(1368)](31,b),6)|e.DqbVV(63,_0x156671[E++]));else if(e.OmTBy(b,224)&&e[n(1331)](b,240))p+=_0x2700ca[n(608)+n(1329)](e[n(1722)](e.ADsQc(e[n(449)](15,b),12),(63&_0x14adfb[E++])<<6)|e[n(1104)](63,_0x1794df[E++]));else if(e[n(1319)](b,240)){let g=e[n(1260)](e[n(1118)](e[n(998)](e[n(1623)](e.OGppi(e.nPIRw(7,b),18),e[n(1061)](63,_0x80f765[E++])<<12),e[n(1669)](e.BAyiF(63,_0x1de2e0[E++]),6)),e[n(858)](63,_0x421ae4[E++])),65536);p+=_0x5ed89d[n(608)+n(1329)](55296+e[n(942)](g,10)),p+=_0x4d9900[n(608)+"Code"](56320+e[n(410)](1023,g))}}return p}else{let p=this[n(364)+n(326)]?.[n(1193)+n(1713)+"nt"](),E=this[n(364)+"tManager"]?.[n(791)+"ackupEnd"+n(1606)+n(1064)+n(303)](),b=this[n(364)+n(326)]?.[n(1193)+n(1713)+"ntTriesC"+n(1401)]();if(E){let g="connect "+p+(n(538)+n(559)+"tries re"+n(1146)+n(1428)+n(396)+n(1706))+E+" to retry",O=e[n(663)](rt,e.HABTv,{message:g,code:Yt["MAX_RETR"+n(1170)+"R"]});this[n(1485)](g),this["_dispatc"+n(1005)+n(1039)](O),this[n(425)]=await this["_generat"+n(1574)](E),this[n(1485)](n(997)+E+" "+b+n(1088)),this[n(250)+n(586)+"rs"]()}else{let g=n(997)+p+(n(538)+n(559)+"tries reached");this[n(1485)](g),this["_dispatchErrorEv"+n(1039)](e[n(785)](rt,e[n(1721)],{message:g,code:Yt["MAX_RETR"+n(1170)+"R"]}));return}}else{let p=this["_endpoin"+n(326)]?.["getCurre"+n(1713)+"ntAndUpdateCount"](),E=this[n(364)+n(326)]?.[n(1193)+n(1713)+n(811)+n(1401)]();this[n(425)]=await this[n(856)+n(1574)](e.AyWVA(p,"")),this[n(1485)](n(997)+p+" "+E+n(1088)),this[n(250)+"sListeners"]()}if(this._isInit)this[n(292)]=!1;else{let p=e[n(909)](ta,e[n(1520)],{message:e[n(999)]});this[n(979)+n(1242)]&&this["onStartR"+n(1242)](p)}let f=this[n(364)+n(326)]?.["getCurre"+n(1713)+n(811)+"ount"]()||0;e[n(1730)](f,1)&&await this[n(1672)](e[n(332)](f,1)),this[n(1485)](n(1214)+n(877)+this._url+(n(739)+n(1224))+this._protocols),this[n(313)]=jx({url:this[n(425)],protocols:[this[n(1093)+"ls"]],headers:this[n(1087)][n(721)+n(1648)+"s"][n(519)+"tpHeader"]},this[n(1087)].ws),(this._isBrowser||this[n(1394)+"r"])&&this[n(313)]&&(this[n(313)][n(1720)+"pe"]=this[n(1339)+n(1310)]),this[n(670)+"steners"](),this["_connect"+n(1541)+n(653)]=e[n(1220)](setTimeout,this[n(1438)+"ut"][n(424)](this),d)}catch(s){throw this[n(1174)+n(473)]=!1,s}}}["_clearTi"+t(1381)](){let n=t;clearTimeout(this[n(1174)+n(1541)+n(653)]),this[n(1174)+n(1541)+n(653)]=null}[t(1096)+t(1288)](){let n=t;e[n(833)](clearTimeout,this[n(552)+n(1041)+"Id"]),e[n(719)](clearTimeout,this[n(775)+n(1345)+n(1273)]),this[n(552)+"gTimeoutId"]=null,this["_reconne"+n(1345)+n(1273)]=null}[t(1485)](...n){let s=t;this[s(1087)].debug&&console[s(1462)][s(446)](console,[e.PzGEZ,...n])}[t(1601)+t(677)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:p}=this._options,E=e[s(1445)](d,Math[s(555)](p,n-1));return e[s(995)](E,f)?f:E}[t(1690)](){let n=t;if(this[n(313)]&&this[n(313)][n(1294)+"te"]===this.CONNECTING){this[n(1096)+n(1288)](),this[n(552)+n(1041)+"Id"]=setTimeout(this[n(1690)][n(424)](this),this[n(1087)][n(1280)+"rval"]);return}if(!this._ws||this[n(313)].readyState!==this[n(367)])return void this["_handleR"+n(1242)]();this[n(313)]&&this._ws[n(709)]("hi"),this[n(775)+n(1345)+"tId"]=e.ntGCE(setTimeout,this["_handleR"+n(1242)+"Timeout"][n(424)](this),this[n(1087)][n(311)+n(1658)+"val"])}[t(764)+"econnect"+t(1110)](){let n=t,s={PBcGM:function(d,f){return e[K(624)](d,f)},gOeLP:function(d,f){return e[K(1028)](d,f)},zLtxX:function(d,f){return d+f},cPxvy:function(d,f){return e[K(1348)](d,f)},USmUX:function(d,f){return d>>>f},NwVNI:function(d,f){return e[K(1228)](d,f)},Rljjh:function(d,f){return d&f},QEHeR:function(d,f){return e[K(278)](d,f)},mmAUO:function(d,f){return d+f},MCzje:function(d,f){return d>>>f}};if(e[n(758)](e[n(1535)],e[n(1535)]))this[n(807)+n(285)]?.[n(684)](),this[n(1443)](e.fXXma,e[n(358)]),this._pingLossCounter?.["checkRea"+n(1589)+"nt"]()?this[n(764)+"econnect"]():this[n(1690)]();else{let d=_0x2c8351[n(493)],f=_0x504614.high;return _0x28575c[_0xab092b]=MBHuhs[n(1199)](f,24),_0x2fe9e4[_0xbb8d74+1]=MBHuhs.gOeLP(MBHuhs[n(1199)](f,16),255),_0x5b083b[MBHuhs[n(550)](_0x3230cc,2)]=MBHuhs[n(378)](MBHuhs[n(1240)](f,8),255),_0x31b8f5[MBHuhs[n(1359)](_0x33b271,3)]=MBHuhs[n(1117)](255,f),_0x8f0f52[MBHuhs[n(919)](_0x5432b3,4)]=MBHuhs[n(1199)](d,24),_0x757828[MBHuhs.mmAUO(_0x44c3b7,5)]=MBHuhs[n(948)](d>>>16,255),_0x483a62[MBHuhs.NwVNI(_0x5d79ed,6)]=MBHuhs.gOeLP(MBHuhs[n(1687)](d,8),255),_0x30fa2c[MBHuhs.zLtxX(_0x4a3ac4,7)]=MBHuhs[n(378)](255,d),_0x2619e4+=8,_0x2a944b}}["_navigat"+t(1124)](){let n=t;return this[n(1151)+"T"]||this[n(416)+"X"]?this[n(359)+"igatorOn"+n(1729)]:(this[n(533)+"er"]||this._isWorker)&&this[n(1087)][n(1544)+n(703)+n(812)]?navigator[n(662)]:!0}[t(764)+t(1242)](){let n=t;!this._navigatorOnline()||this._readyClosed||(this["_endpoin"+n(326)]?.[n(1084)+n(287)+"fig"](),this._pingLossCounter?.["resetCou"+n(1145)](),this[n(313)]?this[n(1160)+"ect"](1001,n(1360)+"ay, try reconnec"+n(1712)+n(1121),!0):this[n(1174)]())}["_onPageNetWorkCh"+t(1004)](){let n=t;this[n(1151)+"T"]?tt[n(448)+"kStatusC"+n(1517)](({isConnected:s})=>{let d=n;this[d(359)+d(821)+d(1729)]=s,s?this["_handleO"+d(1092)]():this[d(944)+"ffLine"]()}):this[n(416)+"X"]&&wx["onNetworkStatusC"+n(1517)](({isConnected:s})=>{let d=n;this["_miniNav"+d(821)+d(1729)]=s,s?this[d(944)+d(1092)]():this[d(944)+d(1192)]()})}[t(1672)](n){let s={xjbwC:function(d,f){return e.cLrbS(d,f)},dteFT:function(d,f){return d*f}};return new Promise(d=>{let f=K;if(e[f(1681)](f(1379),e[f(382)]))setTimeout(d,this["_getInte"+f(677)+"e"](n));else return QMtBzD[f(654)](QMtBzD[f(1091)](1e4,_0x4983c3.now()),_0x1b105c.floor(QMtBzD[f(1091)](1e4,_0x872d2d.random())))})}[t(1160)+t(1252)](n=1e3,s="",d=!1){let f=t;if(e[f(707)](e.gSePi,f(912))){if(!this._ws)return;this[f(1383)+"WebSocket"](n,s,d)}else vamMZT.zRwms(_0x75f504,_0x329fe1[f(1256)]),_0x44891c()}_onTimeout(){let n=t,s=this[n(364)+n(326)]?.[n(1193)+n(1713)+"nt"]();this._debug(n(997)+s+" timeout"),this[n(1160)+n(1252)](1001,e[n(549)],!0)}[t(1491)](n){let s=t,d={oYpIr:s(1370)+"3",etbvo:function(f,p){return f||p},YgDZX:function(f,p){return f!=p}};if(e[s(516)]!==e.NAsib){let f=e[s(701)](Lt,n);this[s(313)]&&e[s(723)](this[s(313)][s(1294)+"te"],this.OPEN)&&(this[s(313)]&&this._ws[s(709)](f),this[s(1485)]("send_ack",n))}else{let f=d[s(471)].split("|"),p=0;for(;;){switch(f[p++]){case"0":if(_0x4a48c0&&_0x120aae[s(1048)+s(522)])return!0;continue;case"1":if(zwjyBG[s(1274)](_0x5a7c3e,_0x27fccc)&&zwjyBG[s(397)](s(531)+"d",typeof _0x22c7ec)&&_0x33b5c6)return!0;continue;case"2":if(_0x5bfaa2&&_0x2f2721[s(1048)+s(522)])return!0;continue;case"3":return!1;case"4":if(_0x303808)return!0;continue}break}}}[t(250)+t(586)+"rs"](){let n=t,s=e[n(927)][n(921)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(313)][n(513)+"entListe"+n(337)](e[n(517)],this[n(1489)+"ge"]);continue;case"1":this[n(313)]["removeEv"+n(1619)+n(337)](e.vbbhT,this._onOpen);continue;case"2":this[n(313)]["removeEv"+n(1619)+"ner"](e[n(1721)],this._onError);continue;case"3":this[n(313)][n(513)+n(1619)+n(337)](e.DgbjI,this[n(1367)]);continue;case"4":if(!this[n(313)])return;continue}break}}[t(670)+t(615)](){let n=t,s=e.GHjOT.split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(313)][n(1604)+n(863)](e.DgbjI,this[n(1367)]);continue;case"1":this[n(313)][n(1604)+n(863)](e[n(1721)],this[n(1540)]);continue;case"2":this._ws[n(1604)+"Listener"](n(251),this[n(463)]);continue;case"3":this[n(313)][n(1604)+"Listener"](e.LzOnL,this._onMessage);continue;case"4":if(!this[n(313)])return;continue}break}}["_wsInsta"+t(978)](n=1e3,s=""){let d=t,f={VEJTS:function(p,E){return p>E},OQoDq:function(p,E){return e[K(1336)](p,E)},Qirnm:function(p,E){return e.imfxa(p,E)},lDkKo:function(p,E,b,g){return e[K(843)](p,E,b,g)},QGEhJ:function(p,E){return e[K(349)](p,E)}};try{if(e[d(1246)]("TRuBB",d(1264))){if(pSfXiG[d(1311)](_0xc0735b,_0x3bb68f))throw new _0x424f6d(d(1709)+d(1496)+"e");let p=3;for(;pSfXiG[d(601)](p,0);){let E=pSfXiG[d(248)](255,_0x34c68a);pSfXiG[d(1122)](_0x10d06c,E,_0x28fc57,pSfXiG.QGEhJ(_0x211a8b,p)),_0x5b0afb>>>=8,p--}return _0x4c2a85+4}else this[d(313)]&&this[d(313)].close(n,s)}catch{}}[t(1383)+t(476)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(1096)+f(1288)](),this[f(1076)+f(1381)](),this[f(250)+"sListeners"](),this[f(440)+"nceClose"](1e3,s),this[f(1174)+f(473)]=!1,d&&this[f(826)+f(1124)]()&&!this[f(295)+f(1169)]){if(this[f(364)+f(326)]?.[f(293)+f(1384)+"es"]())if(e[f(707)](e[f(1456)],e[f(1204)])){let E=this[f(364)+f(326)]?.[f(1193)+"ntEndpoint"]();this[f(1476)+f(1046)+f(1039)](e.AJEEt(lt,e[f(570)],{code:1006,reason:"connect "+E+(f(538)+f(559)+f(249)+f(1259)),wasClean:!0}))}else return new _0x4559bf(e[f(1722)](e.bWtfJ(_0x12679a[4],24),e[f(464)](_0x4832c0[5],16))|e[f(1287)](_0x2d31b0[6],8)|_0x2f8ed6[7],e.xnykL(e[f(1512)](e[f(1182)](_0x1bdd10[0]<<24,_0x3ca9cc[1]<<16),e.irGEe(_0x2520e4[2],8)),_0x105a74[3]),_0x4f6560);else{let E=this[f(1087)][f(865)+"tInterce"+f(1566)](n,s);this._dispatchCloseEvent(lt(f(1671),{code:n,reason:s,wasClean:!0,willReconnect:E})),E&&this[f(1174)]()}return}this["_navigat"+f(1124)]()||this[f(295)+f(1169)]?this[f(1476)+f(1046)+f(1039)](e.llWFG(lt,e.DgbjI,{code:n,reason:e[f(922)]})):this["_dispatc"+f(1046)+"ent"](lt(e.DgbjI,{code:1006,reason:f(1360)+f(647)+f(753)+f(1201)})),this[f(313)]=null,this[f(364)+f(326)]?.[f(1084)+f(287)+f(277)](),this["_pingLos"+f(285)]?.resetCounter()}["_dispatc"+t(1454)+"nt"](n){let s=t,d={GDqCy:function(f,p,E){return e[K(1656)](f,p,E)}};if(e[s(881)](s(350),e.aQtbn))this.emit(e[s(1640)],n),this[s(1444)]&&this[s(1444)](n);else{let f=PBxNIY.GDqCy(_0x43809f,_0x178111,_0x535994);return _0x347468.bytes[s(1395)](f,f+_0x6b36e3)}}[t(1476)+t(1340)+"Event"](n){let s=t;this[s(1443)](e.LzOnL,n),this[s(966)+"e"]&&this[s(966)+"e"](n)}[t(1476)+t(459)+"ageEvent"](n){let s=t;this[s(1443)](e[s(793)],n),this[s(1450)+s(447)]&&this[s(1450)+s(447)](n)}[t(1476)+"hErrorEv"+t(1039)](n){let s=t;this[s(1443)](e[s(1721)],n),this[s(1626)]&&this.onerror(n)}[t(1476)+t(1046)+t(1039)](n){let s=t;this[s(1443)](s(1671),n),this[s(1616)]&&this[s(1616)](n)}get[t(1720)+"pe"](){let n=t;return this._ws?this[n(313)].binaryType:this["_binaryT"+n(1310)]}set[t(1720)+"pe"](n){let s=t,d={ygTXA:function(f,p){return e[K(1336)](f,p)}};if(e[s(699)]!==e[s(699)])return FRPHkX[s(252)](_0x57f88a[s(1371)],_0x2613b5[s(1063)]);this[s(1339)+"ype"]=n,this[s(313)]&&(this[s(313)].binaryType=n)}get[t(560)+"nt"](){let n=t;return this[n(364)+"tManager"]?.[n(1193)+n(1713)+n(811)+"ount"]()||0}get["buffered"+t(539)](){let n=t,s=this[n(1181)+"Queue"][n(1290)]((d,f)=>(d+=f&&f[n(872)+"th"]||0,d),0);return e[n(1293)](s,this._ws?this[n(313)]["buffered"+n(539)]:0)}get[t(633)+"ns"](){let n=t;return this._ws?this[n(313)][n(633)+"ns"]:""}get[t(1519)](){let n=t,s={fsaYU:function(d,f,p){return d(f,p)}};if(e.DqFpk!==e[n(1045)])FiNzLq.fsaYU(_0x401d25,_0xd6056e,82),FiNzLq.fsaYU(_0xec1374,_0x548c7c,_0x406334);else return this[n(313)]?this._ws[n(1519)]:""}get[t(1294)+"te"](){let n=t;if(e.fTWQJ===e[n(1594)])return this[n(313)]?this[n(313)][n(1294)+"te"]:this._options[n(896)+n(1478)]?this[n(1191)+"NG"]:this[n(961)];{let{initReconnectInterval:s,maxReconnectInterval:d,reconnectIntervalGrowFactor:f}=this._options,p=e.sneEC(s,_0x27013f[n(555)](f,_0x31dfe7-1));return e[n(1637)](p,d)?d:p}}get url(){let n=t;return this._ws?this[n(313)][n(950)]:this[n(425)]}[t(1671)](n=1e3,s){let d=t;if(this[d(295)+d(1169)]=!0,this["_clearTi"+d(1381)](),this[d(1096)+"ngTimer"](),this[d(593)+d(1710)+d(863)](),this[d(641)+d(512)]?.[d(568)](),!this[d(313)])return void this[d(1485)](e.POgiH);if(this[d(313)][d(1294)+"te"]===this[d(961)]||this[d(313)][d(1294)+"te"]===this.CLOSING)return void this._debug(e[d(1548)]);this["_destroy"+d(476)+"t"](n,s)}async[t(709)](n,s){let d=t;if(e[d(1194)](null,n))throw new Error(e[d(1100)]);e[d(1396)](d(441),typeof n)&&(n=JSON.stringify(n)),e.mbRFi(e[d(547)],typeof n)&&!(n instanceof ArrayBuffer)&&!(n.buffer&&e[d(770)](n.buffer,ArrayBuffer))&&(n=JSON[d(1547)+"y"](n));let f=await e.OlUIs(Kd,n),p=e[d(1300)](Kx,n),{method:E=0,service:b=this[d(1087)][d(1423)],logID:g=this[d(1087)][d(1433)+d(687)](),headers:O=this[d(1087)].headers,payloadEncoding:N=this[d(1087)][d(823)+"ncoding"],payloadType:F=this[d(1087)][d(1038)+d(1310)],logIDNew:G=this[d(1087)][d(600)+d(283)][d(810)+"toGenerateLogIDNew"]?e[d(1487)](i,this[d(1087)]["logIDNew"+d(283)][d(1239)]):""}=s||{};if(!b)throw new Error(e.GdsyV);let W={SeqID:ae[d(1427)+"er"](this[d(1416)]++),LogID:ae[d(1427)+"er"](g),service:b,method:E,headers:O,payloadEncoding:e[d(770)](N,Object)?N[d(1207)]?N.encoding:"":N,payloadType:e[d(660)](F,Object)?F[d(717)]?F.type:p:F||p,payload:f,LogIDNew:G},ye=e[d(583)](Lt,W);return this._ws&&e[d(1436)](this[d(313)].readyState,this.OPEN)?e[d(1681)](e[d(1662)],e[d(1662)])?(this[d(1055)]=_0x1a3175,this[d(270)]=_0x394077,this[d(934)]=_0x17888e):(this._ws&&this[d(313)].send(ye),this[d(1485)](e.zjWeg,W)):e[d(1361)](this["_message"+d(1400)][d(492)],this[d(1087)][d(1333)+d(390)+d(1680)])?e.JbHrL("rPMZr",e[d(515)])?(_0x41b3c6=_0x8c6f65[e[d(398)](_0x76f018,_0x52891e)+1],_0x35d0cb=_0x294a17[e[d(1250)](e.Nkdrf(_0x1436df,_0x811642),2)],e[d(1316)](e[d(1461)](e[d(906)](_0x2eb3b7,e[d(778)](_0x49e126,8)),49344),32896)?_0x57057e+=_0x440d4b:(_0xa2af73=e[d(1605)](e[d(998)](e[d(658)](e.uHZBL(15,_0x4d8335),12),e[d(1143)](e[d(595)](63,_0x460aae),6)),e.EMWsk(63,_0x129a3e)),e[d(809)](_0x4dde86,2048)||e[d(417)](_0xb305ed,55296)&&e.mFJJa(_0x44266d,57343)?_0x393acb+=_0x10d7b2:(_0x4f3b66+=_0x5af1ee(_0x8c6a08),_0x274156+=2))):(this[d(1181)+d(1400)][d(1426)](ye),this[d(1485)](e[d(1567)],W)):e[d(1305)]!==e[d(371)]?(this._messageQueue.shift(),this["_message"+d(1400)][d(1426)](ye)):this.on(_0x58971a,_0xc2ab3a),{seqID:this._seqId,logID:g,logIDNew:G}}async[t(865)+"t"](n){let s=t,d={JZBaw:e[s(1127)],cCPnW:function(f){return e.EikTZ(f)}};if(e.kvlLD(e[s(781)],e[s(781)]))this[s(1485)](CNncUR[s(847)],_0x4abd6b[s(689)]),CNncUR.cCPnW(_0x126bc8);else{let{url:f}=e.cFzQE(n,{}),p=Array[s(1553)](f)?f:e.VDmHj(e[s(547)],typeof f)?[f]:[];n&&Object[s(777)](this[s(1087)],n),p&&p[s(492)]?this[s(364)+s(326)]=new Hd(p,this[s(1087)][s(1301)+"es"]):this[s(364)+s(326)]?.["resetEnd"+s(287)+s(277)](),this[s(807)+"sCounter"]?.["resetCou"+s(1145)](this[s(1087)].pingLossCount),this[s(295)+"osed"]=!1,this._ws&&e[s(926)](this[s(313)][s(1294)+"te"],this.CLOSED)?this[s(1160)+s(1252)](1e3,e[s(1183)],!0):(this._isInit=!0,this._connect())}}async connect(){let n=t;if(!this["_connect"+n(473)]){let s=e[n(1435)][n(921)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(295)+"osed"]=!1;continue;case"1":this[n(1174)]();continue;case"2":this[n(364)+n(326)]?.["resetEnd"+n(287)+n(277)]();continue;case"3":this[n(807)+"sCounter"]?.["resetCou"+n(1145)]();continue;case"4":this._isInit=!0;continue}break}}}[t(1604)+"Listener"](n,s){this.on(n,s)}[t(1167)+t(1364)](n){let s=t,{type:d}=n;this[s(1443)](d,n)}["removeEv"+t(1619)+t(337)](n,s){this[t(744)](n,s)}[t(1304)](){let n=t,s={fQYKT:function(d,f){return d!==f},EgwcP:e.dIfRa,SgNpm:e.BzDpm,CuYJk:function(d,f){return e.usotR(d,f)},kBzPs:e[n(1330)],ceMIk:e.NHtUR,QVLZl:e[n(1374)],ljtIC:function(d,f){return e[n(1651)](d,f)},KHNWU:e[n(358)]};return new Promise((d,f)=>{let p=n;if(e[p(1277)](e[p(445)],e[p(445)])){if(this[p(1087)][p(1523)+p(253)+"nect"]||this[p(295)+"osed"])return;this[p(764)+"econnect"]()}else{this._clearPingTimer(),this[p(552)+p(1041)+"Id"]=setTimeout(this[p(1690)][p(424)](this),this._options["pingInte"+p(1068)]);let E=()=>{let g=p;if(s.fQYKT(s[g(1526)],s.SgNpm))s[g(1114)](d,s[g(1271)]),this[g(744)](s[g(765)],E),this[g(744)](s.QVLZl,b);else return this[g(1618)+"s"][this[g(1227)+g(888)]]},b=()=>{let g=p;s.ljtIC(f,s.KHNWU),this[g(744)](s[g(765)],E),this.off(s[g(794)],b)};this.on(p(1217)+p(451)+"s",E),this.on(e[p(1374)],b),this[p(1690)]()}})}}})(),Ne[M(373)+M(544)]=Te[M(373)+M(544)],Ne[M(1375)+M(543)]=Te[M(1375)+"rorEvent"],Ne.ErrorCode=Te[M(1678)+"e"],Ne[M(1364)]=Te[M(1364)],Ne[M(598)]=Te[M(598)],Ne[M(981)+M(746)+"vent"]=Te[M(981)+M(746)+M(255)],Ne[M(746)+M(255)]=Te[M(746)+"vent"],Ne.OpenEvent=Te.OpenEvent,Ne[M(1053)+M(958)]=Te.ReconnectEvent,Ne.createCloseEvent=Te["createCl"+M(544)],Ne[M(1663)+M(543)]=Te[M(1663)+M(543)],Ne[M(1424)+M(556)+"nt"]=Te[M(1424)+M(556)+"nt"],Ne[M(887)+M(760)]=Te[M(887)+M(760)],Ne[M(260)+M(1213)+M(255)]=Te["createReconnectE"+M(255)],Ne[M(1303)+M(1554)]=Te["decodedF"+M(1554)],Ne[M(895)+M(1455)]=Te[M(895)+M(1455)];for(go in Te)["CustomCl"+M(544),"CustomEr"+M(543),M(1678)+"e","Event",M(598),M(981)+M(746)+M(255),"MessageEvent",M(572)+"t","ReconnectEvent",M(897)+"oseEvent","createEr"+M(543),M(1424)+M(556)+"nt",M(887)+M(760),"createRe"+M(1213)+M(255),M(1303)+M(1554),M(895)+"ame"][M(1518)](go)===-1&&(Ne[go]=Te[go]);var go;Object.defineProperty(Ne,M(990)+"le",{value:!0})});var jt=ie((L3,K0)=>{"use strict";var j0=["nodebuffer","arraybuffer","fragments"],W0=typeof Blob<"u";W0&&j0.push("blob");K0.exports={BINARY_TYPES:j0,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:W0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Bi=ie((M3,vo)=>{"use strict";var{EMPTY_BUFFER:DE}=jt(),Xc=Buffer[Symbol.species];function kE(t,e){if(t.length===0)return DE;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 Xc(r.buffer,r.byteOffset,i):r}function $0(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function V0(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function OE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Qc(t){if(Qc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Xc(t):ArrayBuffer.isView(t)?e=new Xc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Qc.readOnly=!1),e}vo.exports={concat:kE,mask:$0,toArrayBuffer:OE,toBuffer:Qc,unmask:V0};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ce("bufferutil");vo.exports.mask=function(e,r,i,o,c){c<48?$0(e,r,i,o,c):t.mask(e,r,i,o,c)},vo.exports.unmask=function(e,r){e.length<32?V0(e,r):t.unmask(e,r)}}catch{}});var Y0=ie((B3,Z0)=>{"use strict";var J0=Symbol("kDone"),ed=Symbol("kRun"),td=class{constructor(e){this[J0]=()=>{this.pending--,this[ed]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ed]()}[ed](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[J0])}}};Z0.exports=td});var Rr=ie((z3,th)=>{"use strict";var zi=ce("zlib"),X0=Bi(),PE=Y0(),{kStatusCode:Q0}=jt(),NE=Buffer[Symbol.species],LE=Buffer.from([0,0,255,255]),Io=Symbol("permessage-deflate"),Wt=Symbol("total-length"),Ar=Symbol("callback"),_n=Symbol("buffers"),Tr=Symbol("error"),So,nd=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,!So){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;So=new PE(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[Ar];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){So.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){So.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=zi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Io]=this,this._inflate[Wt]=0,this._inflate[_n]=[],this._inflate.on("error",BE),this._inflate.on("data",eh)}this._inflate[Ar]=i,this._inflate.write(e),r&&this._inflate.write(LE),this._inflate.flush(()=>{let c=this._inflate[Tr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=X0.concat(this._inflate[_n],this._inflate[Wt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Wt]=0,this._inflate[_n]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=zi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Wt]=0,this._deflate[_n]=[],this._deflate.on("data",ME)}this._deflate[Ar]=i,this._deflate.write(e),this._deflate.flush(zi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=X0.concat(this._deflate[_n],this._deflate[Wt]);r&&(c=new NE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Ar]=null,this._deflate[Wt]=0,this._deflate[_n]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};th.exports=nd;function ME(t){this[_n].push(t),this[Wt]+=t.length}function eh(t){if(this[Wt]+=t.length,this[Io]._maxPayload<1||this[Wt]<=this[Io]._maxPayload){this[_n].push(t);return}this[Tr]=new RangeError("Max payload size exceeded"),this[Tr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Tr][Q0]=1009,this.removeListener("data",eh),this.reset()}function BE(t){if(this[Io]._inflate=null,this[Tr]){this[Ar](this[Tr]);return}t[Q0]=1007,this[Ar](t)}});var Cr=ie((F3,Ao)=>{"use strict";var{isUtf8:nh}=ce("buffer"),{hasBlob:zE}=jt(),FE=[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 UE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function rd(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 GE(t){return zE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Ao.exports={isBlob:GE,isValidStatusCode:UE,isValidUTF8:rd,tokenChars:FE};if(nh)Ao.exports.isValidUTF8=function(t){return t.length<24?rd(t):nh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ce("utf-8-validate");Ao.exports.isValidUTF8=function(e){return e.length<32?rd(e):t(e)}}catch{}});var cd=ie((U3,dh)=>{"use strict";var{Writable:HE}=ce("stream"),rh=Rr(),{BINARY_TYPES:qE,EMPTY_BUFFER:ih,kStatusCode:jE,kWebSocket:WE}=jt(),{concat:id,toArrayBuffer:KE,unmask:$E}=Bi(),{isValidStatusCode:VE,isValidUTF8:sh}=Cr(),To=Buffer[Symbol.species],at=0,oh=1,ah=2,ch=3,sd=4,od=5,Ro=6,ad=class extends HE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||qE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[WE]=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=at}_write(e,r,i){if(this._opcode===8&&this._state==at)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new To(i.buffer,i.byteOffset+e,i.length-e),new To(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 To(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 at:this.getInfo(e);break;case oh:this.getPayloadLength16(e);break;case ah:this.getPayloadLength64(e);break;case ch:this.getMask();break;case sd:this.getData(e);break;case od:case Ro:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[rh.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=oh:this._payloadLength===127?this._state=ah:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=ch:this._state=sd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=sd}getData(e){let r=ih;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&$E(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=od,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===at&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=at;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=id(i,r):this._binaryType==="arraybuffer"?o=KE(id(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=at):(this._state=Ro,setImmediate(()=>{this.emit("message",o,!0),this._state=at,this.startLoop(e)}))}else{let o=id(i,r);if(!this._skipUTF8Validation&&!sh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===od||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=at):(this._state=Ro,setImmediate(()=>{this.emit("message",o,!1),this._state=at,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ih),this.end();else{let i=e.readUInt16BE(0);if(!VE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new To(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!sh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=at;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=at):(this._state=Ro,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=at,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[jE]=o,l}};dh.exports=ad});var ud=ie((H3,fh)=>{"use strict";var{Duplex:G3}=ce("stream"),{randomFillSync:JE}=ce("crypto"),lh=Rr(),{EMPTY_BUFFER:ZE,kWebSocket:YE,NOOP:XE}=jt(),{isBlob:Dr,isValidStatusCode:QE}=Cr(),{mask:uh,toBuffer:Un}=Bi(),ct=Symbol("kByteLength"),eb=Buffer.alloc(4),Co=8*1024,Gn,kr=Co,yt=0,tb=1,nb=2,dd=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=yt,this.onerror=XE,this[YE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||eb,r.generateMask?r.generateMask(i):(kr===Co&&(Gn===void 0&&(Gn=Buffer.alloc(Co)),JE(Gn,0,Co),kr=0),i[0]=Gn[kr++],i[1]=Gn[kr++],i[2]=Gn[kr++],i[3]=Gn[kr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ct]!==void 0?u=r[ct]:(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?(uh(e,i,x,c,u),[x]):(uh(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=ZE;else{if(typeof e!="number"||!QE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ct]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yt?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):Dr(e)?(o=e.size,c=!1):(e=Un(e),o=e.length,c=Un.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ct]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==yt?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):Dr(e)?(o=e.size,c=!1):(e=Un(e),o=e.length,c=Un.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ct]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==yt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[lh.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Dr(e)?(u=e.size,h=!1):(e=Un(e),u=e.length,h=Un.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={[ct]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==yt?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ct],this._state=nb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(ld,this,u,o);return}this._bufferedBytes-=i[ct];let l=Un(c);r?this.dispatch(l,r,i,o):(this._state=yt,this.sendFrame(t.frame(l,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[lh.extensionName];this._bufferedBytes+=i[ct],this._state=tb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");ld(this,h,o);return}this._bufferedBytes-=i[ct],this._state=yt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===yt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ct],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ct],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};fh.exports=dd;function ld(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){ld(t,e,r),t.onerror(e)}});var Eh=ie((q3,yh)=>{"use strict";var{kForOnEventAttribute:Fi,kListener:fd}=jt(),hh=Symbol("kCode"),xh=Symbol("kData"),ph=Symbol("kError"),gh=Symbol("kMessage"),mh=Symbol("kReason"),Or=Symbol("kTarget"),wh=Symbol("kType"),_h=Symbol("kWasClean"),Kt=class{constructor(e){this[Or]=null,this[wh]=e}get target(){return this[Or]}get type(){return this[wh]}};Object.defineProperty(Kt.prototype,"target",{enumerable:!0});Object.defineProperty(Kt.prototype,"type",{enumerable:!0});var Hn=class extends Kt{constructor(e,r={}){super(e),this[hh]=r.code===void 0?0:r.code,this[mh]=r.reason===void 0?"":r.reason,this[_h]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[hh]}get reason(){return this[mh]}get wasClean(){return this[_h]}};Object.defineProperty(Hn.prototype,"code",{enumerable:!0});Object.defineProperty(Hn.prototype,"reason",{enumerable:!0});Object.defineProperty(Hn.prototype,"wasClean",{enumerable:!0});var Pr=class extends Kt{constructor(e,r={}){super(e),this[ph]=r.error===void 0?null:r.error,this[gh]=r.message===void 0?"":r.message}get error(){return this[ph]}get message(){return this[gh]}};Object.defineProperty(Pr.prototype,"error",{enumerable:!0});Object.defineProperty(Pr.prototype,"message",{enumerable:!0});var Ui=class extends Kt{constructor(e,r={}){super(e),this[xh]=r.data===void 0?null:r.data}get data(){return this[xh]}};Object.defineProperty(Ui.prototype,"data",{enumerable:!0});var ib={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Fi]&&o[fd]===e&&!o[Fi])return;let i;if(t==="message")i=function(c,l){let u=new Ui("message",{data:l?c:c.toString()});u[Or]=this,Do(e,this,u)};else if(t==="close")i=function(c,l){let u=new Hn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Or]=this,Do(e,this,u)};else if(t==="error")i=function(c){let l=new Pr("error",{error:c,message:c.message});l[Or]=this,Do(e,this,l)};else if(t==="open")i=function(){let c=new Kt("open");c[Or]=this,Do(e,this,c)};else return;i[Fi]=!!r[Fi],i[fd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[fd]===e&&!r[Fi]){this.removeListener(t,r);break}}};yh.exports={CloseEvent:Hn,ErrorEvent:Pr,Event:Kt,EventTarget:ib,MessageEvent:Ui};function Do(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ko=ie((j3,bh)=>{"use strict";var{tokenChars:Gi}=Cr();function Nt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function sb(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,x=-1,_=-1,m=0;for(;m<t.length;m++)if(x=t.charCodeAt(m),l===void 0)if(_===-1&&Gi[x]===1)h===-1&&(h=m);else if(m!==0&&(x===32||x===9))_===-1&&h!==-1&&(_=m);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${m}`);_===-1&&(_=m);let y=t.slice(h,_);x===44?(Nt(e,y,r),r=Object.create(null)):l=y,h=_=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(u===void 0)if(_===-1&&Gi[x]===1)h===-1&&(h=m);else if(x===32||x===9)_===-1&&h!==-1&&(_=m);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${m}`);_===-1&&(_=m),Nt(r,t.slice(h,_),!0),x===44&&(Nt(e,l,r),r=Object.create(null),l=void 0),h=_=-1}else if(x===61&&h!==-1&&_===-1)u=t.slice(h,m),h=_=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){if(Gi[x]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);h===-1?h=m:i||(i=!0),o=!1}else if(c)if(Gi[x]===1)h===-1&&(h=m);else if(x===34&&h!==-1)c=!1,_=m;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(x===34&&t.charCodeAt(m-1)===61)c=!0;else if(_===-1&&Gi[x]===1)h===-1&&(h=m);else if(h!==-1&&(x===32||x===9))_===-1&&(_=m);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${m}`);_===-1&&(_=m);let y=t.slice(h,_);i&&(y=y.replace(/\\/g,""),i=!1),Nt(r,u,y),x===44&&(Nt(e,l,r),r=Object.create(null),l=void 0),u=void 0,h=_=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(h===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=m);let A=t.slice(h,_);return l===void 0?Nt(e,A,r):(u===void 0?Nt(r,A,!0):i?Nt(r,u,A.replace(/\\/g,"")):Nt(r,u,A),Nt(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(", ")}bh.exports={format:ob,parse:sb}});var Lo=ie(($3,Nh)=>{"use strict";var ab=ce("events"),cb=ce("https"),db=ce("http"),Ih=ce("net"),lb=ce("tls"),{randomBytes:ub,createHash:fb}=ce("crypto"),{Duplex:W3,Readable:K3}=ce("stream"),{URL:hd}=ce("url"),yn=Rr(),hb=cd(),xb=ud(),{isBlob:pb}=Cr(),{BINARY_TYPES:vh,CLOSE_TIMEOUT:gb,EMPTY_BUFFER:Oo,GUID:mb,kForOnEventAttribute:xd,kListener:wb,kStatusCode:_b,kWebSocket:Fe,NOOP:Ah}=jt(),{EventTarget:{addEventListener:yb,removeEventListener:Eb}}=Eh(),{format:bb,parse:vb}=ko(),{toBuffer:Sb}=Bi(),Th=Symbol("kAborted"),pd=[8,13],$t=["CONNECTING","OPEN","CLOSING","CLOSED"],Ib=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,xe=class t extends ab{constructor(e,r,i){super(),this._binaryType=vh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Oo,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Rh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vh.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new hb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new xb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Fe]=this,c[Fe]=this,e[Fe]=this,o.on("conclude",Rb),o.on("drain",Cb),o.on("error",Db),o.on("message",kb),o.on("ping",Ob),o.on("pong",Pb),c.onerror=Nb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",kh),e.on("data",No),e.on("end",Oh),e.on("error",Ph),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[yn.extensionName]&&this._extensions[yn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){nt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Dh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){gd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Oo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){gd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Oo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){gd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[yn.extensionName]||(o.compress=!1),this._sender.send(e||Oo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){nt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(xe,"CONNECTING",{enumerable:!0,value:$t.indexOf("CONNECTING")});Object.defineProperty(xe.prototype,"CONNECTING",{enumerable:!0,value:$t.indexOf("CONNECTING")});Object.defineProperty(xe,"OPEN",{enumerable:!0,value:$t.indexOf("OPEN")});Object.defineProperty(xe.prototype,"OPEN",{enumerable:!0,value:$t.indexOf("OPEN")});Object.defineProperty(xe,"CLOSING",{enumerable:!0,value:$t.indexOf("CLOSING")});Object.defineProperty(xe.prototype,"CLOSING",{enumerable:!0,value:$t.indexOf("CLOSING")});Object.defineProperty(xe,"CLOSED",{enumerable:!0,value:$t.indexOf("CLOSED")});Object.defineProperty(xe.prototype,"CLOSED",{enumerable:!0,value:$t.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(xe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(xe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[xd])return e[wb];return null},set(e){for(let r of this.listeners(t))if(r[xd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[xd]:!0})}})});xe.prototype.addEventListener=yb;xe.prototype.removeEventListener=Eb;Nh.exports=xe;function Rh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:gb,protocolVersion:pd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!pd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${pd.join(", ")})`);let c;if(e instanceof hd)c=e;else try{c=new hd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",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,_=ub(16).toString("base64"),m=l?cb.request:db.request,A=new Set,y;if(o.createConnection=o.createConnection||(l?Tb:Ab),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":_,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new yn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=bb({[yn.extensionName]:y.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Ib.test(I)||A.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,R]of Object.entries(I))i.headers[S.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=m(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=m(o);o.timeout&&v.on("timeout",()=>{nt(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Th]||(v=t._req=null,Po(t,I))}),v.on("response",I=>{let S=I.headers.location,R=I.statusCode;if(S&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){nt(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new hd(S,e)}catch{let C=new SyntaxError(`Invalid URL: ${S}`);Po(t,C);return}Rh(t,P,r,i)}else t.emit("unexpected-response",v,I)||nt(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,R)=>{if(t.emit("upgrade",I),t.readyState!==xe.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){nt(t,S,"Invalid Upgrade header");return}let w=fb("sha1").update(_+mb).digest("base64");if(I.headers["sec-websocket-accept"]!==w){nt(t,S,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],D;if(C!==void 0?A.size?A.has(C)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":A.size&&(D="Server sent no subprotocol"),D){nt(t,S,D);return}C&&(t._protocol=C);let L=I.headers["sec-websocket-extensions"];if(L!==void 0){if(!y){nt(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=vb(L)}catch{nt(t,S,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(B);if(V.length!==1||V[0]!==yn.extensionName){nt(t,S,"Server indicated an extension that was not requested");return}try{y.accept(B[yn.extensionName])}catch{nt(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[yn.extensionName]=y}t.setSocket(S,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Po(t,e){t._readyState=xe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ab(t){return t.path=t.socketPath,Ih.connect(t)}function Tb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ih.isIP(t.host)?"":t.host),lb.connect(t)}function nt(t,e,r){t._readyState=xe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,nt),e.setHeader?(e[Th]=!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 gd(t,e,r){if(e){let i=pb(e)?e.size:Sb(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${$t[t.readyState]})`);process.nextTick(r,i)}}function Rb(t,e){let r=this[Fe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Fe]!==void 0&&(r._socket.removeListener("data",No),process.nextTick(Ch,r._socket),t===1005?r.close():r.close(t,e))}function Cb(){let t=this[Fe];t.isPaused||t._socket.resume()}function Db(t){let e=this[Fe];e._socket[Fe]!==void 0&&(e._socket.removeListener("data",No),process.nextTick(Ch,e._socket),e.close(t[_b])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Sh(){this[Fe].emitClose()}function kb(t,e){this[Fe].emit("message",t,e)}function Ob(t){let e=this[Fe];e._autoPong&&e.pong(t,!this._isServer,Ah),e.emit("ping",t)}function Pb(t){this[Fe].emit("pong",t)}function Ch(t){t.resume()}function Nb(t){let e=this[Fe];e.readyState!==xe.CLOSED&&(e.readyState===xe.OPEN&&(e._readyState=xe.CLOSING,Dh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Dh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function kh(){let t=this[Fe];if(this.removeListener("close",kh),this.removeListener("data",No),this.removeListener("end",Oh),t._readyState=xe.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[Fe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Sh),t._receiver.on("finish",Sh))}function No(t){this[Fe]._receiver.write(t)||this.pause()}function Oh(){let t=this[Fe];t._readyState=xe.CLOSING,t._receiver.end(),this.end()}function Ph(){let t=this[Fe];this.removeListener("error",Ph),this.on("error",Ah),t&&(t._readyState=xe.CLOSING,this.destroy())}});var zh=ie((J3,Bh)=>{"use strict";var V3=Lo(),{Duplex:Lb}=ce("stream");function Lh(t){t.emit("close")}function Mb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Mh(t){this.removeListener("error",Mh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Bb(t,e){let r=!0,i=new Lb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Lh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(Lh,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",Mb),i.on("error",Mh),i}Bh.exports=Bb});var md=ie((Z3,Fh)=>{"use strict";var{tokenChars:zb}=Cr();function Fb(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&&zb[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Fh.exports={parse:Fb}});var Kh=ie((X3,Wh)=>{"use strict";var Ub=ce("events"),Mo=ce("http"),{Duplex:Y3}=ce("stream"),{createHash:Gb}=ce("crypto"),Uh=ko(),qn=Rr(),Hb=md(),qb=Lo(),{CLOSE_TIMEOUT:jb,GUID:Wb,kWebSocket:Kb}=jt(),$b=/^[+/0-9A-Za-z]{22}==$/,Gh=0,Hh=1,jh=2,wd=class extends Ub{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:jb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:qb,...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=Mo.createServer((i,o)=>{let c=Mo.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=Vb(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=Gh}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===jh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Hi,this);return}if(e&&this.once("close",e),this._state!==Hh)if(this._state=Hh,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Hi,this):process.nextTick(Hi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Hi(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",qh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){jn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){jn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!$b.test(c)){jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){qi(r,400);return}let h=e.headers["sec-websocket-protocol"],x=new Set;if(h!==void 0)try{x=Hb.parse(h)}catch{jn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],m={};if(this.options.perMessageDeflate&&_!==void 0){let A=new qn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Uh.parse(_);y[qn.extensionName]&&(A.accept(y[qn.extensionName]),m[qn.extensionName]=A)}catch{jn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(y,v,I,S)=>{if(!y)return qi(r,v||401,I,S);this.completeUpgrade(m,c,x,e,r,i,o)});return}if(!this.options.verifyClient(A))return qi(r,401)}this.completeUpgrade(m,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[Kb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gh)return qi(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Gb("sha1").update(r+Wb).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(i.size){let m=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;m&&(x.push(`Sec-WebSocket-Protocol: ${m}`),_._protocol=m)}if(e[qn.extensionName]){let m=e[qn.extensionName].params,A=Uh.format({[qn.extensionName]:[m]});x.push(`Sec-WebSocket-Extensions: ${A}`),_._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&Qi(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 Gp,mkdirSync as qp}from"node:fs";import{join as Hp}from"node:path";function nl(t){let e=t.retentionDays??Kp,r=t.clock??(()=>In(new Date));ts={bridgeSink:new jr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new jr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();Qi(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])Qi(t.agentLogsDir(o),"agent",i,e)}function $p(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function rl(t){wa=t}function il(t){return Qn[wa]<=Qn[t]}function sl(t,e){let r=Qn[t];return r===void 0?!0:r>=Qn[e]}function ns(t){tl={...t}}function ol(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${In(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Wr(t,e,r,i,o){try{let c=`${JSON.stringify({ts:ol(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;qp(t,{recursive:!0}),Gp(Hp(t,Xn("bridge",In(new Date))),c)}catch{}}function Vp(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function es(t,e,r,i,o){if(Qn[t]<Qn[wa])return;let c=`${JSON.stringify({ts:ol(new Date),level:t,module:e,msg:r,...tl,...i})}
|
|
12
|
+
`;if(ts){let l=Vp(o,i),u=l?$p(ts,l):ts.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Wp.write(c):jp.write(c)}function G(t,e){return{debug:(r,i)=>es("debug",t,r,i,e),info:(r,i)=>es("info",t,r,i,e),warn:(r,i)=>es("warn",t,r,i,e),error:(r,i)=>es("error",t,r,i,e),child:r=>G(`${t}.${r}`,e),forAgent:r=>G(t,r)}}var Qn,wa,jp,Wp,tl,Kp,ts,ne=Ze(()=>{"use strict";Xi();ma();Qn={debug:10,info:20,warn:30,error:40},wa=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),jp=process.stdout,Wp=process.stderr,tl={},Kp=Ft("COZE_BRIDGE_LOG_RETENTION_DAYS",30),ts=null});var T,Ke=Ze(()=>{"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 ll={};pa(ll,{ACP_WRAPPER_NPM_PACKAGES:()=>$r,_resetAcpInstallerForTests:()=>eg,_setBinaryPathCacheForTests:()=>tg,buildAcpSpawn:()=>Vr,ensureAcpInstalled:()=>er,getAcpBinaryPath:()=>rs,pickWhichLine:()=>Ea,probeAcpVersion:()=>Qp,resolveAcpCommand:()=>dl});import{readFileSync as al}from"node:fs";import{createRequire as Jp}from"node:module";import{dirname as Zp,resolve as Yp}from"node:path";function Ea(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function Xp(t){let e=cl.resolve(`${t.npmPackage}/package.json`),r=Zp(e),i=JSON.parse(al(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 Yp(r,o)}async function er(t,e){let r=ya[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Kr.get(t);if(i)return i;try{let o=Xp(r);return Kr.set(t,o),_a.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw _a.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 Qp(t){let e=ya[t];if(e)try{let r=cl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(al(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){_a.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function rs(t){return Kr.get(t)}function dl(t,e){if(e)return e;let r=rs(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 Vr(t,e,r){if(e)return{command:e,args:[...r]};let i=dl(t);return{command:process.execPath,args:[i,...r]}}function eg(){Kr.clear()}function tg(t,e){Kr.set(t,e)}var _a,ya,$r,cl,Kr,nn=Ze(()=>{"use strict";Ke();ne();_a=G("agents.acp-installer"),ya={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},$r=Object.values(ya).filter(t=>t!==void 0).map(t=>t.npmPackage),cl=Jp(import.meta.url),Kr=new Map});import{chmod as rg,mkdir as ig,readFile as sg,rename as xl,writeFile as hl}from"node:fs/promises";import{dirname as og}from"node:path";async function tr(t){try{let e=await sg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nr(t,e,r){await ig(og(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await hl(o,i,{encoding:"utf8",mode:r.mode}):await hl(o,i,"utf8"),await xl(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await xl(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Jr=Ze(()=>{"use strict"});import{promises as pl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as Te,resolve as gl}from"node:path";function X(t){let e=t??cg(),r=Te(e,".coze"),i=Te(r,"bridge"),o=Te(i,"lib"),c=Te(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Te(o,"index.js"),binDir:Te(i,"bin"),pidFile:Te(i,"bridge.pid"),portFile:Te(i,"bridge.port"),tokenFile:Te(i,"bridge.token"),patTokenFile:Te(i,"pat-token"),agentEnvFile:Te(i,"agent-env.json"),logFile:Te(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Te(c,"daemon-stdio.log"),installLock:Te(i,"install.lock"),configFile:Te(i,"config.json"),agentsRoot:Te(r,"agents")}}function $e(t,e=X()){let r=Te(e.agentsRoot,t);return{root:r,config:Te(r,"config.json"),workspace:Te(r,"workspace"),logs:Te(r,"logs")}}function is(t=X()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Zr(t,e){let r=await pl.realpath(gl(t)).catch(()=>null);if(!r)return!1;let i=await pl.realpath(gl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+dg)}var Oe=Ze(()=>{"use strict"});var as={};pa(as,{AGENT_CONFIG_FILE_MODE:()=>ss,enforceAgentConfigMode:()=>fg,loadAgentConfig:()=>He,persistAgentSessions:()=>Yr,persistAgentSkills:()=>os,saveAgentConfig:()=>Ye});import{chmod as lg,stat as ug}from"node:fs/promises";function He(t,e){return tr($e(t,e).config)}function Ye(t,e){return nr($e(t.agentId,e).config,t,{mode:ss})}async function fg(t,e){if(process.platform==="win32")return;let r=$e(t,e).config;try{let i=await ug(r);if(!i.isFile())return;let o=i.mode&511;o!==ss&&(await lg(r,ss),ml.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;ml.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Yr(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await Ye(i,r))}async function os(t,e,r){let i=await He(t,r);i&&(i.skills=e,await Ye(i,r))}var ml,ss,rn=Ze(()=>{"use strict";Jr();ne();Oe();ml=G("agent-config"),ss=384});var va=se((M1,El)=>{El.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 ds=se(vl=>{var bl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function mg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(bl))vl[t]=mg(bl[t])});var Cl=se((z1,Tl)=>{var wg=de("fs"),Pe=de("path"),Sl=va(),_g=ds(),yg=typeof process=="object"&&process.platform==="win32",Al=t=>typeof t=="object"&&t!==null,Il=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 be(t){this.sep=Pe.sep,this.fs=wg,Al(t)&&Al(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Tl.exports=be;be.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)};be.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};be.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,x){if(l&&x.isDirectory())return o(!1);var p=Pe.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(_,I){_?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(E,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):I?c.fs.write(I,e,0,e.length,0,function(){c.fs.close(I,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};be.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 x=Pe.join(i,u),p=e.fs.statSync(x);(!o||o.test(x))&&l.push(Pe.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};be.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(x,p){if(x)return e(x);p&&(i.push(Pe.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(w,_){if(w)return e(w);i=i.concat(_),--l||e(null,i)}):--l||e(null,i))})})})};be.prototype.getAttributes=function(){};be.prototype.setAttributes=function(){};be.crc32update=function(t,e){return Il[(t^e)&255]^t>>>8};be.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=be.crc32update(r,t[i++]);return~r>>>0};be.methodToString=function(t){switch(t){case Sl.STORED:return"STORED ("+t+")";case Sl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};be.canonical=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.join(".",e)};be.zipnamefix=function(t){if(!t)return"";let e=Pe.posix.normalize("/"+t.split("\\").join("/"));return Pe.posix.join(".",e)};be.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]};be.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)))};be.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};be.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};be.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)};be.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};be.isWin=yg;be.crcTable=Il});var Rl=se((F1,Dl)=>{var Eg=de("path");Dl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Eg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ol=se((U1,kl)=>{kl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=se((G1,ir)=>{ir.exports=Cl();ir.exports.Constants=va();ir.exports.Errors=ds();ir.exports.FileAttr=Rl();ir.exports.decoder=Ol()});var Ll=se((q1,Pl)=>{var sn=sr(),U=sn.Constants;Pl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,x=0,p=0,w=0,_=0,I=0,E=0,v=0;t|=sn.isWin?2560:768,r|=U.FLG_EFS;let A={extraLen:0},S=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=sn.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&U.FLG_EFS)>0},set flags_efs(y){y?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(y){y?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(y){switch(y){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=y},get time(){return sn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=sn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=S(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=S(y)},get compressedSize(){return l},set compressedSize(y){l=S(y)},get size(){return u},set size(y){u=S(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return A.extraLen},set extraLocalLength(y){A.extraLen=y},get commentLength(){return w},set commentLength(y){w=y},get diskNumStart(){return _},set diskNumStart(y){_=S(y)},get inAttr(){return I},set inAttr(y){I=S(y)},get attr(){return E},set attr(y){E=S(y)},get fileAttr(){return(E||0)>>16&4095},get offset(){return v},set offset(y){v=S(y)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+x+p+w},get realDataOffset(){return v+U.LOCHDR+A.fnameLen+A.extraLen},get localHeader(){return A},loadLocalHeaderFromBinary:function(y){var D=y.slice(v,v+U.LOCHDR);if(D.readUInt32LE(0)!==U.LOCSIG)throw sn.Errors.INVALID_LOC();A.version=D.readUInt16LE(U.LOCVER),A.flags=D.readUInt16LE(U.LOCFLG),A.flags_desc=(A.flags&U.FLG_DESC)>0,A.method=D.readUInt16LE(U.LOCHOW),A.time=D.readUInt32LE(U.LOCTIM),A.crc=D.readUInt32LE(U.LOCCRC),A.compressedSize=D.readUInt32LE(U.LOCSIZ),A.size=D.readUInt32LE(U.LOCLEN),A.fnameLen=D.readUInt16LE(U.LOCNAM),A.extraLen=D.readUInt16LE(U.LOCEXT);let k=v+U.LOCHDR+A.fnameLen,M=k+A.extraLen;return y.slice(k,M)},loadFromBinary:function(y){if(y.length!==U.CENHDR||y.readUInt32LE(0)!==U.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(U.CENVEM),e=y.readUInt16LE(U.CENVER),r=y.readUInt16LE(U.CENFLG),i=y.readUInt16LE(U.CENHOW),o=y.readUInt32LE(U.CENTIM),c=y.readUInt32LE(U.CENCRC),l=y.readUInt32LE(U.CENSIZ),u=y.readUInt32LE(U.CENLEN),x=y.readUInt16LE(U.CENNAM),p=y.readUInt16LE(U.CENEXT),w=y.readUInt16LE(U.CENCOM),_=y.readUInt16LE(U.CENDSK),I=y.readUInt16LE(U.CENATT),E=y.readUInt32LE(U.CENATX),v=y.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(U.LOCHDR);return y.writeUInt32LE(U.LOCSIG,0),y.writeUInt16LE(e,U.LOCVER),y.writeUInt16LE(r,U.LOCFLG),y.writeUInt16LE(i,U.LOCHOW),y.writeUInt32LE(o,U.LOCTIM),y.writeUInt32LE(c,U.LOCCRC),y.writeUInt32LE(l,U.LOCSIZ),y.writeUInt32LE(u,U.LOCLEN),y.writeUInt16LE(x,U.LOCNAM),y.writeUInt16LE(A.extraLen,U.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(U.CENHDR+x+p+w);return y.writeUInt32LE(U.CENSIG,0),y.writeUInt16LE(t,U.CENVEM),y.writeUInt16LE(e,U.CENVER),y.writeUInt16LE(r,U.CENFLG),y.writeUInt16LE(i,U.CENHOW),y.writeUInt32LE(o,U.CENTIM),y.writeUInt32LE(c,U.CENCRC),y.writeUInt32LE(l,U.CENSIZ),y.writeUInt32LE(u,U.CENLEN),y.writeUInt16LE(x,U.CENNAM),y.writeUInt16LE(p,U.CENEXT),y.writeUInt16LE(w,U.CENCOM),y.writeUInt16LE(_,U.CENDSK),y.writeUInt16LE(I,U.CENATT),y.writeUInt32LE(E,U.CENATX),y.writeUInt32LE(v,U.CENOFF),y},toJSON:function(){let y=function(D){return D+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(x),extraLength:y(p),commentLength:y(w),diskNumStart:_,inAttr:I,attr:E,offset:v,centralHeaderSize:y(U.CENHDR+x+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ml=se((H1,Nl)=>{var or=sr(),we=or.Constants;Nl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return we.ENDHDR+o},loadFromBinary:function(c){if((c.length!==we.ENDHDR||c.readUInt32LE(0)!==we.ENDSIG)&&(c.length<we.ZIP64HDR||c.readUInt32LE(0)!==we.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===we.ENDSIG?(t=c.readUInt16LE(we.ENDSUB),e=c.readUInt16LE(we.ENDTOT),r=c.readUInt32LE(we.ENDSIZ),i=c.readUInt32LE(we.ENDOFF),o=c.readUInt16LE(we.ENDCOM)):(t=or.readBigUInt64LE(c,we.ZIP64SUB),e=or.readBigUInt64LE(c,we.ZIP64TOT),r=or.readBigUInt64LE(c,we.ZIP64SIZE),i=or.readBigUInt64LE(c,we.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(we.ENDHDR+o);return c.writeUInt32LE(we.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,we.ENDSUB),c.writeUInt16LE(e,we.ENDTOT),c.writeUInt32LE(r,we.ENDSIZ),c.writeUInt32LE(i,we.ENDOFF),c.writeUInt16LE(o,we.ENDCOM),c.fill(" ",we.ENDHDR),c},toJSON:function(){let c=function(l,u){let x=l.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 Aa=se(Sa=>{Sa.EntryHeader=Ll();Sa.MainHeader=Ml()});var zl=se((W1,Bl)=>{Bl.exports=function(t){var e=de("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),x=0;u.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(u,x),x+=w.length}i&&i(u)}),o.end(t)}}}});var Ul=se((K1,Fl)=>{var bg=+(process.versions?process.versions.node:"").split(".")[0]||0;Fl.exports=function(t,e){var r=de("zlib");let i=bg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(x){l.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var w=0;w<l.length;w++){var _=l[w];_.copy(x,p),p+=_.length}o&&o(x)}),c.end(t)}}}});var Wl=se(($1,jl)=>{"use strict";var{randomFillSync:Gl}=de("crypto"),vg=ds(),Sg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Hl=(t,e)=>Math.imul(t,e)>>>0,ql=(t,e)=>Sg[(t^e)&255]^t>>>8,Xr=()=>typeof Gl=="function"?Gl(Buffer.alloc(12)):Xr.node();Xr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ls={genSalt:Xr};function us(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])}us.prototype.updateKeys=function(t){let e=this.keys;return e[0]=ql(e[0],t),e[1]+=e[0]&255,e[1]=Hl(e[1],134775813)+1,e[2]=ql(e[2],e[1]>>>24),t};us.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Hl(t,t^1)>>8&255};function Ag(t){let e=new us(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 Ig(t){let e=new us(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ag(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Cg(t){Buffer.isBuffer(t)&&t.length>=12?ls.genSalt=function(){return t.slice(0,12)}:t==="node"?ls.genSalt=Xr.node:ls.genSalt=Xr}function Dg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ig(r),c=ls.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}jl.exports={decrypt:Tg,encrypt:Dg,_salter:Cg}});var Kl=se(fs=>{fs.Deflater=zl();fs.Inflater=Ul();fs.ZipCrypto=Wl()});var Ta=se((J1,$l)=>{var oe=sr(),Rg=Aa(),ve=oe.Constants,Ia=Kl();$l.exports=function(t,e){var r=new Rg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let w=t,_=typeof w.decoder=="object"?w.decoder:oe.decoder;p=_.hasOwnProperty("efs")?_.efs:!1;function I(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function E(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(oe.crc32(y)!==r.localHeader.crc)return!1}else{let D={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==ve.LOCSIG||e.readUInt32LE(k)==ve.CENSIG)throw oe.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==ve.EXTSIG)D.crc=e.readUInt32LE(k+ve.EXTCRC),D.compressedSize=e.readUInt32LE(k+ve.EXTSIZ),D.size=e.readUInt32LE(k+ve.EXTLEN);else if(e.readUInt16LE(k+12)===19280)D.crc=e.readUInt32LE(k+ve.EXTCRC-4),D.compressedSize=e.readUInt32LE(k+ve.EXTSIZ-4),D.size=e.readUInt32LE(k+ve.EXTLEN-4);else throw oe.Errors.DESCRIPTOR_UNKNOWN();if(D.compressedSize!==r.compressedSize||D.size!==r.size||D.crc!==r.crc)throw oe.Errors.DESCRIPTOR_FAULTY();if(oe.crc32(y)!==D.crc)return!1}return!0}function v(y,D,k){if(typeof D>"u"&&typeof y=="string"&&(k=y,y=void 0),c)return y&&D&&D(Buffer.alloc(0),oe.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=I();if(M.length===0)return y&&D&&D(M),M;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw oe.Errors.INVALID_PASS_PARAM();M=Ia.ZipCrypto.decrypt(M,r,k)}var B=Buffer.alloc(r.size);switch(r.method){case oe.Constants.STORED:if(M.copy(B),E(B))return y&&D&&D(B),B;throw y&&D&&D(B,oe.Errors.BAD_CRC()),oe.Errors.BAD_CRC();case oe.Constants.DEFLATED:var $=new Ia.Inflater(M,r.size);if(y)$.inflateAsync(function(V){V.copy(V,0),D&&(E(V)?D(V):D(V,oe.Errors.BAD_CRC()))});else{if($.inflate(B).copy(B,0),!E(B))throw oe.Errors.BAD_CRC(`"${_.decode(i)}"`);return B}break;default:throw y&&D&&D(Buffer.alloc(0),oe.Errors.UNKNOWN_METHOD()),oe.Errors.UNKNOWN_METHOD()}}function A(y,D){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&D&&D(I()),I();if(l.length&&!c){var k;switch(r.method){case oe.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),y&&D&&D(k),k;default:case oe.Constants.DEFLATED:var M=new Ia.Deflater(l);if(y)M.deflateAsync(function($){k=Buffer.alloc($.length),r.compressedSize=$.length,$.copy(k),D&&D(k)});else{var B=M.deflate();return r.compressedSize=B.length,B}M=null;break}}else if(y&&D)D(Buffer.alloc(0));else return Buffer.alloc(0)}function S(y,D){return oe.readBigUInt64LE(y,D)}function C(y){try{for(var D=0,k,M,B;D+4<y.length;)k=y.readUInt16LE(D),D+=2,M=y.readUInt16LE(D),D+=2,B=y.slice(D,D+M),D+=M,ve.ID_ZIP64===k&&P(B)}catch{throw oe.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var D,k,M,B;y.length>=ve.EF_ZIP64_SCOMP&&(D=S(y,ve.EF_ZIP64_SUNCOMP),r.size===ve.EF_ZIP64_OR_32&&(r.size=D)),y.length>=ve.EF_ZIP64_RHO&&(k=S(y,ve.EF_ZIP64_SCOMP),r.compressedSize===ve.EF_ZIP64_OR_32&&(r.compressedSize=k)),y.length>=ve.EF_ZIP64_DSN&&(M=S(y,ve.EF_ZIP64_RHO),r.offset===ve.EF_ZIP64_OR_32&&(r.offset=M)),y.length>=ve.EF_ZIP64_DSN+4&&(B=y.readUInt32LE(ve.EF_ZIP64_DSN),r.diskNumStart===ve.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(y){i=oe.toBuffer(y,_.encode);var D=i[i.length-1];c=D===47||D===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,C(y)},get comment(){return _.decode(o)},set comment(y){if(o=oe.toBuffer(y,_.encode),r.commentLength=o.length,o.length>65535)throw oe.Errors.COMMENT_TOO_LONG()},get name(){var y=_.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return A(!1,null)},getCompressedDataAsync:function(y){A(!0,y)},setData:function(y){l=oe.toBuffer(y,oe.decoder.encode),!c&&l.length?(r.size=l.length,r.method=oe.Constants.DEFLATED,r.crc=oe.crc32(y),r.changed=!0):r.method=oe.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,D){r.changed?y(l):v(!0,y,D)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),D=oe.Constants.CENHDR;return i.copy(y,D),D+=i.length,u.copy(y,D),D+=r.extraLength,o.copy(y,D),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let D=r.localHeaderToBinary(),k=Buffer.alloc(D.length+i.length+r.extraLocalLength);return D.copy(k,y),y+=D.length,i.copy(k,y),y+=i.length,x.copy(k,y),y+=x.length,k},toJSON:function(){let y=function(D){return"<"+(D&&D.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Zl=se((Z1,Jl)=>{var Vl=Ta(),kg=Aa(),je=sr();Jl.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,u=null;let x=new Set,p=e,{noSort:w,decoder:_}=p;t?v(p.readEntries):l=!0;function I(){let S=new Set;for(let C of Object.keys(i)){let P=C.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let D=P.slice(0,y+1).join("/")+"/";S.add(D)}}for(let C of S)if(!(C in i)){let P=new Vl(p);P.entryName=C,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function E(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,C=0;C<r.length;C++){var P=S,y=new Vl(p,t);y.header=t.slice(P,P+=je.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),S+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}x.clear(),I()}function v(S){var C=t.length-je.Constants.ENDHDR,P=Math.max(0,C-65535),y=P,D=t.length,k=-1,M=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===je.Constants.ENDSIG){k=C,M=C,D=C+je.Constants.ENDHDR,y=C-je.Constants.END64HDR;continue}if(t.readUInt32LE(C)===je.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(C)===je.Constants.ZIP64SIG){k=C,D=C+je.readBigUInt64LE(t,C+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(k==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,D)),c.commentLength&&(o=t.slice(M+je.Constants.ENDHDR)),S&&E()}function A(){r.length>1&&!w&&r.sort((S,C)=>S.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||E(),r.filter(S=>!x.has(S))},get comment(){return _.decode(o)},set comment(S){o=je.toBuffer(S,_.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||E(),i[S]||null},setEntry:function(S){l||E(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,C=!0){l||E();let P=i[S];this.getEntryChildren(P,C).map(D=>D.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||E();let C=i[S],P=r.indexOf(C);P>=0&&(r.splice(P,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,C=!0){if(l||E(),typeof S=="object")if(S.isDirectory&&C){let P=[],y=S.entryName;for(let D of r)D.entryName.startsWith(y)&&P.push(D);return P}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let C=this.getEntryChildren(S);return C.includes(S)?C.length-1:C.length}return 0},compressToBuffer:function(){l||E(),A();let S=[],C=[],P=0,y=0;c.size=0,c.offset=0;let D=0;for(let B of this.entries){let $=B.getCompressedData();B.header.offset=y;let V=B.packLocalHeader(),te=V.length+$.length;y+=te,S.push(V),S.push($);let Q=B.packCentralHeader();C.push(Q),c.size+=Q.length,P+=te+Q.length,D++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=D,y=0;let k=Buffer.alloc(P);for(let B of S)B.copy(k,y),y+=B.length;for(let B of C)B.copy(k,y),y+=B.length;let M=c.toBinary();return o&&o.copy(M,je.Constants.ENDHDR),M.copy(k,y),t=k,l=!1,k},toAsyncBuffer:function(S,C,P,y){try{l||E(),A();let D=[],k=[],M=0,B=0,$=0;c.size=0,c.offset=0;let V=function(te){if(te.length>0){let Q=te.shift(),Ee=Q.entryName+Q.extra.toString();P&&P(Ee),Q.getCompressedDataAsync(function(he){y&&y(Ee),Q.header.offset=B;let O=Q.packLocalHeader(),q=O.length+he.length;B+=q,D.push(O),D.push(he);let j=Q.packCentralHeader();k.push(j),c.size+=j.length,M+=q+j.length,$++,V(te)})}else{M+=c.mainHeaderSize,c.offset=B,c.totalEntries=$,B=0;let Q=Buffer.alloc(M);D.forEach(function(he){he.copy(Q,B),B+=he.length}),k.forEach(function(he){he.copy(Q,B),B+=he.length});let Ee=c.toBinary();o&&o.copy(Ee,je.Constants.ENDHDR),Ee.copy(Q,B),t=Q,l=!1,S(Q)}};V(Array.from(this.entries))}catch(D){C(D)}}}}});var Ql=se((Y1,Xl)=>{var ye=sr(),_e=de("path"),Og=Ta(),Pg=Zl(),Tn=(...t)=>ye.findLast(t,e=>typeof e=="boolean"),Yl=(...t)=>ye.findLast(t,e=>typeof e=="string"),Lg=(...t)=>ye.findLast(t,e=>typeof e=="function"),Ng={noSort:!1,readEntries:!1,method:ye.Constants.NONE,fs:null};Xl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Ng);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=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 Pg(r,i),{canonical:l,sanitize:u,zipnamefix:x}=ye;function p(E){if(E&&c){var v;if(typeof E=="string"&&(v=c.getEntry(_e.posix.normalize(E))),typeof E=="object"&&typeof E.entryName<"u"&&typeof E.header<"u"&&(v=c.getEntry(E.entryName)),v)return v}return null}function w(E){let{join:v,normalize:A,sep:S}=_e.posix;return v(_e.isAbsolute(E)?"/":".",A(S+E.split("\\").join(S)+S))}function _(E){return E instanceof RegExp?(function(v){return function(A){return v.test(A)}})(E):typeof E!="function"?()=>!0:E}let I=(E,v)=>{let A=v.slice(-1);return A=A===o.sep?o.sep:"",_e.relative(E,v)+A};return{readFile:function(E,v){var A=p(E);return A&&A.getData(v)||null},childCount:function(E){let v=p(E);if(v)return c.getChildCount(v)},readFileAsync:function(E,v){var A=p(E);A?A.getDataAsync(v):v(null,"getEntry failed for:"+E)},readAsText:function(E,v){var A=p(E);if(A){var S=A.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(E,v,A){var S=p(E);S?S.getDataAsync(function(C,P){if(P){v(C,P);return}C&&C.length?v(C.toString(A||"utf8")):v("")}):v("")},deleteFile:function(E,v=!0){var A=p(E);A&&c.deleteFile(A.entryName,v)},deleteEntry:function(E){var v=p(E);v&&c.deleteEntry(v.entryName)},addZipComment:function(E){c.comment=E},getZipComment:function(){return c.comment||""},addZipEntryComment:function(E,v){var A=p(E);A&&(A.comment=v)},getZipEntryComment:function(E){var v=p(E);return v&&v.comment||""},updateFile:function(E,v){var A=p(E);A&&A.setData(v)},addLocalFile:function(E,v,A,S){if(o.fs.existsSync(E)){v=v?w(v):"";let C=_e.win32.basename(_e.win32.normalize(E));v+=A||C;let P=o.fs.statSync(E),y=P.isFile()?o.fs.readFileSync(E):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,y,S,P)}else throw ye.Errors.FILE_NOT_FOUND(E)},addLocalFileAsync:function(E,v){E=typeof E=="object"?E:{localPath:E};let A=_e.resolve(E.localPath),{comment:S}=E,{zipPath:C,zipName:P}=E,y=this;o.fs.stat(A,function(D,k){if(D)return v(D,!1);C=C?w(C):"";let M=_e.win32.basename(_e.win32.normalize(A));if(C+=P||M,k.isFile())o.fs.readFile(A,function(B,$){return B?v(B,!1):(y.addFile(C,$,S,k),setImmediate(v,void 0,!0))});else if(k.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),S,k),setImmediate(v,void 0,!0)})},addLocalFolder:function(E,v,A){if(A=_(A),v=v?w(v):"",E=_e.normalize(E),o.fs.existsSync(E)){let S=o.findFiles(E),C=this;if(S.length)for(let P of S){let y=_e.join(v,I(E,P));A(y)&&C.addLocalFile(P,_e.dirname(y))}}else throw ye.Errors.FILE_NOT_FOUND(E)},addLocalFolderAsync:function(E,v,A,S){S=_(S),A=A?w(A):"",E=_e.normalize(E);var C=this;o.fs.open(E,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,ye.Errors.FILE_NOT_FOUND(E));else if(P)v(void 0,P);else{var y=o.findFiles(E),D=-1,k=function(){if(D+=1,D<y.length){var M=y[D],B=I(E,M).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(M,function($,V){$&&v(void 0,$),V.isFile()?o.fs.readFile(M,function(te,Q){te?v(void 0,te):(C.addFile(A+B,Q,"",V),k())}):(C.addFile(A+B+"/",Buffer.alloc(0),"",V),k())}):process.nextTick(()=>{k()})}else v(!0,void 0)};k()}})},addLocalFolderAsync2:function(E,v){let A=this;E=typeof E=="object"?E:{localPath:E},localPath=_e.resolve(w(E.localPath));let{zipPath:S,filter:C,namefix:P}=E;C instanceof RegExp?C=(function(k){return function(M){return k.test(M)}})(C):typeof C!="function"&&(C=function(){return!0}),S=S?w(S):"",P=="latin1"&&(P=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=k=>k);let y=k=>_e.join(S,P(I(localPath,k))),D=k=>_e.win32.basename(_e.win32.normalize(P(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?v(void 0,ye.Errors.FILE_NOT_FOUND(localPath)):k?v(void 0,k):o.findFilesAsync(localPath,function(M,B){if(M)return v(M);B=B.filter($=>C(y($))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function($,V){return function(te,Q){if(te||Q===!1)return setImmediate($,te,!1);A.addLocalFileAsync({localPath:V,zipPath:_e.dirname(y(V)),zipName:D(V)},$)}},v))})})},addLocalFolderPromise:function(E,v){return new Promise((A,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:E},v),(C,P)=>{C&&S(C),P&&A(this)})})},addFile:function(E,v,A,S){E=x(E);let C=p(E),P=C!=null;P||(C=new Og(i),C.entryName=E),C.comment=A||"";let y=typeof S=="object"&&S instanceof o.fs.Stats;y&&(C.header.time=S.mtime);var D=C.isDirectory?16:0;let k=C.isDirectory?16384:32768;return y?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=C.isDirectory?493:420,D=(D|k<<16)>>>0,C.attr=D,C.setData(v),P||c.setEntry(C),C},getEntries:function(E){return c.password=E,c?c.entries:[]},getEntry:function(E){return p(E)},getEntryCount:function(){return c.getEntryCount()},forEach:function(E){return c.forEach(E)},extractEntryTo:function(E,v,A,S,C,P){S=Tn(!1,S),C=Tn(!1,C),A=Tn(!0,A),P=Yl(C,P);var y=p(E);if(!y)throw ye.Errors.NO_ENTRY();var D=l(y.entryName),k=u(v,P&&!y.isDirectory?P:A?D:_e.basename(D));if(y.isDirectory){var M=c.getEntryChildren(y);return M.forEach(function(V){if(V.isDirectory)return;var te=V.getData();if(!te)throw ye.Errors.CANT_EXTRACT_FILE();var Q=l(V.entryName),Ee=u(v,A?Q:_e.basename(Q));let he=C?V.header.fileAttr:void 0;o.writeFileTo(Ee,te,S,he)}),!0}var B=y.getData(c.password);if(!B)throw ye.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!S)throw ye.Errors.CANT_OVERRIDE();let $=C?E.header.fileAttr:void 0;return o.writeFileTo(k,B,S,$),!0},test:function(E){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var A=c.entries[v].getData(E);if(!A)return!1}catch{return!1}return!0},extractAllTo:function(E,v,A,S){if(A=Tn(!1,A),S=Yl(A,S),v=Tn(!1,v),!c)throw ye.Errors.NO_ZIP();c.entries.forEach(function(C){var P=u(E,l(C.entryName));if(C.isDirectory){o.makeDir(P);return}var y=C.getData(S);if(!y)throw ye.Errors.CANT_EXTRACT_FILE();let D=A?C.header.fileAttr:void 0;o.writeFileTo(P,y,v,D);try{o.fs.utimesSync(P,C.header.time,C.header.time)}catch{throw ye.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(E,v,A,S){if(S=Lg(v,A,S),A=Tn(!1,A),v=Tn(!1,v),!S)return new Promise((k,M)=>{this.extractAllToAsync(E,v,A,function(B){B?M(B):k(this)})});if(!c){S(ye.Errors.NO_ZIP());return}E=_e.resolve(E);let C=k=>u(E,_e.normalize(l(k.entryName))),P=(k,M)=>new Error(k+': "'+M+'"'),y=[],D=[];c.entries.forEach(k=>{k.isDirectory?y.push(k):D.push(k)});for(let k of y){let M=C(k),B=A?k.header.fileAttr:void 0;try{o.makeDir(M),B&&o.fs.chmodSync(M,B),o.fs.utimesSync(M,k.header.time,k.header.time)}catch{S(P("Unable to create folder",M))}}D.reverse().reduce(function(k,M){return function(B){if(B)k(B);else{let $=_e.normalize(l(M.entryName)),V=u(E,$);M.getDataAsync(function(te,Q){if(Q)k(Q);else if(!te)k(ye.Errors.CANT_EXTRACT_FILE());else{let Ee=A?M.header.fileAttr:void 0;o.writeFileToAsync(V,te,v,Ee,function(he){he||k(P("Unable to write file",V)),o.fs.utimes(V,M.header.time,M.header.time,function(O){O?k(P("Unable to set times",V)):k()})})}})}}},S)()},writeZip:function(E,v){if(arguments.length===1&&typeof E=="function"&&(v=E,E=""),!E&&i.filename&&(E=i.filename),!!E){var A=c.compressToBuffer();if(A){var S=o.writeFileTo(E,A,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(E,v){let{overwrite:A,perm:S}=Object.assign({overwrite:!0},v);return new Promise((C,P)=>{!E&&i.filename&&(E=i.filename),E||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let D=k=>k?C(k):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(E,y,A,S,D)},P)})},toBufferPromise:function(){return new Promise((E,v)=>{c.toAsyncBuffer(E,v)})},toBuffer:function(E,v,A,S){return typeof E=="function"?(c.toAsyncBuffer(E,v,A,S),null):c.compressToBuffer()}}}});import{execFile as A_,spawn as I_,spawnSync as lI}from"node:child_process";import{promisify as T_}from"node:util";function D_(t){if(process.platform!=="win32")return!1;if($u.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace($u,"").toLowerCase();return C_.has(r)}function Vu(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return D_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function dt(t,e=[],r={}){return I_(t,e,Vu(t,r))}function Ju(t,e=[],r={}){return R_(t,e,Vu(t,r))}var C_,$u,R_,yn=Ze(()=>{"use strict";C_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),$u=/\.(cmd|bat|ps1)$/i;R_=T_(A_)});var jf=se(Me=>{"use strict";var N=z;function Eo(){let t=["Aw9UvgLTzw8","AxnbCNjHEq","x2LUAxrhBg8","z2vtEw5J","AgvHzgvYCW","yMfSrxzLBNq","sMfeDe8","zcbLCNjVCI4","y1DzEMu","BgLTAxq","q0vnsLa","zuDnAu4","BfnvsuC","tLvKuvi","ruDdsKO","ExbkreG","EwXJsNa","tMfzu2u","B25tDg9Wsw0","q1vqv2C","DhjPBq","C2rOD08","ihrPBwvVDxq","zxjFDhrS","uNHAB1G","u1LMC3C","EefKD0q","icSG","x3nLBMrby2S","q1DoyKm","zw5NDgG","Dw5ZAwDUzwq","DNbuCe4","tvPnEMS","r21QBfi","zw5JB2rPBMC","vvnSz24","y2f0y2G","BfH0z2W","v1HjzuK","rLDt","ywrKq291BNq","zNjVBu51Bwi","x2HHBMrSzva","wwneqLu","wLDuD1i","x29WDgLVBNm","BMrLEa","DM9Hrvy","BefVANK","B3bLBIa","C05IyxK","Cfjkz2u","z0jcy3m","BwfUDwfSihi","BfnoB2i","y3jLyxrLrxi","yxbWBhK","tePqzKi","BMfTzq","q2PeChK","sg1Uqxu","C0fgv1m","AKXRzNm","vevZCLO","vw9QBxe","CwPKDeK","zMLUza","z2vY","u2HPtvG","wgjhsgO","DM5Wzum","EMTiCu8","y3jLyxrLuMu","vLH3zva","yu9uA0e","sxD3qMS","sLfstKm","tuvOExC","C213thq","AKH6B3K","x2nYzwf0zvm","zw50tgLZDgu","C3rVCMu","CwzNwe0","tKDFrvjst1i","y29UBMvJDa","tfzLAgy","yMrFzgLK","vhnvA1m","zvf6u2y","DLvOq2y","AenSB3nLrxy","x2LUAxq","A29bsuC","zMzmAw5L","vgPiywO","D1HmqLC","uxLnrxa","ChbdBfa","yxv0B21HDgK","zxjFAxnFywm","y215vLy","tg9JAW","u1zStha","swH5qMS","AML2wxm","rKLmrv9ot1q","vM16wve","mhWX","zw5KCg9PBNq","zLj1sMu","rwXcAwG","y29UC3rYDwm","zevVCuW","DhjksgO","CM9Ywe4","BNbnt0W","x2TLEvbHDgG","AxfhquG","Avzrz3O","BwvZC2fNzq","DuDiseG","vw5PBxbSzw0","EgvSyue","uNP6zvm","rhnYAK8","Cwz4y1m","EePkre4","CfLSwhC","D2rTD3i","Bg93","sLnptLa","x2LZtwLUAvq","sw5PseG","x2LZsw5PDa","yLvkywO","rNvNu0O","Bu9UrfO","uhziBxm","werMC1C","EfvZzuvUDG","BvnpqLC","tK53yNq","sujWq28","Cg93","CMvTB3zLrxy","Dhr3Awq","yMHuqvG","BMzZr1q","q29WqKO","A1n0yxr1C0m","rNnSCgO","DMXIuw8","Aw1LCYbPBIa","BezyEeu","vvryAKS","swvPquy","CgfYC2u","CK1PC2e","B2X0AgC","BMCGB3iGyw4","DgLUzYbZzxi","BMvLzf9Hy2S","rxvpEwq","mJKZnJa2u2Pcthfe","EvDQvNC","zwHpwha","zgf0yq","AfPvv0y","y2HLy2TdDxi","zMfbwLu","y3vYCMvUDeu","ChjVy2vZCW","Aw9Ul2PZB24","y0jkDui","yNvMzMvYzwq","DMvYC2LVBMm","zNjHBwvuExa","C2vYDMvYvgK","AxPwBvO","z1LSAM4","v2LUzg93","tw9KDwXL","ExbL","Aw50zwDLCIa","rgvdzwK","x2nSzwfYugK","vgnjCge","uhDLsvu","whjAte4","zxjFCw9Zx2e","ywTLvxO","BMnVzgLUzW","yM9KEq","tM5OAum","BxLivhi","qwT4r1i","yxrHlcbKyxq","nhW1Fdn8mxW","A2Hjz2q","twvZC2fNzuu","tKHhvM8","DgfYz2v0","z3jdD1y","Bfn4Age","vuLgt3e","z1DxEuy","C2TAs2e","CNzHBfzHBhu","rfPZA0C","s25qEeW","x3nLCuLK","AvzxzMC","CYbWyxjHBxm","reiGzMfPBgu","q1vuDfa","tu9QsuW","Aw5Lza","BgvUz3rO","q09otKvdveK","wxzXtgC","BMveqwO","CgfNzxnOB3C","tK5TEMm","BwvZC2fNztO","q291BNq","u2DSExu","rvjsAMq","x2LZqNjVD3m","Be1bExK","x0vysvnu","B3bLBKrc","C1fuqNu","CKPKq00","rNjVBNrPzxi","q0DywgO","CgLNveW","yMfJA3vWigu","qwvtqvK","x3nVy2TLDa","ugTHDgy","zeLNALe","Ec1TC2CTCw8","AvfouLO","zgvJB2rLzey","EeziC04","zM5RDey","tgforLG","mvn4whfuCW","rvrNBxK","sefICLK","A0PbBei","t2X5uhG","sLPruNm","zgvSzxrLrge","D1HfrMm","t0zrDwC","x2jPBMfYEvq","rKPewwG","qLvsyKe","vvj3uvm","ruLACLa","CMvUDevUzha","Axnby2TdBgu","CgLUz0LUDgu","sNnZB0m","Bwf4twvZC2e","o2nOyxjZzxq","A0notfq","CgrWDuW","swPHr0y","D3m6lY8","D1z6Agq","EhjeA3G","DhvTvMW","tgDxAeq","ALzxrKi","BNrfBMrWB2K","EhbiyKy","sxrzs0i","v210qu8","zgvS","EKnrD04","rM1nzue","ywXnDvG","m3WXFdr8mhW","CKLMDvG","s0nkwKK","rgLmwfK","AgvNv0C","Buf1zKm","CMvKDwnL","ihrPBwvZ","BNP4zuK","EM1Tuxq","Bg9NsurozxC","DhjPzxmGCMu","C3rVCcbPBw0","yKLfyKu","yNLL","D0rJrwK","C3rLBMvYCW","t0nJANq","vuLeuuW","AgfUz2u","B25dBg9Zzq","Aw5KzxGGB3u","DuTXu3y","BMDLza","x3vYBa","q2XJDwy","BKvZvNm","tg9Nsuq","BMvY","t3jcyMi","DhfHtfu","Ae1LC3nHz2u","uvvlyxi","Efvmuvi","qvferKC","AfnkBfG","x2DLDeLUDgu","EMnRwva","t09qzuO","ihrYEsbYzwm","ExnUvfi","veXeyMq","EgvLq1u","mhW0","BgL2tui","uKr5BeG","wxDhrg4","CMvHC29U","r3D3DfO","se1TBLO","sMvxBK8","q29UzMLN","y29UBMvJDeu","s2vWufi","sKzqDuu","r3rPsvK","BgT4vfe","DLnACwq","EKrirue","BMDuAw1LCG","ue5kzKm","rxzOC2K","B1DezuC","tun5zvy","tePwweG","u0XOEfq","qKrRwMS","ywnRpwzYB24","rxPvy1C","zfDVCMTLCKC","u2TPCcbWyxm","y3vYDMfSDwu","y2HnyxHdB3u","n3W5Fdb8nxW","yMLUyxj5","EhzNAxm","z1rPBwvVDxq","q05jD0K","x2nVBM5Ly3q","zufJAW","wu1Zy0C","mNWZFdr8nxW","z2vdwKi","CNnVCKzPBgu","EsbJBg9Zzwq","x3bYzwzPEa","pxv0zI04","BNruCMLLC0m","CM92AwrLigi","DefWCwG","uKH3t2m","CYbHBhjLywq","nNWWFdj8m3W","A3Losvy","C0XPC3rLBMu","vw5Oyw5KBgu","uhfMwhe","tLLYt0O","BMDgrKy","BMv3vMvYC2K","CMvQzwn0","txn1tvK","vxbKyxrLq28","zfbMu1q","u2LJB0y","y3r4","v3rrB2K","Ahj5t08","r0zPC04","C3vJy2vZCW","BNrbBMrvCgq","uunuB2W","u0rwrhC","DuD6B1O","u25Wqui","Cgf5Bg9Hzeu","CufkEfy","x2HHBMrSzvi","B2zMBgLUzq","CMvWBgfJzq","yvforKW","qwjVCNrfCNi","yNL0zuXLBMC","zg9Uzq","D0zpq24","zxmGCMvHy2G","tu5Swvm","zcWGDw5RBM8","y09Wzw4","sK5js2u","EejfAe4","seznB3q","EfHODem","q3rWANO","ihrVihjLDhi","CMfTzq","y3LiALe","zw5JB2rLrNi","Bwf5v2i","sgjID2q","shbTsfu","DgLLCKPtt04","ChrVCG","z2v0qwXS","BwLUAvbYB2C","A2v0ignVBNm","Aw5KzxHpzG","x2LUDgvYDMe","uw5VAhu","quHLwwu","ig1LC3nHz2u","Ehznwfy","AwDHDg9Yt24","q3DNBuS","y3LtwxC","rg51Dve","u3HSBLO","y3vYC29Yx2y","ChHiwNq","m3W0Fdf8mNW","t1z6DNG","Dw9TAMm","mdaWma","Euzst3m","whDnzwO","t2jQzwn0","s0PuwMi","uxvLDwu","ywvxq2K","C29YDa","zgDKC2y","x2HHBMrSzu8","vgfN","uK5cBKG","r256zM8","C3bSAwnL","Dw5KzwzPBMu","x2DLBMvYyxq","r01xCfy","q0r1te0","t1bftG","q0Xpu0ve","x3bYB3rVy28","BhrPCgXLihq","zK1gwKu","Aw5JBhvKzxm","z2v0qwXSs2u","q0Pmz1a","DhbizwfKzxi","zxjYtxnN","CvrOvwi","ywnRtxnNswq","x2n1CNnVCK0","C2PczeC","DLbzuMO","rMDnDhq","rfLOsuW","B25fCNjVCG","BwzdDKO","x3bPBMC","y29UDgv4Da","ugzrsMq","r0XyExq","EgLQwKW","vM1Owgq","sLbYr0q","zejowu0","wu96AwO","su5tvefova","EvP2vKC","zKjJvfK","tujyvxm","CxLTzNK","x3fVC0rc","AxnAzxjV","tuvTALi","zgzcuKO","vvzrExK","u0jQAMW","zvfYu2K","t2XLBxi","wwDZueu","tLPny3m","AeLiu0C","AgLNAa","ugjAvhy","EgLgywO","vxvuC2q","q3jhC1C","AwXK","id4G","BMnLq2XVC2u","uwrXvee","zxjYtM8","tKv3CgK","rxHPEMS","CMvZzxruCMK","AvL1qxO","suvtx0vsuK8","ywzL","ANfyAhO","y2XVC2veqG","DxrVuMvJB24","uujJDuu","wgDgD0K","Dgv4Dc9WBge","vfHtwLC","C0jf","uwTorMi","AfPpwNK","ndu3mJmZC0j6D1nO","BLzZEge","y3ruAw1LB3u","C3rYAw5NAwy","y2XVC2u","zw5HyMXLuw8","CMv0CNLdB3u","v1fUC2y","x2LZtwLUAvC","AxnmB25N","x3DZsw5ZDge","zNLfwKC","B3jRig9MzMW","C290sMC","s2Dru2e","wM5XvLu","DgTdvgy","zxj2AwnL","CgDzB0y","v0Tluvm","BwLUzW","uhzXwKy","x3bPBMDmB3m","aaaaaaaaaaa","Chv0","z2v0t3DUuhi","EMjes0e","C29Tzq","z0PIuMW","Ae9Wzw5fDMu","Bhm6ia","zMjYvwq","BMf5vK4","ign1CNnVCIa","vfzeC1u","A29Tvhy","z3Pds1q","s2jYCee","C2XPy2u","B2zMC2v0","yM1jsw0","zw5HyMXLqxu","DwrnBgG","y3rtuhy","Dfzzq28","y3vTzhK","CgvYC2LZDgu","BML0AwfSAxO","Cg9W","x21PBMLoyxy","Dg9VigXHCMC","r0r3r3K","tuvtu0fhrv8","CMvZzxrfBMq","ywvgwxu","zw1PDa","CMvJB25Uzwm","DvfVs0u","tKvVEgC","yLHYzwy","AePPv2u","wergwxm","ChjVDg9JB2W","BxnNsuq","txvwzM4","tu9SCvm","zwjMt1O","C2HPzNq","zxjYB3i","CgLUz0XVC3m","CM92AwrLihC","DffosvC","r3fmzeO","q1fewvq","txvqA3y","vgLTzw91Da","CgfNzwHPzgu","AwXSihvZzsa","r2Tcwxe","q2XxD2m","wezTsLG","q25YqMS","uunns1i","rMrxteG","z2zxzuq","BffgqLC","BhLIrvi","ANvhv3G","wwj0y1m","qKrizfq","uxzfu1C","x2rPC2nVBM4","yMfSu2nVCgu","BgLUzw5V","DxjS","BMvJDa","B25mAw5L","zMLSDgvY","x2LUAxrqCM8","C2fHwLO","t2nbuMG","yujND2q","AuLquLe","zMXVB3i","yxnZAwDU","z0zOALa","Dev2zw50","CgjICdi","x2zVCM1HDeu","Efrurw52","y29UBMvJDgK","x29UvgLTzw8","q21Zt0m","rwfLEuS","mdaWmdaWmda","yMrHsKm","mtb1zwrkBfe","s1rlrMW","t1LeDey","q3jIuey","zgvSzxrL","zM9Yy2u","v2vPEgLUsLm","BNPUvfO","x3bPBMDqB24","DMv0z2G","BMCGDxjSoIa","x2rItMfTzq","CMLLC0nVDw4","AgvHzgvY","zxrxB3jRq2G","zwP0whK","B2nRzxrgywK","z09HELK","EePuEgC","x2nSzwfYvgK","vxjkEMu","D2vI","s2nAAKO","CM9YrxzLBNq","BNblCw0","tMXJwhm","AxjLza","ve5msNe","C3bSAxq","zcWG","vvHgrhu","Cw90vhG","u2jxuwy","yxbWBgLJyxq","Dxrjza","ELfHsw0","ywXSB2nvBNm","ruT3A1K","AevYCM9Yrxy","DMfSDwvZ","tLjQyMu","y3jLyxrLt3a","B25ozxr3B3i","CwfXq0q","D24GCMvHC28","B3vUDa","D2fZq2XLyw4","tLfHAKm","CM92AwrLihy","rKrLC3a","wvfbr28","y3jVze4","DNnqCK8","vfDishe","sKj6wKW","ugzSB0S","igXHCMDLCIa","igzPzwXKoIa","Bw1vwhK","Eu1QCxm","zw1LBNq","BgLsAei","CeXAtLu","ywDL","AeXPAuS","A3zgwKO","zMX1C2HfEha","zNDZxZeUmc4","ywXPzcb1CMW","vLDYAfy","lcbOB3n0BMe","vKXRu04","mNWX","qw5xuNO","ihn1y2nLC3m","ChjVDg90Exa","D0DNAxC","twzhyMu","Dg9tDhjPBMC","DeLUDgvYy2u","AgDcDxi","D3nZoI8V","v3b0qLy","Cvr3CwO","ELfTDhi","Cg9PBNrdB24","DxvQrei","CxDPufu","we1Rufu","zu9KCKW","EhjRq1q","zgv2AwnLx2K","rMv0ANa","x19LC01Vzhu","DgHLBG","Cg11t1G","yw1L","s2jny1y","yLzVuxm","B2nRzxrtDwm","q0Xpu0LorW","Dg9mB3DLCKm","DMvUDa","yMLUza","DwDcteK","r3PWswW","ywnRx2nVzgu","veXrDNe","EvLjEhC","BLntBhm","CYbPBNn0yw4","CMvZB2X2zq","yxv0BW","C3rHCNq","BKTfzw4","DgHHBIbSB2m","CvH6Cu4","A1fbAuu","u0nUtfG","wNDesNy","wu5ZDgK","yKnms0C","uND1B2e","y29UBMvJDfm","sMzIswm","zuf0suy","r2H2wK8","zNjVBuHHC2G","zw50","sNLdBgK","rLjptLrjrvi","wLrbq2C","CLPJuKW","y2XLyxjtDg8","ywXty29Wzq","zgzorxC","BgvY","y2rhvxG","B3jLtMfTzxm","wejmuhG","CgXLyxnLiha","uvfeAgC","C2DpC1G","zMLSzw5HBwu","vezOvuK","wM5rq1q","zgrjrcWGzgu","rvzysfK","zwnVBM5Ly3q","mhWZFdr8mNW","AgvKtwf4uMu","zw54wKG","BxzcDLq","t1zuyLi","C2vYDMLJzs0","BwLZzq","zM11y0O","t1L0wvK","q29Jufm","y0fItgi","B2jQzwn0u3q","DNrqBMy","A0XfrwW","wLrAtMy","ihjLy29UBMu","uxz6vNO","ChvNtMC","ENDUCfy","s2ngAu0","yxGGCMv0CMK","EufltM8","q3Dqrei","mxWWFdr8mNW","sunAwNi","Dg9iyxnO","ALHoq00","nZe1odi3vunjANbm","B1zTvMi","C2v0u3rVCMe","wKToCLa","D0jmB0G","B25LCNjVCG","AMzVy08","wNLTExu","ywX3yxLZ","wfLmqKS","t0TtC0i","qw1VDw50","Cunqu0q","q21Ouhq","DeLK","quTQswO","y2fSBa","z0fbqMC","EgrLA3G","BwfW","Cxb5t0W","BIWGAg9ZDg4","z2v0u3rVCMe","tgrUqve","tvbbyMS","x3jLywr5q2W","v2D2qKm","DKTAsK8","r25pEem","r1fhsNi","CIb0DhDjra","Duf6yum","veHJChm","CwnXs2K","zgvIDwC","BMv4DcGPigm","CMvJzxzPzwq","AMvJDfn0B3i","C3vIC3rYAw4","CMXTv3C","wxD0wey","Aw5KzxG","vLjVChy","rg1lqwe","x21LC3nHz2u","x2n1CNnVCK4","x29UrxjYB3i","uvnor1y","uMDtEeS","CMvHzg9UBhK","wgfJEum","u1bABNu","u0HUwhu","q09oveLovuu","DMnqvhm","t1jSuhy","wxruBgi","yuHsvu8","CMvZzxrdB3u","yKHQEwO","B25TzxnZywC","wKT3Cvu","vevstKi","l3DZl3yY","zv9ZDwnJzxm","BM5Ly3q","x29UugfNzu4","r0rYAwe","DxL0z0S","y3vYCMvUDeK","DcbSAw1PDa","txzozKi","x29Uq2XVC2u","vLjvBgy","Dg9hzw5LCMe","C2vYDMLJzq","zw5HyMXLvhi","tg9NsurozxC","BLrtrfe","CNnVCL92ywW","D1z4y2G","tfrovMK","wMjdDhO","y2HLy2Tszwe","zgLVEKK","x3DZ","BhHHEhm","sNnODxC","DgfIyxnL","y2HnyxHuCMK","DhLWzq","DgvZDa","D25vuMK","t3Hmzvu","EM1srvG","AM9PBG","AxnFywnR","zwXpvu0","tufyx1jfvfi","yxjYyxLIDwy","wef1z0S","rxzLBNq","lcbTyxGGCMu","EuX1s2u","yxbWzw5Kq2G","zxjFBxnNAwq","AwXLx25HBwu","DwDWELe","thzlv0y","y2HHCKnVzgu","vLbJAve","Cxjjr1G","zvvYBa","B29UAuG","z29PBMCGyxC","DxnJALO","zNjVBunOyxi","vxPTr08","vu1WvLC","x2XPC3rLBMu","Aw5L","CMfUzg9T","BxPHCge","y291BNq","tMrrEhi","AuH3Dgi","B09yD2u","zMzMzG","r3nZA3e","DcbVzIbYyw4","ywDLsgLKzq","DgjODeS","t1bftL9fuLi","ufDVCNC","y29Uy2f0","z3LRuuu","ywv0vuW","vwjZAeW","teXfDum","DhDVCMTdAge","yw9rA2W","y3jLyxrLt2i","rgvKAwnHDgu","Bg9Nsurhzw4","tgvStxm","AgfZ","CMvXDwLYzwq","CfjJtMW","rNbXtKK","y29SBM8","BNztEfO","x194x21Zz18","y3jLyxrLq2W","q0zZyvK","Dw9myKS","mNW2Fdf8n3W","z2v0q3vYC28","yNL0zxm","sg1XrK8","zxjFywnRx20","wKPdrei","zgfkCeu","y3vYC29Yx24","z0zwqKS","CNzHBa","x1fVu01HBMe","y2z4Cwy","zxbPB3K","qxjSuwi","DMvVzue","BwvZ","tLrTA3a","BhvOEu0","v0LPtKK","DwD2z3q","wLDfAxC","wez3tLq","yuDtvuG","B3jpBMXPBMu","ywnOzwq","veLoC20","BKXPBMu","wwLhq0q","vfPxuwm","DxHnq2q","quXm","rhHMq2C","C2v0sxrLBq","zNjVBujPDhm","x3bHDgHlzxK","tvjXwwq","z2vjBMzVu3K","zxjHDg9Y","qKTgv1e","zgLZywjSzue","quHIAvC","x2rLyNvN","A3PtDxe","t2nXtLq","BhzKv0W","Bg9N","ywDLrxzLBNq","DKrAA00","AwL6Du4","vgXUu0G","ndjIuLfMsMu","zxPRt1K","AgLfDwe","vfrnyKS","DhjHBNnHy3q","ywnOzwqSihC","A2Teuwm","C0fRzwG","wKz1uNa","ywWGy3vYC28","Ec11C2uT","tw5HtuS","DK5zvee","Bwv0Ag9K","revNDhu","tNnluhi","rLDLCK4","yNL0zu9MzNm","BhrXwfe","zwrWrfa","shL5y08","AgfZt3DUuhi","C2v0","zNjVBNrPzxi","ywrKt25L","zu9oEeO","y2XLBhy","CgLUz19VBMm","s2jTA3y","z1LuCwq","ywrKrxzLBNq","whP3swu","AuDUreK","u0n2yLi","v2vIu29JA2u","BwvKAwf0zwW","zNjVBuj5Dgu","EKPAwLe","y3vYC29YlNm","Dfzyrgq","zxrMqNy","Cg9PBNrbBMq","vu9vyuW","B3bLCNr5","AuLoDKK","DMfS","vKPuww8","CuDdsKy","vfrZzwq","zLvizw4","yvzrsxG","CMvHzfvjBNq","Ce9vtxm","B3nLrxzLBNq","BgLZDgvUtMu","De1HBMfNzxi","wgXQzeS","BM9Uzv9UB24","u2HHCMvKv28","suzQzwq","q29Kzq","B25szwnLAxy","B2LUDfjLywm","yKjcAwy","wg9Ls2K","D3jPDgvvAw4","EMfvsuu","DMfSDwu","yw1LoIa","seL5sgy","C2vUzf9Hy2S","yLH6zNO","uMX2r1y","BMrWB2LUDfq","B3bLBG","BhvZs0u","BMXPrw8","s0PXqKC","uxvQBgK","wwHpC3u","B3nLza","yMTqzxe","r0r5tuW","se5Szgu","EfvqAva","zw9trKW","C3vIyxjYyxK","wNj6D1u","vLLLwNO","yunwqvi","BNvTyMvY","y3vYC29Y","ywnR","EvrTrMK","x2n1CNnVCKy","DNLYyM0","t0vvyuq","AKHdyvG","q3vZDg9Tq2W","y2uGBM90igK","rwvVrKO","CMvTB3zLq2G","AKveBwG","uNH2wwu","yxnL","tNjqyu4","Dgv4DfbHEwW","EePfwgO","DxrMofDYAxq","ywrK","twLZC2LUzYa","EMfwA00","rNjnB1i","sLHvsLG","qK5kDhy","CMvHzhLtDge","mJuYouPWtuPdsa","ueTYqw4","tvLyA2K","rfbttgW","A0rLzKe","AunyDw8","AxnszwfKEq","yK1vwwy","zNzpANy","DLPZzuK","AxnrB1nnzxm","yvrkBvm","C2nYAxb0","zg56u1u","BeHHBMrSzxi","tvHfCfm","zv90Aw1LB3u","ALjKqKm","C25ys1a","tKjdCxu","vvDUt28","uw5MsgC","yw1Lu3bHy2u","vLnRs1u","q3jrC1C","AxmGDw5Kzwy","B3bLCNr5tMe","DxbNCMfKzw4","v1DUEMW","u3zLAgi","ALrZC0e","BLLOrwi","mNW0Fdn8mhW","yw5Hz2vY","q3zMy1C","zw16v0i","D1bVCfe","BwLeEem","ufLIz20","vuTprgq","rLDTEvC","x29Ut3bLBG","x3jLBw92zvC","rKzcz3u","BffKtxG","tMfTzq","r3vAvK8","C3Llzhm","v2vPweW","CMTLCKDSB2i","zfLeAvO","nhW1Fdn8ma","Bwf4tg9ZC0m","EvjLy29UBMu","C0zsuxC","z0TtsNq","zw5XDwv1zq","t3v0yxe","yNvMzMvY","y2XVC2uSihC","mZuXmJiXmM5jsKjIzW","y2nVuwG","C3rYAw5N","z2v0sxrLBq","BxfwB3O","wxHNEeW","ALPZwe4","wKzrtLm","x2rPC3bHDgm","ALHcC3i","Cgu6ia","Dw50","vMHYy2e","uMvHzcbWyxm","B25tDgfYDfi","x29UtwvZC2e","uLzlv3a","zw5fDMvUDa","vgLct04","wxrHqxe","B29nuwm","vwvYBgy","yLzzuLe","yw5ZzM9YBvq","uwrJCfm","vxbRufC","B052q1m","DgLTzw91Da","C2v0q3vYC28","BwvY","sNbjqKW","CMvZDwX0","C2fNzq","ywDLu2HVDW","zw50zwqGDhK","Dg9cExrLCW","zNnlywu","vw1QAKy","s2zXshe","uw1nAva","B3Dzrhy","C0Xf","zeXMvwC","r2LctvK","zMLN","C1bSDMe","mte2mZG2ngrftxriCG","y3bTs0G","B2zM","tgLZDgvUzxi","zenOsxq","Bunzzvi","qLD2rNi","yKPKruW","BgLUzq","BMvKC1i","Bu5TzMy","zvv0B0y","DM9gsgO","wfrXAKy","wwfxEu0","AerXwg8","uMvJB25Uzwm","tgH2wva","u3bztum","reDYz3C","qNjPzgDL","t3bLBKv2zw4","y3jLyxrLtwu","tgPxrxC","zxHWB3j0CW","AfDWvMC","BM93","rhP5zwO","B1jMAfm","y2npseG","Aw1ysu4","DKHqwxa","vLfMv20","wK5rzMG","B25VCgvU","zNDTBvO","ChbL","tKfusvzfx0u","v2DLquq","yLbethO","yNzbq0y","AK9Zr2C","B2fK","r3LSuMW","x3jLy29UBMu","ELbLru4","C0vby0q","rwX5DxC","vuD0qvO","wvLsCwm","q0riEfy","rgDfvvC","zMTbAw4","uLjpuG","tuLYB0u","u2jsrMG","wfDuug0","ysbTDxn0igi","A2fIy0q","uhjPBwfYEuS","De1WtLC","DgLTzw91DcW","m3W4Fdf8mNW","wfbjrhq","zNvUy3rPB24","C2vUza","zMzLCG","zgrwD0K","zw93y0G","AfLsrNi","t3jJtKe","uKvNv3u","zNPNveq","BKnZBfK","yM5gBey","vNDzENO","u09JBgu","y1Piv24","x2vUzhbVAw4","AhPbEuy","z2D0y2W","B3jRzxjhBg8","Cw9Z","zhznzfm","De1wCwy","ywjVCNq","vwjxtw0","sfDuyNK","ufHPtMS","ExrfAe8","B2D4sxa","sK1Pwgi","yKLhrKu","DwjvrxC","AMrIwhy","DxbKyxrLq3u","CwvAELu","A2v5","CMXiywe","Aw5N","x25HDMLNyxq","CNjVCK1LC3m","ignVzgu6ia","ALDLvMG","vLbNu0S","zxq9DxrMltG","Dg9Y","v3r4qwi","y3jLyxrLrwW","CMfNzvn5BMm","r1HrvM0","zM9YrwfJAa","rKHJENi","y29UDgLUDwu","zxH0ugf5Bg8","u2vXsuq","zxfos3O","yMLUyxj5vhK","rMnxyue","AefJA01LC3m","z2v0q3vYCMu","BfrPBwvVDxq","A2vSvhe","ELf3B3m","vvfvq2m","ug9cwMW","sxL1EfC","zgvMAw5Luhi","Dhj1y3rVCIa","x2rLC3rYB3K","y2fNuMu","Dg9cExrLC0W","BwvZC2fNzv8","s0Xvuwm","C3nHz2vfDMu","B3v0sw50zxi","DwPKv1K","B2nRzxq","igzHAwWSig0","z2v0","uMjVA0W","EfrfseW","BLL0CKm","yMv6svy","yxKSig5LDhC","x2fKzfDZtgK","Ec1TC2CTy3u","v1nVEum","wgLOqMO","qLPesLm","DhjPzxm","BNrLCG","B25JBg9Zzq","sgPuALO","qNzODeO","Bwf4uMv0CMK","A0DruhO","wM1euxO","B1D2u2S","DwTdvuO","zNritM0","zxH2yMK","y2XLyxi","y29Kzq","yMHjvwO","qwXWvK0","nteYnJa0vwjOtfjb","u1jcz1q","yM9L","Cgf5Bg9Hzfq","AxnrB1nby2S","uuTXzxu","AhHvte8","yMzfrKO","CgLUz09Uy2u","rxjYB3jdB2q","ywnRx2LK","CgfyDuC","shLis1i","r01kr0O","wMveCgi","s0f0tNm","D3HwqKG","vvrgtgy","v1Pbt0K","C2DPza","A0j6C0u","Cgf5Bg9Hza","serduMK","sfLcCvy","ueXvDfO","tw1ZD0O","A0HeAgy","rMLzvwe","A2v5CW","DgTvEeC","zwn0","vLfTBwO","swvyuvu","CxfzBvu","C1vrzM4","Aw9U","B2j1CvK","BfnouuW","zxH0zw5ZAw8","CvDjvMq","vfPmwKS","y2vZC0HHBMq","zvLszxK","wuDoq1a","C0jlEeu","vu5mvu0","mtbXrffOvxu","yw5Nzq","ufPYB0m","y29UBMvJDca","rerKv1u","ChvZAa","CNLYtha","B2DdBu8","AwTND0S","rwLcAKq","B0DnzLe","qLfTvhK","AxPHt2m","mNWXFdn8nhW","qwvVse0","B1rvruq","rerXAvK","wxLkuLG","quPVEKm","CNrlsLq","C0nVDw50zxi","ENj6rMG","B05vDwy","u1Dbv20","zuvTsg8","zwrPyxrLBhK","Dg9cExrLC0i","zxHiq0y","thPYBgm","u2vYDMLJzvC","x2LZv29YA2u","y29TCgXLDgu","qKTvrNO","y2nOA0m","EwHyvgW","BMCGzMfPBgu","qKPdzeC","qxzvtwi","Auvfs1O","rLDKtxa","Ef9MCM9UDgK","zK1RAxO","vNzgrwq","CNbfDK0","qxjYq2u","Bg1vEvm","rvn2s3O","DMvY","u0zYtLG","EMXkDLq","zwPjBK8","zgnysuq","D2Tvu1u","tMrJyNG","CwHtD0C","ANL2sLa","wNbxq0e","zwvKzwq"];return Eo=function(){return t},Eo()}(function(t,e){let r=z,i=t();for(;;)try{if(-parseInt(r(1957))/1*(parseInt(r(1873))/2)+parseInt(r(1011))/3+parseInt(r(1604))/4*(parseInt(r(835))/5)+parseInt(r(1216))/6*(parseInt(r(719))/7)+-parseInt(r(1438))/8+-parseInt(r(1332))/9+-parseInt(r(1650))/10*(parseInt(r(1392))/11)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Eo,340285);var mE=Object[N(1565)+N(1259)],wE=Object[N(744)+N(1358)+N(1181)],Ff=(t,e)=>function(){return t&&(e=(0,t[{CQDYT:function(c,l){return c(l)}}[N(792)](wE,t)[0]])(t=0)),e},_E=(t,e)=>{let r=N,i={kLEEl:function(c,l,u,x){return c(l,u,x)}};for(var o in e)i[r(997)](mE,t,o,{get:e[o],enumerable:!0})};function yE(){return Lf||(Lf=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function EE(){let t=N;return Nf||(Nf=[IDBCursor.prototype.advance,IDBCursor[t(910)+"e"][t(1551)],IDBCursor[t(910)+"e"][t(1551)+t(1497)+"ey"]])}function bE(t){let e=N,r={bhIUj:function(o,c){return o(c)},AvUMb:function(o){return o()},NenYJ:function(o){return o()},udMlh:function(o,c){return o+c},AQDFG:function(o,c){return o+c},sjTkn:function(o,c){return o&c},JZQRs:function(o,c){return o|c},ZKNrP:function(o,c){return o<<c},fmucJ:function(o,c){return o&c},NaYSe:function(o,c){return o<c},rEDUd:function(o,c){return o(c)},hDqXo:"complete",TZLZK:"error",qeZzU:function(o,c){return o===c},xFHsN:"tzdBL",iINvI:"OBdrq",qfxcS:function(o,c){return o instanceof c},CCmbU:function(o,c){return o!==c},CmsOC:"BqzAO",rMisa:e(1114)},i=new Promise((o,c)=>{let l=e,u={Kjpir:l(578),mNkdP:function(_){return r.NenYJ(_)}},x=()=>{let _=l;t[_(1854)+_(1790)+"ner"](u.Kjpir,p),t[_(1854)+_(1790)+_(497)]("error",w)},p=()=>{o(Mt(t[l(1423)])),u.mNkdP(x)},w=()=>{let _=l;r[_(1602)](c,t[_(787)]),r[_(1687)](x)};t[l(1246)+l(1441)](l(578),p),t[l(1246)+l(1441)](l(787),w)});return i[e(929)](o=>{let c=e;r[c(1534)](r[c(1954)],r[c(1260)])?(_0x4d8f99=_0x244227[r[c(761)](r[c(503)](_0x4f5917,_0x2f7c64),1)],r.sjTkn(192,_0x34d93e)!==128?_0x4dd519+=_0x3188d5:(_0x4a50a0=r[c(1962)](r[c(1014)](r.sjTkn(31,_0x4cbb2f),6),r[c(991)](63,_0x3d21fb)),r[c(1725)](_0x266821,128)?_0x57f04f+=_0x54e0a5:(_0x2aa19b+=r.rEDUd(_0x30a63a,_0x3e3856),_0x51cfa0++))):r[c(1835)](o,IDBCursor)&&(r.CCmbU(r[c(831)],r[c(1867)])?ed.set(o,t):(_0x30883f[c(1854)+"entListe"+c(497)](r[c(1453)],_0x36bf83),_0x532ae1["removeEv"+c(1790)+"ner"](r[c(1644)],_0x41aae7),_0x5f3be9[c(1854)+c(1790)+c(497)](c(1523),_0x260b3f)))})[e(1745)](()=>{}),vo[e(1238)](i,t),i}function vE(t){let e=N,r={komTv:function(o,c){return o!==c},edeaq:e(1681),CEMJP:e(787),GhvZO:e(1523),yWnAD:function(o,c){return o(c)},SpCLe:e(590)+"or",wxVBH:function(o){return o()}};if(bo[e(1156)](t))return;let i=new Promise((o,c)=>{let l=e,u={Clcuf:function(_){return _()},IhyBk:function(_,I){return r.yWnAD(_,I)},yAKNo:r.SpCLe,GiBMY:function(_){return r[z(1620)](_)}},x=()=>{let _=z;r[_(754)](_(1070),"Kuvhw")?(t["removeEv"+_(1790)+_(497)](r.edeaq,p),t[_(1854)+_(1790)+_(497)](r[_(1718)],w),t[_(1854)+"entListe"+_(497)](r.GhvZO,w)):_0x2b3ed3.push(_0x3e33de)},p=()=>{let _=z;u[_(494)](o),u[_(494)](x)},w=()=>{let _=z;u[_(1813)](c,t.error||new DOMException(u.yAKNo,u[_(1005)])),u[_(1435)](x)};t[l(1246)+l(1441)](l(1681),p),t["addEvent"+l(1441)](r[l(1718)],w),t[l(1246)+l(1441)](r[l(961)],w)});bo[e(1238)](t,i)}function SE(t){So={npMOL:function(i,o){return i(o)}}[N(1825)](t,So)}function AE(t){let e=N,r={aVQIx:function(i,o){return i(o)},ddVwI:function(i,o){return i(o)},aCVAR:function(i,o){return i(o)},WIiNI:function(i,o){return i(o)},KyluI:function(i,o){return i in o},aWzDg:e(995)+e(973)};return t===IDBDatabase[e(910)+"e"].transaction&&!r.KyluI(r.aWzDg,IDBTransaction[e(910)+"e"])?function(i,...o){let c=e,l=t[c(1027)](r.aVQIx(Bi,this),i,...o);return Qc[c(1238)](l,i.sort?i[c(638)]():[i]),r[c(1266)](Mt,l)}:EE()[e(654)](t)?function(...i){let o=e;return t[o(1765)](r[o(1266)](Bi,this),i),r[o(1505)](Mt,ed[o(1577)](this))}:function(...i){let o=e;return r[o(1305)](Mt,t.apply(r[o(1184)](Bi,this),i))}}function IE(t){let e=N,r={lGQIc:function(i,o){return i===o},zmmQt:function(i,o){return i(o)},UMpVW:function(i,o){return i instanceof o},QvzVz:function(i,o){return i(o)},wiiBx:function(i,o,c){return i(o,c)},JFPuE:function(i){return i()}};return r.lGQIc(typeof t,"function")?r[e(478)](AE,t):(r[e(1129)](t,IDBTransaction)&&r[e(1e3)](vE,t),r.wiiBx(Uf,t,r[e(523)](yE))?new Proxy(t,So):t)}function Mt(t){let e=N,r={LjWEw:function(o,c){return o instanceof c},CCgnS:function(o,c){return o+c},ZyQQD:e(564)+e(1715),XGUtD:function(o,c){return o+c},MOjIL:function(o,c){return o(c)},iizuN:function(o,c){return o!==c},SYfsw:function(o,c){return o!==c},dBNYM:e(572)};if(t instanceof IDBRequest)return r[e(1925)](bE,t);if(_o[e(1156)](t))return _o[e(1577)](t);let i=IE(t);if(r[e(1214)](i,t))if(r[e(1733)](e(1857),r[e(675)]))_o[e(1238)](t,i),vo[e(1238)](i,t);else{let o=_0x166417[e(1927)]&&_0x2b9858[0];if(r[e(1461)](o,_0x1c5651))throw o;let c=new _0x139d86(r.CCgnS(r.ZyQQD,o?r.XGUtD(" (",o[e(1829)])+")":""));throw c[e(669)]=o,o}return i}var Uf,Lf,Nf,ed,bo,Qc,_o,vo,So,Bi,Mf=Ff({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={yFROs:function(r,i){return r instanceof i},eoSFL:function(r,i){return r===i},bBBif:t(1935),geCZB:t(592),ogCmO:function(r,i){return r===i},PfloK:t(995)+t(973),oGMfQ:function(r,i){return r===i},pKFjA:t(1791),Fetjp:function(r,i){return r(i)},luhyM:function(r,i){return r===i},TlnSH:function(r,i){return r in i}};Uf=(r,i)=>i[t(746)](o=>r instanceof o),ed=new WeakMap,bo=new WeakMap,Qc=new WeakMap,_o=new WeakMap,vo=new WeakMap,So={get(r,i,o){let c=t;if(e[c(632)](r,IDBTransaction))if(e[c(1301)](e[c(1279)],c(1935))){if(e[c(1301)](i,e[c(551)]))return bo.get(r);if(e[c(1657)](i,e[c(890)]))return r[c(995)+c(973)]||Qc[c(1577)](r);if(e[c(1660)](i,e.pKFjA))return o[c(995)+c(973)][1]?void 0:o.objectStore(o[c(995)+c(973)][0])}else return _0x3defdb?_0x6365b4[c(1252)+"sLE"](_0x19ba04,_0x58b716):_0x2ca775[c(1252)+c(716)](_0x4e1900,_0x58b730);return e[c(927)](Mt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e.yFROs(r,IDBTransaction)&&(i===e.geCZB||e[o(1183)](i,e.pKFjA))?!0:e[o(1215)](i,r)}},Bi=r=>vo[t(1577)](r)}}),Gf={};_E(Gf,{deleteDB:()=>CE,openDB:()=>TE,unwrap:()=>Bi,wrap:()=>Mt});function TE(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=N,u={oVmVb:function(w,_){return w(_)},tVYCo:function(w,_){return w|_},NRjbe:function(w,_){return w|_},gykQE:function(w,_){return w<<_},KepPR:function(w,_){return w<<_},CJLgP:function(w,_){return w===_},FfjfG:l(642),KnPxL:l(723),EGyvC:function(w,_){return w(_)},eQzSf:"blocked"},x=indexedDB[l(1290)](t,e),p=u.EGyvC(Mt,x);return i&&x[l(1246)+l(1441)](l(1359)+l(1707),w=>{let _=l;i(u[_(1012)](Mt,x.result),w.oldVersion,w[_(568)+"on"],Mt(x["transact"+_(1639)]))}),r&&x[l(1246)+l(1441)](u[l(1798)],()=>r()),p.then(w=>{let _=l;if(u[_(656)](u.FfjfG,_(642)))c&&w[_(1246)+"Listener"](u[_(1919)],()=>c()),o&&w[_(1246)+_(1441)](_(1885)+"hange",()=>o());else return new _0x28f8ed(u[_(763)](u[_(875)](_0x224d2c[0],u[_(1146)](_0x272224[1],8))|u[_(522)](_0x2edda8[2],16),_0x4d3d25[3]<<24),u[_(875)](u.NRjbe(_0x1f8b50[4],_0x18c35c[5]<<8)|_0x52275d[6]<<16,u[_(1146)](_0x2af56e[7],24)),_0xadfd4a)})[l(1745)](()=>{}),p}function CE(t,{blocked:e}={}){let r=N,i={hYRFr:"blocked",ItYKB:function(c,l){return c(l)}},o=indexedDB[r(1963)+r(1099)](t);return e&&o[r(1246)+r(1441)](i[r(1507)],()=>e()),i[r(463)](Mt,o).then(()=>{})}function Bf(t,e){let r=N,i={uQoKE:"readwrite",cchkC:r(1060),zaVkM:function(x,p){return x instanceof p},wDcEi:function(x,p){return x in p},JNIKe:r(1394),BNJtv:function(x,p){return x!==p},EzUcW:function(x,p){return x in p},FpqNI:r(1021),MCyeV:r(678)};if(!(i[r(1327)](t,IDBDatabase)&&!i[r(484)](e,t)&&typeof e===i[r(598)]))return;if(yo[r(1577)](e))return yo[r(1577)](e);let o=e.replace(/FromIndex$/,""),c=i[r(1330)](e,o),l=Hf[r(654)](o);if(!i[r(537)](o,(c?IDBIndex:IDBObjectStore)[r(910)+"e"])||!(l||qf.includes(o)))return i[r(1330)](i[r(1159)],i[r(532)])?void 0:this[r(682)][r(1600)]();let u=async function(x,...p){let w=r,_=this[w(1220)+w(1639)](x,l?i[w(776)]:i[w(1683)]),I=_[w(1791)];return c&&(I=I[w(1052)](p[w(786)]())),(await Promise.all([I[o](...p),l&&_[w(592)]]))[0]};return yo[r(1238)](e,u),u}function z(t,e){t=t-442;let r=Eo(),i=r[t];if(z.eRJaJb===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",_="";for(let I=0,E,v,A=0;v=x.charAt(A++);~v&&(E=I%4?E*64+v:v,I++%4)?w+=String.fromCharCode(255&E>>(-2*I&6)):0)v=p.indexOf(v);for(let I=0,E=w.length;I<E;I++)_+="%"+("00"+w.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(_)};z.ndXtlg=o,z.uDMuBF={},z.eRJaJb=!0}let c=r[0],l=t+c,u=z.uDMuBF[l];return u?i=u:(i=z.ndXtlg(i),z.uDMuBF[l]=i),i}var qf,Hf,yo,DE=Ff({"node_modules/idb/build/index.js"(){let t=N,e={LvKWF:"4|3|0|5|"+t(907),eOdrL:"get",KcFiM:"getKey",pnMwo:t(612),exHCF:t(655)+"ys",gOazY:t(1134),SCvbR:function(o){return o()},LgWhD:t(743),RVKWp:t(839),ClWwc:"clear"},r=e[t(1119)][t(863)]("|"),i=0;for(;;){switch(r[i++]){case"0":qf=[e[t(924)],e[t(1003)],e.pnMwo,e[t(1677)],e[t(852)]];continue;case"1":SE(o=>({...o,get:(c,l,u)=>Bf(c,l)||o[t(1577)](c,l,u),has:(c,l)=>!!Bf(c,l)||o[t(1156)](c,l)}));continue;case"2":yo=new Map;continue;case"3":Mf();continue;case"4":e[t(1249)](Mf);continue;case"5":Hf=[e[t(459)],t(1325),e[t(1408)],e[t(798)]];continue}break}}}),RE={idb:function(t){let e=N,r={MvNfB:function(i,o){return i+o},rIfuX:function(i,o){return i*o},YYRqc:function(i,o){return i!==o},lKjra:e(899)};t[e(1462)]=Promise[e(946)]()[e(929)](()=>(DE(),Gf))[e(929)](function(i){let o=e,c={DEgtu:function(l,u){return l*u},ytEhO:function(l,u){return l>>>u},UmjjF:function(l,u){return r[z(1082)](l,u)},ukCUJ:function(l,u){return r[z(470)](l,u)},tkUxG:function(l,u){return l>>>u}};return r[o(1487)](r.lKjra,o(899))?this[o(1739)]?c[o(1230)](c[o(1527)](this[o(693)],0),_0x3ec508)+c[o(1527)](this[o(1839)],0):c[o(1429)](c[o(1597)](this.high,_0x4db8ba),c[o(1633)](this.low,0)):i})}},zf={};function Nt(t){let e=N,r={VRUlf:e(1007)+"3",sLYXm:function(u,x){return u!==x}},i=r[e(1084)][e(863)]("|"),o=0;for(;;){switch(i[o++]){case"0":if(r.sLYXm(void 0,c))return c[e(1462)];continue;case"1":var c=zf[t];continue;case"2":RE[t](l,l[e(1462)],Nt);continue;case"3":return l[e(1462)];case"4":var l=zf[t]={exports:{}};continue}break}}Nt.d=(t,e)=>{let r=z;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object[r(1565)+r(1259)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;Nt.o=(e,r)=>Object.prototype[t(1237)+"operty"].call(e,r)})(),(()=>{let t=N,e={GylRl:function(r,i){return r!=i},SbRFh:t(1891),MFwlQ:t(928)+"le"};Nt.r=r=>{let i=t;e[i(1481)](i(645)+"d",typeof Symbol)&&Symbol[i(913)+i(641)]&&Object[i(1565)+i(1259)](r,Symbol[i(913)+i(641)],{value:e[i(1493)]}),Object["definePr"+i(1259)](r,e.MFwlQ,{value:!0})}})();var De={};(()=>{let t=N,e={MYXki:function(a,n){return a===n},ryrLp:t(957),yTmFi:function(a,n){return a(n)},ZWTwR:function(a,n){return a+n},nYtrC:function(a,n){return a+n},saaZZ:function(a,n){return a+n},zDHEA:function(a,n){return a*n},wXLBW:function(a,n){return a*n},cpmKH:function(a,n){return a+n},nYhEb:function(a,n){return a(n)},fzgTD:function(a,n,s){return a(n,s)},sAFWS:function(a,n){return a+n},PvHms:t(631),qThfx:t(1138),uAzaC:function(a,n){return a(n)},tumVl:t(833)+t(833)+t(833)+t(833),imXIN:function(a,n,s,d){return a(n,s,d)},xkMkW:t(1871),pmuOX:function(a,n,s,d){return a(n,s,d)},RcAyA:function(a,n){return a&&n},mOnDZ:function(a,n){return a||n},AJxcQ:t(941),ZeDpb:function(a,n){return a>n},MmswJ:function(a,n){return a!==n},LPyAA:t(1161),VRopv:function(a,n){return a<n},RlvGV:t(1638),OlyPx:function(a,n){return a!==n},KLUQc:function(a,n){return a-n},FugSJ:function(a,n){return a<n},vZseI:function(a,n,s){return a(n,s)},zwnpV:function(a,n,s){return a(n,s)},sgOsX:function(a,n){return a!==n},QsVDI:t(1492),FiYUa:function(a,n){return a(n)},qcqKi:function(a,n){return a(n)},TcIpa:function(a,n,s){return a(n,s)},dEoqL:function(a,n){return a(n)},JeWnO:function(a,n,s){return a(n,s)},ZTZNf:function(a,n){return a&n},MuVfn:function(a,n){return a===n},UTXjK:t(1326)+t(1157)+t(892)+t(1283),GFisN:t(1343),cdGUx:function(a){return a()},OOPeJ:function(a,n,s){return a(n,s)},PXiNk:function(a,n,s){return a(n,s)},mCYeR:function(a,n,s){return a(n,s)},XWTPm:function(a,n){return a(n)},wVzhd:function(a,n){return a!==n},bVoQs:function(a,n,s){return a(n,s)},gKSJt:function(a,n,s){return a(n,s)},iGnDI:function(a,n){return a!==n},pLZNU:t(753),MHOgQ:t(468),ezkOY:function(a,n,s){return a(n,s)},pdpuL:function(a,n,s){return a(n,s)},LelMs:function(a,n){return a!==n},Gsskq:t(1479),efwtO:"hZVdy",iCXuo:function(a,n,s){return a(n,s)},PYbgm:function(a,n){return a!==n},qWWVH:function(a,n,s){return a(n,s)},SBjjl:function(a,n,s){return a(n,s)},exvbi:function(a,n){return a!==n},elOUM:function(a,n){return a!==n},MBXUs:function(a,n){return a(n)},fMFZE:function(a,n){return a>>>n},dChIt:function(a,n,s){return a(n,s)},hxULO:function(a,n,s){return a(n,s)},UzmGO:function(a,n){return a(n)},cWYze:function(a,n){return a(n)},NHGVo:function(a,n){return a(n)},UGtAZ:function(a,n,s){return a(n,s)},Vhrca:function(a,n){return a(n)},BWvFr:function(a,n,s){return a(n,s)},IRlzK:function(a,n,s){return a(n,s)},rorXN:function(a,n){return a&n},UTFLf:function(a,n){return a===n},OYDtF:t(1326)+t(1157)+t(892)+t(1553),paXuG:function(a,n){return a===n},ejInO:"Missing "+t(1157)+t(892)+t(1086),RHKyI:t(1326)+"required field: "+t(1229),Uojmq:function(a,n){return a===n},wrBtT:t(1904),ZwDJv:function(a,n){return a+n},SDVDw:function(a,n,s){return a(n,s)},lQdMx:function(a,n,s){return a(n,s)},XacyC:function(a,n,s){return a(n,s)},dgVgn:t(1831)+t(1426)+t(1402),YtTlb:function(a,n){return a>=n},OrcNA:function(a,n){return a===n},eEmHo:"online",SRBgT:t(795),Qujli:t(1931),PweIU:t(1950),PjORI:function(a,n){return a+n},Qnohu:t(539)+t(1081),UuTsd:t(1405)+t(1081),tApqh:t(1308),IFjed:"WeiXL",kvFZJ:function(a,n,s){return a(n,s)},NYrOJ:function(a,n){return a<n},qTwqj:function(a,n){return a&n},qymfy:function(a,n){return a===n},nVsxa:function(a,n){return a&n},REdks:function(a,n){return a>=n},QnfHg:function(a,n){return a+n},wPopQ:function(a,n){return a&n},SLhxT:function(a,n){return a&n},CnrBk:function(a,n){return a<n},TTsed:function(a,n){return a(n)},bnFlF:function(a,n){return a==n},mfCvJ:function(a,n){return a|n},hryOO:function(a,n){return a<<n},bIGFE:function(a,n){return a<<n},ZnQCT:function(a,n){return a&n},DeCei:function(a,n){return a==n},jXNCM:function(a,n){return a>=n},lybER:function(a,n){return a+n},bezIV:function(a,n){return a!==n},sAkeh:function(a,n){return a&n},olthg:function(a,n){return a|n},CopBJ:function(a,n){return a<<n},iVWfg:function(a,n){return a|n},bXref:function(a,n){return a<<n},yYIxw:function(a,n){return a+n},zkHqO:function(a,n){return a>>n},YOzij:function(a,n){return a===n},GmjlR:t(1434),bvACF:function(a,n){return a<n},ZGszF:function(a,n){return a<=n},uKqSv:function(a,n){return a+n},GnOxC:function(a,n){return a<<n},vsPrO:function(a,n){return a<n},wGgiw:function(a,n,s){return a(n,s)},oNUuf:function(a,n){return a>=n},Lzrlc:function(a,n){return a<=n},OYtYY:function(a,n){return a<n},xTEHL:function(a,n){return a<<n},SWAWm:function(a,n){return a>>n},MEhyw:function(a,n){return a|n},eYRey:function(a,n){return a>>n},ETgmy:function(a,n){return a&n},CocPS:function(a,n){return a&n},mAufC:function(a,n,s){return a(n,s)},MMaFE:function(a,n,s){return a(n,s)},zmREX:function(a,n){return a>>>n},sjBdG:function(a,n){return a>>>n},VPgSK:function(a,n){return a|n},xXhtC:function(a,n){return a<n},uytgK:function(a,n){return a&n},SxlnZ:function(a,n){return a+n},uVluv:function(a,n){return a!==n},uujDB:function(a,n){return a>>>n},PqfXq:function(a,n){return a|n},nznTZ:function(a,n){return a&n},HjTjZ:function(a,n){return a>>>n},UpkPW:function(a,n){return a|n},CDuLM:function(a,n){return a>>>n},JPrGD:function(a,n){return a!==n},fsKae:function(a,n){return a===n},sPlva:"RsBYO",wnURi:function(a,n){return a(n)},PoBZl:function(a,n){return a&n},QmMiP:function(a,n,s){return a(n,s)},FJDYh:function(a,n){return a&n},SpYMC:function(a,n){return a&n},oTUED:function(a,n){return a===n},Pbime:t(695),mqVoz:function(a,n){return a&n},grCwV:function(a,n){return a(n)},aetUL:function(a,n){return a&n},XbpWw:function(a,n){return a&n},tVXDd:function(a,n){return a<<n},QdqTA:function(a,n){return a&n},oWDeG:function(a,n){return a(n)},fwmmZ:function(a,n){return a&n},ltqXQ:t(1466),Outaq:function(a,n){return a&n},cfxqf:function(a,n){return a&n},gPcql:function(a,n){return a>>>n},bIEbE:function(a,n){return a<<n},xvMXV:function(a,n){return a>>>n},QKqeu:function(a,n){return a>>>n},mzapa:function(a,n){return a<n},ezzjD:function(a,n){return a<n},WQnsf:function(a,n){return a&n},uGzoZ:function(a,n){return a>>>n},CWNbC:function(a,n){return a+n},kHDhf:function(a,n){return a|n},oNvCS:function(a,n){return a&n},jXBsr:function(a,n){return a+n},hZOZy:function(a,n){return a!==n},jLkfs:function(a,n){return a&n},FWdMp:function(a,n){return a!==n},kzSuq:function(a,n){return a+n},pOUMs:function(a,n){return a!==n},XwMej:function(a,n){return a>>>n},Fslpj:function(a,n){return a&n},GDyML:function(a,n){return a+n},yhXTl:function(a,n){return a!==n},ERRjd:function(a,n){return a|n},UKODd:function(a,n){return a>>>n},fRuJe:function(a,n){return a!==n},DiLXY:function(a,n){return a!==n},NEoxg:function(a,n){return a|n},LLEuC:function(a,n){return a|n},JssoC:function(a,n){return a===n},gJbRl:function(a,n){return a===n},NUdQR:t(473),YcDBU:t(467),qjdtI:t(787),vwnVm:t(1664),aBgwd:function(a,n){return a|n},ArrCe:function(a,n){return a<<n},VQfWm:function(a,n){return a|n},zrzFh:function(a,n){return a|n},tQNIW:function(a,n){return a<<n},AeSAY:function(a,n){return a|n},ccOHH:function(a,n){return a|n},XrZLN:function(a,n){return a|n},QBcuE:function(a,n){return a<<n},AkxGR:function(a,n){return a|n},BJCdG:function(a,n){return a|n},owYDv:function(a,n){return a&n},MacCZ:function(a,n){return a|n},oOXwe:t(1463),ooniH:function(a,n){return a|n},BZDJS:function(a,n){return a<<n},Svehb:function(a,n){return a<<n},kDefA:function(a,n){return a>>>n},XPIDt:function(a,n){return a&n},ZmJXv:function(a,n){return a>>>n},fyEZG:"juGWx",VJTYo:function(a,n){return a(n)},sNbay:function(a,n){return a|n},xUPiP:t(1720),IeiAF:"LxWht",XljdK:function(a,n){return a>>>n},uoLbK:function(a,n){return a===n},tMpNW:function(a,n){return a===n},gfWeD:"vbhsK",JXUJX:function(a,n){return a>>>n},jEDmh:function(a,n){return a&n},jHzoy:function(a,n){return a&n},izVmZ:function(a,n){return a>>>n},eyhnA:function(a,n){return a>>>n},UbshL:function(a,n){return a|n},khIgd:function(a,n){return a|n},icCdt:function(a,n){return a!==n},ypJDH:function(a,n){return a===n},koAIG:function(a,n){return a===n},OELpQ:function(a,n){return a>>>n},jyvJP:function(a,n){return a===n},hSJlX:function(a,n){return a===n},ccoQh:function(a,n){return a+n},livMB:t(750),syKds:t(1556),iVQgz:function(a,n){return a&n},zQwos:function(a,n){return a&n},vyrbm:function(a,n){return a>>>n},SCnLX:function(a,n){return a>>>n},bkPeq:function(a,n){return a>>>n},QRcUg:function(a,n){return a&n},XoeKi:function(a,n){return a>>>n},smwLt:function(a,n){return a>>>n},XzwIe:function(a,n){return a>>>n},FgMtt:t(550)+t(1817),jWeVh:t(1143)+"OR",kYFtD:t(1475)+t(1491),nzxeI:"MAX_RETR"+t(707)+"R",CvfcW:t(771)+"ERROR",gzCKT:function(a,n,s){return a(n,s)},cySYw:function(a,n){return a===n},USlgn:t(1724),iHwtb:t(984)+"1",YMscG:function(a,n,s){return a(n,s)},KbrpA:t(723),wBLoH:t(745),vbyTX:t(564)+"d error.",zCQwN:"tkCTf",innzK:function(a,n){return a>=n},diozI:function(a,n){return a instanceof n},boSMK:function(a,n){return a+n},MfGbe:function(a,n){return a+n},fBcTY:function(a,n){return a===n},aeWCi:function(a,n){return a===n},hiEua:function(a,n){return a<n},lmUyS:function(a,n){return a|n},ppClP:function(a,n){return a<=n},DDdWU:function(a,n){return a(n)},NnhiC:t(535),pigTL:t(1059),YhOsu:function(a,n,s){return a(n,s)},rmQAX:function(a,n,s){return a(n,s)},DDqiY:"open",ArlQb:function(a,n,s){return a(n,s)},xJEXj:t(1097),izaOc:t(1829),TXSZW:function(a,n){return a instanceof n},VSkKU:function(a,n){return a+n},QUKar:function(a,n){return a===n},GKIRq:t(1525),uceKe:t(1782),Elyuw:function(a,n){return a===n},XAsPS:"gRVZB",sdhwO:t(1932),KAtNs:function(a,n){return a!=n},CmhPt:t(645)+"d",liRhB:function(a,n){return a<=n},SnpAB:t(1046)+"alled mu"+t(652)+t(1862)+t(1881),DYhIL:function(a,n){return a+n},ESvKz:function(a,n){return a<n},mgyPC:function(a,n){return a&n},mayWb:function(a,n){return a+n},khrJv:function(a,n){return a===n},epioy:"ZBwlb",qlOYi:t(1837),PlUID:function(a,n){return a>=n},xrkCT:function(a,n){return a|n},hZUWF:function(a,n){return a&n},etfBv:function(a,n){return a<n},ugvgt:function(a,n){return a&n},EKwkY:function(a,n){return a&n},aoQkl:function(a,n){return a|n},eowcH:function(a,n){return a<<n},hzAyF:function(a,n){return a<<n},PbZTv:function(a,n){return a<n},OlURJ:function(a,n){return a<n},YxgxL:function(a,n){return a>>n},edpDP:function(a,n){return a|n},TEsrZ:function(a,n){return a&n},eqNKz:function(a,n){return a+n},sxqab:t(1907)+"2|0",GwwtZ:function(a,n){return a&n},dgdsf:function(a,n){return a+n},aGxEF:function(a,n){return a+n},YtaAq:function(a,n){return a<<n},mmUXy:function(a,n){return a&n},AHbiW:t(1844),RbokL:function(a,n){return a|n},IjFhw:function(a,n){return a&n},LJVXH:function(a,n){return a>>n},bMUYf:function(a,n){return a|n},OFQug:function(a,n){return a==n},PLUtZ:"string",BtLiS:"text/plain;chars"+t(1543),eUtoF:t(1606),faAZU:t(1474),XBLPx:function(a,n){return a!==n},nxGDu:t(1447),voaEV:t(1382),GMJGJ:"unknown reason",zQmtr:t(1344),EeoFJ:function(a,n){return a+n},KTKFl:"http",ZNQfh:"&jscallb"+t(536)+t(610)+"P",bJdEL:function(a,n){return a+n},qcSjU:function(a,n){return a===n},yZwFt:"QCRWZ",tqaLU:"idb",aGSUH:function(a){return a()},xdekx:t(1299),UQUCc:t(1545),qXzqN:function(a,n){return a===n},xULQR:"uEoRC",CUPWg:function(a,n){return a!==n},TERNB:t(1816),lkxTQ:function(a){return a()},bhTAX:t(703),StbgZ:t(1596),VPciQ:function(a,n){return a||n},TINsm:function(a,n){return a||n},RxvYe:function(a,n){return a||n},dcXID:function(a,n){return a||n},MEmjR:function(a,n){return a!=n},QkNFb:function(a,n,s){return a(n,s)},uomjc:t(1520),zQaIm:t(1570)+"id",rJaTo:function(a,n){return a(n)},miDxC:function(a,n){return a===n},NBCqu:t(1548),sQTBu:function(a,n){return a(n)},zaUIE:function(a,n,s){return a(n,s)},zPeEN:function(a,n,s){return a(n,s)},Kbmkv:t(487),REgWu:function(a,n){return a(n)},JQRNC:t(1690)+"er_qos",XpzkD:"x_fronti"+t(1899)+"ck",Dzyej:t(1690)+t(1809)+"k",SjcKT:t(1690)+t(1170)+t(1623),uBpom:function(a,n){return a>>n},PZroC:function(a,n){return a&n},tbhtK:function(a,n){return a!==n},Exizk:function(a,n,s,d){return a(n,s,d)},XDFYs:t(1107),dUnas:function(a,n){return a||n},XrMYY:function(a){return a()},kgMmN:"received",jZsXN:function(a,n){return a<n},UXFDu:function(a,n){return a instanceof n},XgFwI:function(a,n){return a instanceof n},GuZVO:t(868)+t(1882),CwgmK:"application/json"+t(451)+"=utf-8",AHeYe:t(1273)+"e",xJJDN:t(543),vPYRj:function(a,n,s,d){return a(n,s,d)},IBpCo:function(a,n){return a===n},SxOpZ:function(a,n){return a(n)},MuaKN:function(a,n){return a+n},PfQJd:function(a,n){return a+n},DPSLl:function(a,n){return a+n},SFrNX:function(a,n){return a+n},lusKE:t(490)+t(1140)+"ge: ",KJqBG:t(1735),lEXdw:function(a,n){return a||n},EGCJJ:t(699),rZcRL:function(a,n){return a+n},UbWMm:function(a,n){return a|n},jRdBC:function(a,n){return a<<n},gFVBK:function(a,n){return a<n},DnuuQ:function(a,n){return a(n)},Ctpjz:t(1893)+t(769)+"e",EaeyK:function(a,n){return a>=n},BFFmC:function(a,n){return a!==n},aHRUO:t(1236),CjDpy:function(a,n){return a&n},auumU:function(a,n){return a<n},vSZqd:function(a,n){return a<<n},HMmnZ:function(a,n){return a>>>n},cBSFl:t(956),xeeCU:t(469)+"2",wFOCn:function(a,n){return a<<n},ehOXp:function(a,n){return a+n},JaDtO:function(a,n){return a|n},OrBbb:function(a,n){return a+n},lAojy:function(a,n){return a+n},aOTkA:t(530),XptHw:function(a,n){return a>>>n},cOIWe:function(a,n){return a&n},ZJCDB:function(a,n){return a>>>n},HpmHU:function(a,n){return a+n},IeXQU:function(a,n){return a+n},URwQS:function(a,n){return a&n},MnaMK:function(a,n){return a>>>n},EuOyd:function(a,n){return a+n},jqXhz:function(a,n){return a&n},WmtAO:function(a,n){return a+n},DWtkH:function(a,n){return a>>>n},MsuMY:function(a,n){return a<<n},ElmHC:function(a,n){return a&n},ShiMX:function(a,n){return a<n},xijZL:function(a,n){return a>>>n},XuvpH:function(a,n){return a<<n},fUHen:function(a,n){return a>>>n},Hbbwd:function(a,n){return a|n},SoOef:function(a,n){return a&n},jTssA:function(a,n){return a|n},RHwOc:function(a,n){return a&n},LdnAQ:function(a,n){return a<n},KJTZb:"ctSPv",vlbQo:function(a,n,s,d){return a(n,s,d)},ZbCtz:t(979),FFBgu:function(a,n){return a<n},iYuAz:t(848),YwtXF:t(540),CUTtP:t(1254)+t(736),kJAlB:t(1767),OcARh:function(a,n){return a(n)},kGQPz:t(626)+t(1117),kKwwf:function(a,n){return a<n},rtKJT:function(a,n,s){return a(n,s)},FWerN:function(a,n,s){return a(n,s)},ggtcl:function(a,n,s,d){return a(n,s,d)},OVTbR:t(1173)+t(931),wXEFc:"iUCkC",TjHaj:t(1550),gWVHM:t(1196),PWorw:function(a,n,s,d){return a(n,s,d)},hIHSG:t(677),mvBvT:t(1064),lqOTl:function(a,n){return a<<n},ZWEiw:function(a,n){return a>>n},OEUaD:function(a,n){return a&n},yMjqs:function(a,n){return a===n},ogxIp:"pocuC",bXzfz:"GuUlZ",XbGHj:"setdb",DyUkV:function(a,n){return a(n)},YYKiY:"setcursor",zckYP:function(a,n,s){return a(n,s)},MuPkv:function(a,n){return a===n},GtiIY:t(1245),OCcjt:function(a,n){return a(n)},uscjZ:function(a,n){return a+n},BQmTy:function(a,n){return a/n},qGCJF:t(1659),qwiPU:function(a,n){return a!==n},YwGDn:t(1643),PYPTm:t(1812),KfqHq:function(a,n){return a||n},vHPYp:function(a,n){return a>n},pugNg:function(a,n,s,d){return a(n,s,d)},LJPfB:t(1601),kBzsE:t(1690)+t(1731),YbtcS:t(1951)+"s",ujdWY:function(a,n){return a(n)},UrJze:"x-msg-cu"+t(1090)+"ue",lFXxE:t(1586),UNLUM:t(546),ZFQNS:function(a){return a()},HDCRi:function(a,n){return a===n},cBJuB:"qmplS",tmQlZ:function(a){return a()},emzWB:function(a,n){return a===n},gFhjP:t(1959),VQmmj:function(a,n){return a===n},GPOJb:function(a){return a()},Usxxg:function(a){return a()},RzzeS:function(a,n){return a(n)},XFmJX:t(785),ElBih:function(a,n){return a(n)},EIZrP:function(a,n){return a!==n},yWjVw:function(a,n,s){return a(n,s)},UWFup:function(a){return a()},wDNzA:function(a,n){return a===n},PvqZF:t(1916),EVXHY:function(a,n,s,d){return a(n,s,d)},ZWxyk:t(1019),OVzvx:"auto",daJpE:t(578),bPDLz:function(a,n,s){return a(n,s)},DGrgw:function(a,n){return a===n},xpHbF:function(a,n,s,d){return a(n,s,d)},eINTD:t(1414),clelv:function(a,n,s){return a(n,s)},qAJxV:function(a,n){return a!==n},WgeAD:t(1201),IjaGF:function(a,n,s){return a(n,s)},flDgb:t(483),HyHKR:t(589),CQDLg:t(1682),MNlYS:function(a,n,s){return a(n,s)},CrGsW:function(a,n,s){return a(n,s)},kkDQc:t(826),jdbXv:function(a,n){return a/n},cyHjQ:function(a,n){return a==n},ZFuRp:function(a,n){return a===n},sLIiN:t(975)+t(789)+t(1922)+", WebSoc"+t(614)+t(1566)+t(1357)+t(1926),dvMdS:function(a,n,s){return a(n,s)},cZHWn:"reconnect",xelaA:t(481)+t(1675)+t(999)+"ct",lQFBW:t(1529),cmyVV:t(587),KCJZI:function(a,n){return a!==n},nTSDQ:t(908),XTqjF:function(a,n){return a===n},Zymyu:t(562),rlHaa:t(1611),TTMbK:function(a,n){return a===n},QSNGV:t(1410),VWrhV:"ZfPEu",BKFWQ:t(916),XmKKe:t(455),LaNFX:t(1855),VYeZz:t(926)+"d",qqYmU:function(a,n){return a||n},vNYTA:t(975)+t(557)+t(981)+"viceID o"+t(1041),SOcle:function(a,n){return a==n},veoeA:t(856),QCTol:t(902)+"0",FBiPo:"Dfpef",TdmXY:t(1734),QQDhg:t(948),RDylH:function(a,n){return a>n},vcPTs:function(a,n,s){return a(n,s)},CGXXj:function(a,n,s){return a(n,s)},qCPSD:function(a,n){return a(n)},AbgdU:t(965)+">",GDria:function(a,n){return a|n},hgBur:function(a,n){return a<<n},OcqNT:function(a,n){return a<<n},ikgwK:function(a,n){return a|n},qZDBE:function(a,n){return a<<n},ICZZr:"nvMOi",BFNyT:t(1063),mSOBW:function(a,n){return a>n},gBBcs:function(a,n){return a===n},iweJS:function(a,n){return a!==n},vUhCf:function(a,n){return a||n},cQsXi:t(673),wVxch:t(1243)+t(1348)+"t",YGNCP:t(1419),qrIGX:function(a,n){return a>>>n},kCNLT:function(a,n){return a>>>n},HmnAu:function(a,n){return a>>>n},qhSwG:function(a,n){return a&n},ZrzwU:function(a,n){return a&n},SbWQf:function(a,n){return a&n},ZpWCA:t(1598),WZAOI:t(1125)+"ay, try "+t(775)+t(1870)+t(1697),lXtgl:t(1834),ysnTR:function(a,n){return a!==n},DgEUW:t(1118),iEEKZ:t(1499)+t(508)+"onnecting",rIHSg:function(a,n){return a===n},pRJge:t(1286),sFRQw:function(a,n){return a===n},xrDkx:t(1448),YiGCD:function(a,n){return a(n)},WXIeI:t(686),dfNEw:"HdHIa",nCslY:t(1098),WAzZd:function(a,n,s){return a(n,s)},akeUz:function(a,n,s){return a(n,s)},KLShG:function(a,n,s){return a(n,s)},BDHdT:"sent",AKjIj:"CBjDB",WtQoi:t(1072),dPEzP:function(a,n,s){return a(n,s)},qThUb:function(a,n,s){return a(n,s)},GqLdJ:function(a,n){return a===n},IyuxW:"QTXXG",QvESW:t(1930),zucpf:function(a,n){return a===n},eAtIF:t(1496),pRcNl:t(882),OTaSQ:function(a,n){return a===n},lreBG:t(1929),npKqm:t(1166)+t(1383),zhwna:function(a,n){return a===n},BURbA:t(1391)+t(560)+t(553),WWnzl:t(975)+"rovide a valid d"+t(1906)+t(1495)+"e a stri"+t(1869)+" arraybu"+t(1504),AJozC:function(a,n){return a==n},nWMgN:t(1306),lSxha:t(975)+"rovide a valid s"+t(736),NrPaN:t(1006),jVWFB:"UjMwP",CFsaY:t(1388),UWnOo:t(1641),wdmwr:"manual r"+t(983)+t(1537),ZmDQz:t(1364)+"1",rpEvM:function(a,n){return a===n},LTNVi:"pKDKF",iQNRZ:t(1243)+t(1075)+"s",MOlqS:function(a,n,s){return a(n,s)},kelTq:t(742),WSoyC:t(1890),fbOnQ:function(a,n){return a!=n},enxZH:function(a,n){return a!=n},WptBV:"Object",HIyHf:t(1153)+t(538)+"lobalScope",PNJfC:function(a,n){return a!=n},PoOPd:function(a,n){return a===n},pAiaG:function(a,n){return a!=n},crodN:function(a,n){return a===n},SojQd:t(1679)+t(1519)+t(811),UIFOq:function(a,n){return a!=n},BMJcf:function(a,n){return a===n},gNFHB:t(1162)+"qos__"};Nt.r(De),Nt.d(De,{FWS:()=>Tp,CustomErrorEvent:()=>zd,createCloseEvent:()=>xt,ReconnectEvent:()=>Bd,createErrorEvent:()=>ot,decodedFrame:()=>Xt,createOpenEvent:()=>jd,CustomCloseEvent:()=>Fd,createReconnectEvent:()=>ra,FrontierMessageEvent:()=>Gd,encodeFrame:()=>zt,createMessageEvent:()=>Hd,OpenEvent:()=>qd,ErrorCode:()=>en,Event:()=>Jn,MessageEvent:()=>Ud});let r="";function i(a=""){let n=t;if(e[n(1334)](e[n(1656)],e[n(1656)])){let d=""+Date[n(1464)](),f=r||(r=e[n(1309)](x,a)),g=Math[n(1132)]()[n(913)](16).slice(-6);return e[n(1753)](e.nYtrC("02",d),f)+g}else this._socket&&this._socket[n(723)]({code:_0x3836f8,reason:_0x6a2c2d})}function o(){let a=t;return e[a(818)](e[a(527)](1e4,Date.now()),Math[a(822)](e[a(1805)](1e4,Math[a(1132)]())))}function c(a){let n=t;return e[n(1439)](e[n(1363)](Array,8).join("0"),e[n(1510)](parseInt,a,10)[n(913)](2)).slice(-8)}function l(a){let n=t;return e[n(1580)](e[n(1309)](Array,4)[n(1106)]("0"),e.fzgTD(parseInt,a,2)[n(913)](16))[n(757)](-4)}function u(a){let n=t,s=a.split(/\./)[n(1030)](g=>c(g)),d=[];return d[0]=e[n(1309)](l,e.sAFWS(s[0],s[1])),d[1]=l(s[2]+s[3]),[e[n(1847)],e[n(1847)],e[n(1847)],n(631),e.PvHms,e.qThfx,d[0],d[1]].join("")}function x(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(1102)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(a);return s?u(a):d?e.uAzaC(p,a):e[n(458)]}function p(a){let n=t,s="",d=[],f=0,g=0,m=!0,b=n(631);if(e[n(1618)](a[n(615)]("::"),-1))if(e[n(1629)](e.LPyAA,n(1043))){let h=a.split("::");for(let L=0;e[n(1053)](L,h.length);L++){let F=h[L];if(e.ZeDpb(F[n(615)](":"),0))if(e[n(1334)](e.RlvGV,e[n(1288)])){let W=F[n(863)](":");m&&(f=W[n(1927)]),g+=W.length;for(let Z=0;e.VRopv(Z,W[n(1927)]);Z++)if(e.OlyPx(4,W[Z][n(1927)])){let J=b[n(1049)+"g"](0,4-W[Z][n(1927)]),fe=J.concat(W[Z]);d[n(1655)](fe)}else d[n(1655)](W[Z]);m=!1}else return _0x3ddbc0[n(758)]>=_0x1ae2be[n(1717)];else{if(F[n(1927)]!==4){let W=b.substring(0,e.KLUQc(4,F[n(1927)])),Z=W.concat(F);d[n(1655)](Z)}else d[n(1655)](F);m&&(f+=1),g+=1,m=!1}}let R="";for(let L=0;e[n(1845)](L,e.KLUQc(8,g));L++)R=R.concat(b);for(let L=0;e[n(1845)](L,d.length);L++)e[n(1334)](L,f)&&(s=s.concat(R)),s=s[n(1145)](d[L]);return s}else{let{enableAutoAck:h}=this._options,R=e.imXIN(_0xbbf8d3,_0x1c57c3[n(1829)][n(1712)],e.xkMkW,"1"),L=e[n(930)](_0x15b108,_0x5ad08e[n(1829)][n(1712)],"is_ack","1"),F=_0x30d7f9[n(1027)](this,_0x5a89c9);if(e.RcAyA(h,R)){let{SeqID:W,LogID:Z,service:J,LogIDNew:fe,method:Se}=_0x367edb[n(1829)];this._sendAck({SeqID:W,LogID:Z,LogIDNew:fe,service:J,method:Se,headers:[{key:n(1107),value:"1"},{key:n(1614),value:e.mOnDZ(fe,"")},{key:e.AJxcQ,value:"0"}]})}L&&!F[n(1608)]&&this[n(1400)+"hAckMess"+n(1212)](_0x53d658),_0x290a44()}{let h=a[n(863)](":");for(let R=0;R<h.length;R++){let L=h[R];if(e[n(1961)](4,h[R][n(1927)])){let F=b[n(1049)+"g"](0,e[n(1571)](4,h[R].length)),W=F[n(1145)](L);s=s[n(1145)](W)}else s=s[n(1145)](L)}return s}}function w(a,n){let s=t,d=a[s(1535)];e[s(1629)](void 0,d)&&(e[s(1341)](ue,n,10),e[s(1002)](q,n,d));let f=a[s(1283)];e.sgOsX(void 0,f)&&(e[s(977)](e.QsVDI,s(1492))?(_0x4f6c2c[_0x4a26ed[_0x3c1b31][s(1173)+"ame"]]=_0x20d292(_0x2b362c[_0x3afff5].cursor_name),_0xb441c5+=14+_0x7a5820[_0x19fe95[_0xa80236][s(1173)+"ame"]]):(ue(n,18),e[s(1510)](q,n,f)))}function _(a){let n=t,s={};e:for(;!e[n(1631)](V,a);){let d=e[n(1044)](le,a);switch(d>>>3){case 0:break e;case 1:s[n(1535)]=e[n(1896)](O,a,e[n(1822)](le,a));break;case 2:s[n(1283)]=e[n(519)](O,a,e[n(1631)](le,a));break;default:C(a,e[n(998)](7,d))}}if(e[n(1334)](void 0,s[n(1535)]))throw new Error(n(1326)+n(1157)+n(892)+n(1535));if(e[n(783)](void 0,s[n(1283)]))throw new Error(e[n(1864)]);return s}function I(a){let n=t,s={VvFEd:function(d,f){return d*f}};if(e[n(977)](e[n(577)],n(1182))){let d=D();return e[n(1002)](E,a,d),B(d)}else return MVzbVJ[n(1692)](1e4,_0x5cab6e[n(1464)]())+_0x556394[n(822)](1e4*_0x4ae75c[n(1132)]())}function E(a,n){let s=t,d={TZWQc:function(Se){return e.cdGUx(Se)},SQszB:function(Se,Qe,ht){return Se(Qe,ht)},VwYzz:function(Se,Qe){return e[z(1042)](Se,Qe)}},f=a[s(1553)];e[s(977)](void 0,f)&&(ue(n,8),e[s(507)](ft,n,f));let g=a[s(496)];e[s(977)](void 0,g)&&(e.zwnpV(ue,n,16),e[s(1896)](ft,n,g));let m=a[s(1086)];e[s(1629)](void 0,m)&&(e.PXiNk(ue,n,24),e.mCYeR(ft,n,e.XWTPm(P,m)));let b=a[s(1229)];b!==void 0&&(ue(n,32),ft(n,P(b)));let h=a[s(1712)];if(h!==void 0)for(let Se of h){e.zwnpV(ue,n,42);let Qe=e[s(972)](D);e[s(1896)](w,Se,Qe),e[s(1002)](ue,n,Qe[s(1717)]),j(n,Qe),k(Qe)}let R=a[s(584)+"ncoding"];e.wVzhd(void 0,R)&&(e[s(933)](ue,n,50),e[s(1387)](q,n,R));let L=a["payloadT"+s(1892)];if(e.iGnDI(void 0,L))if(e[s(1334)](e[s(897)],e.MHOgQ)){let Se=vJirfm[s(1194)](_0x5212d2);return vJirfm.SQszB(_0xb199b3,_0x18968d,Se),vJirfm[s(1513)](_0x5991ef,Se)}else e[s(1217)](ue,n,58),e[s(453)](q,n,L);let F=a[s(1625)];if(F!==void 0)if(e[s(1155)](e[s(1139)],e.efwtO))ue(n,66),ue(n,F[s(1927)]),e[s(1337)](he,n,F);else return!!this[s(682)];let W=a[s(1088)];e[s(1370)](void 0,W)&&(e.qWWVH(ue,n,74),e[s(687)](q,n,W));let Z=a[s(1887)+"ming"];e.LelMs(void 0,Z)&&(e.gKSJt(ue,n,82),e.SBjjl(q,n,Z));let J=a[s(782)];e.exvbi(void 0,J)&&(e.iCXuo(ue,n,90),q(n,J));let fe=a[s(1886)+"e"];e[s(1108)](void 0,fe)&&(e[s(1002)](ue,n,96),e[s(1337)](ft,n,P(fe)))}function v(a){return A(e[t(680)](M,a))}function A(a){let n=t,s={};e:for(;!e[n(1044)](V,a);){let d=le(a);switch(e[n(653)](d,3)){case 0:break e;case 1:s[n(1553)]=e[n(1442)](St,a,!0);break;case 2:s.LogID=e[n(1610)](St,a,!0);break;case 3:s[n(1086)]=e.UzmGO(le,a);break;case 4:s[n(1229)]=e[n(1716)](le,a);break;case 5:{let f=S(a);(s[n(1712)]||(s[n(1712)]=[])).push(e[n(1910)](_,a)),a.limit=f;break}case 6:s["payloadE"+n(1901)]=e[n(1486)](O,a,e[n(680)](le,a));break;case 7:s["payloadT"+n(1892)]=e[n(1486)](O,a,e[n(1404)](le,a));break;case 8:s[n(1625)]=e[n(1444)](Ee,a,le(a));break;case 9:s.LogIDNew=e[n(1443)](O,a,e.NHGVo(le,a));break;case 10:s["serverTi"+n(739)]=O(a,le(a));break;case 11:s[n(782)]=e.IRlzK(O,a,le(a));break;case 12:s[n(1886)+"e"]=le(a);break;default:e[n(1341)](C,a,e[n(1824)](7,d))}}if(e[n(1621)](void 0,s[n(1553)]))throw new Error(e[n(837)]);if(e[n(1615)](void 0,s[n(496)]))throw new Error(n(1326)+n(1157)+n(892)+"LogID");if(e.MYXki(void 0,s.service))throw new Error(e[n(1700)]);if(e[n(1621)](void 0,s[n(1229)]))throw new Error(e.RHKyI);return s}function S(a){let n=t;if(e[n(1773)](n(1904),e.wrBtT)){let s=le(a),d=a.limit;return a[n(1717)]=e[n(954)](a[n(758)],s),d}else this[n(682)]?.[n(723)](),this[n(682)]=void 0}function C(a,n){let s=t;switch(n){case 0:for(;e.rorXN(128,e[s(1042)](ie,a)););break;case 2:e[s(581)]($,a,e[s(1042)](le,a));break;case 5:e[s(1376)]($,a,4);break;case 1:e[s(1061)]($,a,8);break;default:throw new Error(e[s(1770)](e.dgVgn,n))}}function P(a){let n=t;return a|=0,{low:a,high:a>>31,unsigned:e[n(1067)](a,0)}}let y=[];function D(){let a=t,n=y[a(767)]();return n?(n[a(758)]=n[a(1717)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){y[t(1655)](a)}function M(a){return{bytes:a,offset:0,limit:a[t(1927)]}}function B(a){let n=t,s=a[n(1168)],d=a[n(1717)];return e[n(1508)](s[n(1927)],d)?s:s[n(1302)](0,d)}function $(a,n){let s=t,d={zlJvT:e[s(1674)],gGjqt:"offline",RxZoX:e[s(1605)],voFHj:e[s(1294)]};if(e.Uojmq(e[s(1897)],e[s(1897)])){if(e[s(1618)](e.PjORI(a[s(758)],n),a[s(1717)]))throw new Error(e[s(617)]);a[s(758)]+=n}else this[s(1937)+"er"]&&_0x54a50a["addEvent"+s(1441)](d[s(1699)],this[s(640)+s(1192)]),this._isBrowser&&_0x3cfc85[s(1246)+s(1441)](d.gGjqt,this[s(640)+s(1803)]),this._isBrowser&&_0x380a22[s(1246)+"Listener"](d[s(1732)],this[s(1751)+s(1141)]),this[s(1937)+"er"]&&_0x34cf72[s(1246)+s(1441)](d[s(1450)],this[s(1751)+"ageShow"])}function V(a){return a[t(758)]>=a.limit}function te(a,n){let s=t,d=a[s(1168)],f=a[s(758)],g=a.limit,m=e[s(1753)](f,n);if(m>d[s(1927)]){let b=new Uint8Array(e[s(1805)](2,m));b[s(1238)](d),a.bytes=b}return a[s(758)]=m,e[s(1618)](m,g)&&(a[s(1717)]=m),f}function Q(a,n){let s=t,d=a.offset;if(e[s(1580)](d,n)>a[s(1717)])throw new Error(e[s(696)]);return a[s(758)]+=n,d}function Ee(a,n){let s=t,d=e[s(1337)](Q,a,n);return a.bytes[s(1302)](d,d+n)}function he(a,n){let s=t,d=e[s(507)](te,a,n.length);a[s(1168)][s(1238)](n,d)}function O(a,n){let s=t,d={XYLBK:e.tApqh};if(e[s(1621)](s(1380),e[s(1275)])){let f=e[s(900)](Q,a,n),g=String[s(1127)+s(1276)],m=a[s(1168)],b="\uFFFD",h="";for(let R=0;e[s(566)](R,n);R++){let L=m[e[s(1580)](R,f)],F,W,Z,J;e[s(1508)](e[s(918)](128,L),0)?h+=g(L):e.qymfy(e[s(720)](224,L),192)?e.REdks(R+1,n)?h+=b:(F=m[e[s(1353)](R,f)+1],e[s(456)](e[s(1368)](192,F),128)?h+=b:(J=(31&L)<<6|e.SLhxT(63,F),e[s(800)](J,128)?h+=b:(h+=e[s(1264)](g,J),R++))):e[s(1512)](240&L,224)?e[s(1067)](e[s(1580)](R,2),n)?h+=b:(F=m[R+f+1],W=m[R+f+2],(e[s(667)](F,e[s(576)](W,8))&49344)!==32896?h+=b:(J=e.mfCvJ(e[s(667)](e[s(576)](e[s(918)](15,L),12),e[s(1530)](e[s(720)](63,F),6)),e.ZnQCT(63,W)),e[s(566)](J,2048)||J>=55296&&J<=57343?h+=b:(h+=g(J),R+=2))):e[s(1894)](248&L,240)?e[s(1010)](R+3,n)?h+=b:(F=m[e[s(1580)](e[s(818)](R,f),1)],W=m[R+f+2],Z=m[e.QnfHg(e[s(805)](R,f),3)],e[s(1581)](e[s(1223)](e[s(1868)](e[s(1868)](F,e[s(1858)](W,8)),e.bIGFE(Z,16)),12632256),8421504)?h+=b:(J=e[s(1868)](e.iVWfg(e[s(1858)](7&L,18),e[s(576)](e[s(1368)](63,F),12))|e[s(778)](e.wPopQ(63,W),6),e[s(998)](63,Z)),e[s(800)](J,65536)||J>1114111?h+=b:(J-=65536,h+=e.TcIpa(g,e[s(943)](e[s(1780)](J,10),55296),e[s(1439)](e.ZTZNf(1023,J),56320)),R+=3))):h+=b}return h}else this[s(774)](d[s(1020)],_0x2b6e40),this[s(1277)+"eAck"]&&this["onReceiv"+s(548)](_0x4ed7cc)}function q(a,n){let s=t;if(e[s(676)](e[s(1742)],e[s(1742)])){let d=n[s(1927)],f=0;for(let b=0;e.bvACF(b,d);b++){let h=n[s(1120)+"At"](b);e[s(1010)](h,55296)&&e.ZGszF(h,56319)&&b+1<d&&(h=e.KLUQc(e[s(491)](e[s(1039)](h,10),n[s(1120)+"At"](++b)),56613888)),f+=h<128?1:e[s(887)](h,2048)?2:e[s(1053)](h,65536)?3:4}e[s(911)](ue,a,f);let g=te(a,f),m=a[s(1168)];for(let b=0;e[s(1845)](b,d);b++){let h=n.charCodeAt(b);e[s(1672)](h,55296)&&e[s(1678)](h,56319)&&e.OYtYY(b+1,d)&&(h=e[s(1571)](e[s(1579)](h,10)+n[s(1120)+"At"](++b),56613888)),h<128?m[g++]=h:(e.vsPrO(h,2048)?m[g++]=e.rorXN(e[s(1673)](h,6),31)|192:(e[s(1478)](h,65536)?m[g++]=e[s(1868)](h>>12&15,224):(m[g++]=e[s(1786)](e[s(918)](e[s(1646)](h,18),7),240),m[g++]=e[s(1958)](e[s(1646)](h,12),63)|128),m[g++]=e[s(993)](e[s(1646)](h,6),63)|128),m[g++]=e[s(1868)](e.sAkeh(63,h),128))}}else return _0x598da2?this[s(1569)+"E"]():this[s(1676)+"E"]()}function j(a,n){let s=t,d=te(a,n[s(1717)]),f=a[s(1168)],g=n[s(1168)];for(let m=0,b=n[s(1717)];e[s(566)](m,b);m++)f[m+d]=g[m]}function ie(a){let n=t;return a[n(1168)][e[n(474)](Q,a,1)]}function Je(a,n){let s=t,d=e.MMaFE(te,a,1);a[s(1168)][d]=n}function le(a){let n=t,s={IwwBk:function(d,f){return e.zmREX(d,f)},JpIBL:function(d,f){return e[z(662)](d,f)},FDesp:function(d,f){return e.VPgSK(d,f)},NiWHE:function(d,f){return e[z(1858)](d,f)},TsUkS:function(d,f){return e.sjBdG(d,f)},JyCli:function(d,f){return e[z(1773)](d,f)},zJZZQ:function(d,f){return e[z(566)](d,f)},VLkSN:function(d,f){return e[z(1478)](d,f)},FWmyW:function(d,f){return e[z(601)](d,f)},wHBOx:function(d,f,g){return d(f,g)},nKEen:function(d,f){return e[z(818)](d,f)},WKKQS:function(d,f){return e[z(1079)](d,f)},YNsti:function(d,f){return e[z(625)](d,f)},eQrSi:function(d,f){return e.uVluv(d,f)},tMVqf:function(d,f){return e[z(921)](d,f)},YgsPE:function(d,f){return d+f},YQAGo:function(d,f){return e[z(565)](d,f)},bmIIm:function(d,f){return e[z(842)](d,f)},ZnqVU:function(d,f){return e[z(1591)](d,f)},fkAin:function(d,f){return e.UpkPW(d,f)},FrMoR:function(d,f){return e[z(1591)](d,f)},SPZnu:function(d,f){return e[z(648)](d,f)},HmqFO:function(d,f){return d+f},GzpIl:function(d,f){return e[z(648)](d,f)},fMkiz:function(d,f){return e[z(674)](d,f)}};if(e[n(1428)](e[n(1437)],e[n(1437)])){let d=0,f=0,g;do g=e.wnURi(ie,a),e[n(992)](d,32)&&(f|=e[n(1579)](e[n(1563)](127,g),d)),d+=7;while(128&g);return f}else{let d=s[n(1784)](_0x139df9[n(1839)],0),f=s.JpIBL(s.FDesp(_0x1fa98e[n(1839)]>>>28,s.NiWHE(_0x34fd04[n(693)],4)),0),g=s[n(1797)](_0x2e482c.high,24),m=s[n(964)](0,g)?f===0?s[n(1253)](d,16384)?d<128?1:2:s[n(1253)](d,2097152)?3:4:s[n(906)](f,16384)?s.VLkSN(f,128)?5:6:s[n(906)](f,2097152)?7:8:s[n(1372)](g,128)?9:10,b=s.wHBOx(_0x56a786,_0x1dc324,m),h=_0x4d272f[n(1168)];switch(m){case 10:h[s[n(949)](b,9)]=s[n(738)](s[n(1797)](g,7),1);case 9:h[s.YNsti(b,8)]=s[n(688)](9,m)?s.FDesp(128,g):s[n(738)](127,g);case 8:h[s[n(949)](b,7)]=m!==8?s[n(1797)](f,21)|128:s[n(738)](s[n(1522)](f,21),127);case 7:h[s[n(690)](b,6)]=s.eQrSi(7,m)?s[n(885)](f>>>14,128):s[n(759)](f>>>14,127);case 6:h[b+5]=m!==6?f>>>7|128:s[n(734)](f,7)&127;case 5:h[s[n(949)](b,4)]=s.eQrSi(5,m)?s[n(884)](128,f):s[n(738)](127,f);case 4:h[b+3]=s[n(688)](4,m)?s[n(1490)](s[n(1422)](d,21),128):d>>>21&127;case 3:h[s[n(955)](b,2)]=s[n(688)](3,m)?s[n(884)](s[n(1328)](d,14),128):s[n(1062)](d,14)&127;case 2:h[s[n(1169)](b,1)]=m!==2?s[n(885)](s[n(940)](d,7),128):s[n(1062)](d,7)&127;case 1:h[b]=s[n(1691)](1,m)?s[n(885)](128,d):127&d}}}function ue(a,n){let s=t;for(n>>>=0;n>=128;)e[s(1431)](Je,a,e[s(565)](e[s(1079)](127,n),128)),n>>>=7;e[s(1526)](Je,a,n)}function St(a,n){let s=t,d=0,f=0,g=0,m;if(m=e[s(1044)](ie,a),d=e.nVsxa(127,m),e.FJDYh(128,m)&&(m=e.dEoqL(ie,a),d|=e[s(1530)](e[s(1456)](127,m),7),e[s(1824)](128,m)))if(e[s(1665)](s(695),e.Pbime))m=e.nYhEb(ie,a),d|=e[s(576)](e[s(1396)](127,m),14),e[s(1079)](128,m)&&(m=e[s(1912)](ie,a),d|=e[s(1530)](e[s(1147)](127,m),21),128&m&&(m=ie(a),f=127&m,e.XbpWw(128,m)&&(m=ie(a),f|=e[s(778)](127&m,7),e.SpYMC(128,m)&&(m=e[s(1912)](ie,a),f|=e[s(1255)](e.ZnQCT(127,m),14),e[s(701)](128,m)&&(m=e[s(531)](ie,a),f|=(127&m)<<21,e[s(1473)](128,m)&&(e.qymfy(e[s(1234)],e.ltqXQ)?(m=ie(a),g=e[s(1389)](127,m),e[s(1177)](128,m)&&(m=e[s(1128)](ie,a),g|=e[s(1579)](e[s(442)](127,m),7))):_0x59d8cc[s(1211)](_0x3ef5a6)))))));else try{this[s(682)]?.[s(723)](),this[s(682)]=void 0}catch(b){_0x252299[s(1211)](b)}return{low:d|e[s(1858)](f,28),high:e.gPcql(f,4)|e[s(482)](g,24),unsigned:n}}function ft(a,n){let s=t,d=e.HjTjZ(n[s(1839)],0),f=e[s(620)](n[s(1839)]>>>28|e[s(576)](n[s(693)],4),0),g=e[s(1609)](n[s(693)],24),m=e[s(681)](0,g)?f===0?e[s(887)](d,16384)?d<128?1:2:e[s(601)](d,2097152)?3:4:e[s(1133)](f,16384)?e[s(566)](f,128)?5:6:e.ezzjD(f,2097152)?7:8:g<128?9:10,b=e.SDVDw(te,a,m),h=a.bytes;switch(m){case 10:h[b+9]=e[s(726)](e[s(582)](g,7),1);case 9:h[e.CWNbC(b,8)]=m!==9?e[s(565)](128,g):127&g;case 8:h[e[s(954)](b,7)]=m!==8?e[s(1630)](e[s(1591)](f,21),128):e[s(1418)](e.uujDB(f,21),127);case 7:h[e.jXBsr(b,6)]=e[s(718)](7,m)?f>>>14|128:e[s(1771)](f>>>14,127);case 6:h[b+5]=e[s(1689)](6,m)?e[s(1921)](e[s(582)](f,7),128):e[s(998)](f>>>7,127);case 5:h[e.jXBsr(b,4)]=e.FWdMp(5,m)?e[s(1921)](128,f):127&f;case 4:h[e[s(1208)](b,3)]=e[s(1268)](4,m)?e[s(667)](e.XwMej(d,21),128):e[s(1860)](d>>>21,127);case 3:h[e[s(1298)](b,2)]=e[s(1684)](3,m)?e[s(1936)](e[s(633)](d,14),128):e[s(1389)](e[s(1371)](d,14),127);case 2:h[b+1]=e[s(1819)](2,m)?e.VPgSK(d>>>7,128):e[s(1368)](e[s(662)](d,7),127);case 1:h[b]=e.DiLXY(1,m)?e[s(777)](128,d):127&d}}function Xt(a){return e.MBXUs(v,a)}function zt(a){return I(a)}let Qt=65536,Gr=e[t(1560)],me=e[t(527)](Qt,Qt),Ie=me*me,Vn=Ie/2,ke=String[t(910)+"e"][t(1120)+"At"];class ce{constructor(n,s,d){let f=t;this.isLong=!0,this[f(1839)]=e[f(1542)](0,n),this[f(693)]=e[f(1149)](0,s),this.unsigned=!!d}static[t(728)](n){let s=t;return n&&e[s(449)](!0,n[s(728)])}static[t(1199)](n,s,d){return new ce(n,s,d)}static[t(1252)+"s"](n,s,d){let f=t;if(e[f(747)](e[f(1721)],e[f(1752)]))_0x4955c3(_0x5aef78,32),_0x11ef44(_0x4b5c6,e.qcqKi(_0x3c84bb,_0x534d93));else return d?ce["fromByte"+f(1433)](n,s):ce[f(1252)+f(716)](n,s)}static fromBytesLE(n,s){let d=t,f={nEsVs:function(g,m,b){return e[z(581)](g,m,b)},sQfnr:e[d(1774)],wkUSU:function(g,m){return g+m}};if(e[d(1248)](e.vwnVm,d(1038)))return new ce(e[d(565)](e[d(820)](n[0]|e.ArrCe(n[1],8),e[d(1039)](n[2],16)),e[d(1579)](n[3],24)),e[d(1470)](e[d(565)](e[d(1671)](n[4],e[d(790)](n[5],8)),e[d(1039)](n[6],16)),e[d(778)](n[7],24)),s);{let g=_0x114ec6[d(1390)][d(757)](_0x4bba24[d(1233)+"et"],f[d(1702)](_0x414756[d(591)+"th"],_0x45ebe8[d(1233)+"et"]));this[d(1948)]&&this[d(1948)][d(1503)]({data:g,fail:m=>{let b=d;this[b(774)](b(787),f[b(495)](_0x343a8f,f.sQfnr,{message:this["_formatE"+b(1539)+"age"](m)}))}})}}static[t(1252)+t(716)](n,s){let d=t;return new ce(e[d(1947)](e[d(777)](e.VPgSK(e[d(1039)](n[4],24),e[d(1694)](n[5],16)),n[6]<<8),n[7]),e[d(1467)](e[d(1898)](e[d(712)](n[0],24)|e[d(1579)](n[1],16),n[2]<<8),n[3]),s)}static[t(962)](n){let s=t,d={JfbIc:function(f,g){return e.wPopQ(f,g)},TLQvq:function(f,g){return f>>g},obuqY:function(f,g){return e[z(1905)](f,g)},KbMcV:function(f,g){return e[z(1686)](f,g)},GDwGy:function(f,g){return f+g},xvgis:function(f,g){return e[z(778)](f,g)},XAugK:function(f,g){return e[z(1432)](f,g)},RrSWO:function(f,g){return e.MacCZ(f,g)},lvdWL:function(f,g){return e[z(1079)](f,g)}};if(e[s(1137)]===s(1463))return e[s(1665)](n,Gr)?Md:new ce((e.ooniH(ke[s(1027)](n,0),e[s(1587)](ke.call(n,1),8))|e[s(482)](ke[s(1027)](n,2),16)|e.Svehb(ke[s(1027)](n,3),24))>>>0,e.UKODd(e[s(1417)](e[s(777)](ke[s(1027)](n,4),e.bIEbE(ke[s(1027)](n,5),8)),ke[s(1027)](n,6)<<16)|e[s(576)](ke[s(1027)](n,7),24),0),!0);{let f=("3|5|1|2|"+s(512))[s(863)]("|"),g=0;for(;;){switch(f[g++]){case"0":_0x144615[_0x1be131++]=d.JfbIc(d.TLQvq(_0x1ada03,6),63)|128;continue;case"1":_0xbbd360[_0x5420f1++]=d[s(1640)](_0x15190f>>18,240);continue;case"2":_0x11e2d0[_0x47ef3f++]=d[s(932)](d.JfbIc(d[s(942)](_0x3e368d,12),63),128);continue;case"3":_0x3ff231=d[s(770)](65536+d[s(544)](d[s(959)](1023,_0xccc508),10),d[s(1111)](1023,_0x4f8a03));continue;case"4":_0xa0a1d4[_0x37d12d++]=d.RrSWO(d[s(1210)](63,_0x276f66),128);continue;case"5":++_0x58b616;continue}break}}}[t(1009)](){let n=t;return String.fromCharCode(e[n(918)](255,this.low),e.nznTZ(e[n(1336)](this[n(1839)],8),255),e.nVsxa(e[n(582)](this[n(1839)],16),255),e.zmREX(this[n(1839)],24),e[n(1501)](255,this[n(693)]),e.ZmJXv(this[n(693)],8)&255,e[n(1501)](e[n(662)](this[n(693)],16),255),e[n(1609)](this[n(693)],24))}static fromNumber(n,s=!0){let d=t;if(e[d(1689)](e[d(730)],d(806))){let f=_0x2259c1[d(1049)+"g"](0,e.KLUQc(4,_0x2eafce[_0x27d7df][d(1927)])),g=f[d(1145)](_0x244201);_0x5697b7=_0x6a8fc[d(1145)](g)}else{if(e[d(1262)](isNaN,n))return s?Fh:Md;if(s){if(e[d(1672)](n,Ie))return Gh}else{if(n<=-Vn)return qh;if(e[d(943)](n,1)>=Vn)return Uh}return ce[d(1199)](e[d(1542)](n%me,0),e.sNbay(n/me,0),s)}}toNumber(){let n=t,s={DmKAa:function(d,f){return e[z(1334)](d,f)},GQGJr:function(d,f){return e[z(800)](d,f)},XJmeX:function(d,f){return d===f}};if(e[n(1508)](e[n(1300)],e[n(1865)])){if(s[n(1054)](void 0,_0x2f5762))this[n(1130)+"rs"]={};else if(_0x2fee86===void 0)this[n(1130)+"rs"][_0x3d860f]=null;else{let d=this[n(1130)+"rs"][_0x5dc0de];if(d)for(let f=0;s[n(1040)](f,d.length);)s.XJmeX(d[f].fn,_0xb858d8)?d[n(644)](f,1):++f}return this}else return this[n(1739)]?e[n(1805)](this[n(693)]>>>0,me)+e[n(648)](this[n(1839)],0):e[n(1737)](this[n(693)]*me,e[n(1272)](this[n(1839)],0))}[t(683)](){let n=t;return e[n(1165)](0,this[n(693)])&&e.tMpNW(0,this.low)}[t(1325)](n){let s=t,d={jfocO:function(f,g){return e[z(1846)](f,g)},uxMCd:function(f,g){return f==g},FdWLH:s(1762)+s(983)+s(1537)};if(e[s(1689)](e[s(803)],s(857))){ce[s(728)](n)||(n=ce[s(1750)+"er"](n));let f=e[s(1329)](this[s(693)],16),g=e[s(1318)](65535,this.high),m=this[s(1839)]>>>16,b=e.SpYMC(65535,this.low),h=n[s(693)]>>>16,R=e[s(1788)](65535,n[s(693)]),L=e.JXUJX(n[s(1839)],16),F=65535&n[s(1839)],W=0,Z=0,J=0,fe=0;return fe+=e[s(954)](b,F),J+=e[s(1888)](fe,16),fe&=65535,J+=e[s(1401)](m,L),Z+=J>>>16,J&=65535,Z+=e.yYIxw(g,R),W+=e.eyhnA(Z,16),Z&=65535,W+=e[s(1439)](f,h),W&=65535,ce[s(1199)](e[s(1148)](J<<16,fe),e[s(1908)](e[s(1530)](W,16),Z),this.unsigned)}else{let{url:f}=d[s(1017)](_0x2731cf,{}),g=_0x528a89.isArray(f)?f:d[s(1195)](s(1394),typeof f)?[f]:[];_0xac29dc&&_0x323734.assign(this._options,_0x2942d6),g&&g[s(1927)]?this[s(1516)+"tManager"]=new _0x8d010(g,this[s(1754)][s(1593)+"es"]):this[s(1516)+s(1271)]?.[s(772)+s(920)+s(1436)](),this["_pingLos"+s(1670)]?.[s(1069)+"nter"](this[s(1754)][s(788)+s(1934)]),this._readyClosed=!1,this._ws&&this._ws[s(1331)+"te"]!==this[s(650)]?this[s(810)+s(1634)](1e3,d[s(802)],!0):(this[s(1843)]=!0,this[s(547)]())}}equals(n){let s=t;return ce[s(728)](n)||(n=ce[s(1750)+"er"](n)),e.icCdt(this.unsigned,n[s(1739)])&&e[s(1723)](e[s(1609)](this[s(693)],31),1)&&e[s(1802)](e.OELpQ(n[s(693)],31),1)?!1:e.jyvJP(this[s(693)],n.high)&&e[s(504)](this[s(1839)],n.low)}[t(1240)](){let n=t;return e.qymfy(-1,this[n(1839)])&&this[n(693)]===-1?ce[n(1199)](0,0,this[n(1739)]):e[n(1615)](-1,this[n(1839)])?ce.fromBits(0,e[n(1393)](this.high,1),this[n(1739)]):ce[n(1199)](e[n(818)](this[n(1839)],1),this.high,this[n(1739)])}[t(1427)](n){let s=t;if(e[s(977)](s(1842),e[s(513)]))return n?this[s(1569)+"E"]():this[s(1676)+"E"]();ZXTXGV.VJTYo(_0x99a5ac,_0x2bc6d6[s(787)]),ZXTXGV[s(972)](_0xe1fe74)}[t(1569)+"E"](){let n=t;if(e[n(1248)](e[n(1379)],n(764))){let s=this[n(693)],d=this[n(1839)];return[e[n(1828)](255,d),e[n(1563)](d>>>8,255),e[n(1561)](e[n(1371)](d,16),255),e[n(1371)](d,24),e.aetUL(255,s),e[n(1311)](s,8)&255,e[n(1105)](s,16)&255,e[n(953)](s,24)]}else return this[n(682)]?.[n(1238)]({message_id:_0x479c29,timestamp:_0x2534ae})}[t(1676)+"E"](){let n=t,s=this[n(693)],d=this.low;return[e[n(1105)](s,24),s>>>16&255,e[n(918)](e[n(1297)](s,8),255),e.QRcUg(255,s),e[n(1280)](d,24),e[n(1787)](d,16)&255,e[n(534)](e[n(1247)](d,8),255),e[n(720)](255,d)]}}let Md=new ce(0,0,!1),Fh=new ce(0,0,!0),Uh=ce[t(1199)](-1,2147483647,!1),Gh=ce[t(1199)](-1,-1,!0),qh=ce[t(1199)](0,-2147483648,!1);var en=(function(a){let n=t,s=e[n(664)].split("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[n(1143)+"OR"]=5005]=e[n(1541)];continue;case"1":return a;case"2":a[a[n(1475)+"RROR"]=5001]=e.kYFtD;continue;case"3":a[a[n(1928)+n(1793)]=5002]=n(1928)+"NG_ERROR";continue;case"4":a[a[n(1109)+n(707)+"R"]=5003]=e[n(477)];continue;case"5":a[a[e[n(1366)]]=5004]=e.CvfcW;continue}break}})({});class Jn{constructor(n){let s=t;this[s(1101)]=n,this[s(1911)]=null}}class Bd extends Jn{constructor(n,s){let d=t;super(n),this.message=s&&s[d(1829)]||null}}class zd extends Jn{constructor(n,s){let d=t;if(e[d(623)](e[d(1744)],e[d(1744)])){let f=(d(561)+"5|1|4").split("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(787)]=s&&s[d(787)]||null;continue;case"1":this.message=s&&s[d(1829)]||"";continue;case"2":this[d(1160)]=s&&s[d(1160)]||0;continue;case"3":this[d(978)]=s&&s[d(978)]||"";continue;case"4":this.code=s&&s[d(1601)]||5001;continue;case"5":this[d(812)]=s&&s.lineno||0;continue;case"6":super(n);continue}break}}else e[d(755)](_0x3d3635,_0x10e37d,10),_0x2d4664(_0x44a4fe,_0x33d06c)}}class Fd extends Jn{constructor(n,s){let d=t,f=e[d(1136)][d(863)]("|"),g=0;for(;;){switch(f[g++]){case"0":super(n);continue;case"1":this.willReconnect=s&&s["willReco"+d(1076)]||!1;continue;case"2":this[d(881)]=s&&s.wasClean||!1;continue;case"3":this.code=s&&s[d(1601)]||0;continue;case"4":this[d(516)]=s&&s.reason||"";continue}break}}}class Ud extends Jn{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1876)]||null}}class Gd extends Ud{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1876)]||null,this.message=s&&s.message||null}}class qd extends Jn{constructor(n,s){let d=t;super(n),this[d(1876)]=s&&s[d(1876)]||null}}function ot(a,{message:n,code:s,error:d}){let f=t;if(e[f(504)](f(838),e[f(1015)])){let g=e[f(549)](_0x136649,e[f(1774)],{message:this[f(827)+f(1539)+f(898)](_0x193dc7)});this[f(774)](e[f(1774)],g);let m=e[f(687)](_0x20705d,f(723),{reason:this[f(827)+"rrorMess"+f(898)](_0x1e35de)});this[f(774)](e[f(756)],m)}else return new zd(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Fd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Hd(a,{data:n,message:s}){return new Gd(a,{data:n,message:s})}function jd(a,{data:n}){return new qd(a,{data:n})}function ra(a,{message:n}){return new Bd(a,{message:n})}class Wd{constructor(n,s){let d=t;this[d(1818)+"s"]=n,this[d(1593)+"es"]=s,this[d(1080)+d(1755)]=0,this[d(1880)+"ndpointT"+d(847)+"t"]=0}[t(772)+t(920)+t(1436)](){let n=t;this.currentIndex=0,this["currentEndpointT"+n(847)+"t"]=0}[t(705)+"es"](){let n=t;this["currentE"+n(1289)+n(847)+"t"]=0}["getCurre"+t(461)+"nt"](){let n=t;if(e[n(472)](n(735),e[n(466)])){let s=this[n(1130)+"rs"][_0x1b2048];if(s)s[n(757)]().forEach(d=>d.fn[n(1765)](d[n(574)],_0x210314));else if(e.paXuG("error",_0x385337)&&!this.onerror){let d=_0x3dc73e.length&&_0x5e35c7[0];if(d instanceof _0x259b4a)throw d;let f=new _0x2446c0(e.vbyTX+(d?e[n(491)](" (",d[n(1829)])+")":""));throw f[n(669)]=d,d}return this}else return this[n(1818)+"s"][this[n(1080)+"ndex"]]}[t(1558)+t(461)+"ntTriesCount"](){let n=t;return this[n(1880)+n(1289)+n(847)+"t"]}[t(1094)+t(1100)+"es"](){let n=t;return!!(e.innzK(this[n(1080)+"ndex"],this[n(1818)+"s"][n(1927)])||e[n(1705)](this[n(1080)+n(1755)],e[n(1571)](this[n(1818)+"s"][n(1927)],1))&&this[n(1880)+"ndpointT"+n(847)+"t"]===this[n(1593)+"es"])}[t(1878)+t(446)+t(1278)+t(985)+t(1588)](){let n=t;return this[n(1080)+n(1755)]==this[n(1818)+"s"][n(1927)]?!0:this[n(1880)+n(1289)+n(847)+"t"]>this.maxRetries}["replaceBackupEnd"+t(1257)+t(571)+"unt"](){let n=t;return this[n(1880)+n(1289)+n(847)+"t"]=1,this[n(1080)+n(1755)]++,this[n(1818)+"s"][this[n(1080)+n(1755)]]}["getCurre"+t(461)+t(579)+"ateCount"](){let n=t;return this[n(1880)+n(1289)+n(847)+"t"]++,this[n(1558)+n(461)+"nt"]()}}let Zn=(e[t(1619)](e[t(1024)],typeof globalThis)&&e[t(1773)](e[t(1585)],globalThis[t(1821)+t(1544)][t(1767)])||e.fbOnQ(e.CmhPt,typeof window)&&e[t(1457)](e.WSoyC,window[t(1821)+t(1544)][t(1767)]))&&e[t(986)](e[t(1024)],typeof document),An=e[t(1024)]!=typeof globalThis&&(e[t(917)]===globalThis[t(1821)+t(1544)][t(1767)]||e[t(1285)]===globalThis[t(1821)+t(1544)].name)&&e[t(529)](e.CmhPt,typeof tt),qr=(t(645)+"d"!=typeof globalThis&&e.PoOPd(e[t(917)],globalThis[t(1821)+t(1544)][t(1767)])||e.OFQug(t(645)+"d",typeof globalThis)||e.pAiaG(e[t(1024)],typeof globalThis)&&!!globalThis[t(841)+t(1458)])&&e[t(1619)](e.CmhPt,typeof wx),Hr=e[t(529)](e[t(1024)],typeof globalThis)&&(e[t(1285)]===globalThis[t(1821)+t(1544)].name||e[t(1165)](t(1274)+t(1381)+t(969),globalThis[t(1821)+t(1544)][t(1767)])||e[t(886)](e.SojQd,globalThis[t(1821)+t(1544)][t(1767)]))&&e[t(1024)]!=typeof self,Hh=e[t(1914)](e[t(1024)],typeof globalThis)&&e.BMJcf(e[t(917)],globalThis[t(1821)+t(1544)][t(1767)])&&e.pAiaG(e[t(1024)],typeof global)&&e.BMJcf(t(634),global[t(1821)+t(1544)][t(1767)])&&e[t(1024)]!=typeof process&&!!process.version;class ia{constructor(){let n=t;this[n(1130)+"rs"]={}}[t(774)](n,...s){let d=t,f=this[d(1130)+"rs"][n];if(f)f.slice()[d(1549)](g=>g.fn[d(1765)](g[d(574)],s));else if(e[d(504)](d(787),n)&&!this[d(1016)]){let g=s[d(1927)]&&s[0];if(e[d(1095)](g,Error))throw g;let m=new Error(e.boSMK(d(564)+d(1715),g?e[d(943)](e[d(912)](" (",g[d(1829)]),")"):""));throw m[d(669)]=g,g}return this}[t(1440)](n,s){let d=t;if(e[d(679)](void 0,n))this[d(1130)+"rs"]={};else if(e[d(637)](void 0,s))this[d(1130)+"rs"][n]=null;else{let f=this[d(1130)+"rs"][n];if(f)for(let g=0;e[d(1218)](g,f[d(1927)]);)e[d(1498)](f[g].fn,s)?f.splice(g,1):++g}return this}on(n,s,d){let f=t,g={NlcXs:function(m,b){return e[z(1695)](m,b)},gYljn:function(m,b){return e[z(576)](m,b)},NZMcs:function(m,b){return e.aetUL(m,b)},MXEpS:function(m,b){return m<<b},ZTACg:function(m,b){return m<b},XDfsW:function(m,b){return e[z(1067)](m,b)},oNOpv:function(m,b){return e[z(1807)](m,b)},qqNux:function(m,b){return e[z(1654)](m,b)}};if(e[f(1903)]===e[f(1945)])_0x42e5aa=wWBFHD[f(860)](wWBFHD[f(1889)](wWBFHD.NZMcs(15,_0x5e2dcc),12),wWBFHD[f(1347)](wWBFHD.NZMcs(63,_0x27bda9),6))|wWBFHD[f(691)](63,_0x3b0172),wWBFHD[f(966)](_0x2cbb94,2048)||wWBFHD[f(1848)](_0x163739,55296)&&wWBFHD.oNOpv(_0x49553f,57343)?_0x32c2d2+=_0x1dbe57:(_0x3e82c2+=wWBFHD.qqNux(_0x6f5c07,_0x339fbd),_0x3c86c9+=2);else return(this[f(1130)+"rs"][n]||(this[f(1130)+"rs"][n]=[]))[f(1655)]({fn:s,ctx:d||this}),this}}class jh extends ia{[t(827)+t(1539)+t(898)](n){let s=t;return n[s(658)]||n[s(702)]?(s(1933)+" "+(n[s(658)]||"")+s(1540)+(n.errNo||""))[s(1728)]():JSON[s(722)+"y"](n)}constructor(n,s,d){let f=t;super(),this._socket=null,qr&&wx[f(958)+f(1575)]&&(this._socket=wx[f(958)+f(1575)]({url:n,protocols:s,header:d,fail:this[f(1789)+f(851)+"lHandler"][f(938)](this),success:this["_createS"+f(934)+"cessHand"+f(971)].bind(this)})),An&&tt[f(958)+f(1575)]&&(this._socket=tt[f(958)+f(1575)]({url:n,protocols:s,header:d,fail:this[f(1789)+f(851)+"lHandler"].bind(this),success:this["_createSocketSuc"+f(1645)+f(971)][f(938)](this)}))}[t(1789)+t(934)+t(1645)+t(971)](){let n=t;Promise[n(946)]()[n(929)](()=>{this["_addWsLi"+n(485)]()})}["_createS"+t(851)+t(1346)](n){let s=t;Promise[s(946)]()[s(929)](()=>{let d=s,f=e[d(1443)](ot,e[d(1774)],{message:this["_formatE"+d(1539)+"age"](n)});this.emit(d(787),f);let g=e[d(1295)](xt,e[d(756)],{reason:this[d(827)+"rrorMessage"](n)});this[d(774)](e[d(756)],g)})}["_addWsLi"+t(485)](){let n=t,s={JBzZL:e[n(1666)],qaqCD:function(d,f,g){return e[n(1179)](d,f,g)},jivYs:function(d,f){return e[n(1428)](d,f)},QyMEp:e[n(1323)],BvhtJ:e.izaOc};this[n(1948)].onOpen(d=>{let f=n;this[f(774)](s[f(889)],s[f(878)](jd,s.JBzZL,{...d,data:d.errMsg||""}))}),this._socket[n(489)](d=>{let f=n;this[f(774)](e[f(756)],xt(e[f(756)],{...d}))}),this._socket.onMessage(d=>{let f=n;if(s[f(1814)](s[f(1806)],"lxaxs"))this[f(774)](s[f(1592)],Hd(s[f(1592)],{...d}));else return _0xe2e5c8+=_0x17e8de&&_0x3161e3[f(591)+"th"]||0,_0x3a27af}),this[n(1948)][n(666)](d=>{let f=n;this.emit(e.qjdtI,e.rmQAX(ot,e[f(1774)],{...d,message:d[f(658)]||""}))})}[t(1503)](n){let s=t;if(e[s(715)](n,Uint8Array)){let d=n[s(1390)].slice(n[s(1233)+"et"],e[s(1355)](n[s(591)+"th"],n[s(1233)+"et"]));this[s(1948)]&&this[s(1948)][s(1503)]({data:d,fail:f=>{let g=s;this[g(774)]("error",ot(e[g(1774)],{message:this["_formatE"+g(1539)+"age"](f)}))}})}else this._socket&&this[s(1948)][s(1503)]({data:n,fail:d=>{let f=s;this[f(774)](e[f(1774)],e.PXiNk(ot,e[f(1774)],{message:this[f(827)+f(1539)+f(898)](d)}))}})}[t(723)](n,s){let d=t;this[d(1948)]&&this._socket[d(723)]({code:n,reason:s})}[t(1246)+t(1441)](n,s){this.on(n,s)}[t(1854)+t(1790)+"ner"](n,s){let d=t;e[d(501)](e.GKIRq,e.uceKe)?(this[d(768)+d(621)+d(1446)]=_0x34458f,_0x1e2d61?this[d(640)+"nLine"]():this[d(640)+d(1803)]()):this.off(n,s)}get[t(1331)+"te"](){let n=t;return this[n(1948)][n(1331)+"te"]}get binaryType(){let n=t;return this[n(1948)][n(1555)+"pe"]}set[t(1555)+"pe"](n){}get url(){let n=t;return e[n(1485)](e.XAsPS,e[n(1729)])?this[n(682)][n(1338)]:this[n(1948)][n(813)]}get[t(781)](){return this[t(1948)].protocol}get[t(1642)+"ns"](){return this._socket.extensions}get[t(1884)+"Amount"](){return 0}}function Wh(a,n){let s=t;if(n)return new n(a.url,a[s(781)]);if(qr||An)return new jh(a[s(813)],a[s(781)],a[s(1712)]);if(e[s(1846)](Zn,Hr)&&e.KAtNs(e[s(1024)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a.protocols)}function Kh(a){let n=t;return!!(a||qr&&wx["connectS"+n(1575)]||An&&tt["connectS"+n(1575)]||(Zn||Hr)&&e[n(1024)]!=typeof WebSocket&&WebSocket)}function Kd(a,n,s){let d=t,f={ToIbh:function(b,h){return e[z(896)](b,h)},uGHHH:e[d(583)],UOUaL:function(b,h){return e.DYhIL(b,h)}},g=-1;async function m(b){let h=d;return f.ToIbh(b,g)?Promise[h(569)](new Error(f[h(1830)])):(g=b,b===s[h(1927)]?Promise[h(946)]():s[b][h(938)](a)(n,m.bind(null,f[h(1258)](b,1))))}e.oWDeG(m,0)}function $d(a){let n=t,s=0,d=0;for(let f=0;e[n(1696)](f,a[n(1927)]);++f)if(d=a[n(1120)+"At"](f),d<128)s+=1;else if(e[n(1053)](d,2048))s+=2;else if(e[n(1334)](64512&d,55296)&&e.mgyPC(64512,a[n(1120)+"At"](e[n(607)](f,1)))===56320)if(e.khrJv(e[n(1178)],n(1187))){if(!this[n(547)+n(1811)]){let g=(n(1663)+"0")[n(863)]("|"),m=0;for(;;){switch(g[m++]){case"0":this[n(547)]();continue;case"1":this[n(741)+n(1670)]?.["resetCou"+n(1589)]();continue;case"2":this[n(1516)+n(1271)]?.[n(772)+n(920)+n(1436)]();continue;case"3":this[n(1036)+n(1296)]=!1;continue;case"4":this[n(1843)]=!0;continue}break}}}else++f,s+=4;else s+=3;return s}function Vd(a,n,s){let d=t;if(e.PYbgm(d(1837),e.qlOYi))return this[d(1818)+"s"][this["currentI"+d(1755)]];{if(e[d(1571)](s,n)<1)return"";let f="";for(let g=n;e[d(887)](g,s);){let m=a[g++];if(e[d(1807)](m,127))f+=String[d(1127)+"Code"](m);else if(e.PlUID(m,192)&&m<224)f+=String.fromCharCode(e[d(925)](e[d(1877)](31,m)<<6,e[d(1501)](63,a[g++])));else if(e.PlUID(m,224)&&e[d(1256)](m,240))f+=String[d(1127)+d(1276)](e[d(712)](e[d(1561)](15,m),12)|e.ArrCe(e[d(1185)](63,a[g++]),6)|e[d(872)](63,a[g++]));else if(m>=240){let b=e[d(1571)](e[d(1151)](e[d(1506)](e[d(1368)](7,m),18)|e[d(1517)](63&a[g++],12),e[d(1506)](e[d(980)](63,a[g++]),6))|e[d(1177)](63,a[g++]),65536);f+=String[d(1127)+d(1276)](55296+e.zkHqO(b,10)),f+=String[d(1127)+d(1276)](56320+e[d(1877)](1023,b))}}return f}}function sa(a,n,s){let d=t,f={yJuyM:function(h,R){return h<R},CrQsW:function(h,R){return e[z(1716)](h,R)}},g=s,m,b;for(let h=0;e[d(694)](h,a.length);++h)if(m=a[d(1120)+"At"](h),m<128)n[s++]=m;else if(e.OlURJ(m,2048))n[s++]=e[d(1397)](m,6)|192,n[s++]=e[d(1235)](e[d(1456)](63,m),128);else if((64512&m)===55296&&e.MYXki(e[d(1772)](64512,b=a[d(1120)+"At"](e[d(1554)](h,1))),56320)){let R=e.sxqab[d(863)]("|"),L=0;for(;;){switch(R[L++]){case"0":n[s++]=e[d(517)](63,m)|128;continue;case"1":n[s++]=e[d(1646)](m,12)&63|128;continue;case"2":n[s++]=e[d(1786)](e.eYRey(m,6)&63,128);continue;case"3":n[s++]=e[d(1905)](m>>18,240);continue;case"4":m=e[d(639)](e.aGxEF(65536,e[d(1411)](e[d(1563)](1023,m),10)),e[d(893)](1023,b));continue;case"5":++h;continue}break}}else if(e[d(1206)]===e[d(1206)])n[s++]=m>>12|224,n[s++]=e.RbokL(e.IjFhw(e[d(533)](m,6),63),128),n[s++]=e[d(1339)](e[d(720)](63,m),128);else{let R=0,L={};for(let F=0;f.yJuyM(F,_0x631c6e.length);F++)L[_0x42e1c3[F][d(1173)+d(931)]]=f[d(1356)](_0x1f6889,_0x27b309[F][d(1173)+"ame"]),R+=14+L[_0xda0ef1[F]["cursor_n"+d(931)]];return[R,L]}return e[d(1571)](s,g)}async function Jd(a){let n=t;if(e[n(1965)](e[n(1628)],typeof a)){let s=new Uint8Array(e[n(1912)]($d,a));return sa(a,s,0),s}return e[n(1095)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1390)],a.byteOffset,a[n(591)+"th"])}function $h(a){let n=t;try{return typeof a!="string"&&(a instanceof ArrayBuffer||a[n(1390)]&&a[n(1390)]instanceof ArrayBuffer)||e[n(1628)]!=typeof a?"":(JSON[n(1866)](a),n(868)+"ion/json")}catch{return e[n(1628)]==typeof a?e.BtLiS:""}}let Vh=(a,n)=>{let s=t;switch(a){case e[s(1449)]:case e[s(1879)]:return{[s(1226)+a]:1,"x-tt-env":n};default:return{}}};class Jh{constructor(n){let s=t;this[s(1384)+s(880)]=n,this[s(1134)]=0}[t(1749)](){this.count++}[t(1094)+t(541)+"nt"](){let n=t;return e[n(1010)](this.count,this[n(1384)+n(880)])}["resetCou"+t(1589)](n=0){let s=t,d={Olemr:e[s(1774)],kDZcE:function(f,g,m){return f(g,m)}};e[s(974)](e.nxGDu,e[s(1756)])?(this["maxLossC"+s(880)]=n,this[s(1134)]=0):this[s(774)](SMhsuQ[s(689)],SMhsuQ.kDZcE(_0x2beb1e,SMhsuQ[s(689)],{..._0x23472e,message:_0x7d28ff[s(658)]||""}))}}async function Zh(a){let n={bdaJC:e.GMJGJ};return new Promise(s=>{let d=z;if(!Zn)return e[d(1103)](s,e[d(1617)]);try{let f=document[d(1546)+d(895)](e[d(919)]);window.frontierJSONP=g=>{let m=d;document[m(1902)][m(1317)+"ild"](f),window[m(1239)+m(1840)]=void 0,s(g&&g.msg||n[m(834)])},f.type="text/javascript",f.src=e[d(1316)](a[d(588)](/^ws/,e[d(836)]),e[d(1471)]);try{document[d(1902)][d(1115)+d(698)](f)}catch{document[d(1902)][d(1317)+d(698)](f)}}catch{window[d(1239)+d(1840)]=void 0,e[d(1262)](s,e[d(1617)])}})}function tn(a,n,s){let d=t;return!!a?.[d(1775)](f=>f[d(1535)]===n&&f[d(1283)]===s)}function Yn(a,n){let s=t;return a?.[s(1775)](d=>d[s(1535)]===n)?.[s(1283)]}let oa=null;async function Yh(){let a=t,n={pgYoF:function(s,d){return e.bJdEL(s,d)}};if(e.qcSjU("HNkAb",e.yZwFt)){let s=this[a(1055)+"Queue"].reduce((d,f)=>(d+=f&&f[a(591)+"th"]||0,d),0);return n[a(737)](s,this._ws?this[a(1096)][a(1884)+a(1022)]:0)}else return oa||(oa=Promise[a(946)]()[a(929)](Nt[a(938)](Nt,e[a(499)]))),oa}class Xh extends ia{constructor(n,s){let d=t;super(),this[d(846)]=n,this[d(1826)]=s,this[d(682)]=void 0,this[d(817)+"mise"]=null}async openDB(){await this[t(1801)]()}async[t(1801)](){let n=t,s={HFMot:function(d){return e[z(1188)](d)}};if(e[n(1029)]===e[n(1029)]){if(this[n(682)])return;if(this["_initPro"+n(990)])return this[n(817)+"mise"];try{let d=this[n(846)],f=this[n(1826)];this._initPromise=(async()=>{let g=n,{openDB:m}=await s[g(600)](Yh);this._qosDB=await m(g(1239)+"_"+d,1,{upgrade(b){let h=g;b[h(1152)+h(1048)+"e"](d,{keyPath:f})}})})(),await this[n(817)+n(990)]}catch(d){console[n(1211)](d)}finally{this[n(817)+n(990)]=null}}else{if(_0x849670)return new _0x4fe7b8(_0x57a078[n(813)],_0x3b3d9f.protocol);if(e[n(1846)](_0x5a86c1,_0xd84853))return new _0x4dcc6e(_0x375a44[n(813)],_0x3c8c0c[n(781)],_0x1d2773[n(1712)]);if(e[n(1846)](_0xdb52db,_0x5a73ec)&&n(645)+"d"!=typeof _0xdeea19&&_0x269b0c)return new _0x4e9884(_0x325515[n(813)],_0x19acaa.protocols)}}async[t(1577)](n){let s=t;try{return await this[s(1801)](),this[s(682)]?.[s(1577)](this[s(846)],n)}catch(d){console[s(1211)](d)}}async[t(1238)](n,s){let d=t;return e[d(1562)]===d(1531)?this._socket[d(781)]:(await this[d(1801)](),this[d(682)]?.[d(743)](this._dbName,n))}async del(n){let s=t;try{return await this[s(1801)](),this[s(682)]?.[s(839)](this._dbName,n)}catch(d){console[s(1211)](d)}}async[t(1600)](){let n=t;try{return await this[n(1801)](),this[n(682)]?.[n(1600)](this[n(846)])}catch(s){if(e[n(951)](e[n(502)],e[n(502)]))console[n(1211)](s);else return this[n(1839)]===-1&&this[n(693)]===-1?_0x15458c[n(1199)](0,0,this.unsigned):this[n(1839)]===-1?_0x63b32[n(1199)](0,e[n(665)](this[n(693)],1),this[n(1739)]):_0x430906[n(1199)](this[n(1839)]+1,this[n(693)],this[n(1739)])}}async[t(1632)](){let n=t;return await this[n(1801)](),this[n(682)]?.[n(655)+"ys"](this[n(846)])}async getAll(){let n=t;if(e[n(1727)](e[n(1073)],"jGnhk"))return await this[n(1801)](),this[n(682)]?.getAll(this._dbName);this[n(1384)+n(880)]=_0x4787f0,this[n(1134)]=0}async[t(710)](){let n=t;try{this[n(682)]?.[n(723)](),this[n(682)]=void 0}catch(s){console[n(1211)](s)}}get[t(1338)](){let n=t;try{return!!this._qosDB}catch(s){return console[n(1211)](s),!1}}}class Qh{constructor(n,s){let d=t;this._DBName=n,this[d(1200)]=s,this[d(682)]=localStorage}async[t(1940)](){}get _prefix(){return t(1239)+"_"+this._DBName}async[t(1577)](n){let s=t,d={QCMKR:function(f){return e[z(525)](f)}};if(e[s(1108)](e[s(1856)],s(1066))){let f=this[s(682)][s(1395)](this[s(554)]);return JSON[s(1866)](e[s(1846)](f,"{}"))[n]}else return this[s(1400)+s(500)+s(1112)](_0x3a558e),d[s(801)](_0x431c78)}async[t(1238)](n,s){let d=t,f=this[d(682)].getItem(this[d(554)]),g=JSON[d(1866)](e[d(1846)](f,"{}"));return g[s||n[this[d(1200)]]]=n,this._qosDB[d(1198)](this._prefix,JSON[d(722)+"y"](g)),s||n[this._pathKey]}async[t(465)](n){let s=t,d=this._qosDB[s(1395)](this._prefix),f=JSON[s(1866)](e[s(1846)](d,"{}"));return f[n]=void 0,this._qosDB.setItem(this[s(554)],JSON[s(722)+"y"](f))}async[t(1600)](){let n=t,s={AlpVM:e[n(1774)],GkBYq:function(d,f,g){return d(f,g)},gAABg:function(d,f){return e[n(715)](d,f)}};if(e[n(783)](n(952),e.StbgZ))if(QXJAYT[n(1028)](_0x5c5af8,_0x42e468)){let d=_0x150a9d[n(1390)].slice(_0x5d5bde.byteOffset,_0x27ca0e[n(591)+"th"]+_0x26241a[n(1233)+"et"]);this._socket&&this[n(1948)][n(1503)]({data:d,fail:f=>{let g=n;this.emit(QXJAYT[g(1603)],_0x3633c6(QXJAYT[g(1603)],{message:this[g(827)+g(1539)+g(898)](f)}))}})}else this._socket&&this._socket.send({data:_0x378298,fail:d=>{let f=n;this.emit(f(787),QXJAYT[f(797)](_0x585deb,f(787),{message:this["_formatE"+f(1539)+f(898)](d)}))}});else return this[n(682)].clear()}async[t(1632)](){let n=t,s=this[n(682)][n(1395)](this[n(554)]),d=JSON[n(1866)](s||"{}");return Object.keys(d)}async[t(612)](){let n=t,s=this[n(682)][n(1395)](this[n(554)]),d=JSON[n(1866)](e[n(1121)](s,"{}"));return Object[n(874)](d)}[t(710)](){return Promise.resolve()}get[t(1338)](){return!!this[t(682)]}}class ep{constructor(n,s){let d=t;this._DBName=n,this[d(1200)]=s,this._qosDB=An?tt:qr?wx:null}async[t(1940)](){}get[t(554)](){return t(1239)+"_"+this._DBName}async[t(1577)](n){let s=t,d=this[s(682)][s(1033)+s(1711)](this[s(554)]);return JSON[s(1866)](e.VPciQ(d,"{}"))[n]}async set(n,s){let d=t,f=this[d(682)][d(1033)+d(1711)](this[d(554)]),g=JSON.parse(f||"{}");return g[s||n[this[d(1200)]]]=n,this[d(682)]["setStora"+d(1711)](this[d(554)],JSON[d(722)+"y"](g)),s||n[this[d(1200)]]}async[t(465)](n){let s=t,d=this._qosDB[s(1033)+s(1711)](this[s(554)]),f=JSON[s(1866)](e[s(1191)](d,"{}"));return f[n]=void 0,this[s(682)][s(1013)+s(1711)](this[s(554)],JSON.stringify(f))}async[t(1600)](){let n=t;return this._qosDB[n(968)+n(1547)]()}async[t(1632)](){let n=t,s=this[n(682)][n(1033)+n(1202)+"nc"](this[n(554)]),d=JSON.parse(e[n(1319)](s,"{}"));return Object[n(1632)](d)}async[t(612)](){let n=t,s=this[n(682)]["getStora"+n(1202)+"nc"](this[n(554)]),d=JSON.parse(e[n(1191)](s,"{}"));return Object[n(874)](d)}[t(710)](){return Promise[t(946)]()}get[t(1338)](){return!!this[t(682)]}}function Zd(a,n){let s=t;if(e[s(1701)](An,An))return new ep(a,n);if((Zn||Hr)&&e[s(1619)](e[s(1024)],typeof indexedDB))return new Xh(a,n);if((Zn||Hr)&&e[s(684)](e.CmhPt,typeof localStorage))return new Qh(a,n);throw new Error("init QoS"+s(1923)+"d")}class tp{constructor(){let n=t;this[n(616)+n(1559)+"Id"]=null,this[n(616)+"l"]=36e5,this[n(682)]=e[n(717)](Zd,e[n(630)],e[n(870)])}async[t(616)+"lFlush"](){let n=t,s={TLDbd:function(d,f){return e.rJaTo(d,f)},NdQxr:function(d,f){return e.diozI(d,f)},cAbLb:function(d,f){return d(f)},NsKPr:function(d,f,g){return d(f,g)},CDHxV:function(d){return d()}};if(e[n(1369)](e.NBCqu,e[n(1351)]))e[n(1941)](clearInterval,this["_interva"+n(1559)+"Id"]),this[n(616)+n(1559)+"Id"]=e[n(1282)](setInterval,()=>{this.flushExpired()},this._interval);else return typeof _0x1c0cf9===n(1502)?vYWUmM[n(510)](_0x28f966,_0x1500ff):(vYWUmM[n(1135)](_0x2d9d07,_0x592f19)&&vYWUmM[n(994)](_0x41a1dc,_0x514441),vYWUmM[n(1231)](_0x210bc6,_0x3f9312,vYWUmM[n(1488)](_0x38852c))?new _0x4adbe6(_0x19a998,_0x45b06a):_0x5c23fc)}async[t(1940)](){let n=t,s={rlmWw:function(d,f){return d===f},ngFFF:n(1703)};await this[n(682)][n(1940)]()[n(929)](()=>{let d=n,f={GLXyt:function(g,m){return g(m)}};if(s[d(1050)](s[d(567)],s[d(567)]))this[d(616)+"lFlush"]();else return function(...g){let m=d;return _0x1b21b6[m(1765)](KFYAFn[m(671)](_0x45ea5d,this),g),_0x1a443d(_0x147cbb[m(1577)](this))}})}async[t(901)+t(861)](){let n=t;(await this[n(682)]?.[n(612)]()||[])[n(816)](({timestamp:f})=>f<Date.now())[n(1549)](f=>{let g=n;this[g(682)]?.[g(465)](f[g(1570)+"id"])})}async[t(465)](n){let s=t;return this[s(682)]?.[s(465)](n)}async[t(1238)](n,s){let d=t,f={Uerlf:function(g,m,b){return e[z(1483)](g,m,b)}};if(e[d(1244)]!==e[d(1244)]){let g=XrnfaG[d(1413)](_0x4a7c21,_0x5c404c,1);_0xa6f85e[d(1168)][g]=_0x2bd51d}else return this[d(682)]?.[d(1238)]({message_id:n,timestamp:s})}async[t(1577)](n){let s=t;return this[s(682)]?.[s(1577)](n)}async closeDB(){let n=t;e[n(1509)](clearInterval,this[n(616)+n(1559)+"Id"]),await this[n(682)]?.[n(710)]()}get isReady(){let n=t;return this[n(682)]?.[n(1338)]}}function aa(a){let n=t,s=!!this[n(1754)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e.imXIN(tn,a[n(1829)][n(1712)],e[n(1785)],"2"),f=d&&tn(a[n(1829)][n(1712)],e.XpzkD,"1"),g=d&&e.imXIN(tn,a[n(1829)][n(1712)],e[n(1465)],"1"),m=g?Yn(a.message[n(1712)],e.SjcKT)?.[n(863)](",")[n(816)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:g,ackMsgIds:m}}async function Yd(){let a=t;return this[a(1176)+a(1776)]||(this._QoSManager=new tp),this["_QoSMana"+a(1776)][a(1338)]||await this[a(1176)+a(1776)].openDB(),this[a(1176)+a(1776)]}async function np(a,n){let s=t;if(e[s(1142)](s(853),s(853)))_0x113b1a[_0x14c565++]=e[s(1456)](e.uBpom(_0x3389c0,18),7)|240,_0x569a38[_0x50e9e1++]=e[s(1759)](e[s(1652)](e[s(1646)](_0x125f0b,12),63),128);else{let{enableAutoAck:d}=this[s(1754)],f=tn(a[s(1829)].headers,s(1871),"1"),g=e[s(704)](tn,a.message.headers,e.XDFYs,"1"),m=aa[s(1027)](this,a);if(d&&f){let{SeqID:b,LogID:h,service:R,LogIDNew:L,method:F}=a.message;this[s(1736)]({SeqID:b,LogID:h,LogIDNew:L,service:R,method:F,headers:[{key:"is_ack",value:"1"},{key:"ack_id",value:e.dUnas(L,"")},{key:e.AJxcQ,value:"0"}]})}g&&!m[s(1608)]&&this[s(1400)+s(1557)+"ageEvent"](a),e.XrMYY(n)}}async function rp(a,n){let s=t;this[s(1207)](e.kgMmN,a.message),e[s(972)](n)}async function ip(a,n){let s=t,d={fvOjv:function(g,m){return e[z(1398)](g,m)},DxfCg:function(g,m){return e[z(974)](g,m)}},f=Xt(await e[s(1941)](Jd,a[s(1876)]));try{if(e.UXFDu(f[s(1625)],Uint8Array))if(e[s(1689)](s(647),s(1627))){let g=e[s(713)](this._options[s(584)+s(1901)],Object)?{force:!!this[s(1754)][s(584)+s(1901)][s(840)],encoding:this[s(1754)][s(584)+s(1901)][s(1743)]?this[s(1754)]["payloadE"+s(1901)][s(1743)][s(588)](/\s/g,"")[s(936)+"ase"]():""}:{force:!1,encoding:this[s(1754)][s(584)+s(1901)]?this[s(1754)]["payloadE"+s(1901)][s(588)](/\s/g,"")[s(936)+"ase"]():""},m=f.payloadEncoding?f["payloadE"+s(1901)][s(588)](/\s/g,"")[s(936)+s(1320)]():"",b=e[s(715)](this._options[s(1607)+s(1892)],Object)?{force:!!this[s(1754)].payloadType[s(840)],type:this[s(1754)][s(1607)+s(1892)].type?this._options["payloadT"+s(1892)][s(1101)][s(588)](/\s/g,"")["toLowerC"+s(1320)]():""}:{force:!1,type:this[s(1754)][s(1607)+s(1892)]?this[s(1754)][s(1607)+"ype"][s(588)](/\s/g,"")[s(936)+"ase"]():""},h=f["payloadT"+s(1892)]?f[s(1607)+"ype"].replace(/\s/g,"")[s(936)+s(1320)]():"",R=b[s(840)]?b.type:h||b[s(1101)],L=g.force?g[s(1743)]:m||g.encoding,F=[e.BtLiS,e[s(1378)],e[s(622)],e[s(1628)]],W=[e[s(618)],e[s(1836)]];this[s(1754)][s(1087)+"ansformT"+s(1552)+"ad"]&&F.includes(R)&&(!L||W[s(654)](L))?f[s(1322)+s(1480)]=e[s(663)](Vd,f.payload,0,f.payload[s(591)+"th"]):f["textPayl"+s(1480)]=""}else{let g=_0x19b302[s(863)](":");_0x3c67ed&&(_0x2961f9=g[s(1927)]),_0x5f5b02+=g[s(1927)];for(let m=0;ekwTCU[s(1340)](m,g[s(1927)]);m++)if(ekwTCU[s(1197)](4,g[m][s(1927)])){let b=_0x1ec747[s(1049)+"g"](0,4-g[m][s(1927)]),h=b[s(1145)](g[m]);_0x3c8c7e[s(1655)](h)}else _0x16075a.push(g[m]);_0x106c5a=!1}else f[s(1322)+s(1480)]=""}catch(g){f.textPayload="",console.log(g)}a.message=f,e.cdGUx(n)}function sp(a,n,s){let d=t,f={JFYZT:function(R,L){return e[z(1852)](R,L)},gvpzb:d(1213),snXKP:function(R,L){return e.FiYUa(R,L)},nSSls:function(R,L){return e.ZeDpb(R,L)},gWWyF:function(R,L){return e[d(1770)](R,L)},GPRnt:function(R,L){return e[d(1759)](R,L)}},g=s||8192,m=g>>>1,b=null,h=g;return function(R){let L=d;if(f.JFYZT(f.gvpzb,L(1213))){if(R<1||R>m)return f[L(1350)](a,R);f[L(944)](f[L(1915)](h,R),g)&&(b=f[L(1350)](a,g),h=0);let F=n.call(b,h,h+=R);return 7&h&&(h=f[L(1915)](f.GPRnt(7,h),1)),F}else this[L(1384)+L(880)]=_0x7687dd,this[L(1134)]=0}}let op=4294967295;function ap(a,n,s){let d=t;return e.SxOpZ(RangeError,e[d(805)](e.MuaKN(e[d(670)](e[d(1335)](e[d(1698)](e[d(1291)],a),e[d(1293)]),e.lEXdw(n,1)),e[d(1722)]),s))}function cp(a,n,s){let d=t,f={qotTx:function(m,b){return e[z(967)](m,b)},vetgh:function(m,b){return m+b},xDyEI:function(m,b){return e[z(1208)](m,b)},hJiWe:function(m,b){return e[z(1772)](m,b)},mragY:function(m,b){return m<<b},kkwoq:function(m,b){return m|b},FQuHM:function(m,b){return e.UbWMm(m,b)},aeFYu:function(m,b){return e[z(1349)](m,b)},lMAyy:function(m,b){return e[z(1174)](m,b)},KgQSa:function(m,b){return m<=b},DZskG:function(m,b){return e[z(624)](m,b)}};if(s>op)throw new Error(e[d(602)]);let g=3;for(;e[d(832)](g,0);)if(e.BFFmC(e[d(1068)],"HyycO"))_0x547f44=_0x164478[wQxpzX[d(866)](wQxpzX[d(866)](_0x665b9c,_0x5e289a),1)],_0x1cb081=_0x1eb26d[wQxpzX[d(844)](wQxpzX.xDyEI(_0x424237,_0x123b09),2)],wQxpzX[d(779)](_0x48b85f|wQxpzX.mragY(_0x7e2390,8),49344)!==32896?_0x42be74+=_0x1739c3:(_0x129939=wQxpzX.kkwoq(wQxpzX.FQuHM(wQxpzX[d(779)](15,_0x402a67)<<12,wQxpzX[d(773)](63&_0x309c96,6)),wQxpzX[d(779)](63,_0x250a6b)),wQxpzX[d(1938)](_0x25d1d2,2048)||_0x56a12e>=55296&&wQxpzX[d(733)](_0xc282b8,57343)?_0x1b8fe7+=_0x4cc21f:(_0x236d48+=wQxpzX[d(1918)](_0x2df1bd,_0x3988e1),_0x4b09c9+=2));else{let m=e[d(1768)](255,s);e.vPYRj(da,m,a,n+g),s>>>=8,g--}return n+4}function dp(a,n){let s=t,d=0,f=n,g=n+4;for(;e.auumU(f,g);){let{value:m,offset:b}=ca(a,f);f=b,d=e[s(953)](e.vSZqd(d,8),0),d+=m}return{value:d,offset:g}}function lp(a,n,s){let d=t;if(e.cBSFl==="bCLKG"){let f=e[d(511)].split("|"),g=0;for(;;){switch(f[g++]){case"0":if(n.write)return n.write(a,s)+s;continue;case"1":if(a[d(1927)]<40)return e[d(1401)](sa(a,n,s),s);continue;case"2":return e[d(1737)](sa(a,n,s),s);case"3":if(!a)return s;continue;case"4":if(n[d(1324)+"e"])return e[d(1401)](n[d(1324)+"e"](a,s),s);continue}break}}else{let{value:f,offset:g}=_0x5e754f(_0xf3431f,_0x33471f);_0x1347ff=g,_0x206864=e[d(518)](e[d(1349)](_0x2dd9f0,8),0),_0x563e18+=f}}function up(a,n){let s=t,d=new ce(e[s(1124)](e[s(593)](a[n+4],24)|a[e[s(1580)](n,5)]<<16|a[e.saaZZ(n,6)]<<8,a[e[s(1875)](n,7)]),e[s(667)](e[s(1714)](e.hzAyF(a[e.CWNbC(n,0)],24),a[e[s(498)](n,1)]<<16)|e[s(526)](a[n+2],8),a[e[s(954)](n,3)]),!0);return n+=8,{value:d,offset:e[s(1757)](n,8)}}function fp(a,n,s){let d=t,f={QdcpS:function(g,m){return g||m}};if(e[d(1370)](e.aOTkA,e[d(1783)])){let g=this[d(682)][d(1033)+d(1711)](this[d(554)]);return _0x544961[d(1866)](rKONVf[d(1416)](g,"{}"))[_0x3d24a3]}else{let g=a[d(1839)],m=a.high;return n[s]=e.XptHw(m,24),n[e[d(1770)](s,1)]=e.cOIWe(e[d(1171)](m,16),255),n[e[d(1445)](s,2)]=m>>>8&255,n[e[d(609)](s,3)]=e[d(1652)](255,m),n[e[d(967)](s,4)]=g>>>24,n[e[d(1636)](s,5)]=e[d(444)](g>>>16,255),n[e[d(1698)](s,6)]=e[d(1828)](e[d(1227)](g,8),255),n[e[d(1872)](s,7)]=e[d(709)](255,g),s+=8,s}}function ca(a,n){let s=t;return a.readUInt8?{value:a[s(1267)+"8"](n),offset:e[s(464)](n,1)}:{value:e[s(872)](255,a[n]),offset:e[s(1445)](n,1)}}function da(a,n,s){let d=t;return n[d(1281)+"t8"]?n.writeUint8(a,s):n[s]=e[d(1432)](255,a),s+1}let xp=function(a){return new Uint8Array(a)},hp=e[t(1024)]!=typeof Buffer?Buffer[t(871)+t(708)]:e[t(659)](sp,xp,Uint8Array[t(910)+"e"][t(1302)]),pp=16,la=32;function gp(a){let n=t,s={GThGr:n(714)+"in;charset=utf-8",JoxPN:e[n(1378)],Gnzfo:n(868)+n(1882)+n(451)+n(555),nayVN:e[n(1628)],trJHj:e[n(618)],SicoF:function(d,f,g,m){return e.Exizk(d,f,g,m)}};if(n(979)!==e[n(1093)]){let d=this[n(1754)][n(584)+"ncoding"]instanceof _0x2899ce?{force:!!this[n(1754)][n(584)+n(1901)].force,encoding:this[n(1754)][n(584)+n(1901)][n(1743)]?this[n(1754)][n(584)+n(1901)][n(1743)][n(588)](/\s/g,"")[n(936)+"ase"]():""}:{force:!1,encoding:this._options[n(584)+n(1901)]?this._options[n(584)+n(1901)][n(588)](/\s/g,"")[n(936)+n(1320)]():""},f=_0x319eae[n(584)+n(1901)]?_0x4b1ee8[n(584)+"ncoding"][n(588)](/\s/g,"")[n(936)+"ase"]():"",g=this[n(1754)][n(1607)+"ype"]instanceof _0x3e650c?{force:!!this[n(1754)]["payloadT"+n(1892)][n(840)],type:this[n(1754)][n(1607)+"ype"].type?this[n(1754)]["payloadT"+n(1892)][n(1101)][n(588)](/\s/g,"")[n(936)+n(1320)]():""}:{force:!1,type:this._options["payloadT"+n(1892)]?this[n(1754)][n(1607)+n(1892)][n(588)](/\s/g,"")["toLowerC"+n(1320)]():""},m=_0x435904["payloadT"+n(1892)]?_0x43da96[n(1607)+n(1892)].replace(/\s/g,"")[n(936)+n(1320)]():"",b=g[n(840)]?g[n(1101)]:m||g[n(1101)],h=d[n(840)]?d[n(1743)]:f||d.encoding,R=[SKkKlk.GThGr,SKkKlk.JoxPN,SKkKlk[n(643)],SKkKlk[n(751)]],L=[SKkKlk[n(1823)],n(543)];this[n(1754)][n(1087)+n(1415)+"extPayload"]&&R[n(654)](b)&&(!h||L[n(654)](h))?_0x1f45c5[n(1322)+"oad"]=SKkKlk[n(573)](_0x4d3e19,_0x94c63a[n(1625)],0,_0x2285af[n(1625)][n(591)+"th"]):_0x334a6f[n(1322)+n(1480)]=""}else{let d=0,f={};for(let g=0;e[n(1375)](g,a[n(1927)]);g++)f[a[g][n(1173)+n(931)]]=$d(a[g][n(1173)+"ame"]),d+=e[n(491)](14,f[a[g][n(1173)+n(931)]]);return[d,f]}}function Xd(a,n,s){let d=t,[f,g]=e[d(819)](gp,a),m=e.NHGVo(hp,f),b=0;return a[d(1549)](h=>{let R=d,L=(R(542)+R(1500)+"10|4|6")[R(863)]("|"),F=0;for(;;){switch(L[F++]){case"0":console[R(1211)](e[R(706)],b);continue;case"1":console[R(1211)](R(989)+R(1767),b);continue;case"2":b=lp(h[R(1173)+R(931)],m,b);continue;case"3":console[R(1211)](R(1086),b);continue;case"4":b=fp(ce[R(1750)+"er"](h.cursor||n),m,b);continue;case"5":b=e[R(704)](cp,m,b,h[R(1086)]||0);continue;case"6":console[R(1211)](e[R(1051)],b);continue;case"7":console[R(1211)](e[R(1924)],h,h[R(1086)]);continue;case"8":b=e[R(1861)](da,g[h[R(1173)+R(931)]],m,b);continue;case"9":b=da(0,m,b);continue;case"10":console.log(e[R(1960)],b);continue}break}}),{frameType:la,headers:[{key:e[d(1594)],value:s}],payload:m}}function mp(a){let n=t,s=0,d=[];for(;e.kKwwf(s,a[n(591)+"th"]);){let{offset:f}=e[n(911)](ca,a,s);s=f;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:b}=e[n(1669)](dp,a,s);g.service=m,s=b;let{value:h,offset:R}=e[n(1232)](ca,a,s);s=R,g[n(1173)+n(931)]=e[n(1518)](Vd,a,s,s+h),s+=h;let{value:L,offset:F}=up(a,s);g.cursor=L.toNumber(),s=F,d[n(1655)](g)}return d}function wp(){let a=t;return{frameType:la,headers:[{key:e[a(1594)],value:a(1815)+a(1939)}],payload:void 0}}class _p{constructor(n,s,d){let f=t;this[f(1056)+f(1354)]=n,this[f(1310)+"ileName"]=s,this[f(1055)+"Strategy"]=d,this[f(682)]=e[f(1442)](Zd,this[f(1056)+"ameSpace"],e[f(988)])}async openDB(){let n=t;await this[n(682)][n(1940)]()}async getCursors(){let n=t;if(e[n(1964)]!==e[n(1804)]){if(!this[n(682)][n(1338)])return;let s=this[n(1055)+"Strategy"],d=await this[n(682)][n(612)]();switch(console.log("allCursorValues",d),s){case e.gWVHM:return d&&d[n(1927)]?e[n(1144)](Xd,d,0,this[n(1310)+"ileName"]):void 0;case e[n(692)]:return;case e[n(987)]:return d&&d[n(1927)]?Xd(d,0,this[n(1310)+"ileName"]):wp()}}else this[n(1843)]=!0,this[n(547)]()}async[t(1238)](n,s,d){let f=t,g={UlJRD:function(m,b){return e.PqfXq(m,b)},dnzSU:function(m,b){return e.lqOTl(m,b)},LVehf:function(m,b){return e[z(1772)](m,b)},QbGcQ:function(m,b){return m<b},WgvBC:function(m,b){return e[z(1618)](m,b)},vpTpN:function(m,b,h){return m(b,h)},MZMzk:function(m,b){return e[z(1186)](m,b)},ugBLI:function(m,b){return e[z(1393)](m,b)},sotJg:function(m,b){return e[z(1312)](m,b)}};if(e[f(894)](e[f(1528)],e[f(1287)]))_0x9cd3ae=BMffWj.UlJRD(BMffWj[f(1345)](BMffWj.LVehf(7,_0x27585b),18)|BMffWj[f(1345)](63&_0x320b78,12)|BMffWj[f(1795)](63,_0x16b581)<<6,63&_0x127dd2),BMffWj.QbGcQ(_0x4efbd3,65536)||BMffWj[f(1037)](_0x1810d5,1114111)?_0x8d0bb3+=_0x86a324:(_0x1c9a60-=65536,_0x133dd1+=BMffWj[f(1740)](_0x35f85c,BMffWj[f(1741)](_0x2bc4da,10)+55296,BMffWj[f(939)](BMffWj[f(732)](1023,_0x51228f),56320)),_0x5e7ce4+=3);else return console[f(1211)](e[f(1778)],n,s,d),this[f(682)][f(1238)]({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d=e.DyUkV(mp,n);for(let f of d)console[s(1211)](e.YYKiY,d),await this[s(682)][s(1238)](f)}async get(n){let s=t;return(await this[s(682)].get(n))?.[s(1307)]}async[t(710)](){let n=t;if(e[n(793)](n(1245),e[n(524)]))await this[n(682)][n(710)]();else{let s=this[n(1516)+n(1271)]?.["getCurre"+n(461)+"nt"]();this[n(1400)+n(1800)+n(963)](e[n(506)](_0x3395b1,e[n(756)],{code:1006,reason:n(1653)+s+(n(1730)+n(1113)+n(480)+n(1190)),wasClean:!0}))}}[t(1533)+"rsorFile"+t(1377)](n){let s=t,d={qpyOL:function(f,g){return e[z(486)](f,g)},sEAcD:function(f,g){return e[z(1672)](f,g)},qfgXM:function(f,g){return f<=g},iIPRQ:function(f,g){return e[z(1126)](f,g)},cGoSy:function(f,g){return e[z(1362)](f,g)},vtPnf:function(f,g){return f%g},nQUWp:function(f,g){return e[z(1151)](f,g)},cagRe:function(f,g){return e[z(1661)](f,g)}};if(e[s(1852)](e[s(1263)],e[s(1263)]))this[s(1310)+"ileName"]=n;else{if(ZQZOTz[s(1031)](_0x17a338,_0x2bd5d3))return _0x341c84?_0x1da618:_0x55a858;if(_0xc3c951){if(ZQZOTz[s(1484)](_0x24916d,_0x2824f3))return _0x37a5fe}else{if(ZQZOTz[s(1792)](_0x5ee103,-_0x14dede))return _0x26cb1d;if(ZQZOTz[s(1484)](ZQZOTz[s(821)](_0x37e3e4,1),_0x2b6da3))return _0x30b897}return _0xab4996[s(1199)](ZQZOTz.cGoSy(ZQZOTz[s(996)](_0x18fe7d,_0x2e91dc),0),ZQZOTz.nQUWp(ZQZOTz[s(1568)](_0x3bd77e,_0x12c029),0),_0x4f6f1b)}}get[t(1338)](){let n=t;return this[n(682)][n(1338)]}}let yp=e.gNFHB;async function Qd(a){let n=t,s={kSTKs:function(d,f){return d(f)},rJdCM:function(d){return d()}};if(e[n(922)](e[n(515)],e.PYPTm)){if(!this[n(1754)][n(724)+"S"])return null;let{aID:d,fpID:f,messageStrategy:g}=this[n(1754)],m=e.KfqHq(a,yp);try{return this[n(661)+n(1365)]?a&&this[n(661)+n(1365)][n(1533)+n(552)+n(1377)](a):this["_cursorM"+n(1365)]=new _p(f+"_"+d+"_"+m,m,g),this[n(661)+n(1365)][n(1338)]||await this[n(661)+"anager"][n(1940)](),this[n(661)+n(1365)]}catch{return null}}else _0x149e46(fIeyEG.kSTKs(_0x5e1ad2,_0x5b47d4.result)),fIeyEG[n(1942)](_0xdc9a52)}async function Ep(a,n){let s=t,d={NNwbt:function(Z,J){return e[z(1430)](Z,J)}},f=e[s(1001)](tn,a[s(1829)][s(1712)],e[s(1766)],"-1"),g=e[s(1468)](tn,a[s(1829)][s(1712)],e[s(780)],"1"),m=e[s(1610)](Yn,a[s(1829)][s(1712)],s(1690)+s(1116)),b=e.UzmGO(Number,Yn(a[s(1829)][s(1712)],e[s(1624)]))||0,h=aa[s(1027)](this,a),R=e[s(930)](tn,a[s(1829)][s(1712)],e[s(807)],"2"),L=Yn(a[s(1829)][s(1712)],s(1584)+"rsor_name"),F=e[s(1574)](Number,e[s(1444)](Yn,a[s(1829)][s(1712)],e[s(855)]));if(h[s(1608)])return e[s(525)](n);let W=h[s(1342)+"sage"]?await Yd[s(1027)](this):null;if(a[s(1829)].service>0&&g&&!f||a[s(1829)][s(1086)]>0){if(m&&h.isQoSMessage&&W)return!!!await W[s(1577)](m)&&(this["_dispatchMessage"+s(1112)](a),await W.set(m,e.DYhIL(Date[s(1464)](),b))),n();if(R){let Z=await Qd[s(1027)](this);if(!Z)if(e[s(1863)]===e[s(1649)]){let fe=this[s(682)]["getStora"+s(1202)+"nc"](this[s(554)]),Se=_0x246bc1[s(1866)](Hiekti[s(1851)](fe,"{}"));return _0x3d3e18[s(874)](Se)}else return this[s(1400)+"hMessage"+s(1112)](a),e[s(1399)](n);let J=await Z.get(L)??-1;if(e[s(601)](J,F))if(e[s(1626)](s(1452),e[s(1883)])){let fe=_0x2af5b7[s(1168)],Se=_0x318656[s(758)],Qe=_0xf52ccd[s(1717)],ht=Se+_0x5a4604;if(e[s(1618)](ht,fe.length)){let Yi=new _0x4998ce(2*ht);Yi.set(fe),_0x488f4f[s(1168)]=Yi}return _0x34f4a4[s(758)]=ht,e[s(1469)](ht,Qe)&&(_0x31e67a.limit=ht),Se}else this[s(1400)+s(500)+s(1112)](a),Z[s(1238)](L,F,a[s(1829)][s(1086)]);else throw new Error(s(1047)+s(619)+s(752)+F+(s(891)+s(950)+s(1225)+"r ")+J);return e[s(1188)](n)}return this[s(1400)+s(500)+s(1112)](a),n()}}async function bp(a,n){let s=t,d=aa.call(this,a);if(!d[s(1342)+s(1424)])return e[s(1188)](n);let f=await Yd[s(1027)](this);if(d[s(447)+"anupMess"+s(898)]&&d.ackMsgIds[s(1927)])for(let g of d[s(660)+"s"])await f[s(465)](g);e.tmQlZ(n)}async function vp(a,n){let s=t;if(e[s(1367)]("kgsoc",e[s(824)]))return this[s(1880)+s(1289)+s(847)+"t"];{let d=e.VQmmj(a[s(1829)][s(1886)+"e"],pp),f=e.qcSjU(a.message[s(1886)+"e"],la);if(!d&&!f)return e.GPOJb(n);let g=Yn(a[s(1829)][s(1712)],s(626)+s(1117));if(!g)return e.Usxxg(n);let m=await Qd[s(1027)](this,g);if(!m)return e[s(525)](n);if(d){let b=await m[s(1167)+"rs"](),h={frameType:b?.[s(1886)+"e"],SeqID:ce.fromNumber(this[s(1920)]++),LogID:ce[s(1750)+"er"](this[s(1754)][s(1154)+s(1203)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[s(1625)]},R=e[s(1833)](I,h);this[s(1096)]&&this[s(1096)][s(1331)+"te"]&&this[s(1096)].send(R)}if(f)if(e[s(1248)](e[s(799)],e[s(799)]))this[s(1096)]&&this[s(1096)][s(1503)](_0x3a19d4),this["_message"+s(636)][_0x1a3609]=null;else{let b=a[s(1829)][s(1625)];b&&m[s(1420)+"rs"](b)}}}let Sp=async function(a,n){let s=t;this[s(1843)]=!1,e[s(1820)](clearTimeout,this[s(547)+s(1708)+s(869)]),n()},Ap=async function(a,n){let s=t;if(!this._ws||e[s(445)](this[s(1096)][s(1331)+"te"],this[s(649)]))return e.XrMYY(n);let{pingInterval:d}=this._options;this[s(1516)+s(1271)]?.[s(772)+s(920)+"fig"]();for(let g=0;g<this[s(1055)+s(636)][s(1927)];g++){let m=this._messageQueue[g];if(e[s(1498)](this._ws[s(1331)+"te"],this[s(649)])&&e[s(1599)](null,m))this[s(1096)]&&this._ws[s(1503)](m),this[s(1055)+s(636)][g]=null;else break}this[s(1055)+s(636)]=this[s(1055)+s(636)][s(816)](g=>!!g),this["_pingPon"+s(545)+"Id"]=e[s(1874)](setTimeout,()=>this._ping(),d),this[s(1400)+s(748)+"nt"](a),this[s(1937)+"er"]&&this[s(1096)]&&(this[s(1096)].binaryType=this[s(1966)+s(1892)]);let f=this[s(1516)+"tManager"]?.[s(1558)+s(461)+"nt"]();this[s(1207)](s(1758)+f+s(909)),e.UWFup(n)},Ip=async function(a,n){let s=t,d=this[s(1516)+s(1271)]?.[s(1558)+"ntEndpoint"]();this._debug("open "+d),e[s(1399)](n)};class Tp extends ia{constructor(n){let s=t,d={nliEo:e[s(756)],jHCaX:function(b,h,R){return e[s(697)](b,h,R)},ejtXy:e[s(1774)],dfBRJ:e[s(1666)]};super(),this[s(768)+s(621)+s(1446)]=!0,this[s(1937)+"er"]=Zn,this._isNode=Hh,this[s(1841)+"T"]=An,this._isMiniWX=qr,this._isWorker=Hr,this[s(1055)+s(636)]=[],this[s(1516)+s(1271)]=null,this[s(1036)+"osed"]=!1,this[s(1966)+s(1892)]=s(1110)+"fer",this["_connect"+s(1811)]=!1,this[s(547)+"ionTimeo"+s(869)]=null,this["_reconne"+s(721)+"tId"]=null,this[s(843)+s(545)+"Id"]=null,this[s(1920)]=0,this._isInit=!1,this[s(493)]="",this[s(1176)+s(1776)]=null,this[s(661)+s(1365)]=null,this[s(741)+"sCounter"]=null,this[s(651)+"ls"]=e[s(1222)],this[s(650)]=3,this[s(1928)+"NG"]=0,this[s(649)]=1,this[s(935)]=2,this[s(1373)]=b=>{let h=s;if(e.wDNzA(h(1916),e[h(740)]))try{e[h(982)](Kd,this,b,[Sp,Ap,Ip])}catch(R){let L=e.yWjVw(ot,e[h(1774)],{message:R[h(1829)],code:en.OPEN_ERROR,error:R});this["_dispatc"+h(873)+h(963)](L)}else this[h(774)](d[h(1292)],_0xc5d1e1),this[h(1590)]&&this[h(1590)](_0x310d13)},this[s(1407)+"ge"]=async b=>{let h=s,R={OxLeU:h(1829),lSNob:function(W,Z,J){return e.ezkOY(W,Z,J)}},{pingInterval:L,pingFrequency:F}=this[h(1754)];if((b[h(1876)]==="hi"&&e.ZWxyk===F||e[h(1615)](e[h(629)],F))&&(this["_clearPi"+h(528)](),this[h(774)](h(1243)+h(1075)+"s",e[h(1172)]),this._pingPongTimeoutId=e[h(1477)](setTimeout,this[h(668)][h(938)](this),L)),!e[h(1457)]("hi",b[h(1876)]))try{e[h(462)](Kd,this,b,[ip,np,bp,vp,Ep,rp])}catch(W){if(e.eINTD!==h(923)){let Z=e[h(1242)](ot,e.qjdtI,{message:W[h(1829)],code:en[h(771)+"ERROR"],error:W});this[h(1400)+h(873)+"ent"](Z)}else this[h(774)](IaEdGA[h(1104)],IaEdGA[h(1763)](_0x48cd77,IaEdGA.OxLeU,{..._0x1700de}))}},this[s(1057)]=b=>{let h=s,R=this[h(1516)+h(1271)]?.[h(1094)+h(1100)+"es"](),L=this[h(1516)+h(1271)]?.[h(1558)+h(461)+"nt"]();if(R&&!b[h(1829)]){let F="connect "+L+(h(1576)+"ax retri"+h(594)+"ed");this[h(1400)+"hErrorEv"+h(963)](d[h(1313)](ot,d[h(850)],{message:F,code:en[h(1109)+h(707)+"R"],error:b}));return}this._ws&&this[h(1096)].readyState===this[h(649)]&&this[h(810)+h(1634)](),this[h(1400)+h(873)+h(963)](d[h(1313)](ot,d[h(850)],{message:b.message,code:en[h(1475)+h(1491)],error:b}))},this[s(1083)]=async b=>{let h=s;this[h(854)+h(1421)](),this[h(1895)+h(528)](),this["_removeW"+h(563)+"rs"](),this[h(1096)]=null,this[h(547)+h(1811)]=!1;let R=this["_endpoin"+h(1271)]?.[h(1094)+h(1100)+"es"]();if(!R&&this["_navigat"+h(1189)]()&&!this[h(1036)+"osed"]){let L=this[h(1516)+"tManager"]?.["getCurre"+h(461)+"nt"](),F=this[h(1754)][h(775)+h(914)+h(611)](b[h(1601)],b[h(516)]);this[h(1400)+"hCloseEv"+h(963)](xt(e.KbrpA,{code:1006,reason:b[h(516)]||h(829)+h(1685)+h(596)+h(879)+"n, hostn"+h(1284)+L,willReconnect:F})),F&&this[h(547)]();return}if(b[h(1601)]!==1e3&&this[h(1036)+h(1296)])if(e[h(585)](h(1827),e[h(1476)])){this[h(1400)+h(1800)+"ent"](e[h(454)](xt,h(723),{code:1e3,reason:e.flDgb})),this[h(1516)+h(1271)]?.[h(772)+h(920)+h(1436)](),this[h(741)+"sCounter"]?.[h(1069)+h(1589)]();return}else this[h(774)](d[h(685)],_0x171e3b),this[h(1472)]&&this.onopen(_0x174765);if(e[h(1599)](1e3,b[h(1601)])&&R)if(e[h(472)](e[h(1616)],e.CQDLg)){let L=this[h(1516)+h(1271)]?.[h(1558)+h(461)+"nt"](),F=b[h(516)];F||(F=await e[h(1912)](Zh,this[h(493)])),F=h(829)+h(1685)+h(864)+F+(h(905)+"me: ")+L+(h(1113)+"tries re"+h(1190)),this[h(1400)+h(1800)+h(963)](e[h(453)](xt,e[h(756)],{code:b[h(1601)],reason:F}));let W=h(1653)+L+(h(1576)+h(1004)+h(594)+"ed");this[h(1400)+h(873)+h(963)](e[h(595)](ot,e[h(1774)],{message:W,code:en["MAX_RETR"+h(707)+"R"]})),this[h(1516)+h(1271)]?.["resetEnd"+h(920)+h(1436)](),this[h(741)+h(1670)]?.[h(1069)+h(1589)]();return}else _0x3f3cf0[h(1902)][h(1317)+"ild"](_0xbd7ad);if(e[h(977)](1e3,b[h(1601)])&&!b[h(516)]){let L=this[h(1516)+"tManager"]?.[h(1558)+h(461)+"nt"]();this[h(1400)+h(1800)+h(963)](e[h(1002)](xt,e[h(756)],{code:b[h(1601)],reason:"connecti"+h(1685)+h(596)+"wn reaso"+h(1032)+h(1284)+L})),this["_endpoin"+h(1271)]?.[h(772)+h(920)+h(1436)](),this[h(741)+h(1670)]?.[h(1069)+h(1589)]();return}this[h(1400)+h(1800)+h(963)](b),this[h(1516)+h(1271)]?.[h(772)+h(920)+h(1436)](),this["_pingLos"+h(1670)]?.[h(1069)+h(1589)]()},this[s(1590)]=null,this[s(1016)]=null,this[s(1071)+"e"]=null,this.onopen=null,this["onStartR"+s(983)]=null,this["onReceiv"+s(548)]=null,this[s(1726)+s(1251)+"yReconnect"]=null,this[s(640)+s(1192)]=this[s(640)+s(1192)][s(938)](this),this[s(640)+s(1803)]=this[s(640)+"ffLine"][s(938)](this),this["_handleP"+s(1141)]=this["_handleP"+s(1141)][s(938)](this),this[s(1751)+"ageShow"]=this[s(1751)+"ageShow"].bind(this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1532)](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(947),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(987)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:g}=n,m=Array[s(1709)](f)?f:e[s(605)](e[s(1628)],typeof f)?[f]:[];if(!m||e[s(1224)](0,m[s(1927)]))throw new Error("please p"+s(883)+s(903));if(!Kh(g))throw new Error(e.sLIiN);Object[s(823)](this._options,n),this[s(1516)+"tManager"]=new Wd(m,this._options[s(1593)+"es"]),this[s(741)+s(1670)]=new Jh(this[s(1754)][s(788)+s(1934)]),this._options["automati"+s(597)]&&(this[s(1843)]=!0,this[s(547)]()),this[s(1754)][s(1270)+s(1150)+s(492)]&&(this[s(1841)+"T"]||this[s(727)+"X"]?this["_onPageN"+s(849)+s(1651)]():this[s(1937)+"er"]&&this[s(1710)+s(1713)+s(1441)]())}[t(640)+t(1192)](){let n=t;this[n(1754)][n(1205)+n(711)+n(814)]||this[n(1036)+"osed"]||this[n(586)+"econnect"]()}["_handleO"+t(1803)](){let n=t;this[n(1567)+n(1250)+"t"]();let s=e[n(1521)](ra,e[n(1515)],{message:e[n(1832)]});this[n(1726)+n(1251)+n(1385)+"ct"]&&this["onStopImmediatel"+n(1385)+"ct"](s)}[t(1710)+t(1713)+t(1441)](){let n=t;e[n(445)](e[n(804)],n(1529))?(this[n(774)](e[n(1774)],_0x1897c3),this[n(1016)]&&this.onerror(_0x13c891)):(this._isBrowser&&window["addEvent"+n(1441)](e[n(1674)],this[n(640)+n(1192)]),this._isBrowser&&window[n(1246)+n(1441)](e[n(1810)],this[n(640)+n(1803)]),this[n(1937)+"er"]&&window[n(1246)+n(1441)](e[n(1605)],this[n(1751)+n(1141)]),this[n(1937)+"er"]&&window[n(1246)+"Listener"](e[n(1294)],this[n(1751)+"ageShow"]))}["_dropGlo"+t(1713)+t(1441)](){let n=t;if(e[n(471)](n(908),e[n(1089)]))return _0x35dc25[n(1168)][_0x3d96ef(_0x41be19,1)];this[n(1937)+"er"]&&window[n(1854)+n(1790)+n(497)](e[n(1674)],this["_handleO"+n(1192)]),this[n(1937)+"er"]&&window[n(1854)+n(1790)+n(497)](n(587),this[n(640)+n(1803)]),this[n(1937)+"er"]&&window[n(1854)+"entListe"+n(497)](e[n(1605)],this._handlePageHide),this[n(1937)+"er"]&&window[n(1854)+n(1790)+n(497)](e.Qujli,this[n(1751)+n(1425)])}[t(1751)+t(1141)](n){let s=t,d={vnpeC:function(f,g){return e.VJTYo(f,g)}};if(!n[s(765)+"d"]){if(e[s(1451)](e[s(1018)],e[s(1536)]))return AutFgj[s(1779)](_0x17e3eb,_0x16deab(_0xcdd1c7));this[s(1937)+"er"]&&window["removeEventListe"+s(497)](s(795),this[s(1751)+s(1141)]),this[s(1937)+"er"]&&window["removeEv"+s(1790)+"ner"](e[s(1294)],this[s(1751)+s(1425)]),this.close()}this[s(1937)+"er"]&&window[s(1854)+"entListe"+s(497)](e[s(1674)],this[s(640)+s(1192)]),this._isBrowser&&window[s(1854)+s(1790)+"ner"](e[s(1810)],this[s(640)+s(1803)])}[t(1751)+t(1425)](n){let s=t;if(e[s(1219)](e[s(1058)],e[s(904)]))return!!this[s(682)];n.persisted&&(this[s(1538)+"orOnline"]()&&(!this[s(1096)]||this._ws[s(1331)+"te"]!==this[s(649)]||this[s(1096)][s(1331)+"te"]!==this[s(1928)+"NG"])&&this[s(640)+"nLine"](),this._isBrowser&&window["addEvent"+s(1441)](e.eEmHo,this[s(640)+s(1192)]),this._isBrowser&&window[s(1246)+s(1441)](e[s(1810)],this["_handleO"+s(1803)]))}async[t(646)+t(1123)](n){let s=t,{fpID:d,deviceID:f,bddID:g,ttwID:m,accessKey:b,aID:h,customParams:R={},enableAutoAck:L,enableQoS:F,QoSLevel:W,env:Z}=this[s(1754)],J,fe,Se;this._isBrowser||this[s(727)+"X"]||this[s(1841)+"T"]?(J=location&&e.bnFlF("https:",location[s(781)])?e[s(1204)]:e.XmKKe,fe=n[s(588)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Se=/^wss(.*:\/\/)/[s(1102)](n)?n:""+J+fe):(J=e[s(1204)],fe=n.replace(/(^http)((?:[s]*:\/\/))/,""),Se=/(^ws)((?:[s]*:\/\/))/[s(1102)](fe)?fe:""+J+fe);let Qe=g?s(1796):m?e[s(1956)]:e[s(1304)],ht=g||m||f;if(e[s(1637)](!ht,!Qe))throw new Error(e[s(1228)]);let Yi=e[s(1514)](s(1502),typeof R)?await R():R,Cp=Z?e[s(1295)](Vh,Z[s(1849)],Z[s(828)]):{},ua=Object[s(823)]({device_platform:e[s(1180)],version_code:e[s(580)],access_key:b,fpid:d,aid:h,[Qe]:ht,xsack:L?1:0,xaack:L?1:0,xsqos:F?1:0,qos_level:F?W:void 0,qos_sdk_version:2,...Cp},Yi),Dp=Object[s(1632)](ua)[s(475)]((fa,xa)=>ua[xa]!==void 0?""+fa+(fa?"&":"?")+xa+"="+ua[xa]:fa,"");return Se+s(1074)+Dp}async[t(547)](){let n=t;if(!(this["_connect"+n(1811)]||this[n(1036)+n(1296)])){this[n(547)+n(1811)]=!0;try{let s=this[n(1516)+n(1271)]?.[n(1878)+"rentEndp"+n(1278)+n(985)+n(1588)](),{timeoutInterval:d}=this._options;if(s){let g=this[n(1516)+n(1271)]?.[n(1558)+n(461)+"nt"](),m=this[n(1516)+n(1271)]?.["replaceBackupEnd"+n(1257)+n(571)+n(1403)](),b=this[n(1516)+n(1271)]?.[n(1558)+n(461)+n(556)+"ount"]();if(m)if(e.fRuJe(e.FBiPo,e.TdmXY)){let h=n(1653)+g+(n(1730)+n(1113)+"tries re"+n(1221)+n(796)+n(1946)+"ndpoint ")+m+(n(603)+"y"),R=e[n(1521)](ot,"error",{message:h,code:en.MAX_RETRIES_ERROR});this._debug(h),this["_dispatc"+n(873)+n(963)](R),this[n(493)]=await this[n(646)+n(1123)](m),this[n(1207)](n(1653)+m+" "+b+n(476)),this[n(1374)+n(563)+"rs"]()}else this[n(1937)+"er"]&&_0x5bac74[n(1854)+"entListe"+n(497)](e[n(1605)],this[n(1751)+"ageHide"]),this[n(1937)+"er"]&&_0x1f8e42[n(1854)+n(1790)+n(497)](e.Qujli,this[n(1751)+n(1425)]),this.close();else{let h="connect "+g+(" timeout, max re"+n(480)+n(1190));this._debug(h),this["_dispatc"+n(873)+"ent"](ot(n(787),{message:h,code:en[n(1109)+n(707)+"R"]}));return}}else{let g=this._endpointManager?.[n(1558)+n(461)+n(579)+"ateCount"](),m=this[n(1516)+n(1271)]?.[n(1558)+"ntEndpoi"+n(556)+"ount"]();this[n(493)]=await this["_generat"+n(1123)](g||""),this[n(1207)](n(1653)+g+" "+m+n(476)),this[n(1374)+"sListeners"]()}if(this[n(1843)])this[n(1843)]=!1;else{let g=e[n(1002)](ra,e[n(1515)],{message:e[n(976)]});this[n(1406)+n(983)]&&this["onStartR"+n(983)](g)}let f=this[n(1516)+n(1271)]?.[n(1558)+"ntEndpoi"+n(556)+n(880)]()||0;e[n(514)](f,1)&&await this._wait(f-1),this._debug(n(829)+n(845)+this[n(493)]+(" protoco"+n(749))+this[n(651)+"ls"]),this[n(1096)]=e[n(1065)](Wh,{url:this[n(493)],protocols:[this[n(651)+"ls"]],headers:this[n(1754)][n(613)+"ramParams"]["customHt"+n(657)]},this[n(1754)].ws),(this[n(1937)+"er"]||this._isWorker)&&this._ws&&(this._ws[n(1555)+"pe"]=this[n(1966)+"ype"]),this[n(1583)+n(485)](),this[n(547)+"ionTimeo"+n(869)]=e[n(1944)](setTimeout,this[n(830)+"ut"][n(938)](this),d)}catch(s){throw this[n(547)+n(1811)]=!1,s}}}[t(854)+t(1421)](){let n=t;e[n(1716)](clearTimeout,this[n(547)+n(1708)+n(869)]),this[n(547)+n(1708)+n(869)]=null}[t(1895)+t(528)](){let n=t;clearTimeout(this._pingPongTimeoutId),e[n(1023)](clearTimeout,this[n(1482)+"ctTimeou"+n(1025)]),this[n(843)+n(545)+"Id"]=null,this[n(1482)+n(721)+n(1025)]=null}[t(1207)](...n){let s=t;this[s(1754)][s(1045)]&&console.log[s(1765)](console,[e.AbgdU,...n])}[t(505)+t(1917)+"e"](n){let s=t;if(e[s(1008)]!==e.BFNyT){let{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:g}=this[s(1754)],m=d*Math[s(1853)](g,e[s(1571)](n,1));return e[s(1850)](m,f)?f:m}else return e[s(679)](_0x2d22e3,_0x5567b8)?_0x4ee276:new _0x28898b(e[s(653)](e[s(667)](e[s(1078)](e[s(1151)](_0xbe1d95[s(1027)](_0x473742,0),e[s(915)](_0x481e60[s(1027)](_0x544639,1),8)),_0x564081.call(_0x5d6a92,2)<<16),e[s(1209)](_0x4cab34.call(_0x5740fb,3),24)),0),e.XoeKi(e[s(1524)](e[s(1658)](_0xc30466[s(1027)](_0x3a6548,4)|e.qZDBE(_0x334db8[s(1027)](_0x5e12d5,5),8),_0x4a210e.call(_0x3b1ab1,6)<<16),e[s(1361)](_0x2d79bc[s(1027)](_0x1b981a,7),24)),0),!0)}[t(668)](){let n=t;if(this._ws&&e[n(1761)](this[n(1096)][n(1331)+"te"],this.CONNECTING)){this[n(1895)+n(528)](),this[n(843)+n(545)+"Id"]=setTimeout(this._ping.bind(this),this[n(1754)][n(448)+n(1175)]);return}if(!this[n(1096)]||e.iweJS(this._ws[n(1331)+"te"],this.OPEN))return void this[n(586)+"econnect"]();this[n(1096)]&&this[n(1096)][n(1503)]("hi"),this[n(1482)+n(721)+"tId"]=e[n(1179)](setTimeout,this[n(586)+n(983)+n(794)][n(938)](this),this[n(1754)]["pingTime"+n(1573)+n(1261)])}[t(586)+"econnectTimeout"](){let n=t;if(e[n(1370)](e.cQsXi,n(673))){let s=this[n(682)][n(1033)+n(1202)+"nc"](this[n(554)]),d=_0x50ee0f[n(1866)](e[n(1799)](s,"{}"));return _0x147ce3[n(1632)](d)}else this._pingLossCounter?.addCount(),this[n(774)](e.wVxch,e[n(1647)]),this[n(741)+"sCounter"]?.[n(1094)+"chMaxCount"]()?this["_handleR"+n(983)]():this[n(668)]()}[t(1538)+"orOnline"](){let n=t;if(e[n(1219)](e[n(1706)],e.ZpWCA))return this[n(1841)+"T"]||this[n(727)+"X"]?this[n(768)+"igatorOnline"]:(this[n(1937)+"er"]||this[n(1680)+"r"])&&this[n(1754)][n(1270)+n(1150)+n(492)]?navigator[n(815)]:!0;{let s=this[n(693)],d=this[n(1839)];return[e[n(1122)](s,24),e.PZroC(e[n(452)](s,16),255),e[n(1769)](s,8)&255,e[n(1704)](255,s),e.fUHen(d,24),e[n(1303)](e[n(1769)](d,16),255),d>>>8&255,e[n(867)](255,d)]}}_handleReconnect(){let n=t;!this[n(1538)+n(1189)]()||this[n(1036)+n(1296)]||(this[n(1516)+n(1271)]?.["resetEndpointCon"+n(1436)](),this[n(741)+n(1670)]?.[n(1069)+n(1589)](),this[n(1096)]?this[n(810)+n(1634)](1001,e[n(1622)],!0):this[n(547)]())}[t(1077)+"etWorkChange"](){let n=t,s={Pracf:function(d,f){return e[z(1635)](d,f)},gOpNi:n(1412),sBKxE:function(d,f){return d(f)}};if(e[n(637)](e[n(1746)],e[n(1746)]))this._isMiniTT?tt[n(877)+n(1859)+n(488)](({isConnected:d})=>{let f=n;this[f(768)+"igatorOn"+f(1446)]=d,d?this[f(640)+f(1192)]():this["_handleO"+f(1803)]()}):this._isMiniWX&&wx[n(877)+"kStatusC"+n(488)](({isConnected:d})=>{let f=n;if(s.Pracf(s.gOpNi,s.gOpNi))this[f(768)+"igatorOn"+f(1446)]=d,d?this[f(640)+f(1192)]():this[f(640)+f(1803)]();else return _0x5051d6.resolve()});else{let d=/(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(1102)](_0x211bfa),f=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1102)](_0x3ff578);return d?KKKkhC[n(1648)](_0x3f8902,_0x42e122):f?_0x15a808(_0x427277):n(833)+n(833)+n(833)+n(833)}}_wait(n){return new Promise(s=>{setTimeout(s,this._getIntervalValue(n))})}["_disconn"+t(1634)](n=1e3,s="",d=!1){let f=t;if(e[f(509)](e[f(1489)],e[f(1489)]))this[f(1101)]=_0x1ef0b5,this[f(1911)]=null;else{if(!this[f(1096)])return;this[f(1567)+f(1250)+"t"](n,s,d)}}[t(830)+"ut"](){let n=t,s=this[n(1516)+n(1271)]?.[n(1558)+n(461)+"nt"]();this[n(1207)](n(1653)+s+n(1730)),this[n(810)+n(1634)](1001,e[n(1688)],!0)}_sendAck(n){let s=t,d=zt(n);this[s(1096)]&&e.rIHSg(this[s(1096)].readyState,this.OPEN)&&(this[s(1096)]&&this[s(1096)][s(1503)](d),this[s(1207)](e[s(1760)],n))}_removeWsListeners(){let n=t;if(e[n(1386)](e.xrDkx,e[n(457)])){let s=(n(628)+"0")[n(863)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1096)][n(1854)+n(1790)+n(497)]("error",this[n(1057)]);continue;case"1":this[n(1096)][n(1854)+"entListe"+n(497)](e[n(756)],this[n(1083)]);continue;case"2":this[n(1096)][n(1854)+n(1790)+"ner"](e[n(1662)],this[n(1407)+"ge"]);continue;case"3":if(!this[n(1096)])return;continue;case"4":this[n(1096)]["removeEv"+n(1790)+n(497)](e.DDqiY,this[n(1373)]);continue}break}}else return(this[n(1130)+"rs"][_0x320f82]||(this[n(1130)+"rs"][_0x14149e]=[])).push({fn:_0x2fcdb8,ctx:_0x106d0e||this}),this}[t(1583)+t(485)](){let n=t;this[n(1096)]&&(this[n(1096)][n(1246)+n(1441)](e[n(1666)],this[n(1373)]),this[n(1096)][n(1246)+n(1441)](e[n(756)],this[n(1083)]),this._ws[n(1246)+"Listener"](e[n(1662)],this._onMessage),this[n(1096)].addEventListener(e[n(1774)],this._onError))}[t(729)+t(700)](n=1e3,s=""){let d=t;try{this[d(1096)]&&this[d(1096)][d(723)](n,s)}catch{}}[t(1567)+t(1250)+"t"](n=1e3,s="",d=!1){let f=t;if(e[f(1747)]!==e[f(970)]){if(this[f(1895)+f(528)](),this[f(854)+"mer"](),this[f(1374)+f(563)+"rs"](),this[f(729)+"nceClose"](1e3,s),this["_connect"+f(1811)]=!1,d&&this[f(1538)+f(1189)]()&&!this["_readyCl"+f(1296)]){if(e[f(1511)]!==e[f(1511)])return _0x3c3cca(_0xda9122[f(1765)](ZXTXGV[f(1193)](_0x1f89eb,this),_0x38fb38));if(this[f(1516)+f(1271)]?.[f(1094)+"chMaxTries"]()){let m=this._endpointManager?.[f(1558)+"ntEndpoint"]();this[f(1400)+f(1800)+f(963)](e.WAzZd(xt,"close",{code:1006,reason:f(1653)+m+(f(1730)+f(1113)+"tries re"+f(1190)),wasClean:!0}))}else{let m=this._options[f(775)+"tInterce"+f(611)](n,s);this["_dispatc"+f(1800)+"ent"](e[f(1900)](xt,e[f(756)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[f(547)]()}return}this["_navigat"+f(1189)]()||this[f(1036)+"osed"]?this[f(1400)+f(1800)+"ent"](e.KLShG(xt,f(723),{code:n,reason:e.flDgb})):this[f(1400)+f(1800)+"ent"](e[f(1065)](xt,e.KbrpA,{code:1006,reason:f(1125)+f(1582)+f(731)+f(1131)})),this[f(1096)]=null,this[f(1516)+"tManager"]?.[f(772)+f(920)+f(1436)](),this[f(741)+f(1670)]?.[f(1069)+f(1589)]()}else return!!this[f(682)]}[t(1400)+t(748)+"nt"](n){let s=t;this.emit(s(1290),n),this.onopen&&this[s(1472)](n)}[t(1400)+t(500)+t(1112)](n){let s=t;this[s(774)](e[s(1662)],n),this[s(1071)+"e"]&&this.onmessage(n)}[t(1400)+"hAckMess"+t(1212)](n){let s=t;this[s(774)](e[s(558)],n),this[s(1277)+"eAck"]&&this.onReceiveAck(n)}[t(1400)+t(873)+t(963)](n){let s=t;e[s(1026)]===e[s(575)]?(this[s(1096)]&&this[s(1096)][s(1503)](_0xf55a41),this[s(1207)](e[s(808)],_0x207d25)):(this.emit(e[s(1774)],n),this[s(1016)]&&this[s(1016)](n))}[t(1400)+t(1800)+t(963)](n){let s=t;this.emit(e[s(756)],n),this[s(1590)]&&this.onclose(n)}get binaryType(){let n=t,s={pxHZt:function(d,f,g){return e.dPEzP(d,f,g)},ixXlc:function(d,f,g){return e.qThUb(d,f,g)}};if(e[n(1386)](n(1035),n(1719)))MssCfL[n(627)](_0x271291,_0x34ec5c,66),_0xe451c2(_0x3030be,_0x13e6de.length),MssCfL.ixXlc(_0x470d47,_0x30afd9,_0x3e0cbb);else return this[n(1096)]?this._ws[n(1555)+"pe"]:this["_binaryT"+n(1892)]}set[t(1555)+"pe"](n){let s=t;this[s(1966)+s(1892)]=n,this[s(1096)]&&(this._ws.binaryType=n)}get[t(725)+"nt"](){let n=t;return this._endpointManager?.["getCurre"+n(461)+n(556)+"ount"]()||0}get[t(1884)+"Amount"](){let n=t;if(e[n(791)](e[n(1564)],e[n(809)])){let s="connect "+_0x5973d9+(" fail, max retri"+n(594)+"ed");this[n(1400)+n(873)+n(963)](_0x38183b("error",{message:s,code:_0x3ac001[n(1109)+n(707)+"R"],error:_0x2c0908}));return}else{let s=this[n(1055)+n(636)][n(475)]((d,f)=>(d+=f&&f.byteLength||0,d),0);return e[n(954)](s,this[n(1096)]?this[n(1096)][n(1884)+n(1022)]:0)}}get[t(1642)+"ns"](){let n=t;return this[n(1096)]?this._ws[n(1642)+"ns"]:""}get[t(781)](){let n=t;return this._ws?this[n(1096)][n(781)]:""}get[t(1331)+"te"](){let n=t;return this[n(1096)]?this[n(1096)][n(1331)+"te"]:this._options[n(1808)+"cOpen"]?this[n(1928)+"NG"]:this[n(650)]}get[t(813)](){let n=t;if(e.zucpf(e[n(960)],e[n(1158)]))++_0x10da43,_0x4830bb+=4;else return this[n(1096)]?this._ws[n(813)]:this[n(493)]}[t(723)](n=1e3,s){let d=t;if(e.OTaSQ(e.lreBG,d(1929))){let f=e[d(859)][d(863)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(1567)+d(1250)+"t"](n,s);continue;case"1":this._clearPingTimer();continue;case"2":this[d(1036)+d(1296)]=!0;continue;case"3":if(this[d(1096)][d(1331)+"te"]===this[d(650)]||e.zhwna(this[d(1096)].readyState,this[d(935)]))return void this[d(1207)](e[d(443)]);continue;case"4":this[d(1176)+d(1776)]?.[d(710)]();continue;case"5":if(!this._ws)return void this[d(1207)](d(1391)+d(945)+d(1315)+d(766)+"ed");continue;case"6":this._clearTimer();continue;case"7":this["_dropGlo"+d(1713)+d(1441)]();continue}break}}else return this._socket.extensions}async[t(1503)](n,s){let d=t;if(e[d(1512)](null,n))throw new Error(e[d(1360)]);e[d(1668)](e.nWMgN,typeof n)&&(n=JSON[d(722)+"y"](n)),e.PLUtZ!=typeof n&&!(n instanceof ArrayBuffer)&&!(n.buffer&&n[d(1390)]instanceof ArrayBuffer)&&(n=JSON[d(722)+"y"](n));let f=await e[d(1494)](Jd,n),g=e[d(1910)]($h,n),{method:m=0,service:b=this[d(1754)][d(1086)],logID:h=this[d(1754)][d(1154)+"erator"](),headers:R=this._options[d(1712)],payloadEncoding:L=this[d(1754)][d(584)+d(1901)],payloadType:F=this[d(1754)][d(1607)+"ype"],logIDNew:W=this[d(1754)][d(479)+d(520)][d(760)+d(1085)+"teLogIDNew"]?e[d(1264)](i,this._options["logIDNew"+d(520)].userIp):""}=e.mOnDZ(s,{});if(!b)throw new Error(e[d(1913)]);let Z={SeqID:ce[d(1750)+"er"](this[d(1920)]++),LogID:ce[d(1750)+"er"](h),service:b,method:m,headers:R,payloadEncoding:e[d(865)](L,Object)?L[d(1743)]?L[d(1743)]:"":L,payloadType:e.XgFwI(F,Object)?F[d(1101)]?F.type:g:F||g,payload:f,LogIDNew:W},J=e[d(1044)](zt,Z);if(this[d(1096)]&&this._ws[d(1331)+"te"]===this[d(649)]){if(e[d(1321)]===e[d(460)])return this._ws?this._ws.extensions:"";this._ws&&this[d(1096)].send(J),this[d(1207)](e.BDHdT,Z)}else this[d(1055)+"Queue"][d(1927)]<this[d(1754)][d(450)+"geQueueL"+d(1738)]?(this[d(1055)+"Queue"][d(1655)](J),this[d(1207)](e[d(1164)],Z)):e[d(1352)]!==e[d(1352)]?(this["_dispatc"+d(500)+d(1112)](_0x43912f),_0x31b549[d(1238)](_0x286c99,_0x1a5459,_0x54e3df.message[d(1086)])):(this[d(1055)+d(636)][d(786)](),this[d(1055)+d(636)][d(1655)](J));return{seqID:this._seqId,logID:h,logIDNew:W}}async[t(775)+"t"](n){let s=t,{url:d}=e[s(1701)](n,{}),f=Array.isArray(d)?d:e.bnFlF(e[s(1628)],typeof d)?[d]:[];n&&Object.assign(this[s(1754)],n),f&&f[s(1927)]?this[s(1516)+s(1271)]=new Wd(f,this[s(1754)].maxRetries):this["_endpoin"+s(1271)]?.["resetEnd"+s(920)+s(1436)](),this["_pingLos"+s(1670)]?.[s(1069)+s(1589)](this[s(1754)][s(788)+"Count"]),this._readyClosed=!1,this._ws&&e[s(1370)](this[s(1096)][s(1331)+"te"],this.CLOSED)?this[s(810)+s(1634)](1e3,e[s(1838)],!0):(this[s(1843)]=!0,this[s(547)]())}async[t(1794)](){let n=t;if(!this[n(547)+n(1811)]){let s=e[n(1595)][n(863)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1843)]=!0;continue;case"1":this[n(547)]();continue;case"2":this["_endpoin"+n(1271)]?.[n(772)+n(920)+n(1436)]();continue;case"3":this[n(1036)+n(1296)]=!1;continue;case"4":this[n(741)+n(1670)]?.[n(1069)+n(1589)]();continue}break}}}["addEvent"+t(1441)](n,s){this.on(n,s)}dispatchEvent(n){let s=t;if(e.JPrGD(s(1241),s(1241)))this["_binaryT"+s(1892)]=_0x30d90e,this[s(1096)]&&(this[s(1096)][s(1555)+"pe"]=_0x5d12a4);else{let{type:d}=n;this.emit(d,n)}}[t(1854)+"entListe"+t(497)](n,s){let d=t;e[d(1693)](e[d(1092)],e.LTNVi)?this[d(1440)](n,s):_0x5c9d4d=ZXTXGV[d(1716)](_0x39ea4c,_0x4acba1)}[t(1612)](){let n=t,s={fnktF:e[n(1952)],Pkatf:function(d,f){return e[n(1833)](d,f)},TWHHq:function(d,f,g){return e[n(784)](d,f,g)},IrNrZ:e[n(1091)]};return new Promise((d,f)=>{let g=n,m={PKrAn:function(R,L){return R(L)},LhvYP:g(578),YyJRX:s[g(1955)],xBEhN:g(1243)+g(1348)+"t",TNLJq:function(R,L){return s[g(1949)](R,L)},aMaTK:g(1419)};this[g(1895)+g(528)](),this[g(843)+g(545)+"Id"]=s[g(888)](setTimeout,this[g(668)][g(938)](this),this._options[g(448)+g(1175)]);let b=()=>{let R=g;m[R(1333)](d,m[R(1455)]),this[R(1440)](m[R(1667)],b),this[R(1440)](m[R(599)],h)},h=()=>{let R=g;m[R(862)](f,m.aMaTK),this[R(1440)](m.YyJRX,b),this[R(1440)](R(1243)+"e_timeout",h)};this.on(s.fnktF,b),this.on(s.IrNrZ,h),this[g(668)]()})}}})(),Me[N(1314)+N(1269)]=De[N(1314)+N(1269)],Me["CustomEr"+N(858)]=De.CustomErrorEvent,Me[N(1613)+"e"]=De.ErrorCode,Me[N(1112)]=De[N(1112)],Me[N(1748)]=De[N(1748)],Me[N(1943)+N(1909)+"vent"]=De[N(1943)+N(1909)+N(937)],Me["MessageE"+N(937)]=De["MessageE"+N(937)],Me[N(1459)+"t"]=De.OpenEvent,Me[N(1454)+N(825)]=De["Reconnec"+N(825)],Me["createCl"+N(1269)]=De[N(1163)+N(1269)],Me[N(1764)+N(858)]=De[N(1764)+"rorEvent"],Me[N(1460)+N(1572)+"nt"]=De["createMe"+N(1572)+"nt"],Me["createOp"+N(1409)]=De[N(876)+"enEvent"],Me[N(1781)+"connectE"+N(937)]=De[N(1781)+N(521)+"vent"],Me[N(1953)+N(604)]=De[N(1953)+"rame"],Me[N(606)+N(931)]=De[N(606)+N(931)];for(wo in De)["CustomCl"+N(1269),"CustomEr"+N(858),"ErrorCode",N(1112),N(1748),N(1943)+"MessageE"+N(937),N(1909)+N(937),"OpenEvent","Reconnec"+N(825),N(1163)+N(1269),N(1764)+"rorEvent",N(1460)+N(1572)+"nt","createOpenEvent",N(1781)+N(521)+"vent",N(1953)+N(604),N(606)+N(931)][N(615)](wo)===-1&&(Me[wo]=De[wo]);var wo;Object[N(1565)+N(1259)](Me,N(928)+"le",{value:!0})});var $t=se((M3,$f)=>{"use strict";var Wf=["nodebuffer","arraybuffer","fragments"],Kf=typeof Blob<"u";Kf&&Wf.push("blob");$f.exports={BINARY_TYPES:Wf,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Kf,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var zi=se((B3,Ao)=>{"use strict";var{EMPTY_BUFFER:kE}=$t(),td=Buffer[Symbol.species];function OE(t,e){if(t.length===0)return kE;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 td(r.buffer,r.byteOffset,i):r}function Vf(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Jf(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function PE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function nd(t){if(nd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new td(t):ArrayBuffer.isView(t)?e=new td(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),nd.readOnly=!1),e}Ao.exports={concat:OE,mask:Vf,toArrayBuffer:PE,toBuffer:nd,unmask:Jf};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=de("bufferutil");Ao.exports.mask=function(e,r,i,o,c){c<48?Vf(e,r,i,o,c):t.mask(e,r,i,o,c)},Ao.exports.unmask=function(e,r){e.length<32?Jf(e,r):t.unmask(e,r)}}catch{}});var Xf=se((z3,Yf)=>{"use strict";var Zf=Symbol("kDone"),rd=Symbol("kRun"),id=class{constructor(e){this[Zf]=()=>{this.pending--,this[rd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[rd]()}[rd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Zf])}}};Yf.exports=id});var Rr=se((F3,nx)=>{"use strict";var Fi=de("zlib"),Qf=zi(),LE=Xf(),{kStatusCode:ex}=$t(),NE=Buffer[Symbol.species],ME=Buffer.from([0,0,255,255]),To=Symbol("permessage-deflate"),Vt=Symbol("total-length"),Cr=Symbol("callback"),bn=Symbol("buffers"),Dr=Symbol("error"),Io,sd=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Io){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Io=new LE(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Cr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Io.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Io.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Fi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[To]=this,this._inflate[Vt]=0,this._inflate[bn]=[],this._inflate.on("error",zE),this._inflate.on("data",tx)}this._inflate[Cr]=i,this._inflate.write(e),r&&this._inflate.write(ME),this._inflate.flush(()=>{let c=this._inflate[Dr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=Qf.concat(this._inflate[bn],this._inflate[Vt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Vt]=0,this._inflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Fi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Vt]=0,this._deflate[bn]=[],this._deflate.on("data",BE)}this._deflate[Cr]=i,this._deflate.write(e),this._deflate.flush(Fi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Qf.concat(this._deflate[bn],this._deflate[Vt]);r&&(c=new NE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Cr]=null,this._deflate[Vt]=0,this._deflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};nx.exports=sd;function BE(t){this[bn].push(t),this[Vt]+=t.length}function tx(t){if(this[Vt]+=t.length,this[To]._maxPayload<1||this[Vt]<=this[To]._maxPayload){this[bn].push(t);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][ex]=1009,this.removeListener("data",tx),this.reset()}function zE(t){if(this[To]._inflate=null,this[Dr]){this[Cr](this[Dr]);return}t[ex]=1007,this[Cr](t)}});var kr=se((U3,Co)=>{"use strict";var{isUtf8:rx}=de("buffer"),{hasBlob:FE}=$t(),UE=[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 GE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function od(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 qE(t){return FE&&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:qE,isValidStatusCode:GE,isValidUTF8:od,tokenChars:UE};if(rx)Co.exports.isValidUTF8=function(t){return t.length<24?od(t):rx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=de("utf-8-validate");Co.exports.isValidUTF8=function(e){return e.length<32?od(e):t(e)}}catch{}});var ud=se((G3,lx)=>{"use strict";var{Writable:HE}=de("stream"),ix=Rr(),{BINARY_TYPES:jE,EMPTY_BUFFER:sx,kStatusCode:WE,kWebSocket:KE}=$t(),{concat:ad,toArrayBuffer:$E,unmask:VE}=zi(),{isValidStatusCode:JE,isValidUTF8:ox}=kr(),Do=Buffer[Symbol.species],lt=0,ax=1,cx=2,dx=3,cd=4,dd=5,Ro=6,ld=class extends HE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||jE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[KE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Do(i.buffer,i.byteOffset+e,i.length-e),new Do(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 Do(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 ax:this.getPayloadLength16(e);break;case cx:this.getPayloadLength64(e);break;case dx:this.getMask();break;case cd:this.getData(e);break;case dd:case Ro: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[ix.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=ax:this._payloadLength===127?this._state=cx: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=dx:this._state=cd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=cd}getData(e){let r=sx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&VE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=dd,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[ix.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=ad(i,r):this._binaryType==="arraybuffer"?o=$E(ad(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=Ro,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=ad(i,r);if(!this._skipUTF8Validation&&!ox(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===dd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=Ro,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,sx),this.end();else{let i=e.readUInt16BE(0);if(!JE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Do(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ox(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=Ro,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[WE]=o,l}};lx.exports=ld});var hd=se((H3,xx)=>{"use strict";var{Duplex:q3}=de("stream"),{randomFillSync:ZE}=de("crypto"),ux=Rr(),{EMPTY_BUFFER:YE,kWebSocket:XE,NOOP:QE}=$t(),{isBlob:Or,isValidStatusCode:eb}=kr(),{mask:fx,toBuffer:qn}=zi(),ut=Symbol("kByteLength"),tb=Buffer.alloc(4),ko=8*1024,Hn,Pr=ko,vt=0,nb=1,rb=2,fd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=vt,this.onerror=QE,this[XE]=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):(Pr===ko&&(Hn===void 0&&(Hn=Buffer.alloc(ko)),ZE(Hn,0,ko),Pr=0),i[0]=Hn[Pr++],i[1]=Hn[Pr++],i[2]=Hn[Pr++],i[3]=Hn[Pr++]),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 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],l?[p,e]:o?(fx(e,i,p,c,u),[p]):(fx(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=YE;else{if(typeof e!="number"||!eb(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ut]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==vt?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ut]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[ux.extensionName],c=r.binary?2:1,l=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Or(e)?(u=e.size,x=!1):(e=qn(e),u=e.length,x=qn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[ut]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==vt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ut],this._state=rb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(xd,this,u,o);return}this._bufferedBytes-=i[ut];let l=qn(c);r?this.dispatch(l,r,i,o):(this._state=vt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(ib,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[ux.extensionName];this._bufferedBytes+=i[ut],this._state=nb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");xd(this,x,o);return}this._bufferedBytes-=i[ut],this._state=vt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===vt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][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)}};xx.exports=fd;function xd(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function ib(t,e,r){xd(t,e,r),t.onerror(e)}});var vx=se((j3,bx)=>{"use strict";var{kForOnEventAttribute:Ui,kListener:pd}=$t(),hx=Symbol("kCode"),px=Symbol("kData"),gx=Symbol("kError"),mx=Symbol("kMessage"),_x=Symbol("kReason"),Lr=Symbol("kTarget"),yx=Symbol("kType"),Ex=Symbol("kWasClean"),Jt=class{constructor(e){this[Lr]=null,this[yx]=e}get target(){return this[Lr]}get type(){return this[yx]}};Object.defineProperty(Jt.prototype,"target",{enumerable:!0});Object.defineProperty(Jt.prototype,"type",{enumerable:!0});var jn=class extends Jt{constructor(e,r={}){super(e),this[hx]=r.code===void 0?0:r.code,this[_x]=r.reason===void 0?"":r.reason,this[Ex]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[hx]}get reason(){return this[_x]}get wasClean(){return this[Ex]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Nr=class extends Jt{constructor(e,r={}){super(e),this[gx]=r.error===void 0?null:r.error,this[mx]=r.message===void 0?"":r.message}get error(){return this[gx]}get message(){return this[mx]}};Object.defineProperty(Nr.prototype,"error",{enumerable:!0});Object.defineProperty(Nr.prototype,"message",{enumerable:!0});var Gi=class extends Jt{constructor(e,r={}){super(e),this[px]=r.data===void 0?null:r.data}get data(){return this[px]}};Object.defineProperty(Gi.prototype,"data",{enumerable:!0});var sb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ui]&&o[pd]===e&&!o[Ui])return;let i;if(t==="message")i=function(c,l){let u=new Gi("message",{data:l?c:c.toString()});u[Lr]=this,Oo(e,this,u)};else if(t==="close")i=function(c,l){let u=new jn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Lr]=this,Oo(e,this,u)};else if(t==="error")i=function(c){let l=new Nr("error",{error:c,message:c.message});l[Lr]=this,Oo(e,this,l)};else if(t==="open")i=function(){let c=new Jt("open");c[Lr]=this,Oo(e,this,c)};else return;i[Ui]=!!r[Ui],i[pd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[pd]===e&&!r[Ui]){this.removeListener(t,r);break}}};bx.exports={CloseEvent:jn,ErrorEvent:Nr,Event:Jt,EventTarget:sb,MessageEvent:Gi};function Oo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Po=se((W3,Sx)=>{"use strict";var{tokenChars:qi}=kr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ob(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,x=-1,p=-1,w=-1,_=0;for(;_<t.length;_++)if(p=t.charCodeAt(_),l===void 0)if(w===-1&&qi[p]===1)x===-1&&(x=_);else if(_!==0&&(p===32||p===9))w===-1&&x!==-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_);let E=t.slice(x,w);p===44?(Bt(e,E,r),r=Object.create(null)):l=E,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(w===-1&&qi[p]===1)x===-1&&(x=_);else if(p===32||p===9)w===-1&&x!==-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_),Bt(r,t.slice(x,w),!0),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),x=w=-1}else if(p===61&&x!==-1&&w===-1)u=t.slice(x,_),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(qi[p]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);x===-1?x=_:i||(i=!0),o=!1}else if(c)if(qi[p]===1)x===-1&&(x=_);else if(p===34&&x!==-1)c=!1,w=_;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(w===-1&&qi[p]===1)x===-1&&(x=_);else if(x!==-1&&(p===32||p===9))w===-1&&(w=_);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${_}`);w===-1&&(w=_);let E=t.slice(x,w);i&&(E=E.replace(/\\/g,""),i=!1),Bt(r,u,E),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),u=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=_);let I=t.slice(x,w);return l===void 0?Bt(e,I,r):(u===void 0?Bt(r,I,!0):i?Bt(r,u,I.replace(/\\/g,"")):Bt(r,u,I),Bt(e,l,r)),e}function ab(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(", ")}Sx.exports={format:ab,parse:ob}});var Bo=se((V3,Mx)=>{"use strict";var cb=de("events"),db=de("https"),lb=de("http"),Tx=de("net"),ub=de("tls"),{randomBytes:fb,createHash:xb}=de("crypto"),{Duplex:K3,Readable:$3}=de("stream"),{URL:gd}=de("url"),vn=Rr(),hb=ud(),pb=hd(),{isBlob:gb}=kr(),{BINARY_TYPES:Ax,CLOSE_TIMEOUT:mb,EMPTY_BUFFER:Lo,GUID:wb,kForOnEventAttribute:md,kListener:_b,kStatusCode:yb,kWebSocket:Ge,NOOP:Cx}=$t(),{EventTarget:{addEventListener:Eb,removeEventListener:bb}}=vx(),{format:vb,parse:Sb}=Po(),{toBuffer:Ab}=zi(),Dx=Symbol("kAborted"),wd=[8,13],Zt=["CONNECTING","OPEN","CLOSING","CLOSED"],Ib=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends cb{constructor(e,r,i){super(),this._binaryType=Ax[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]),Rx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ax.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 hb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new pb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ge]=this,c[Ge]=this,e[Ge]=this,o.on("conclude",Db),o.on("drain",Rb),o.on("error",kb),o.on("message",Ob),o.on("ping",Pb),o.on("pong",Lb),c.onerror=Nb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Px),e.on("data",Mo),e.on("end",Lx),e.on("error",Nx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[vn.extensionName]&&this._extensions[vn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ox(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){_d(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){_d(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){_d(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Lo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ge,"CONNECTING",{enumerable:!0,value: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[md])return e[_b];return null},set(e){for(let r of this.listeners(t))if(r[md]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[md]:!0})}})});ge.prototype.addEventListener=Eb;ge.prototype.removeEventListener=bb;Mx.exports=ge;function Rx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:mb,protocolVersion:wd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!wd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${wd.join(", ")})`);let c;if(e instanceof gd)c=e;else try{c=new gd(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:",x;if(c.protocol!=="ws:"&&!l&&!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 A=new SyntaxError(x);if(t._redirects===0)throw A;No(t,A);return}let p=l?443:80,w=fb(16).toString("base64"),_=l?db.request:lb.request,I=new Set,E;if(o.createConnection=o.createConnection||(l?Cb:Tb),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":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(E=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=vb({[vn.extensionName]:E.offer()})),r.length){for(let A of r){if(typeof A!="string"||!Ib.test(A)||I.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(A)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let A=o.path.split(":");o.socketPath=A[0],o.path=A[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let A=i&&i.headers;if(i={...i,headers:{}},A)for(let[S,C]of Object.entries(A))i.headers[S.toLowerCase()]=C}else if(t.listenerCount("redirect")===0){let A=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!A||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=_(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=_(o);o.timeout&&v.on("timeout",()=>{st(t,v,"Opening handshake has timed out")}),v.on("error",A=>{v===null||v[Dx]||(v=t._req=null,No(t,A))}),v.on("response",A=>{let S=A.headers.location,C=A.statusCode;if(S&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){st(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new gd(S,e)}catch{let D=new SyntaxError(`Invalid URL: ${S}`);No(t,D);return}Rx(t,P,r,i)}else t.emit("unexpected-response",v,A)||st(t,v,`Unexpected server response: ${A.statusCode}`)}),v.on("upgrade",(A,S,C)=>{if(t.emit("upgrade",A),t.readyState!==ge.CONNECTING)return;v=t._req=null;let P=A.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){st(t,S,"Invalid Upgrade header");return}let y=xb("sha1").update(w+wb).digest("base64");if(A.headers["sec-websocket-accept"]!==y){st(t,S,"Invalid Sec-WebSocket-Accept header");return}let D=A.headers["sec-websocket-protocol"],k;if(D!==void 0?I.size?I.has(D)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":I.size&&(k="Server sent no subprotocol"),k){st(t,S,k);return}D&&(t._protocol=D);let M=A.headers["sec-websocket-extensions"];if(M!==void 0){if(!E){st(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=Sb(M)}catch{st(t,S,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(B);if($.length!==1||$[0]!==vn.extensionName){st(t,S,"Server indicated an extension that was not requested");return}try{E.accept(B[vn.extensionName])}catch{st(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=E}t.setSocket(S,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function No(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Tb(t){return t.path=t.socketPath,Tx.connect(t)}function Cb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Tx.isIP(t.host)?"":t.host),ub.connect(t)}function st(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,st),e.setHeader?(e[Dx]=!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 _d(t,e,r){if(e){let i=gb(e)?e.size:Ab(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 Db(t,e){let r=this[Ge];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ge]!==void 0&&(r._socket.removeListener("data",Mo),process.nextTick(kx,r._socket),t===1005?r.close():r.close(t,e))}function Rb(){let t=this[Ge];t.isPaused||t._socket.resume()}function kb(t){let e=this[Ge];e._socket[Ge]!==void 0&&(e._socket.removeListener("data",Mo),process.nextTick(kx,e._socket),e.close(t[yb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ix(){this[Ge].emitClose()}function Ob(t,e){this[Ge].emit("message",t,e)}function Pb(t){let e=this[Ge];e._autoPong&&e.pong(t,!this._isServer,Cx),e.emit("ping",t)}function Lb(t){this[Ge].emit("pong",t)}function kx(t){t.resume()}function Nb(t){let e=this[Ge];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Ox(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ox(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Px(){let t=this[Ge];if(this.removeListener("close",Px),this.removeListener("data",Mo),this.removeListener("end",Lx),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[Ge]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ix),t._receiver.on("finish",Ix))}function Mo(t){this[Ge]._receiver.write(t)||this.pause()}function Lx(){let t=this[Ge];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function Nx(){let t=this[Ge];this.removeListener("error",Nx),this.on("error",Cx),t&&(t._readyState=ge.CLOSING,this.destroy())}});var Ux=se((Z3,Fx)=>{"use strict";var J3=Bo(),{Duplex:Mb}=de("stream");function Bx(t){t.emit("close")}function Bb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function zx(t){this.removeListener("error",zx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function zb(t,e){let r=!0,i=new Mb({...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(Bx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Bx,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",Bb),i.on("error",zx),i}Fx.exports=zb});var yd=se((Y3,Gx)=>{"use strict";var{tokenChars:Fb}=kr();function Ub(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&&Fb[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}Gx.exports={parse:Ub}});var Vx=se((Q3,$x)=>{"use strict";var Gb=de("events"),zo=de("http"),{Duplex:X3}=de("stream"),{createHash:qb}=de("crypto"),qx=Po(),Wn=Rr(),Hb=yd(),jb=Bo(),{CLOSE_TIMEOUT:Wb,GUID:Kb,kWebSocket:$b}=$t(),Vb=/^[+/0-9A-Za-z]{22}==$/,Hx=0,jx=1,Kx=2,Ed=class extends Gb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Wb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:jb,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=zo.createServer((i,o)=>{let c=zo.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=Jb(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=Hx}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===Kx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Hi,this);return}if(e&&this.once("close",e),this._state!==jx)if(this._state=jx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Hi,this):process.nextTick(Hi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Hi(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",Wx);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Vb.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ji(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=Hb.parse(x)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&w!==void 0){let I=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=qx.parse(w);E[Wn.extensionName]&&(I.accept(E[Wn.extensionName]),_[Wn.extensionName]=I)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(E,v,A,S)=>{if(!E)return ji(r,v||401,A,S);this.completeUpgrade(_,c,p,e,r,i,o)});return}if(!this.options.verifyClient(I))return ji(r,401)}this.completeUpgrade(_,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[$b])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Hx)return ji(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${qb("sha1").update(r+Kb).digest("base64")}`],w=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: ${_}`),w._protocol=_)}if(e[Wn.extensionName]){let _=e[Wn.extensionName].params,I=qx.format({[Wn.extensionName]:[_]});p.push(`Sec-WebSocket-Extensions: ${I}`),w._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",Wx),w.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Hi,this)})),u(w,o)}};$x.exports=Ed;function Jb(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 Hi(t){t._state=Kx,t.emit("close")}function Wx(){this.destroy()}function ji(t,e,r,i){r=r||zo.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} ${zo.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
|
|
21
|
-
<string>${
|
|
20
|
+
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else ji(r,i,o,c)}});import{existsSync as _v,openSync as yv}from"node:fs";import{mkdir as Ev}from"node:fs/promises";import{dirname as bv}from"node:path";import{fileURLToPath as vv}from"node:url";function Av(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ad(t=X()){return _v(t.libEntry)?t.libEntry:vv(new URL("../index.ts",import.meta.url))}async function ch(t={}){let e=t.paths??X(),r=t.entryOverride??Ad(e),i=Av(e,process.env.COZE_BRIDGE_LOG_MODE);await Ev(bv(i),{recursive:!0});let o=yv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=dt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[$i]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return Sv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var Sv,$i,jo=Ze(()=>{"use strict";yn();ne();Oe();Sv=G("spawn-daemon"),$i="COZE_BRIDGE_DAEMON"});import{spawn as xS}from"node:child_process";import{mkdir as hS,unlink as pS,writeFile as gS}from"node:fs/promises";import{dirname as mS,join as wS}from"node:path";function Fr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function _S(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Fr(r)}</key>
|
|
21
|
+
<string>${Fr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function yS(t,e){return new Promise((r,i)=>{let o=xS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var zr,Ji,Yo,Od,Ah=Ze(()=>{"use strict";ne();zr=G("supervisor.launchd"),Ji="ai.coze.bridge",Yo=yS,Od={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>${Ji}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Fr(t.nodeBin)}</string>
|
|
35
|
+
<string>${Fr(t.entry)}</string>
|
|
36
36
|
<string>--daemon</string>
|
|
37
37
|
</array>
|
|
38
38
|
<key>RunAtLoad</key>
|
|
@@ -42,13 +42,13 @@ ${e}
|
|
|
42
42
|
<key>ThrottleInterval</key>
|
|
43
43
|
<integer>10</integer>
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Fr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Fr(t.logFile)}</string>${_S(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return wS(t.homeDir,"Library","LaunchAgents",`${Ji}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await hS(mS(i),{recursive:!0}),await gS(i,this.renderConfig(t),"utf8"),zr.info("plist written",{plistPath:i,activate:r}),!r)return;await Yo("launchctl",["unload","-w",i]).catch(c=>zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await Yo("launchctl",["load","-w",i]),zr.info("launchd job loaded",{label:Ji});let o=process.getuid?.()??0;await Yo("launchctl",["kickstart","-k",`gui/${o}/${Ji}`]),zr.info("launchd job kickstarted",{label:Ji,uid:o})},async uninstall(t){let e=this.configPath(t);await Yo("launchctl",["unload","-w",e]).catch(r=>zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await pS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),zr.info("launchd job removed",{plistPath:e})}}});import{spawn as ES}from"node:child_process";import{mkdir as bS,unlink as vS,writeFile as SS}from"node:fs/promises";import{dirname as AS,join as Ih}from"node:path";function Qo(t,e){return t.isRoot?e:["--user",...e]}function TS(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function ea(t,e){return new Promise((r,i)=>{let o=ES(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 Xo,Ur,IS,Pd,Th=Ze(()=>{"use strict";ne();Xo=G("supervisor.systemd"),Ur="coze-bridge.service",IS="/etc/systemd/system";Pd={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
|
+
${TS(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Ih(IS,Ur):Ih(t.homeDir,".config","systemd","user",Ur)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await bS(AS(i),{recursive:!0}),await SS(i,this.renderConfig(t),"utf8"),Xo.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await ea("systemctl",Qo(t,["daemon-reload"])),await ea("systemctl",Qo(t,r?["enable","--now",Ur]:["enable",Ur])),Xo.info("systemd unit enabled",{unitName:Ur,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await ea("systemctl",Qo(t,["disable","--now",Ur])).catch(r=>Xo.warn("systemctl disable failed (ignored)",{err:String(r)})),await vS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ea("systemctl",Qo(t,["daemon-reload"])).catch(()=>{}),Xo.info("systemd unit removed",{unitPath:e})}}});import{spawn as CS}from"node:child_process";import{join as DS}from"node:path";function Ch(t,e){return new Promise((r,i)=>{let o=CS(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 Ld,ta,Nd,Dh=Ze(()=>{"use strict";ne();Ld=G("supervisor.taskscheduler"),ta="CozeBridge",Nd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,43 +86,43 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return Rv(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Tx("schtasks",["/Create","/SC","ONLOGON","/TN",Qo,"/TR",r,"/RU",t.userName,"/F"]),kd.info("task scheduler entry created",{task:Qo,logFile:t.logFile})},async uninstall(t){await Tx("schtasks",["/Delete","/TN",Qo,"/F"]).catch(e=>kd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),kd.info("task scheduler entry removed",{task:Qo})}}});var Cx={};ha(Cx,{buildContext:()=>Nv,getSupervisor:()=>kv,launchdSupervisor:()=>Cd,systemdSupervisor:()=>Dd,taskSchedulerSupervisor:()=>Od});import{homedir as Cv,userInfo as Dv}from"node:os";function kv(t=process.platform){switch(t){case"darwin":return Cd;case"linux":return Dd;case"win32":return Od;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function Pv(){let t={};for(let e of Ov){let r=process.env[e];r&&(t[e]=r)}return t}function Nv(){let t=Y();return{nodeBin:process.execPath,entry:bd(t),logFile:t.logFile,homeDir:Cv(),userName:Dv().username,isRoot:process.getuid?.()===0,env:Pv()}}var Ov,Dx=$e(()=>{"use strict";De();Ho();Sx();Ax();Rx();Ov=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();Qt();var dl=U("acp-installer-warmup"),ng=["claude-code","codex"];async function ll(t={}){let e=t.ensure??Xn,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);dl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&dl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}en();te();import{readdir as xg}from"node:fs/promises";import{mkdir as gl,writeFile as ml}from"node:fs/promises";import{join as ya}from"node:path";var hg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function tr(t,e,r){await gl(t,{recursive:!0});let i=hg[e],o=ya(t,i);return await ml(o,r??"","utf8"),o}async function wl(t){let e=ya(t,".claude");await gl(e,{recursive:!0});let r=ya(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await ml(r,i,"utf8"),r}var Ye=U("agent-detail-sync"),pg=6e4,gg=5*6e4,os=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await xg(r)}catch(o){Ye.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Ye.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ge(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ye.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Ye.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Ye.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){Ye.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Ye.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ge(e,this.opts.paths);if(!i){Ye.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){Ye.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let h=this.retryQueue.get(e),x=h?Math.min(h.currentDelay*2,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+x,currentDelay:x});return}if(o.agentId&&o.agentId!==e){Ye.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&Ye.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ye.debug("detail sync: no diff",{agentId:e});return}await Je(i,this.opts.paths),Ye.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await tr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Lf=bt(Yl(),1);import{lstat as Lc,mkdir as Mc,readFile as kf,readdir as qw,rm as jw,stat as Ww,writeFile as Bc}from"node:fs/promises";import{dirname as Kw,join as Ct,normalize as $w,relative as Uc,resolve as zc,sep as Of}from"node:path";import{Readable as Pf}from"node:stream";import{pipeline as Nf}from"node:stream/promises";import zg from"events";import Ze from"fs";import{EventEmitter as _c}from"node:events";import Ou from"node:stream";import{StringDecoder as Fg}from"node:string_decoder";import Lu from"node:path";import hr from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import ec from"assert";import{Buffer as Ln}from"buffer";import*as nu from"zlib";import cm from"zlib";import{posix as or}from"node:path";import{basename as Lm}from"node:path";import zs from"fs";import At from"fs";import du from"path";import{win32 as Km}from"node:path";import gu from"path";import Zu from"node:fs";import dw from"node:assert";import{randomBytes as Yu}from"node:crypto";import ne from"node:fs";import Oe from"node:path";import Xu from"fs";import $s from"node:fs";import pi from"node:path";import et from"node:fs";import gw from"node:fs/promises";import Gs from"node:path";import{join as lf}from"node:path";import Qe from"node:fs";import hf from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},Xl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof zn||t instanceof Ou||Gg(t)||Hg(t)),Gg=t=>!!t&&typeof t=="object"&&t instanceof _c&&typeof t.pipe=="function"&&t.pipe!==Ou.Writable.prototype.pipe,Hg=t=>!!t&&typeof t=="object"&&t instanceof _c&&typeof t.write=="function"&&typeof t.end=="function",Bt=Symbol("EOF"),zt=Symbol("maybeEmitEnd"),nn=Symbol("emittedEnd"),us=Symbol("emittingEnd"),Xr=Symbol("emittedError"),fs=Symbol("closed"),Ql=Symbol("read"),hs=Symbol("flush"),eu=Symbol("flushChunk"),ft=Symbol("encoding"),sr=Symbol("decoder"),Le=Symbol("flowing"),Qr=Symbol("paused"),lr=Symbol("resume"),Me=Symbol("buffer"),We=Symbol("pipes"),Be=Symbol("bufferLength"),Aa=Symbol("bufferPush"),xs=Symbol("bufferShift"),qe=Symbol("objectMode"),ve=Symbol("destroyed"),Ta=Symbol("error"),Ra=Symbol("emitData"),tu=Symbol("emitEnd"),Ca=Symbol("emitEnd2"),vt=Symbol("async"),Da=Symbol("abort"),ps=Symbol("aborted"),ei=Symbol("signal"),An=Symbol("dataListeners"),Xe=Symbol("discarded"),ti=t=>Promise.resolve().then(t),qg=t=>t(),jg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Pu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[lr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},$g=class extends Pu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Vg=t=>!!t.objectMode,Jg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",zn=class extends _c{[Le]=!1;[Qr]=!1;[We]=[];[Me]=[];[qe];[ft];[vt];[sr];[Bt]=!1;[nn]=!1;[us]=!1;[fs]=!1;[Xr]=null;[Be]=0;[ve]=!1;[ei];[ps]=!1;[An]=0;[Xe]=!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");Vg(e)?(this[qe]=!0,this[ft]=null):Jg(e)?(this[ft]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ft]=null),this[vt]=!!e.async,this[sr]=this[ft]?new Fg(this[ft]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Me]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[We]});let{signal:r}=e;r&&(this[ei]=r,r.aborted?this[Da]():r.addEventListener("abort",()=>this[Da]()))}get bufferLength(){return this[Be]}get encoding(){return this[ft]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[qe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(t){this[vt]=this[vt]||!!t}[Da](){this[ps]=!0,this.emit("abort",this[ei]?.reason),this.destroy(this[ei]?.reason)}get aborted(){return this[ps]}set aborted(t){}write(t,e,r){if(this[ps])return!1;if(this[Bt])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[vt]?ti:qg;if(!this[qe]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Le]&&this[Be]!==0&&this[hs](!0),this[Le]?this.emit("data",t):this[Aa](t),this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le]):t.length?(typeof t=="string"&&!(e===this[ft]&&!this[sr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ft]&&(t=this[sr].write(t)),this[Le]&&this[Be]!==0&&this[hs](!0),this[Le]?this.emit("data",t):this[Aa](t),this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le]):(this[Be]!==0&&this.emit("readable"),r&&i(r),this[Le])}read(t){if(this[ve])return null;if(this[Xe]=!1,this[Be]===0||t===0||t&&t>this[Be])return this[zt](),null;this[qe]&&(t=null),this[Me].length>1&&!this[qe]&&(this[Me]=[this[ft]?this[Me].join(""):Buffer.concat(this[Me],this[Be])]);let e=this[Ql](t||null,this[Me][0]);return this[zt](),e}[Ql](t,e){if(this[qe])this[xs]();else{let r=e;t===r.length||t===null?this[xs]():typeof r=="string"?(this[Me][0]=r.slice(t),e=r.slice(0,t),this[Be]-=t):(this[Me][0]=r.subarray(t),e=r.subarray(0,t),this[Be]-=t)}return this.emit("data",e),!this[Me].length&&!this[Bt]&&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[Bt]=!0,this.writable=!1,(this[Le]||!this[Qr])&&this[zt](),this}[lr](){this[ve]||(!this[An]&&!this[We].length&&(this[Xe]=!0),this[Qr]=!1,this[Le]=!0,this.emit("resume"),this[Me].length?this[hs]():this[Bt]?this[zt]():this.emit("drain"))}resume(){return this[lr]()}pause(){this[Le]=!1,this[Qr]=!0,this[Xe]=!1}get destroyed(){return this[ve]}get flowing(){return this[Le]}get paused(){return this[Qr]}[Aa](t){this[qe]?this[Be]+=1:this[Be]+=t.length,this[Me].push(t)}[xs](){return this[qe]?this[Be]-=1:this[Be]-=this[Me][0].length,this[Me].shift()}[hs](t=!1){do;while(this[eu](this[xs]())&&this[Me].length);!t&&!this[Me].length&&!this[Bt]&&this.emit("drain")}[eu](t){return this.emit("data",t),this[Le]}pipe(t,e){if(this[ve])return t;this[Xe]=!1;let r=this[nn];return e=e||{},t===Xl.stdout||t===Xl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[We].push(e.proxyErrors?new $g(this,t,e):new Pu(this,t,e)),this[vt]?ti(()=>this[lr]()):this[lr]()),t}unpipe(t){let e=this[We].find(r=>r.dest===t);e&&(this[We].length===1?(this[Le]&&this[An]===0&&(this[Le]=!1),this[We]=[]):this[We].splice(this[We].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[Xe]=!1,this[An]++,!this[We].length&&!this[Le]&&this[lr]();else if(t==="readable"&&this[Be]!==0)super.emit("readable");else if(jg(t)&&this[nn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Xr]){let i=e;this[vt]?ti(()=>i.call(this,this[Xr])):i.call(this,this[Xr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[An]=this.listeners("data").length,this[An]===0&&!this[Xe]&&!this[We].length&&(this[Le]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[An]=0,!this[Xe]&&!this[We].length&&(this[Le]=!1)),e}get emittedEnd(){return this[nn]}[zt](){!this[us]&&!this[nn]&&!this[ve]&&this[Me].length===0&&this[Bt]&&(this[us]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[fs]&&this.emit("close"),this[us]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ve&&this[ve])return!1;if(t==="data")return!this[qe]&&!r?!1:this[vt]?(ti(()=>this[Ra](r)),!0):this[Ra](r);if(t==="end")return this[tu]();if(t==="close"){if(this[fs]=!0,!this[nn]&&!this[ve])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Xr]=r,super.emit(Ta,r);let o=!this[ei]||this.listeners("error").length?super.emit("error",r):!1;return this[zt](),o}else if(t==="resume"){let o=super.emit("resume");return this[zt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[zt](),i}[Ra](t){for(let r of this[We])r.dest.write(t)===!1&&this.pause();let e=this[Xe]?!1:super.emit("data",t);return this[zt](),e}[tu](){return this[nn]?!1:(this[nn]=!0,this.readable=!1,this[vt]?(ti(()=>this[Ca]()),!0):this[Ca]())}[Ca](){if(this[sr]){let e=this[sr].end();if(e){for(let r of this[We])r.dest.write(e);this[Xe]||super.emit("data",e)}}for(let e of this[We])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ft]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ve,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Xe]=!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[Bt])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[Bt]})},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,_)=>{o=_,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[Xe]=!1;let t=!1,e=()=>(this.pause(),this.off(Ta,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(Ta,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[Xe]=!0,this[Me].length=0,this[Be]=0;let e=this;return typeof e.close=="function"&&!this[fs]&&e.close(),t?this.emit("error",t):this.emit(ve),this}static get isStream(){return Ug}},Zg=Ze.writev,hn=Symbol("_autoClose"),gt=Symbol("_close"),ni=Symbol("_ended"),oe=Symbol("_fd"),ka=Symbol("_finished"),Ht=Symbol("_flags"),Oa=Symbol("_flush"),Xa=Symbol("_handleChunk"),Qa=Symbol("_makeBuf"),hi=Symbol("_mode"),gs=Symbol("_needDrain"),pr=Symbol("_onerror"),gr=Symbol("_onopen"),Pa=Symbol("_onread"),ur=Symbol("_onwrite"),xn=Symbol("_open"),pt=Symbol("_path"),cn=Symbol("_pos"),St=Symbol("_queue"),fr=Symbol("_read"),Na=Symbol("_readSize"),Gt=Symbol("_reading"),ri=Symbol("_remain"),La=Symbol("_size"),As=Symbol("_write"),Tn=Symbol("_writing"),Ts=Symbol("_defaultFlag"),Nn=Symbol("_errored"),yc=class extends zn{[Nn]=!1;[oe];[pt];[Na];[Gt]=!1;[La];[ri];[hn];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[Nn]=!1,this[oe]=typeof e.fd=="number"?e.fd:void 0,this[pt]=t,this[Na]=e.readSize||16*1024*1024,this[Gt]=!1,this[La]=typeof e.size=="number"?e.size:1/0,this[ri]=this[La],this[hn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[oe]=="number"?this[fr]():this[xn]()}get fd(){return this[oe]}get path(){return this[pt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[xn](){Ze.open(this[pt],"r",(t,e)=>this[gr](t,e))}[gr](t,e){t?this[pr](t):(this[oe]=e,this.emit("open",e),this[fr]())}[Qa](){return Buffer.allocUnsafe(Math.min(this[Na],this[ri]))}[fr](){if(!this[Gt]){this[Gt]=!0;let t=this[Qa]();if(t.length===0)return process.nextTick(()=>this[Pa](null,0,t));Ze.read(this[oe],t,0,t.length,null,(e,r,i)=>this[Pa](e,r,i))}}[Pa](t,e,r){this[Gt]=!1,t?this[pr](t):this[Xa](e,r)&&this[fr]()}[gt](){if(this[hn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,Ze.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[pr](t){this[Gt]=!0,this[gt](),this.emit("error",t)}[Xa](t,e){let r=!1;return this[ri]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ri]<=0)&&(r=!1,this[gt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[oe]=="number"&&this[fr](),!1;case"error":return this[Nn]?!1:(this[Nn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Yg=class extends yc{[xn](){let t=!0;try{this[gr](null,Ze.openSync(this[pt],"r")),t=!1}finally{t&&this[gt]()}}[fr](){let t=!0;try{if(!this[Gt]){this[Gt]=!0;do{let e=this[Qa](),r=e.length===0?0:Ze.readSync(this[oe],e,0,e.length,null);if(!this[Xa](r,e))break}while(!0);this[Gt]=!1}t=!1}finally{t&&this[gt]()}}[gt](){if(this[hn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,Ze.closeSync(t),this.emit("close")}}},Hs=class extends zg{readable=!1;writable=!0;[Nn]=!1;[Tn]=!1;[ni]=!1;[St]=[];[gs]=!1;[pt];[hi];[hn];[oe];[Ts];[Ht];[ka]=!1;[cn];constructor(t,e){e=e||{},super(e),this[pt]=t,this[oe]=typeof e.fd=="number"?e.fd:void 0,this[hi]=e.mode===void 0?438:e.mode,this[cn]=typeof e.start=="number"?e.start:void 0,this[hn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[cn]!==void 0?"r+":"w";this[Ts]=e.flags===void 0,this[Ht]=e.flags===void 0?r:e.flags,this[oe]===void 0&&this[xn]()}emit(t,...e){if(t==="error"){if(this[Nn])return!1;this[Nn]=!0}return super.emit(t,...e)}get fd(){return this[oe]}get path(){return this[pt]}[pr](t){this[gt](),this[Tn]=!0,this.emit("error",t)}[xn](){Ze.open(this[pt],this[Ht],this[hi],(t,e)=>this[gr](t,e))}[gr](t,e){this[Ts]&&this[Ht]==="r+"&&t&&t.code==="ENOENT"?(this[Ht]="w",this[xn]()):t?this[pr](t):(this[oe]=e,this.emit("open",e),this[Tn]||this[Oa]())}end(t,e){return t&&this.write(t,e),this[ni]=!0,!this[Tn]&&!this[St].length&&typeof this[oe]=="number"&&this[ur](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ni]?(this.emit("error",new Error("write() after end()")),!1):this[oe]===void 0||this[Tn]||this[St].length?(this[St].push(t),this[gs]=!0,!1):(this[Tn]=!0,this[As](t),!0)}[As](t){Ze.write(this[oe],t,0,t.length,this[cn],(e,r)=>this[ur](e,r))}[ur](t,e){t?this[pr](t):(this[cn]!==void 0&&typeof e=="number"&&(this[cn]+=e),this[St].length?this[Oa]():(this[Tn]=!1,this[ni]&&!this[ka]?(this[ka]=!0,this[gt](),this.emit("finish")):this[gs]&&(this[gs]=!1,this.emit("drain"))))}[Oa](){if(this[St].length===0)this[ni]&&this[ur](null,0);else if(this[St].length===1)this[As](this[St].pop());else{let t=this[St];this[St]=[],Zg(this[oe],t,this[cn],(e,r)=>this[ur](e,r))}}[gt](){if(this[hn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,Ze.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Nu=class extends Hs{[xn](){let t;if(this[Ts]&&this[Ht]==="r+")try{t=Ze.openSync(this[pt],this[Ht],this[hi])}catch(e){if(e?.code==="ENOENT")return this[Ht]="w",this[xn]();throw e}else t=Ze.openSync(this[pt],this[Ht],this[hi]);this[gr](null,t)}[gt](){if(this[hn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,Ze.closeSync(t),this.emit("close")}}[As](t){let e=!0;try{this[ur](null,Ze.writeSync(this[oe],t,0,t.length,this[cn])),e=!1}finally{if(e)try{this[gt]()}catch{}}}},em=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,Ec=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},bi=(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=Ec(c);if(o?.(h,l),tm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(nm(h)){let x=e(h,l);return u?x.then(()=>u(),u):x}else if(rm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(im(h)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(h,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),dm=cm.constants||{ZLIB_VERNUM:4736},Rt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},dm)),lm=Ln.concat,ru=Object.getOwnPropertyDescriptor(Ln,"concat"),um=t=>t,Ma=ru?.writable===!0||ru?.set!==void 0?t=>{Ln.concat=t?um:lm}:t=>{},Mn=Symbol("_superWrite"),ms=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"}},Ba=Symbol("flushFlag"),bc=class extends zn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof nu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new nu[e](t)}catch(r){throw new ms(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 ms(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ec(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Ln.alloc(0),{[Ba]: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}[Mn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Ln.from(t,e)),this.#e)return;ec(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ma(!0);let l;try{let h=typeof t[Ba]=="number"?t[Ba]:this.#r;l=this.#t._processChunk(t,h),Ma(!1)}catch(h){Ma(!1),this.#o(new ms(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 ms(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[Mn](Ln.from(h));for(let x=1;x<l.length;x++)u=this[Mn](l[x])}else u=this[Mn](Ln.from(l));return r&&r(),u}},Mu=class extends bc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Rt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Rt.Z_FINISH,t.fullFlushFlag=Rt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Rt.Z_SYNC_FLUSH),ec(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},fm=class extends Mu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Mn](t){return this.#e?(this.#e=!1,t[9]=255,super[Mn](t)):super[Mn](t)}},hm=class extends Mu{constructor(t){super(t,"Unzip")}},Bu=class extends bc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Rt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Rt.BROTLI_OPERATION_FLUSH,super(t,e)}},xm=class extends Bu{constructor(t){super(t,"BrotliCompress")}},pm=class extends Bu{constructor(t){super(t,"BrotliDecompress")}},zu=class extends bc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Rt.ZSTD_e_end,t.fullFlushFlag=Rt.ZSTD_e_flush,super(t,e)}},gm=class extends zu{constructor(t){super(t,"ZstdCompress")}},mm=class extends zu{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Fu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Uu(o))}},Em=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?bm(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},bm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Fu(c):c===0?l=c:(i=!0,l=Uu(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Fu=t=>(255^t)&255,Uu=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>vc,isCode:()=>Rs,isName:()=>Im,name:()=>qs});var Rs=t=>qs.has(t),Im=t=>vc.has(t),qs=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"]]),vc=new Map(Array.from(qs).map(t=>[t[1],t[0]])),Bn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Rn(t,e,100),this.mode=r?.mode??i?.mode??dn(t,e+100,8),this.uid=r?.uid??i?.uid??dn(t,e+108,8),this.gid=r?.gid??i?.gid??dn(t,e+116,8),this.size=r?.size??i?.size??dn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??za(t,e+136,12),this.cksum=dn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Rn(t,e+156,1);if(Rs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Rn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Rn(t,e+265,32),this.gname=r?.gname??i?.gname??Rn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??dn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??dn(t,e+337,8)??0,t[e+475]!==0){let l=Rn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Rn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??za(t,e+476,12),this.ctime=r?.ctime??i?.ctime??za(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Am(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Cn(t,e,100,o)||this.needPax,this.needPax=ln(t,e+100,8,this.mode)||this.needPax,this.needPax=ln(t,e+108,8,this.uid)||this.needPax,this.needPax=ln(t,e+116,8,this.gid)||this.needPax,this.needPax=ln(t,e+124,12,this.size)||this.needPax,this.needPax=Fa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Cn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Cn(t,e+265,32,this.uname)||this.needPax,this.needPax=Cn(t,e+297,32,this.gname)||this.needPax,this.needPax=ln(t,e+329,8,this.devmaj)||this.needPax,this.needPax=ln(t,e+337,8,this.devmin)||this.needPax,this.needPax=Cn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Cn(t,e+345,155,c)||this.needPax:(this.needPax=Cn(t,e+345,130,c)||this.needPax,this.needPax=Fa(t,e+476,12,this.atime)||this.needPax,this.needPax=Fa(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,ln(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:qs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(vc.get(t));if(Rs(e)||e==="Unsupported")this.#e=e;else if(Rs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Am=(t,e)=>{let r=t,i="",o,c=or.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=or.dirname(r),r=or.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=or.join(or.basename(i),r),i=or.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Rn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),za=(t,e,r)=>Tm(dn(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),dn=(t,e,r)=>Number(t[e])&128?Em(t.subarray(e,e+r)):Cm(t,e,r),Rm=t=>isNaN(t)?void 0:t,Cm=(t,e,r)=>Rm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Dm={12:8589934591,8:2097151},ln=(t,e,r,i)=>i===void 0?!1:i>Dm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Om(i,r),e,r,"ascii"),Om=(t,e)=>Pm(Math.floor(t).toString(8),e),Pm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Fa=(t,e,r,i)=>i===void 0?!1:ln(t,e,r,i.getTime()/1e3),Nm=new Array(156).join("\0"),Cn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Nm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Bs=class Gu{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 Bn({path:("PaxHeader/"+Lm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new
|
|
91
|
-
`).reduce(zm,Object.create(null)),zm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Fm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Hu=class extends zn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},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))},Um=1024*1024,tc=Buffer.from([31,139]),nc=Buffer.from([40,181,47,253]),Gm=Math.max(tc.length,nc.length),it=Symbol("state"),Dn=Symbol("writeEntry"),Ft=Symbol("readEntry"),Ua=Symbol("nextEntry"),iu=Symbol("processEntry"),It=Symbol("extendedHeader"),ii=Symbol("globalExtendedHeader"),rn=Symbol("meta"),su=Symbol("emitMeta"),ue=Symbol("buffer"),Ut=Symbol("queue"),sn=Symbol("ended"),Ga=Symbol("emittedEnd"),kn=Symbol("emit"),Ae=Symbol("unzip"),ws=Symbol("consumeChunk"),_s=Symbol("consumeChunkSub"),Ha=Symbol("consumeBody"),ou=Symbol("consumeMeta"),au=Symbol("consumeHeader"),si=Symbol("consuming"),qa=Symbol("bufferConcat"),ys=Symbol("maybeEnd"),ar=Symbol("writing"),on=Symbol("aborted"),Es=Symbol("onDone"),On=Symbol("sawValidEntry"),bs=Symbol("sawNullBlock"),vs=Symbol("sawEOF"),cu=Symbol("closeStream"),Hm=()=>!0,Ei=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ut]=[];[ue];[Ft];[Dn];[it]="begin";[rn]="";[It];[ii];[sn]=!1;[Ae];[on]=!1;[On];[bs]=!1;[vs]=!1;[ar]=!1;[si]=!1;[Ga]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Es,()=>{(this[it]==="begin"||this[On]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Es,t.ondone):this.on(Es,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:Hm;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[cu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){js(this,t,e,r)}[au](t,e){this[On]===void 0&&(this[On]=!1);let r;try{r=new Bn(t,e,this[It],this[ii])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[bs]?(this[vs]=!0,this[it]==="begin"&&(this[it]="header"),this[kn]("eof")):(this[bs]=!0,this[kn]("nullBlock"));else if(this[bs]=!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[Dn]=new Hu(r,this[It],this[ii]);if(!this[On])if(o.remain){let c=()=>{o.invalid||(this[On]=!0)};o.on("end",c)}else this[On]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[kn]("ignoredEntry",o),this[it]="ignore",o.resume()):o.size>0&&(this[rn]="",o.on("data",c=>this[rn]+=c),this[it]="meta"):(this[It]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[kn]("ignoredEntry",o),this[it]=o.remain?"ignore":"header",o.resume()):(o.remain?this[it]="body":(this[it]="header",o.end()),this[Ft]?this[Ut].push(o):(this[Ut].push(o),this[Ua]())))}}}[cu](){queueMicrotask(()=>this.emit("close"))}[iu](t){let e=!0;if(!t)this[Ft]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ft]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ua]()),e=!1);return e}[Ua](){do;while(this[iu](this[Ut].shift()));if(this[Ut].length===0){let t=this[Ft];!t||t.flowing||t.size===t.remain?this[ar]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ha](t,e){let r=this[Dn];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[it]="header",this[Dn]=void 0,r.end()),o.length}[ou](t,e){let r=this[Dn],i=this[Ha](t,e);return!this[Dn]&&r&&this[su](r),i}[kn](t,e,r){this[Ut].length===0&&!this[Ft]?this.emit(t,e,r):this[Ut].push([t,e,r])}[su](t){switch(this[kn]("meta",this[rn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[It]=Bs.parse(this[rn],this[It],!1);break;case"GlobalExtendedHeader":this[ii]=Bs.parse(this[rn],this[ii],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[It]??Object.create(null);this[It]=e,e.path=this[rn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[It]||Object.create(null);this[It]=e,e.linkpath=this[rn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[on]=!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[on])return r?.(),!1;if((this[Ae]===void 0||this.brotli===void 0&&this[Ae]===!1)&&t){if(this[ue]&&(t=Buffer.concat([this[ue],t]),this[ue]=void 0),t.length<Gm)return this[ue]=t,r?.(),!0;for(let l=0;this[Ae]===void 0&&l<tc.length;l++)t[l]!==tc[l]&&(this[Ae]=!1);let o=!1;if(this[Ae]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<nc.length;l++)if(t[l]!==nc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ae]===!1&&c)if(t.length<512)if(this[sn])this.brotli=!0;else return this[ue]=t,r?.(),!0;else try{new Bn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ae]===void 0||this[Ae]===!1&&(this.brotli||o)){let l=this[sn];this[sn]=!1,this[Ae]=this[Ae]===void 0?new hm({}):o?new mm({}):new pm({}),this[Ae].on("data",h=>this[ws](h)),this[Ae].on("error",h=>this.abort(h)),this[Ae].on("end",()=>{this[sn]=!0,this[ws]()}),this[ar]=!0;let u=!!this[Ae][l?"end":"write"](t);return this[ar]=!1,r?.(),u}}this[ar]=!0,this[Ae]?this[Ae].write(t):this[ws](t),this[ar]=!1;let i=this[Ut].length>0?!1:this[Ft]?this[Ft].flowing:!0;return!i&&this[Ut].length===0&&this[Ft]?.once("drain",()=>this.emit("drain")),r?.(),i}[qa](t){t&&!this[on]&&(this[ue]=this[ue]?Buffer.concat([this[ue],t]):t)}[ys](){if(this[sn]&&!this[Ga]&&!this[on]&&!this[si]){this[Ga]=!0;let t=this[Dn];if(t&&t.blockRemain){let e=this[ue]?this[ue].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ue]&&t.write(this[ue]),t.end()}this[kn](Es)}}[ws](t){if(this[si]&&t)this[qa](t);else if(!t&&!this[ue])this[ys]();else if(t){if(this[si]=!0,this[ue]){this[qa](t);let e=this[ue];this[ue]=void 0,this[_s](e)}else this[_s](t);for(;this[ue]&&this[ue]?.length>=512&&!this[on]&&!this[vs];){let e=this[ue];this[ue]=void 0,this[_s](e)}this[si]=!1}(!this[ue]||this[sn])&&this[ys]()}[_s](t){let e=0,r=t.length;for(;e+512<=r&&!this[on]&&!this[vs];)switch(this[it]){case"begin":case"header":this[au](t,e),e+=512;break;case"ignore":case"body":e+=this[Ha](t,e);break;case"meta":e+=this[ou](t,e);break;default:throw new Error("invalid state: "+this[it])}e<r&&(this[ue]=this[ue]?Buffer.concat([t.subarray(e),this[ue]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[on]||(this[Ae]?(t&&this[Ae].write(t),this[Ae].end()):(this[sn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[ys]())),this}},xi=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},qm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},qu=(t,e)=>{let r=new Map(e.map(c=>[xi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Qg(c).root||".",h;if(c===u)h=!1;else{let x=r.get(c);h=x!==void 0?x:o(Xg(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(xi(c)):c=>o(xi(c))},jm=t=>{let e=new Ei(t),r=t.file,i;try{i=hr.openSync(r,"r");let o=hr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=hr.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=hr.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{hr.closeSync(i)}catch{}}},Wm=(t,e)=>{let r=new Ei(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),hr.stat(o,(u,h)=>{if(u)l(u);else{let x=new yc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},mr=bi(jm,Wm,t=>new Ei(t),t=>new Ei(t),(t,e)=>{e?.length&&qu(t,e),t.noResume||qm(t)}),ju=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:$m,parse:lu}=Km,Sc=t=>{let e="",r=lu(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=lu(t)}return[e,t]},Ws=["|","<",">","?",":"],Ic=Ws.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Vm=new Map(Ws.map((t,e)=>[t,Ic[e]])),Jm=new Map(Ic.map((t,e)=>[t,Ws[e]])),uu=t=>Ws.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),Zm=t=>Ic.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),Wu=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),xi(e)+"/"+t):Z(t),Ym=16*1024*1024,fu=Symbol("process"),hu=Symbol("file"),xu=Symbol("directory"),rc=Symbol("symlink"),pu=Symbol("hardlink"),oi=Symbol("header"),Cs=Symbol("read"),ic=Symbol("lstat"),Ds=Symbol("onlstat"),sc=Symbol("onread"),oc=Symbol("onreadlink"),ac=Symbol("openfile"),cc=Symbol("onopenfile"),un=Symbol("close"),Fs=Symbol("mode"),dc=Symbol("awaitDrain"),ja=Symbol("ondrain"),Tt=Symbol("prefix"),Ku=class extends zn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Ec(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Ym,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Sc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Zm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||du.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ds](o):this[ic]()}warn(t,e,r={}){return js(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[ic](){At.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ds](e)})}[Ds](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[fu]()}[fu](){switch(this.type){case"File":return this[hu]();case"Directory":return this[xu]();case"SymbolicLink":return this[rc]();default:return this.end()}}[Fs](t){return ju(t,this.type==="Directory",this.portable)}[Tt](t){return Wu(t,this.prefix)}[oi](){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 Bn({path:this[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](this.linkpath):this.linkpath,mode:this[Fs](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 Bs({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[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[xu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[oi](),this.end()}[rc](){At.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[oc](e)})}[oc](t){this.linkpath=Z(t),this[oi](),this.end()}[pu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(du.relative(this.cwd,t)),this.stat.size=0,this[oi](),this.end()}[hu](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[pu](e);this.linkCache.set(t,this.absolute)}if(this[oi](),this.stat.size===0)return this.end();this[ac]()}[ac](){At.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[cc](e)})}[cc](t){if(this.fd=t,this.#e)return this[un]();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[Cs]()}[Cs](){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");At.read(t,e,r,i,o,(c,l)=>{if(c)return this[un](()=>this.emit("error",c));this[sc](l)})}[un](t=()=>{}){this.fd!==void 0&&At.close(this.fd,t)}[sc](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[un](()=>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[un](()=>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[ja]():this[dc](()=>this[ja]())}[dc](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)}[ja](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[un](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[Cs]()}},Xm=class extends Ku{sync=!0;[ic](){this[Ds](At.lstatSync(this.absolute))}[rc](){this[oc](At.readlinkSync(this.absolute))}[ac](){this[cc](At.openSync(this.absolute,"r"))}[Cs](){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=At.readSync(e,r,i,o,c);this[sc](l),t=!1}finally{if(t)try{this[un](()=>{})}catch{}}}[dc](t){t()}[un](t=()=>{}){this.fd!==void 0&&At.closeSync(this.fd),t()}},Qm=class extends zn{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=Ec(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Fs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Sc(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 Bn({path:this[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](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 Bs({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[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](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)}[Tt](t){return Wu(t,this.prefix)}[Fs](t){return ju(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=class xr{tail;head;length=0;static create(e=[]){return new xr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new xr;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 xr;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 xr;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 xr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=nw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Ac(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Ac(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Ac(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Ac=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},mu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},wu=Buffer.alloc(1024),ks=Symbol("onStat"),ai=Symbol("ended"),ht=Symbol("queue"),ci=Symbol("queue"),an=Symbol("current"),Pn=Symbol("process"),di=Symbol("processing"),Ss=Symbol("processJob"),xt=Symbol("jobs"),Wa=Symbol("jobDone"),Os=Symbol("addFSEntry"),_u=Symbol("addTarEntry"),lc=Symbol("stat"),uc=Symbol("readdir"),Ps=Symbol("onreaddir"),Ns=Symbol("pipe"),yu=Symbol("entry"),Ka=Symbol("entryOpt"),Ls=Symbol("writeEntryClass"),$u=Symbol("write"),$a=Symbol("ondrain"),Ks=class extends zn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ls];onWriteEntry;[ht];[ci]=new Map;[xt]=0;[di]=!1;[ai]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ls]=Ku,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new fm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new xm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[$a]()),this.on("resume",()=>e.resume())}else this.on("drain",this[$a]);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[ht]=new tw,this[xt]=0,this.jobs=Number(t.jobs)||4,this[di]=!1,this[ai]=!1}[$u](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[ai]=!0,this[Pn](),r&&r(),this}write(t){if(this[ai])throw new Error("write after end");return t instanceof Hu?this[_u](t):this[Os](t),this.flowing}[_u](t){let e=Z(gu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new mu(t.path,e);r.entry=new Qm(t,this[Ka](r)),r.entry.on("end",()=>this[Wa](r)),this[xt]+=1,this[ht].push(r)}this[Pn]()}[Os](t){let e=Z(gu.resolve(this.cwd,t));this[ht].push(new mu(t,e)),this[Pn]()}[lc](t){t.pending=!0,this[xt]+=1;let e=this.follow?"stat":"lstat";zs[e](t.absolute,(r,i)=>{t.pending=!1,this[xt]-=1,r?this.emit("error",r):this[ks](t,i)})}[ks](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[an])this[Ss](t);else{let r=`${e.dev}:${e.ino}`,i=this[ci].get(r);i?i.push(t):this[ci].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Pn]()}[uc](t){t.pending=!0,this[xt]+=1,zs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[xt]-=1,e)return this.emit("error",e);this[Ps](t,r)})}[Ps](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Pn]()}[Pn](){if(!this[di]){this[di]=!0;for(let t=this[ht].head;t&&this[xt]<this.jobs;t=t.next)if(this[Ss](t.value),t.value.ignore){let e=t.next;this[ht].removeNode(t),t.next=e}this[di]=!1,this[ai]&&this[ht].length===0&&this[xt]===0&&(this.zip?this.zip.end(wu):(super.write(wu),super.end()))}}get[an](){return this[ht]&&this[ht].head&&this[ht].head.value}[Wa](t){this[ht].shift(),this[xt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[ci].get(r);if(i){this[ci].delete(r);for(let o of i)o.pending=!1,this[Ss](o)}}this[Pn]()}[Ss](t){if(t.pending&&t.pendingLink&&t===this[an]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[an]&&!t.piped&&this[Ns](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ks](t,e):this[lc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ps](t,e):this[uc](t),!t.readdir)return}if(t.entry=this[yu](t),!t.entry){t.ignore=!0;return}t===this[an]&&!t.piped&&this[Ns](t)}}}[Ka](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[yu](t){this[xt]+=1;try{return new this[Ls](t.path,this[Ka](t)).on("end",()=>this[Wa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[$a](){this[an]&&this[an].entry&&this[an].entry.resume()}[Ns](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Os](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){js(this,t,e,r)}},Tc=class extends Ks{sync=!0;constructor(t){super(t),this[Ls]=Xm}pause(){}resume(){}[lc](t){let e=this.follow?"statSync":"lstatSync";this[ks](t,zs[e](t.absolute))}[uc](t){this[Ps](t,zs.readdirSync(t.absolute))}[Ns](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Os](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[$u](i)})}},sw=(t,e)=>{let r=new Tc(t),i=new Nu(t.file,{mode:t.mode||438});r.pipe(i),Vu(r,e)},ow=(t,e)=>{let r=new Ks(t),i=new Hs(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return Ju(r,e).catch(c=>r.emit("error",c)),o},Vu=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?mr({file:Lu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Ju=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await mr({file:Lu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new Tc(t);return Vu(r,e),r},cw=(t,e)=>{let r=new Ks(t);return Ju(r,e).catch(i=>r.emit("error",i)),r},g2=bi(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,Qu=lw==="win32",{O_CREAT:ef,O_NOFOLLOW:Eu,O_TRUNC:tf,O_WRONLY:nf}=Xu.constants,rf=Number(process.env.__FAKE_FS_O_FILENAME__)||Xu.constants.UV_FS_O_FILEMAP||0,uw=Qu&&!!rf,fw=512*1024,hw=rf|tf|ef|nf,bu=!Qu&&typeof Eu=="number"?Eu|tf|ef|nf:null,sf=bu!==null?()=>bu:uw?t=>t<fw?hw:"w":()=>"w",fc=(t,e,r)=>{try{return $s.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Us=(t,e,r,i)=>{$s.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},xw=(t,e,r,i,o)=>{if(e.isDirectory())of(pi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=pi.resolve(t,e.name);Us(l,r,i,o)});else{let c=pi.resolve(t,e.name);Us(c,r,i,o)}},of=(t,e,r,i)=>{$s.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 Us(t,e,r,i);let l=c.length,u=null,h=x=>{if(!u){if(x)return i(u=x);if(--l===0)return Us(t,e,r,i)}};for(let x of c)xw(t,x,e,r,h)})},pw=(t,e,r,i)=>{e.isDirectory()&&af(pi.resolve(t,e.name),r,i),fc(pi.resolve(t,e.name),r,i)},af=(t,e,r)=>{let i;try{i=$s.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return fc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return fc(t,e,r)},cf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Vs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{et.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new cf(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=Z(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,_=e.unlink,m=Z(e.cwd),A=(v,I)=>{v?r(v):I&&h?of(I,l,u,S=>A(S)):c?et.chmod(t,o,r):r()};if(t===m)return mw(t,A);if(x)return gw.mkdir(t,{mode:o,recursive:!0}).then(v=>A(null,v??void 0),A);let y=Z(Gs.relative(m,t)).split("/");hc(m,y,o,_,m,void 0,A)},hc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=Z(Gs.resolve(t+"/"+u));et.mkdir(h,r,df(h,e,r,i,o,c,l))},df=(t,e,r,i,o,c,l)=>u=>{u?et.lstat(t,(h,x)=>{if(h)h.path=h.path&&Z(h.path),l(h);else if(x.isDirectory())hc(t,e,r,i,o,c,l);else if(i)et.unlink(t,_=>{if(_)return l(_);et.mkdir(t,r,df(t,e,r,i,o,c,l))});else{if(x.isSymbolicLink())return l(new Vs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,hc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=et.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new cf(t,r??"ENOTDIR")}},yw=(t,e)=>{t=Z(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,_=Z(e.cwd),m=v=>{v&&u&&af(v,c,l),o&&et.chmodSync(t,i)};if(t===_)return _w(_),m();if(h)return m(et.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=Z(Gs.relative(_,t)).split("/"),y;for(let v=A.shift(),I=_;v&&(I+="/"+v);v=A.shift()){I=Z(Gs.resolve(I));try{et.mkdirSync(I,i),y=y||I}catch{let S=et.lstatSync(I);if(S.isDirectory())continue;if(x){et.unlinkSync(I),et.mkdirSync(I,i),y=y||I;continue}else if(S.isSymbolicLink())return new Vs(I,I+"/"+A.join("/"))}}return m(y)},Va=Object.create(null),vu=1e4,cr=new Set,Ew=t=>{cr.has(t)?cr.delete(t):Va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),cr.add(t);let e=Va[t],r=cr.size-vu;if(r>vu/10){for(let i of cr)if(cr.delete(i),delete Va[i],--r<=0)break}return e},bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=bw==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=lf(i,r)),e.push(r||"/"),e},[]),Iw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>xi(lf(Ew(i))));let r=new Set(t.map(i=>Sw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let h of u)o.add(h)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Aw=()=>process.umask(),Su=Symbol("onEntry"),xc=Symbol("checkFs"),Iu=Symbol("checkFs2"),pc=Symbol("isReusable"),st=Symbol("makeFs"),gc=Symbol("file"),mc=Symbol("directory"),Ms=Symbol("link"),Au=Symbol("symlink"),Tu=Symbol("hardlink"),fi=Symbol("ensureNoSymlink"),Ru=Symbol("unsupported"),Cu=Symbol("checkPath"),Ja=Symbol("stripAbsolutePath"),fn=Symbol("mkdir"),ze=Symbol("onError"),Is=Symbol("pending"),Du=Symbol("pend"),dr=Symbol("unpend"),Za=Symbol("ended"),Ya=Symbol("maybeClose"),wc=Symbol("skip"),gi=Symbol("doChown"),mi=Symbol("uid"),wi=Symbol("gid"),_i=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,yi=Tw==="win32",Rw=1024,Cw=(t,e)=>{if(!yi)return ne.unlink(t,e);let r=t+".DELETE."+Yu(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},Dw=t=>{if(!yi)return ne.unlinkSync(t);let e=t+".DELETE."+Yu(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},ku=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Rc=class extends Ei{[Za]=!1;[_i]=!1;[Is]=0;reservations=new Iw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Za]=!0,this[Ya]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Rw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||yi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Oe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Aw():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Su](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ya](){this[Za]&&this[Is]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ja](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Sc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||yi&&/^[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}[Cu](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ja](t,"path")||!this[Ja](t,"linkpath"))return!1;if(t.absolute=Oe.isAbsolute(t.path)?Z(Oe.resolve(t.path)):Z(Oe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Oe.win32.parse(String(t.absolute));t.absolute=i+uu(String(t.absolute).slice(i.length));let{root:o}=Oe.win32.parse(t.path);t.path=o+uu(t.path.slice(o.length))}return!0}[Su](t){if(!this[Cu](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[xc](t);default:return this[Ru](t)}}[ze](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[dr](),e.resume())}[fn](t,e,r){ww(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[gi](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}[mi](t){return ku(this.uid,t.uid,this.processUid)}[wi](t){return ku(this.gid,t.gid,this.processGid)}[gc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Hs(String(t.absolute),{flags:sf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[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[dr](),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,_=t.mtime;ne.futimes(h,x,_,m=>m?ne.utimes(u,x,_,A=>c(A&&m)):c())}if(typeof h=="number"&&this[gi](t)){o++;let x=this[mi](t),_=this[wi](t);typeof x=="number"&&typeof _=="number"&&ne.fchown(h,x,_,m=>m?ne.chown(u,x,_,A=>c(A&&m)):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)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[fn](String(t.absolute),r,i=>{if(i){this[ze](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[dr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[gi](t)&&(o++,ne.chown(String(t.absolute),Number(this[mi](t)),Number(this[wi](t)),c)),c()})}[Ru](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Au](t,e){let r=Z(Oe.relative(this.cwd,Oe.resolve(Oe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[fi](t,this.cwd,r,()=>this[Ms](t,String(t.linkpath),"symlink",e),i=>{this[ze](i,t),e()})}[Tu](t,e){let r=Z(Oe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[fi](t,this.cwd,i,()=>this[Ms](t,r,"link",e),o=>{this[ze](o,t),e()})}[fi](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 Vs(l,Oe.resolve(l,r.join("/"))));this[fi](t,l,r,i,o)})}[Du](){this[Is]++}[dr](){this[Is]--,this[Ya]()}[wc](t){this[dr](),t.resume()}[pc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!yi}[xc](t){this[Du]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Iu](t,r))}[Iu](t,e){let r=l=>{e(l)},i=()=>{this[fn](this.cwd,this.dmode,l=>{if(l){this[ze](l,t),r();return}this[_i]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Oe.dirname(String(t.absolute)));if(l!==this.cwd)return this[fn](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[wc](t),r();return}if(l||this[pc](t,u))return this[st](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=_=>this[st](_??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[st](h??null,t,r))}if(t.absolute===this.cwd)return this[st](null,t,r);Cw(String(t.absolute),h=>this[st](h??null,t,r))})};this[_i]?o():i()}[st](t,e,r){if(t){this[ze](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[gc](e,r);case"Link":return this[Tu](e,r);case"SymbolicLink":return this[Au](e,r);case"Directory":case"GNUDumpDir":return this[mc](e,r)}}[Ms](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[ze](o,t):(this[dr](),t.resume()),i()})}},li=t=>{try{return[null,t()]}catch(e){return[e,null]}},uf=class extends Rc{sync=!0;[st](t,e){return super[st](t,e,()=>{})}[xc](t){if(!this[_i]){let o=this[fn](this.cwd,this.dmode);if(o)return this[ze](o,t);this[_i]=!0}if(t.absolute!==this.cwd){let o=Z(Oe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[fn](o,this.dmode);if(c)return this[ze](c,t)}}let[e,r]=li(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[wc](t);if(e||this[pc](t,r))return this[st](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?li(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[st](l,t)}let[o]=li(()=>ne.rmdirSync(String(t.absolute)));this[st](o,t)}let[i]=t.absolute===this.cwd?[]:li(()=>Dw(String(t.absolute)));this[st](i,t)}[gc](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),sf(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[gi](t)){let u=this[mi](t),h=this[wi](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)})}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[fn](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[gi](t))try{ne.chownSync(String(t.absolute),Number(this[mi](t)),Number(this[wi](t)))}catch{}e(),t.resume()}[fn](t,e){try{return yw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[fi](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]=li(()=>ne.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new Vs(c,Oe.resolve(e,r.join("/"))))}i()}[Ms](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)}}},kw=t=>{let e=new uf(t),r=t.file,i=Zu.statSync(r),o=t.maxReadSize||16*1024*1024;new Yg(r,{readSize:o,size:i.size}).pipe(e)},Ow=(t,e)=>{let r=new Rc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Zu.stat(o,(u,h)=>{if(u)l(u);else{let x=new yc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},ff=bi(kw,Ow,t=>new uf(t),t=>new Rc(t),(t,e)=>{e?.length&&qu(t,e)}),Pw=(t,e)=>{let r=new Tc(t),i=!0,o,c;try{try{o=Qe.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=Qe.openSync(t.file,"w+");else throw h}let l=Qe.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let _=0,m=0;_<512;_+=m){if(m=Qe.readSync(o,u,_,u.length-_,c+_),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!m)break e}let h=new Bn(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,Nw(t,r,c,o,e)}finally{if(i)try{Qe.closeSync(o)}catch{}}},Nw=(t,e,r,i,o)=>{let c=new Nu(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Lw=(t,e)=>{e=Array.from(e);let r=new Ks(t),i=(o,c,l)=>{let u=(A,y)=>{A?Qe.close(o,v=>l(A)):l(null,y)},h=0;if(c===0)return u(null,0);let x=0,_=Buffer.alloc(512),m=(A,y)=>{if(A||y===void 0)return u(A);if(x+=y,x<512&&y)return Qe.read(o,_,x,_.length-x,h+x,m);if(h===0&&_[0]===31&&_[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,h);let v=new Bn(_);if(!v.cksumValid)return u(null,h);let I=512*Math.ceil((v.size??0)/512);if(h+I+512>c||(h+=I+512,h>=c))return u(null,h);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),x=0,Qe.read(o,_,0,512,h,m)};Qe.read(o,_,0,512,h,m)};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+",Qe.open(t.file,l,u);if(h||!x)return c(h);Qe.fstat(x,(_,m)=>{if(_)return Qe.close(x,()=>c(_));i(x,m.size,(A,y)=>{if(A)return c(A);let v=new Hs(t.file,{fd:x,start:y});r.pipe(v),v.on("error",c),v.on("close",o),Bw(r,e)})})};Qe.open(t.file,l,u)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?mr({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await mr({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},ui=bi(Pw,Lw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!sm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),k2=bi(ui.syncFile,ui.asyncFile,ui.syncNoFile,ui.asyncNoFile,(t,e=[])=>{ui.validate?.(t,e),zw(t)}),zw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};en();var mt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function vi(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function xf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Cc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function pf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function wr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}je();te();De();je();function qt(t,e){if(vi(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Js(t){return t.startsWith("http://")||t.startsWith("https://")}function Zs(t){return t.endsWith("/")?t.slice(0,-1):t}je();te();var Ys="1008033",gf="1289";var mf="pbbp2",wf="https://www.coze.cn",_f="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",Gw="wss://frontier.coze.cn";function Xs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function yf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Gw}function _r(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 Ii(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Si=U("handshake");async function Dc(t){let e=Xs(t.endpoint),r=t.timeoutMs??1e4,i=`${Zs(e)}${_f}?aid=${encodeURIComponent(Ys)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",..._r(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Si.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",x=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${v.slice(0,200)}`)}let _=await u.json();if(_.code!==void 0&&_.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${h}`);let m=_.data??{},A=typeof m.access_key=="string"&&m.access_key||typeof m.accessKey=="string"&&m.accessKey||void 0,y=typeof m.device_id=="string"&&m.device_id||typeof m.deviceId=="string"&&m.deviceId||void 0;if(!A||!y){let v=JSON.stringify(_).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${v}`)}return Si.info("handshake ok",{remoteDeviceId:y,logid:h,traceId:x}),{accessKey:A,deviceId:y}}catch(u){if(u instanceof T)throw Si.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Si.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw Si.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 kc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",wt="auto",Ef=2e5;function bf(t){return{model:Oc(t.model)??wt,...t.modelToken?{modelToken:t.modelToken}:{}}}function vf(t){return!t||t===wt}var Hw=new Set(["auto","\u81EA\u52A8"]);function Oc(t){let e=t?.trim();if(e)return Hw.has(e.toLowerCase())?wt:e}function Sf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=kc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||wt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else vf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function If(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||wt}"`):vf(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${kc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Ef;e.push("-c",`model_context_window=${r}`)}return e}function Af(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Pc(t,e){let{ttEnv:r,usePpe:i}=Ii(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Tf(t,e,r){if(!t.modelToken)return{};let i=Pc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
-
`)}}function Nc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Rf(t,e,r){if(!t.modelToken)return null;let i=t.model||wt,o=Pc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${kc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Ef,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Cf(t,e,r){if(!t.modelToken)return[];let i=Pc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Pe=U("agent-handlers"),Df=5*1024*1024,Vw=1,Jw=6,Zw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Qs=class{constructor(e){this.opts=e}opts;async listSkills(e){qt(e._meta,"_agent/listSkills");let r=wr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ve(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=Ct(o,u.relPath,"SKILL.md");await Ww(h).then(_=>_.isFile()).catch(()=>!1)&&l.push(t_(u))}return{skills:l}}async addSkills(e){qt(e._meta,"_agent/addSkills");let r=wr(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 Gc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});Hc(c,l,x),u.push(h)}return await is(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){qt(e._meta,"_agent/removeSkills");let r=wr(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=Ct(i.workspace,u.relPath);await jw(h,{recursive:!0,force:!0}),Pe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await is(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,Pe.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,Pe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(x=>Pe.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 Pe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ge(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Pe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await tr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Pe.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 Je(i),Pe.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ge(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Je(i),Pe.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}):(Pe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(qt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Oc(e.model)??wt,i=await Ge(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 Je(i),Pe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Pe.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=>Pe.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),Pe.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(qt(e._meta,mt.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${mt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,mt.RESET),await this.runDetailSync(e.agentId,mt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Pe.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await Zr(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ge(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Je(r)}async repairAgent(e){if(qt(e._meta,mt.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${mt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${mt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Pe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,mt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Pe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Pe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){qt(e._meta,"_agent/getFileTree");let r=e._meta,i=wr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Lc(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 Jr(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=f_(e.depth);return u.isDirectory()?{tree:await u_(o,l,c,h)}:{tree:[{name:h_(c),path:Bf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){qt(e._meta,"_agent/getFileContent");let r=wr(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 Lc(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 Jr(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Df)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Df})`);let l=await kf(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ge(e).catch(()=>null))?.workspace??Ve(e).workspace}safeJoin(e,r){let i=zc(e,r||"."),o=Uc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Of}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ge(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function Yw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Xw(t){return t==="claude-code"?Ct(".claude","skills"):Ct(".agents","skills")}var Qw=3e4,e_=50*1024*1024,yr=3e4;async function Gc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=Yw(o.skillName),h=Xw(i),x=Ct(h,u),_=Ct(r,x);if(await Mc(_,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");Ai(A.length),await Bc(Ct(_,"SKILL.md"),A,"utf8")}else{let A=await n_(o.downloadUrl);i_(A)?await c_(A,_):s_(A)?await o_(A,_):await Bc(Ct(_,"SKILL.md"),A.toString("utf8"),"utf8")}let m={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 Pe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:x,source:c?"content":"downloadUrl"}),m}function Hc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function t_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function n_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ai(e);let r=r_(t);return Ai(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await kf(e);return Ai(r.length),r}if(Js(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ai(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 Ai(t){if(t>e_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(t){return t.length>=2&&t[0]===31&&t[1]===139}function s_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function Fc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new Lf.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Fc(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=a_(i),c=zc(e);for(let l of i){if(Fc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=zc(e,u),x=Uc(c,h);if(x.startsWith("..")||x==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Mc(h,{recursive:!0});continue}await Mc(Kw(h),{recursive:!0});let _;try{_=l.getData()}catch(m){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${m.message}`,{cause:m})}await Bc(h,_)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||Fc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=ff({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${yr}ms)`))},yr);try{await Nf(Pf.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${yr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=mr({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 (${yr}ms)`))},yr);try{await Nf(Pf.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${yr}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var l_=5e3;async function u_(t,e,r,i){return Mf(t,e,r,i,{count:0})}async function Mf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await qw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(Zw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Ct(e,u.name),x=$w(Ct(r,u.name)),_=null;try{_=await Lc(h)}catch{continue}if(_.isSymbolicLink())continue;o.count++;let m={name:u.name,path:Bf(Uc(t,h)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&i>1&&(m.children=await Mf(t,h,x,i-1,o)),l.push(m)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function f_(t){return!t||t<=0?Vw:Math.min(t,Jw)}function h_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Bf(t){return t.split(Of).join("/")}te();import{readFileSync as GI}from"node:fs";import{dirname as qI,join as jI}from"node:path";import{fileURLToPath as KI}from"node:url";var Er="0.1.97";var pn=U("agent-health-reporter"),x_=1e4,Ti=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??x_}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),pn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),pn.info("heartbeat stopped"))}async tick(){if(this.inFlight){pn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){pn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=p_(l);if(!u)continue;let h={agentId:l.agentId,status:u};l.patToken&&(h.patToken=l.patToken),l.accountId&&(h.accountId=l.accountId),r.push(h)}if(r.length===0)return;let i={agents:r,bridgeVersion:Er,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){pn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(pn.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){pn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){pn.warn("onTickEnd hook failed",{err:String(r)})}}};function p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}en();import{chmod as ay,mkdir as co,rm as cy,stat as dy,writeFile as ly}from"node:fs/promises";import{homedir as uy}from"node:os";import{join as i0}from"node:path";Qt();import{spawnSync as O_}from"node:child_process";import{existsSync as P_}from"node:fs";import{release as N_}from"node:os";import{basename as L_,isAbsolute as M_}from"node:path";function Ri(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function br(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function vr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function gn(t,e){return{jsonrpc:"2.0",id:t,error:e}}je();var eo=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function zf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Ff(t){return"method"in t&&!("id"in t)}function to(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Q.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Q.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Q.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ci(t.message)}:typeof t=="string"?Ci(t):typeof t=="object"?__(t):t}var w_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Ci(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ci(i):e[r]=i;return e}function Di(t){if(t instanceof T){let e=m_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:g_[t.code]??Q.INTERNAL_ERROR,message:Ci(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Ci(t instanceof Error?t.message:String(t))}}function Uf(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...u}=e;c=u}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function Hf(t){return`${JSON.stringify(t)}
|
|
93
|
-
`}var
|
|
94
|
-
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var jf={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},rA=Object.fromEntries(Object.entries(jf).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Sr=class{seq=0;next(e,r){this.seq+=1;let i=jf[e]??E_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>qf(r?.[h]??"")),u=b_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>qf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function E_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function qf(t){return t.replace(/[:_\s]+/g,"-")}function b_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Vr();import{readFileSync as v_}from"node:fs";var S_=384;async function qc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await er(t.agentEnvFile,r,{mode:S_})}function jc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Wf(t,e,r={},i=o=>o){return{...i({...t,...jc(e)}),...r}}mn();Zi();je();te();De();var k_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function Jf(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=Mt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),z_=200,F_=40,U_=Mt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),G_=Mt("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),H_=Mt("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Zf=500;function q_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Zf?t:`${e.slice(0,Zf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Yf(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),O_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function Xf(t){try{return P_(t)}catch{return}}function j_(t,e){return{platform:process.platform,osRelease:N_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?Xf(e.command):void 0,cwd:e.cwd,cwdExists:Xf(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${L_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Dt=class{constructor(e){this.opts=e;this.log=U(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new no({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Sr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Wf(process.env,this.opts.agentEnvFile??Y().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=ot(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>z_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=j_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",W_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Yf(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Yf(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=U_,i=G_,o=H_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(br("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(vr(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(gn(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),u=Ri(l,e,r),h=(()=>{if(typeof r!="object"||r===null)return;let m=r.sessionId;return typeof m=="string"?m:void 0})(),x=i>0&&Number.isFinite(i),_=o>0&&Number.isFinite(o);return new Promise((m,A)=>{let y={resolve:m,reject:A,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(x){let S=()=>{y.timer=setTimeout(()=>{let R=Date.now()-v;if(this.inflightAgentRequests.size>0&&R<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:R,approvalMaxMs:c,...h?{sessionId:h}:{}}),S();return}this.pending.delete(l),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer);let P=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:P,...h?{sessionId:h}:{}}),A(P?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=_?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...h?{sessionId:h}:{}}),I?.();return}y.timer&&clearTimeout(y.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...h?{sessionId:h}:{}}),A(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;y.onFirstUpdate=_?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=null,y.onFirstUpdate=null}:null,this.pending.set(l,y),I?.();try{this.writeFrame(u)}catch(S){y.timer&&clearTimeout(y.timer),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),this.pending.delete(l),A(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Hf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(to(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(Uf(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new 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:q_(e.result)}),r.resolve(e.result));return}if(Ff(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(zf(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(gn(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(gn(e.id,Di(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(F_).join(`
|
|
95
|
-
`),o=Jf(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var ro=class extends Dt{framework="claude-code";constructor(e){let{command:r,args:i}=$r("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return K_(e)}};Qt();import{mkdtempSync as $_,rmSync as V_}from"node:fs";import{tmpdir as J_}from"node:os";import{join as Z_}from"node:path";var io=class extends Dt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=$r("codex",e.command,i),l=e.isolateCodexHome?$_(Z_(J_(),"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{V_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Y_=3e4,Ir=class extends Dt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Y_))}get acpSessionName(){return this.sessionName}};je();te();De();function Wc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Qt();var wn=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 so=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 wn,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)ki(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 ki(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}mn();te();import{constants as Qf}from"node:fs";import{access as X_}from"node:fs/promises";import{delimiter as Q_,join as ey}from"node:path";var _t=U("framework-detector"),e0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ty=[".exe",".cmd",".bat",".ps1"],Fn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??ot,access:e.access??X_}}async detect(e){let r=e0[e],i=await this.which(r);if(!i)return _t.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(e0).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(Q_).filter(Boolean),i=this.env.platform==="win32"?["",...ty]:[""];for(let o of r)for(let c of i){let l=ey(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Qf.F_OK:Qf.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return _t.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return _t.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 _t.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 _t.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?(_t.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}:(_t.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return _t.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 _t.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||_t.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){_t.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(ry(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),u(null)},15e3),h.stdout?.on("data",x=>{o+=x.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},ny=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ry(t){return t.replace(ny,"")}import{homedir as iy}from"node:os";import{join as sy}from"node:path";mn();je();Vr();te();async function r0(){let t=sy(iy(),".openclaw/openclaw.json");return(await Qn(t))?.gateway?.auth?.token??""}var t0=U("openclaw.config"),oy=[0,5e3,5e3],n0="models.providers.",oo="agents.defaults.models",ao=class{command;env;retryDelaysMs;queue=new wn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??oy}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,t0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new 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=ot(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){t0.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${n0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${n0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${oo}[${e}]`,()=>this.runCli(["config","set",oo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${oo}[${e}]`,`${oo}.${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 he=U("agent-manager"),fy=(t,e,r,i,o,c,l,u,h)=>{switch(t){case"claude-code":{let x={...o?{...Sf(o),...Tf(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new ro({cwd:r,env:x,agentId:i})}case"codex":{let _=[...o?[...If(o),...Cf(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],m={...o?Af(o):{},...h??{}},A=!!o;return new io({cwd:r,agentId:i,..._.length>0?{extraArgs:_}:{},...Object.keys(m).length>0?{env:m}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Ir({command:e,cwd:r,agentId:i,...c?{sessionName:Wc(c)}:{}})}};function Kc(t){return t==="claude-code"||t==="codex"}function hy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(xy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return DS(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 Ch("schtasks",["/Create","/SC","ONLOGON","/TN",ta,"/TR",r,"/RU",t.userName,"/F"]),Ld.info("task scheduler entry created",{task:ta,logFile:t.logFile})},async uninstall(t){await Ch("schtasks",["/Delete","/TN",ta,"/F"]).catch(e=>Ld.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ld.info("task scheduler entry removed",{task:ta})}}});var Rh={};pa(Rh,{buildContext:()=>NS,getSupervisor:()=>OS,launchdSupervisor:()=>Od,systemdSupervisor:()=>Pd,taskSchedulerSupervisor:()=>Nd});import{homedir as RS,userInfo as kS}from"node:os";function OS(t=process.platform){switch(t){case"darwin":return Od;case"linux":return Pd;case"win32":return Nd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function LS(){let t={};for(let e of PS){let r=process.env[e];r&&(t[e]=r)}return t}function NS(){let t=X();return{nodeBin:process.execPath,entry:Ad(t),logFile:t.logFile,homeDir:RS(),userName:kS().username,isRoot:process.getuid?.()===0,env:LS()}}var PS,kh=Ze(()=>{"use strict";Oe();jo();Ah();Th();Dh();PS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();nn();var ul=G("acp-installer-warmup"),ng=["claude-code","codex"];async function fl(t={}){let e=t.ensure??er,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);ul.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&ul.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();ne();import{readdir as hg}from"node:fs/promises";import{mkdir as wl,writeFile as _l}from"node:fs/promises";import{join as ba}from"node:path";var xg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await wl(t,{recursive:!0});let i=xg[e],o=ba(t,i);return await _l(o,r??"","utf8"),o}async function yl(t){let e=ba(t,".claude");await wl(e,{recursive:!0});let r=ba(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await _l(r,i,"utf8"),r}var et=G("agent-detail-sync"),pg=6e4,gg=5*6e4,cs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await hg(r)}catch(o){et.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}et.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){et.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){et.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),et.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){et.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){et.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){et.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){et.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){et.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&et.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){et.debug("detail sync: no diff",{agentId:e});return}await Ye(i,this.opts.paths),et.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Mu=At(Ql(),1);import{lstat as Bc,mkdir as zc,readFile as Ou,readdir as Hw,rm as jw,stat as Ww,writeFile as Fc}from"node:fs/promises";import{dirname as Kw,join as Ot,normalize as $w,relative as qc,resolve as Uc,sep as Pu}from"node:path";import{Readable as Lu}from"node:stream";import{pipeline as Nu}from"node:stream/promises";import zg from"events";import Xe from"fs";import{EventEmitter as Ec}from"node:events";import L0 from"node:stream";import{StringDecoder as Fg}from"node:string_decoder";import B0 from"node:path";import pr from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import nc from"assert";import{Buffer as Bn}from"buffer";import*as i0 from"zlib";import cm from"zlib";import{posix as cr}from"node:path";import{basename as Nm}from"node:path";import Us from"fs";import Dt from"fs";import u0 from"path";import{win32 as Km}from"node:path";import w0 from"path";import X0 from"node:fs";import dw from"node:assert";import{randomBytes as Q0}from"node:crypto";import re from"node:fs";import Le from"node:path";import eu from"fs";import Js from"node:fs";import gi from"node:path";import it from"node:fs";import gw from"node:fs/promises";import Hs from"node:path";import{join as uu}from"node:path";import rt from"node:fs";import hu from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},e0=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof L0||Gg(t)||qg(t)),Gg=t=>!!t&&typeof t=="object"&&t instanceof Ec&&typeof t.pipe=="function"&&t.pipe!==L0.Writable.prototype.pipe,qg=t=>!!t&&typeof t=="object"&&t instanceof Ec&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),xs=Symbol("emittingEnd"),Qr=Symbol("emittedError"),hs=Symbol("closed"),t0=Symbol("read"),ps=Symbol("flush"),n0=Symbol("flushChunk"),pt=Symbol("encoding"),ar=Symbol("decoder"),Be=Symbol("flowing"),ei=Symbol("paused"),fr=Symbol("resume"),ze=Symbol("buffer"),Ve=Symbol("pipes"),Fe=Symbol("bufferLength"),Ca=Symbol("bufferPush"),gs=Symbol("bufferShift"),We=Symbol("objectMode"),Ae=Symbol("destroyed"),Da=Symbol("error"),Ra=Symbol("emitData"),r0=Symbol("emitEnd"),ka=Symbol("emitEnd2"),It=Symbol("async"),Oa=Symbol("abort"),ms=Symbol("aborted"),ti=Symbol("signal"),Cn=Symbol("dataListeners"),nt=Symbol("discarded"),ni=t=>Promise.resolve().then(t),Hg=t=>t(),jg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),N0=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[fr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},$g=class extends N0{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)}},Vg=t=>!!t.objectMode,Jg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends Ec{[Be]=!1;[ei]=!1;[Ve]=[];[ze]=[];[We];[pt];[It];[ar];[Ut]=!1;[on]=!1;[xs]=!1;[hs]=!1;[Qr]=null;[Fe]=0;[Ae]=!1;[ti];[ms]=!1;[Cn]=0;[nt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Vg(e)?(this[We]=!0,this[pt]=null):Jg(e)?(this[pt]=e.encoding,this[We]=!1):(this[We]=!1,this[pt]=null),this[It]=!!e.async,this[ar]=this[pt]?new Fg(this[pt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ze]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ve]});let{signal:r}=e;r&&(this[ti]=r,r.aborted?this[Oa]():r.addEventListener("abort",()=>this[Oa]()))}get bufferLength(){return this[Fe]}get encoding(){return this[pt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[We]}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}[Oa](){this[ms]=!0,this.emit("abort",this[ti]?.reason),this.destroy(this[ti]?.reason)}get aborted(){return this[ms]}set aborted(t){}write(t,e,r){if(this[ms])return!1;if(this[Ut])throw new Error("write after end");if(this[Ae])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[It]?ni:Hg;if(!this[We]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[We]?(this[Be]&&this[Fe]!==0&&this[ps](!0),this[Be]?this.emit("data",t):this[Ca](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Be]):t.length?(typeof t=="string"&&!(e===this[pt]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[pt]&&(t=this[ar].write(t)),this[Be]&&this[Fe]!==0&&this[ps](!0),this[Be]?this.emit("data",t):this[Ca](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Be]):(this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Be])}read(t){if(this[Ae])return null;if(this[nt]=!1,this[Fe]===0||t===0||t&&t>this[Fe])return this[Gt](),null;this[We]&&(t=null),this[ze].length>1&&!this[We]&&(this[ze]=[this[pt]?this[ze].join(""):Buffer.concat(this[ze],this[Fe])]);let e=this[t0](t||null,this[ze][0]);return this[Gt](),e}[t0](t,e){if(this[We])this[gs]();else{let r=e;t===r.length||t===null?this[gs]():typeof r=="string"?(this[ze][0]=r.slice(t),e=r.slice(0,t),this[Fe]-=t):(this[ze][0]=r.subarray(t),e=r.subarray(0,t),this[Fe]-=t)}return this.emit("data",e),!this[ze].length&&!this[Ut]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ut]=!0,this.writable=!1,(this[Be]||!this[ei])&&this[Gt](),this}[fr](){this[Ae]||(!this[Cn]&&!this[Ve].length&&(this[nt]=!0),this[ei]=!1,this[Be]=!0,this.emit("resume"),this[ze].length?this[ps]():this[Ut]?this[Gt]():this.emit("drain"))}resume(){return this[fr]()}pause(){this[Be]=!1,this[ei]=!0,this[nt]=!1}get destroyed(){return this[Ae]}get flowing(){return this[Be]}get paused(){return this[ei]}[Ca](t){this[We]?this[Fe]+=1:this[Fe]+=t.length,this[ze].push(t)}[gs](){return this[We]?this[Fe]-=1:this[Fe]-=this[ze][0].length,this[ze].shift()}[ps](t=!1){do;while(this[n0](this[gs]())&&this[ze].length);!t&&!this[ze].length&&!this[Ut]&&this.emit("drain")}[n0](t){return this.emit("data",t),this[Be]}pipe(t,e){if(this[Ae])return t;this[nt]=!1;let r=this[on];return e=e||{},t===e0.stdout||t===e0.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ve].push(e.proxyErrors?new $g(this,t,e):new N0(this,t,e)),this[It]?ni(()=>this[fr]()):this[fr]()),t}unpipe(t){let e=this[Ve].find(r=>r.dest===t);e&&(this[Ve].length===1?(this[Be]&&this[Cn]===0&&(this[Be]=!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[nt]=!1,this[Cn]++,!this[Ve].length&&!this[Be]&&this[fr]();else if(t==="readable"&&this[Fe]!==0)super.emit("readable");else if(jg(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Qr]){let i=e;this[It]?ni(()=>i.call(this,this[Qr])):i.call(this,this[Qr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Cn]=this.listeners("data").length,this[Cn]===0&&!this[nt]&&!this[Ve].length&&(this[Be]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[nt]&&!this[Ve].length&&(this[Be]=!1)),e}get emittedEnd(){return this[on]}[Gt](){!this[xs]&&!this[on]&&!this[Ae]&&this[ze].length===0&&this[Ut]&&(this[xs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[hs]&&this.emit("close"),this[xs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ae&&this[Ae])return!1;if(t==="data")return!this[We]&&!r?!1:this[It]?(ni(()=>this[Ra](r)),!0):this[Ra](r);if(t==="end")return this[r0]();if(t==="close"){if(this[hs]=!0,!this[on]&&!this[Ae])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Qr]=r,super.emit(Da,r);let o=!this[ti]||this.listeners("error").length?super.emit("error",r):!1;return this[Gt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Gt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Gt](),i}[Ra](t){for(let r of this[Ve])r.dest.write(t)===!1&&this.pause();let e=this[nt]?!1:super.emit("data",t);return this[Gt](),e}[r0](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[It]?(ni(()=>this[ka]()),!0):this[ka]())}[ka](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[Ve])r.dest.write(e);this[nt]||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[We]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[We]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[We])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[pt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ae,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[nt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(Ae,x),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(Ae,x),this.pause(),i({value:p,done:!!this[Ut]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ae,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{o=w,i=p,this.once(Ae,x),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[nt]=!1;let t=!1,e=()=>(this.pause(),this.off(Da,e),this.off(Ae,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Da,e),this.once(Ae,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ae])return t?this.emit("error",t):this.emit(Ae),this;this[Ae]=!0,this[nt]=!0,this[ze].length=0,this[Fe]=0;let e=this;return typeof e.close=="function"&&!this[hs]&&e.close(),t?this.emit("error",t):this.emit(Ae),this}static get isStream(){return Ug}},Zg=Xe.writev,gn=Symbol("_autoClose"),_t=Symbol("_close"),ri=Symbol("_ended"),ae=Symbol("_fd"),Pa=Symbol("_finished"),Wt=Symbol("_flags"),La=Symbol("_flush"),ec=Symbol("_handleChunk"),tc=Symbol("_makeBuf"),hi=Symbol("_mode"),ws=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Na=Symbol("_onread"),xr=Symbol("_onwrite"),mn=Symbol("_open"),wt=Symbol("_path"),un=Symbol("_pos"),Tt=Symbol("_queue"),hr=Symbol("_read"),Ma=Symbol("_readSize"),jt=Symbol("_reading"),ii=Symbol("_remain"),Ba=Symbol("_size"),Cs=Symbol("_write"),Dn=Symbol("_writing"),Ds=Symbol("_defaultFlag"),Mn=Symbol("_errored"),bc=class extends Un{[Mn]=!1;[ae];[wt];[Ma];[jt]=!1;[Ba];[ii];[gn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Mn]=!1,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[wt]=t,this[Ma]=e.readSize||16*1024*1024,this[jt]=!1,this[Ba]=typeof e.size=="number"?e.size:1/0,this[ii]=this[Ba],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ae]=="number"?this[hr]():this[mn]()}get fd(){return this[ae]}get path(){return this[wt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){Xe.open(this[wt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[ae]=e,this.emit("open",e),this[hr]())}[tc](){return Buffer.allocUnsafe(Math.min(this[Ma],this[ii]))}[hr](){if(!this[jt]){this[jt]=!0;let t=this[tc]();if(t.length===0)return process.nextTick(()=>this[Na](null,0,t));Xe.read(this[ae],t,0,t.length,null,(e,r,i)=>this[Na](e,r,i))}}[Na](t,e,r){this[jt]=!1,t?this[mr](t):this[ec](e,r)&&this[hr]()}[_t](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[jt]=!0,this[_t](),this.emit("error",t)}[ec](t,e){let r=!1;return this[ii]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ii]<=0)&&(r=!1,this[_t](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ae]=="number"&&this[hr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Yg=class extends bc{[mn](){let t=!0;try{this[wr](null,Xe.openSync(this[wt],"r")),t=!1}finally{t&&this[_t]()}}[hr](){let t=!0;try{if(!this[jt]){this[jt]=!0;do{let e=this[tc](),r=e.length===0?0:Xe.readSync(this[ae],e,0,e.length,null);if(!this[ec](r,e))break}while(!0);this[jt]=!1}t=!1}finally{t&&this[_t]()}}[_t](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}},js=class extends zg{readable=!1;writable=!0;[Mn]=!1;[Dn]=!1;[ri]=!1;[Tt]=[];[ws]=!1;[wt];[hi];[gn];[ae];[Ds];[Wt];[Pa]=!1;[un];constructor(t,e){e=e||{},super(e),this[wt]=t,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[hi]=e.mode===void 0?438:e.mode,this[un]=typeof e.start=="number"?e.start:void 0,this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[un]!==void 0?"r+":"w";this[Ds]=e.flags===void 0,this[Wt]=e.flags===void 0?r:e.flags,this[ae]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[ae]}get path(){return this[wt]}[mr](t){this[_t](),this[Dn]=!0,this.emit("error",t)}[mn](){Xe.open(this[wt],this[Wt],this[hi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Ds]&&this[Wt]==="r+"&&t&&t.code==="ENOENT"?(this[Wt]="w",this[mn]()):t?this[mr](t):(this[ae]=e,this.emit("open",e),this[Dn]||this[La]())}end(t,e){return t&&this.write(t,e),this[ri]=!0,!this[Dn]&&!this[Tt].length&&typeof this[ae]=="number"&&this[xr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ri]?(this.emit("error",new Error("write() after end()")),!1):this[ae]===void 0||this[Dn]||this[Tt].length?(this[Tt].push(t),this[ws]=!0,!1):(this[Dn]=!0,this[Cs](t),!0)}[Cs](t){Xe.write(this[ae],t,0,t.length,this[un],(e,r)=>this[xr](e,r))}[xr](t,e){t?this[mr](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[Tt].length?this[La]():(this[Dn]=!1,this[ri]&&!this[Pa]?(this[Pa]=!0,this[_t](),this.emit("finish")):this[ws]&&(this[ws]=!1,this.emit("drain"))))}[La](){if(this[Tt].length===0)this[ri]&&this[xr](null,0);else if(this[Tt].length===1)this[Cs](this[Tt].pop());else{let t=this[Tt];this[Tt]=[],Zg(this[ae],t,this[un],(e,r)=>this[xr](e,r))}}[_t](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},M0=class extends js{[mn](){let t;if(this[Ds]&&this[Wt]==="r+")try{t=Xe.openSync(this[wt],this[Wt],this[hi])}catch(e){if(e?.code==="ENOENT")return this[Wt]="w",this[mn]();throw e}else t=Xe.openSync(this[wt],this[Wt],this[hi]);this[wr](null,t)}[_t](){if(this[gn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}[Cs](t){let e=!0;try{this[xr](null,Xe.writeSync(this[ae],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[_t]()}catch{}}}},em=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,vc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},vi=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let x=vc(c);if(o?.(x,l),tm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(nm(x)){let p=e(x,l);return u?p.then(()=>u(),u):p}else if(rm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(im(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),dm=cm.constants||{ZLIB_VERNUM:4736},kt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},dm)),lm=Bn.concat,s0=Object.getOwnPropertyDescriptor(Bn,"concat"),um=t=>t,za=s0?.writable===!0||s0?.set!==void 0?t=>{Bn.concat=t?um:lm}:t=>{},zn=Symbol("_superWrite"),_s=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Fa=Symbol("flushFlag"),Sc=class extends Un{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof i0[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new i0[e](t)}catch(r){throw new _s(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 _s(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return nc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[Fa]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[zn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;nc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},za(!0);let l;try{let x=typeof t[Fa]=="number"?t[Fa]:this.#r;l=this.#t._processChunk(t,x),za(!1)}catch(x){za(!1),this.#o(new _s(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 _s(x,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];u=this[zn](Bn.from(x));for(let p=1;p<l.length;p++)u=this[zn](l[p])}else u=this[zn](Bn.from(l));return r&&r(),u}},z0=class extends Sc{#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),nc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},fm=class extends z0{#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)}},xm=class extends z0{constructor(t){super(t,"Unzip")}},F0=class extends Sc{constructor(t,e){t=t||{},t.flush=t.flush||kt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||kt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=kt.BROTLI_OPERATION_FLUSH,super(t,e)}},hm=class extends F0{constructor(t){super(t,"BrotliCompress")}},pm=class extends F0{constructor(t){super(t,"BrotliDecompress")}},U0=class extends Sc{constructor(t,e){t=t||{},t.flush=t.flush||kt.ZSTD_e_continue,t.finishFlush=t.finishFlush||kt.ZSTD_e_end,t.fullFlushFlag=kt.ZSTD_e_flush,super(t,e)}},gm=class extends U0{constructor(t){super(t,"ZstdCompress")}},mm=class extends U0{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=G0(o):o===0?e[i-1]=0:(r=!0,e[i-1]=q0(o))}},Em=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?bm(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},bm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=G0(c):c===0?l=c:(i=!0,l=q0(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},G0=t=>(255^t)&255,q0=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>Ac,isCode:()=>Rs,isName:()=>Am,name:()=>Ws});var Rs=t=>Ws.has(t),Am=t=>Ac.has(t),Ws=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Ac=new Map(Array.from(Ws).map(t=>[t[1],t[0]])),Fn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Rn(t,e,100),this.mode=r?.mode??i?.mode??fn(t,e+100,8),this.uid=r?.uid??i?.uid??fn(t,e+108,8),this.gid=r?.gid??i?.gid??fn(t,e+116,8),this.size=r?.size??i?.size??fn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ua(t,e+136,12),this.cksum=fn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Rn(t,e+156,1);if(Rs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Rn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Rn(t,e+265,32),this.gname=r?.gname??i?.gname??Rn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??fn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??fn(t,e+337,8)??0,t[e+475]!==0){let l=Rn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Rn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Ua(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Ua(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Im(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=xn(t,e+100,8,this.mode)||this.needPax,this.needPax=xn(t,e+108,8,this.uid)||this.needPax,this.needPax=xn(t,e+116,8,this.gid)||this.needPax,this.needPax=xn(t,e+124,12,this.size)||this.needPax,this.needPax=Ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=xn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=xn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(t,e+345,130,c)||this.needPax,this.needPax=Ga(t,e+476,12,this.atime)||this.needPax,this.needPax=Ga(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,xn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ws.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Ac.get(t));if(Rs(e)||e==="Unsupported")this.#e=e;else if(Rs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Im=(t,e)=>{let r=t,i="",o,c=cr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=cr.dirname(r),r=cr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=cr.join(cr.basename(i),r),i=cr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Rn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ua=(t,e,r)=>Tm(fn(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?Em(t.subarray(e,e+r)):Dm(t,e,r),Cm=t=>isNaN(t)?void 0:t,Dm=(t,e,r)=>Cm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Rm={12:8589934591,8:2097151},xn=(t,e,r,i)=>i===void 0?!1:i>Rm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Om(i,r),e,r,"ascii"),Om=(t,e)=>Pm(Math.floor(t).toString(8),e),Pm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ga=(t,e,r,i)=>i===void 0?!1:xn(t,e,r,i.getTime()/1e3),Lm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Lm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Fs=class H0{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Fn({path:("PaxHeader/"+Nm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new H0(Mm(Bm(e),r),i)}},Mm=(t,e)=>e?Object.assign({},e,t):t,Bm=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(zm,Object.create(null)),zm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=Fm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),j0=class extends Un{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Y(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Y(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Y(t.path)),t.linkpath&&(t.linkpath=Y(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ks=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Um=1024*1024,rc=Buffer.from([31,139]),ic=Buffer.from([40,181,47,253]),Gm=Math.max(rc.length,ic.length),at=Symbol("state"),On=Symbol("writeEntry"),qt=Symbol("readEntry"),qa=Symbol("nextEntry"),o0=Symbol("processEntry"),Ct=Symbol("extendedHeader"),si=Symbol("globalExtendedHeader"),an=Symbol("meta"),a0=Symbol("emitMeta"),xe=Symbol("buffer"),Ht=Symbol("queue"),cn=Symbol("ended"),Ha=Symbol("emittedEnd"),Pn=Symbol("emit"),Ce=Symbol("unzip"),ys=Symbol("consumeChunk"),Es=Symbol("consumeChunkSub"),ja=Symbol("consumeBody"),c0=Symbol("consumeMeta"),d0=Symbol("consumeHeader"),oi=Symbol("consuming"),Wa=Symbol("bufferConcat"),bs=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),vs=Symbol("onDone"),Ln=Symbol("sawValidEntry"),Ss=Symbol("sawNullBlock"),As=Symbol("sawEOF"),l0=Symbol("closeStream"),qm=()=>!0,bi=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ht]=[];[xe];[qt];[On];[at]="begin";[an]="";[Ct];[si];[cn]=!1;[Ce];[dn]=!1;[Ln];[Ss]=!1;[As]=!1;[dr]=!1;[oi]=!1;[Ha]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(vs,()=>{(this[at]==="begin"||this[Ln]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(vs,t.ondone):this.on(vs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:qm;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[l0]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ks(this,t,e,r)}[d0](t,e){this[Ln]===void 0&&(this[Ln]=!1);let r;try{r=new Fn(t,e,this[Ct],this[si])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ss]?(this[As]=!0,this[at]==="begin"&&(this[at]="header"),this[Pn]("eof")):(this[Ss]=!0,this[Pn]("nullBlock"));else if(this[Ss]=!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 j0(r,this[Ct],this[si]);if(!this[Ln])if(o.remain){let c=()=>{o.invalid||(this[Ln]=!0)};o.on("end",c)}else this[Ln]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Pn]("ignoredEntry",o),this[at]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[at]="meta"):(this[Ct]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Pn]("ignoredEntry",o),this[at]=o.remain?"ignore":"header",o.resume()):(o.remain?this[at]="body":(this[at]="header",o.end()),this[qt]?this[Ht].push(o):(this[Ht].push(o),this[qa]())))}}}[l0](){queueMicrotask(()=>this.emit("close"))}[o0](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[qa]()),e=!1);return e}[qa](){do;while(this[o0](this[Ht].shift()));if(this[Ht].length===0){let t=this[qt];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ja](t,e){let r=this[On];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[at]="header",this[On]=void 0,r.end()),o.length}[c0](t,e){let r=this[On],i=this[ja](t,e);return!this[On]&&r&&this[a0](r),i}[Pn](t,e,r){this[Ht].length===0&&!this[qt]?this.emit(t,e,r):this[Ht].push([t,e,r])}[a0](t){switch(this[Pn]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Ct]=Fs.parse(this[an],this[Ct],!1);break;case"GlobalExtendedHeader":this[si]=Fs.parse(this[an],this[si],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Ct]??Object.create(null);this[Ct]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Ct]||Object.create(null);this[Ct]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<Gm)return this[xe]=t,r?.(),!0;for(let l=0;this[Ce]===void 0&&l<rc.length;l++)t[l]!==rc[l]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<ic.length;l++)if(t[l]!==ic[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new Fn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Ce]=this[Ce]===void 0?new xm({}):o?new mm({}):new pm({}),this[Ce].on("data",x=>this[ys](x)),this[Ce].on("error",x=>this.abort(x)),this[Ce].on("end",()=>{this[cn]=!0,this[ys]()}),this[dr]=!0;let u=!!this[Ce][l?"end":"write"](t);return this[dr]=!1,r?.(),u}}this[dr]=!0,this[Ce]?this[Ce].write(t):this[ys](t),this[dr]=!1;let i=this[Ht].length>0?!1:this[qt]?this[qt].flowing:!0;return!i&&this[Ht].length===0&&this[qt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Wa](t){t&&!this[dn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[bs](){if(this[cn]&&!this[Ha]&&!this[dn]&&!this[oi]){this[Ha]=!0;let t=this[On];if(t&&t.blockRemain){let e=this[xe]?this[xe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[xe]&&t.write(this[xe]),t.end()}this[Pn](vs)}}[ys](t){if(this[oi]&&t)this[Wa](t);else if(!t&&!this[xe])this[bs]();else if(t){if(this[oi]=!0,this[xe]){this[Wa](t);let e=this[xe];this[xe]=void 0,this[Es](e)}else this[Es](t);for(;this[xe]&&this[xe]?.length>=512&&!this[dn]&&!this[As];){let e=this[xe];this[xe]=void 0,this[Es](e)}this[oi]=!1}(!this[xe]||this[cn])&&this[bs]()}[Es](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[As];)switch(this[at]){case"begin":case"header":this[d0](t,e),e+=512;break;case"ignore":case"body":e+=this[ja](t,e);break;case"meta":e+=this[c0](t,e);break;default:throw new Error("invalid state: "+this[at])}e<r&&(this[xe]=this[xe]?Buffer.concat([t.subarray(e),this[xe]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[dn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[bs]())),this}},pi=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},Hm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},W0=(t,e)=>{let r=new Map(e.map(c=>[pi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Qg(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(Xg(c),u)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(pi(c)):c=>o(pi(c))},jm=t=>{let e=new bi(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=pr.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let x=pr.readSync(i,u,0,c,l);if(x===0)break;l+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},Wm=(t,e)=>{let r=new bi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(u,x)=>{if(u)l(u);else{let p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},_r=vi(jm,Wm,t=>new bi(t),t=>new bi(t),(t,e)=>{e?.length&&W0(t,e),t.noResume||Hm(t)}),K0=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:$m,parse:f0}=Km,Ic=t=>{let e="",r=f0(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=f0(t)}return[e,t]},$s=["|","<",">","?",":"],Tc=$s.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Vm=new Map($s.map((t,e)=>[t,Tc[e]])),Jm=new Map(Tc.map((t,e)=>[t,$s[e]])),x0=t=>$s.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),Zm=t=>Tc.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),$0=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),pi(e)+"/"+t):Y(t),Ym=16*1024*1024,h0=Symbol("process"),p0=Symbol("file"),g0=Symbol("directory"),sc=Symbol("symlink"),m0=Symbol("hardlink"),ai=Symbol("header"),ks=Symbol("read"),oc=Symbol("lstat"),Os=Symbol("onlstat"),ac=Symbol("onread"),cc=Symbol("onreadlink"),dc=Symbol("openfile"),lc=Symbol("onopenfile"),hn=Symbol("close"),Gs=Symbol("mode"),uc=Symbol("awaitDrain"),Ka=Symbol("ondrain"),Rt=Symbol("prefix"),V0=class extends Un{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=vc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Ym,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Y(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Y(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Ic(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Zm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||u0.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[Os](o):this[oc]()}warn(t,e,r={}){return Ks(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[oc](){Dt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Os](e)})}[Os](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[h0]()}[h0](){switch(this.type){case"File":return this[p0]();case"Directory":return this[g0]();case"SymbolicLink":return this[sc]();default:return this.end()}}[Gs](t){return K0(t,this.type==="Directory",this.portable)}[Rt](t){return $0(t,this.prefix)}[ai](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Fn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this[Gs](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Fs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[g0](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ai](),this.end()}[sc](){Dt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[cc](e)})}[cc](t){this.linkpath=Y(t),this[ai](),this.end()}[m0](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(u0.relative(this.cwd,t)),this.stat.size=0,this[ai](),this.end()}[p0](){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[m0](e);this.linkCache.set(t,this.absolute)}if(this[ai](),this.stat.size===0)return this.end();this[dc]()}[dc](){Dt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[lc](e)})}[lc](t){if(this.fd=t,this.#e)return this[hn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ks]()}[ks](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Dt.read(t,e,r,i,o,(c,l)=>{if(c)return this[hn](()=>this.emit("error",c));this[ac](l)})}[hn](t=()=>{}){this.fd!==void 0&&Dt.close(this.fd,t)}[ac](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[hn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[hn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Ka]():this[uc](()=>this[Ka]())}[uc](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)}[Ka](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[hn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[ks]()}},Xm=class extends V0{sync=!0;[oc](){this[Os](Dt.lstatSync(this.absolute))}[sc](){this[cc](Dt.readlinkSync(this.absolute))}[dc](){this[lc](Dt.openSync(this.absolute,"r"))}[ks](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Dt.readSync(e,r,i,o,c);this[ac](l),t=!1}finally{if(t)try{this[hn](()=>{})}catch{}}}[uc](t){t()}[hn](t=()=>{}){this.fd!==void 0&&Dt.closeSync(this.fd),t()}},Qm=class extends Un{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Ks(this,t,e,r)}constructor(t,e={}){let r=vc(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[Gs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Ic(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Fn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new Fs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Rt](t){return $0(t,this.prefix)}[Gs](t){return K0(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=class gr{tail;head;length=0;static create(e=[]){return new gr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new gr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new gr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=nw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Cc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Cc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Cc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Cc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},_0=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},y0=Buffer.alloc(1024),Ps=Symbol("onStat"),ci=Symbol("ended"),gt=Symbol("queue"),di=Symbol("queue"),ln=Symbol("current"),Nn=Symbol("process"),li=Symbol("processing"),Is=Symbol("processJob"),mt=Symbol("jobs"),$a=Symbol("jobDone"),Ls=Symbol("addFSEntry"),E0=Symbol("addTarEntry"),fc=Symbol("stat"),xc=Symbol("readdir"),Ns=Symbol("onreaddir"),Ms=Symbol("pipe"),b0=Symbol("entry"),Va=Symbol("entryOpt"),Bs=Symbol("writeEntryClass"),J0=Symbol("write"),Ja=Symbol("ondrain"),Vs=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Bs];onWriteEntry;[gt];[di]=new Map;[mt]=0;[li]=!1;[ci]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Y(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Bs]=V0,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new fm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new hm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[gt]=new tw,this[mt]=0,this.jobs=Number(t.jobs)||4,this[li]=!1,this[ci]=!1}[J0](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[ci]=!0,this[Nn](),r&&r(),this}write(t){if(this[ci])throw new Error("write after end");return t instanceof j0?this[E0](t):this[Ls](t),this.flowing}[E0](t){let e=Y(w0.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new _0(t.path,e);r.entry=new Qm(t,this[Va](r)),r.entry.on("end",()=>this[$a](r)),this[mt]+=1,this[gt].push(r)}this[Nn]()}[Ls](t){let e=Y(w0.resolve(this.cwd,t));this[gt].push(new _0(t,e)),this[Nn]()}[fc](t){t.pending=!0,this[mt]+=1;let e=this.follow?"stat":"lstat";Us[e](t.absolute,(r,i)=>{t.pending=!1,this[mt]-=1,r?this.emit("error",r):this[Ps](t,i)})}[Ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Is](t);else{let r=`${e.dev}:${e.ino}`,i=this[di].get(r);i?i.push(t):this[di].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Nn]()}[xc](t){t.pending=!0,this[mt]+=1,Us.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[mt]-=1,e)return this.emit("error",e);this[Ns](t,r)})}[Ns](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Nn]()}[Nn](){if(!this[li]){this[li]=!0;for(let t=this[gt].head;t&&this[mt]<this.jobs;t=t.next)if(this[Is](t.value),t.value.ignore){let e=t.next;this[gt].removeNode(t),t.next=e}this[li]=!1,this[ci]&&this[gt].length===0&&this[mt]===0&&(this.zip?this.zip.end(y0):(super.write(y0),super.end()))}}get[ln](){return this[gt]&&this[gt].head&&this[gt].head.value}[$a](t){this[gt].shift(),this[mt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[di].get(r);if(i){this[di].delete(r);for(let o of i)o.pending=!1,this[Is](o)}}this[Nn]()}[Is](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[Ms](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ps](t,e):this[fc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ns](t,e):this[xc](t),!t.readdir)return}if(t.entry=this[b0](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Ms](t)}}}[Va](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}}[b0](t){this[mt]+=1;try{return new this[Bs](t.path,this[Va](t)).on("end",()=>this[$a](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Ms](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ls](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={}){Ks(this,t,e,r)}},Dc=class extends Vs{sync=!0;constructor(t){super(t),this[Bs]=Xm}pause(){}resume(){}[fc](t){let e=this.follow?"statSync":"lstatSync";this[Ps](t,Us[e](t.absolute))}[xc](t){this[Ns](t,Us.readdirSync(t.absolute))}[Ms](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ls](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[J0](i)})}},sw=(t,e)=>{let r=new Dc(t),i=new M0(t.file,{mode:t.mode||438});r.pipe(i),Z0(r,e)},ow=(t,e)=>{let r=new Vs(t),i=new js(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return Y0(r,e).catch(c=>r.emit("error",c)),o},Z0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:B0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Y0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:B0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new Dc(t);return Z0(r,e),r},cw=(t,e)=>{let r=new Vs(t);return Y0(r,e).catch(i=>r.emit("error",i)),r},m2=vi(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,tu=lw==="win32",{O_CREAT:nu,O_NOFOLLOW:v0,O_TRUNC:ru,O_WRONLY:iu}=eu.constants,su=Number(process.env.__FAKE_FS_O_FILENAME__)||eu.constants.UV_FS_O_FILEMAP||0,uw=tu&&!!su,fw=512*1024,xw=su|ru|nu|iu,S0=!tu&&typeof v0=="number"?v0|ru|nu|iu:null,ou=S0!==null?()=>S0:uw?t=>t<fw?xw:"w":()=>"w",hc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},qs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},hw=(t,e,r,i,o)=>{if(e.isDirectory())au(gi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=gi.resolve(t,e.name);qs(l,r,i,o)});else{let c=gi.resolve(t,e.name);qs(c,r,i,o)}},au=(t,e,r,i)=>{Js.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return qs(t,e,r,i);let l=c.length,u=null,x=p=>{if(!u){if(p)return i(u=p);if(--l===0)return qs(t,e,r,i)}};for(let p of c)hw(t,p,e,r,x)})},pw=(t,e,r,i)=>{e.isDirectory()&&cu(gi.resolve(t,e.name),r,i),hc(gi.resolve(t,e.name),r,i)},cu=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return hc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return hc(t,e,r)},du=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"}},Zs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{it.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new du(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,x=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,w=e.unlink,_=Y(e.cwd),I=(v,A)=>{v?r(v):A&&x?au(A,l,u,S=>I(S)):c?it.chmod(t,o,r):r()};if(t===_)return mw(t,I);if(p)return gw.mkdir(t,{mode:o,recursive:!0}).then(v=>I(null,v??void 0),I);let E=Y(Hs.relative(_,t)).split("/");pc(_,E,o,w,_,void 0,I)},pc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),x=Y(Hs.resolve(t+"/"+u));it.mkdir(x,r,lu(x,e,r,i,o,c,l))},lu=(t,e,r,i,o,c,l)=>u=>{u?it.lstat(t,(x,p)=>{if(x)x.path=x.path&&Y(x.path),l(x);else if(p.isDirectory())pc(t,e,r,i,o,c,l);else if(i)it.unlink(t,w=>{if(w)return l(w);it.mkdir(t,r,lu(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Zs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,pc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=it.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new du(t,r??"ENOTDIR")}},yw=(t,e)=>{t=Y(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),x=e.preserve,p=e.unlink,w=Y(e.cwd),_=v=>{v&&u&&cu(v,c,l),o&&it.chmodSync(t,i)};if(t===w)return _w(w),_();if(x)return _(it.mkdirSync(t,{mode:i,recursive:!0})??void 0);let I=Y(Hs.relative(w,t)).split("/"),E;for(let v=I.shift(),A=w;v&&(A+="/"+v);v=I.shift()){A=Y(Hs.resolve(A));try{it.mkdirSync(A,i),E=E||A}catch{let S=it.lstatSync(A);if(S.isDirectory())continue;if(p){it.unlinkSync(A),it.mkdirSync(A,i),E=E||A;continue}else if(S.isSymbolicLink())return new Zs(A,A+"/"+I.join("/"))}}return _(E)},Za=Object.create(null),A0=1e4,lr=new Set,Ew=t=>{lr.has(t)?lr.delete(t):Za[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=Za[t],r=lr.size-A0;if(r>A0/10){for(let i of lr)if(lr.delete(i),delete Za[i],--r<=0)break}return e},bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=bw==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=uu(i,r)),e.push(r||"/"),e},[]),Aw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>pi(uu(Ew(i))));let r=new Set(t.map(i=>Sw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let x of u)o.add(x)}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 x=l[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Iw=()=>process.umask(),I0=Symbol("onEntry"),gc=Symbol("checkFs"),T0=Symbol("checkFs2"),mc=Symbol("isReusable"),ct=Symbol("makeFs"),wc=Symbol("file"),_c=Symbol("directory"),zs=Symbol("link"),C0=Symbol("symlink"),D0=Symbol("hardlink"),xi=Symbol("ensureNoSymlink"),R0=Symbol("unsupported"),k0=Symbol("checkPath"),Ya=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),Ue=Symbol("onError"),Ts=Symbol("pending"),O0=Symbol("pend"),ur=Symbol("unpend"),Xa=Symbol("ended"),Qa=Symbol("maybeClose"),yc=Symbol("skip"),mi=Symbol("doChown"),wi=Symbol("uid"),_i=Symbol("gid"),yi=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ei=Tw==="win32",Cw=1024,Dw=(t,e)=>{if(!Ei)return re.unlink(t,e);let r=t+".DELETE."+Q0(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Rw=t=>{if(!Ei)return re.unlinkSync(t);let e=t+".DELETE."+Q0(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},P0=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Rc=class extends bi{[Xa]=!1;[yi]=!1;[Ts]=0;reservations=new Aw;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[Xa]=!0,this[Qa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Cw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ei,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Le.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Iw():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[I0](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Qa](){this[Xa]&&this[Ts]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ya](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Ic(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ei&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Le.posix.dirname(t.path),x=Le.posix.normalize(Le.posix.join(u,l.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[k0](t){let e=Y(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Y(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ya](t,"path")||!this[Ya](t,"linkpath"))return!1;if(t.absolute=Le.isAbsolute(t.path)?Y(Le.resolve(t.path)):Y(Le.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}=Le.win32.parse(String(t.absolute));t.absolute=i+x0(String(t.absolute).slice(i.length));let{root:o}=Le.win32.parse(t.path);t.path=o+x0(t.path.slice(o.length))}return!0}[I0](t){if(!this[k0](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[gc](t);default:return this[R0](t)}}[Ue](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ur](),e.resume())}[pn](t,e,r){ww(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[mi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[wi](t){return P0(this.uid,t.uid,this.processUid)}[_i](t){return P0(this.gid,t.gid,this.processGid)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new js(String(t.absolute),{flags:ou(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[Ue](u,t),e()});let o=1,c=u=>{if(u){i.fd&&re.close(i.fd,()=>{}),this[Ue](u,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[Ue](x,t):this[ur](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,w=t.mtime;re.futimes(x,p,w,_=>_?re.utimes(u,p,w,I=>c(I&&_)):c())}if(typeof x=="number"&&this[mi](t)){o++;let p=this[wi](t),w=this[_i](t);typeof p=="number"&&typeof w=="number"&&re.fchown(x,p,w,_=>_?re.chown(u,p,w,I=>c(I&&_)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Ue](u,t),e()}),t.pipe(l)),l.pipe(i)}[_c](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[Ue](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[ur](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[mi](t)&&(o++,re.chown(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)),c)),c()})}[R0](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[C0](t,e){let r=Y(Le.relative(this.cwd,Le.resolve(Le.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[xi](t,this.cwd,r,()=>this[zs](t,String(t.linkpath),"symlink",e),i=>{this[Ue](i,t),e()})}[D0](t,e){let r=Y(Le.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[xi](t,this.cwd,i,()=>this[zs](t,r,"link",e),o=>{this[Ue](o,t),e()})}[xi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Le.resolve(e,c);re.lstat(l,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new Zs(l,Le.resolve(l,r.join("/"))));this[xi](t,l,r,i,o)})}[O0](){this[Ts]++}[ur](){this[Ts]--,this[Qa]()}[yc](t){this[ur](),t.resume()}[mc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ei}[gc](t){this[O0]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[T0](t,r))}[T0](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[Ue](l,t),r();return}this[yi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Le.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,u=>{if(u){this[Ue](u,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[yc](t),r();return}if(l||this[mc](t,u))return this[ct](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=w=>this[ct](w??null,t,r);return x?re.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),x=>this[ct](x??null,t,r))}if(t.absolute===this.cwd)return this[ct](null,t,r);Dw(String(t.absolute),x=>this[ct](x??null,t,r))})};this[yi]?o():i()}[ct](t,e,r){if(t){this[Ue](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[wc](e,r);case"Link":return this[D0](e,r);case"SymbolicLink":return this[C0](e,r);case"Directory":case"GNUDumpDir":return this[_c](e,r)}}[zs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[Ue](o,t):(this[ur](),t.resume()),i()})}},ui=t=>{try{return[null,t()]}catch(e){return[e,null]}},fu=class extends Rc{sync=!0;[ct](t,e){return super[ct](t,e,()=>{})}[gc](t){if(!this[yi]){let o=this[pn](this.cwd,this.dmode);if(o)return this[Ue](o,t);this[yi]=!0}if(t.absolute!==this.cwd){let o=Y(Le.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[Ue](c,t)}}let[e,r]=ui(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[yc](t);if(e||this[mc](t,r))return this[ct](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?ui(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ct](l,t)}let[o]=ui(()=>re.rmdirSync(String(t.absolute)));this[ct](o,t)}let[i]=t.absolute===this.cwd?[]:ui(()=>Rw(String(t.absolute)));this[ct](i,t)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{re.closeSync(o)}catch(x){u=x}(l||u)&&this[Ue](l||u,t),e()},o;try{o=re.openSync(String(t.absolute),ou(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Ue](l,t)),t.pipe(c)),c.on("data",l=>{try{re.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,u,x)}catch(p){try{re.utimesSync(String(t.absolute),u,x)}catch{l=p}}}if(this[mi](t)){let u=this[wi](t),x=this[_i](t);try{re.fchownSync(o,Number(u),Number(x))}catch(p){try{re.chownSync(String(t.absolute),Number(u),Number(x))}catch{l=l||p}}}i(l)})}[_c](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[Ue](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[mi](t))try{re.chownSync(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)))}catch{}e(),t.resume()}[pn](t,e){try{return yw(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[xi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Le.resolve(c,l);let[u,x]=ui(()=>re.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new Zs(c,Le.resolve(e,r.join("/"))))}i()}[zs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Ue](c,t)}}},kw=t=>{let e=new fu(t),r=t.file,i=X0.statSync(r),o=t.maxReadSize||16*1024*1024;new Yg(r,{readSize:o,size:i.size}).pipe(e)},Ow=(t,e)=>{let r=new Rc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),X0.stat(o,(u,x)=>{if(u)l(u);else{let p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},xu=vi(kw,Ow,t=>new fu(t),t=>new Rc(t),(t,e)=>{e?.length&&W0(t,e)}),Pw=(t,e)=>{let r=new Dc(t),i=!0,o,c;try{try{o=rt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=rt.openSync(t.file,"w+");else throw x}let l=rt.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,_=0;w<512;w+=_){if(_=rt.readSync(o,u,w,u.length-w,c+w),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!_)break e}let x=new Fn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Lw(t,r,c,o,e)}finally{if(i)try{rt.closeSync(o)}catch{}}},Lw=(t,e,r,i,o)=>{let c=new M0(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Nw=(t,e)=>{e=Array.from(e);let r=new Vs(t),i=(o,c,l)=>{let u=(I,E)=>{I?rt.close(o,v=>l(I)):l(null,E)},x=0;if(c===0)return u(null,0);let p=0,w=Buffer.alloc(512),_=(I,E)=>{if(I||E===void 0)return u(I);if(p+=E,p<512&&E)return rt.read(o,w,p,w.length-p,x+p,_);if(x===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let v=new Fn(w);if(!v.cksumValid)return u(null,x);let A=512*Math.ceil((v.size??0)/512);if(x+A+512>c||(x+=A+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,rt.read(o,w,0,512,x,_)};rt.read(o,w,0,512,x,_)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",rt.open(t.file,l,u);if(x||!p)return c(x);rt.fstat(p,(w,_)=>{if(w)return rt.close(p,()=>c(w));i(p,_.size,(I,E)=>{if(I)return c(I);let v=new js(t.file,{fd:p,start:E});r.pipe(v),v.on("error",c),v.on("close",o),Bw(r,e)})})};rt.open(t.file,l,u)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:hu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:hu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},fi=vi(Pw,Nw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!sm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),O2=vi(fi.syncFile,fi.asyncFile,fi.syncNoFile,fi.asyncNoFile,(t,e=[])=>{fi.validate?.(t,e),zw(t)}),zw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var yt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Si(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function pu(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function kc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function gu(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function yr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ke();ne();Oe();Ke();function Kt(t,e){if(Si(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ys(t){return t.startsWith("http://")||t.startsWith("https://")}function Xs(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();ne();var Qs="1008033",mu="1289";var wu="pbbp2",_u="https://www.coze.cn",yu="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",Gw="wss://frontier.coze.cn";function eo(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function Eu(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Gw}function Er(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Ii(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ai=G("handshake");async function Oc(t){let e=eo(t.endpoint),r=t.timeoutMs??1e4,i=`${Xs(e)}${yu}?aid=${encodeURIComponent(Qs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Er(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ai.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 T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let _=w.data??{},I=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,E=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!I||!E){let v=JSON.stringify(w).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ai.info("handshake ok",{remoteDeviceId:E,logid:x,traceId:p}),{accessKey:I,deviceId:E}}catch(u){if(u instanceof T)throw Ai.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ai.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw Ai.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Pc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto",bu=2e5;function vu(t){return{model:Lc(t.model)??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function Su(t){return!t||t===Et}var qw=new Set(["auto","\u81EA\u52A8"]);function Lc(t){let e=t?.trim();if(e)return qw.has(e.toLowerCase())?Et:e}function Au(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Pc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||Et;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Su(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Iu(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||Et}"`):Su(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Pc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??bu;e.push("-c",`model_context_window=${r}`)}return e}function Tu(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Nc(t,e){let{ttEnv:r,usePpe:i}=Ii(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Cu(t,e,r){if(!t.modelToken)return{};let i=Nc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function Mc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Du(t,e,r){if(!t.modelToken)return null;let i=t.model||Et,o=Nc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Pc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??bu,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Ru(t,e,r){if(!t.modelToken)return[];let i=Nc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Ne=G("agent-handlers"),ku=5*1024*1024,Vw=1,Jw=6,Zw=new Set(["node_modules",".git",".coze","dist","build",".next"]),to=class{constructor(e){this.opts=e}opts;async listSkills(e){Kt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??$e(r).workspace,c=i?.skills??[],l=[];for(let u of c){let x=Ot(o,u.relPath,"SKILL.md");await Ww(x).then(w=>w.isFile()).catch(()=>!1)&&l.push(t_(u))}return{skills:l}}async addSkills(e){Kt(e._meta,"_agent/addSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of o){let p=await Hc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});jc(c,l,p),u.push(x)}return await os(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Kt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let x=Ot(i.workspace,u.relPath);await jw(x,{recursive:!0,force:!0}),Ne.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await os(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ne.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Ne.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(p=>Ne.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 Ne.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await He(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ne.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ne.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ye(i),Ne.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ye(i),Ne.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Ne.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Kt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Lc(e.model)??Et,i=await He(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ye(i),Ne.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ne.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Ne.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Ne.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Kt(e._meta,yt.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,yt.RESET),await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ne.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await Yr(e,o)}async clearPersistedAcpSessionIds(e){let r=await He(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Ye(r)}async repairAgent(e){if(Kt(e._meta,yt.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Ne.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ne.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ne.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Kt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Bc(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 Zr(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=f_(e.depth);return u.isDirectory()?{tree:await u_(o,l,c,x)}:{tree:[{name:x_(c),path:zu(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Kt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Bc(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 Zr(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>ku)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${ku})`);let l=await Ou(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??$e(e).workspace}safeJoin(e,r){let i=Uc(e,r||"."),o=qc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Pu}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return He(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function Yw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Xw(t){return t==="claude-code"?Ot(".claude","skills"):Ot(".agents","skills")}var Qw=3e4,e_=50*1024*1024,br=3e4;async function Hc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new 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=Yw(o.skillName),x=Xw(i),p=Ot(x,u),w=Ot(r,p);if(await zc(w,{recursive:!0}),c){let I=Buffer.from(o.content,"utf8");Ti(I.length),await Fc(Ot(w,"SKILL.md"),I,"utf8")}else{let I=await n_(o.downloadUrl);i_(I)?await c_(I,w):s_(I)?await o_(I,w):await Fc(Ot(w,"SKILL.md"),I.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 Ne.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),_}function jc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function t_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function n_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ti(e);let r=r_(t);return Ti(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Ou(e);return Ti(r.length),r}if(Ys(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ti(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ti(t){if(t>e_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(t){return t.length>=2&&t[0]===31&&t[1]===139}function s_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function Gc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new Mu.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||Gc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=a_(i),c=Uc(e);for(let l of i){if(Gc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Uc(e,u),p=qc(c,x);if(p.startsWith("..")||p==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await zc(x,{recursive:!0});continue}await zc(Kw(x),{recursive:!0});let w;try{w=l.getData()}catch(_){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${_.message}`,{cause:_})}await Fc(x,w)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||Gc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=xu({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`))},br);try{await Nu(Lu.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`))},br);try{await Nu(Lu.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var l_=5e3;async function u_(t,e,r,i){return Bu(t,e,r,i,{count:0})}async function Bu(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Hw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(Zw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ot(e,u.name),p=$w(Ot(r,u.name)),w=null;try{w=await Bc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let _={name:u.name,path:zu(qc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(_.children=await Bu(t,x,p,i-1,o)),l.push(_)}return l.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),l}function f_(t){return!t||t<=0?Vw:Math.min(t,Jw)}function x_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function zu(t){return t.split(Pu).join("/")}ne();import{readFileSync as qA}from"node:fs";import{dirname as jA,join as WA}from"node:path";import{fileURLToPath as $A}from"node:url";var vr="0.1.98-alpha.0";var wn=G("agent-health-reporter"),h_=1e4,Ci=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??h_}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),wn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),wn.info("heartbeat stopped"))}async tick(){if(this.inFlight){wn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){wn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=p_(l);if(!u)continue;let x={agentId:l.agentId,status:u};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){wn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(wn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){wn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){wn.warn("onTickEnd hook failed",{err:String(r)})}}};function p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as cy,mkdir as uo,rm as dy,stat as ly,writeFile as uy}from"node:fs/promises";import{homedir as fy}from"node:os";import{join as Vc}from"node:path";nn();import{spawnSync as O_}from"node:child_process";import{existsSync as P_}from"node:fs";import{release as L_}from"node:os";import{basename as N_,isAbsolute as M_}from"node:path";function Di(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ar(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var no=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ee={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function Fu(t){return"method"in t&&"id"in t&&t.id!==void 0}function Uu(t){return"method"in t&&!("id"in t)}function ro(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ee.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ee.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ee.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ee.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ri(t.message)}:typeof t=="string"?Ri(t):typeof t=="object"?__(t):t}var w_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Ri(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ri(i):e[r]=i;return e}function ki(t){if(t instanceof T){let e=m_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:g_[t.code]??ee.INTERNAL_ERROR,message:Ri(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:Ri(t instanceof Error?t.message:String(t))}}function Gu(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 Hu(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var qu=10*1024*1024,io=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>qu){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${qu} 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 Wu={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},iI=Object.fromEntries(Object.entries(Wu).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ir=class{seq=0;next(e,r){this.seq+=1;let i=Wu[e]??E_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>ju(r?.[x]??"")),u=b_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>ju(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function E_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function ju(t){return t.replace(/[:_\s]+/g,"-")}function b_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Jr();import{readFileSync as v_}from"node:fs";var S_=384;async function Wc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:S_})}function Kc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Ku(t,e,r={},i=o=>o){return{...i({...t,...Kc(e)}),...r}}yn();Xi();Ke();ne();Oe();var k_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function Zu(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=Ft("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),z_=200,F_=40,U_=Ft("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),G_=Ft("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),q_=Ft("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Yu=500;function H_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Yu?t:`${e.slice(0,Yu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Xu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),O_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function Qu(t){try{return P_(t)}catch{return}}function j_(t,e){return{platform:process.platform,osRelease:L_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?Qu(e.command):void 0,cwd:e.cwd,cwdExists:Qu(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${N_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new io({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ir;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Ku(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=dt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>z_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=j_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",W_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Xu(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Xu(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=U_,i=G_,o=q_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ar(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_n(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),u=Di(l,e,r),x=(()=>{if(typeof r!="object"||r===null)return;let _=r.sessionId;return typeof _=="string"?_:void 0})(),p=i>0&&Number.isFinite(i),w=o>0&&Number.isFinite(o);return new Promise((_,I)=>{let E={resolve:_,reject:I,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(p){let S=()=>{E.timer=setTimeout(()=>{let C=Date.now()-v;if(this.inflightAgentRequests.size>0&&C<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:C,approvalMaxMs:c,...x?{sessionId:x}:{}}),S();return}this.pending.delete(l),E.firstUpdateTimer&&clearTimeout(E.firstUpdateTimer);let P=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:P,...x?{sessionId:x}:{}}),I(P?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let A=w?()=>{E.firstUpdateTimer&&clearTimeout(E.firstUpdateTimer),E.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),A?.();return}E.timer&&clearTimeout(E.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),I(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;E.onFirstUpdate=w?()=>{E.firstUpdateTimer&&clearTimeout(E.firstUpdateTimer),E.firstUpdateTimer=null,E.onFirstUpdate=null}:null,this.pending.set(l,E),A?.();try{this.writeFrame(u)}catch(S){E.timer&&clearTimeout(E.timer),E.firstUpdateTimer&&clearTimeout(E.firstUpdateTimer),this.pending.delete(l),I(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Hu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(ro(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(Gu(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:H_(e.result)}),r.resolve(e.result));return}if(Uu(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Fu(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_n(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(_n(e.id,ki(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(F_).join(`
|
|
95
|
+
`),o=Zu(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var so=class extends Pt{framework="claude-code";constructor(e){let{command:r,args:i}=Vr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return K_(e)}};nn();import{mkdirSync as $_,mkdtempSync as V_,rmSync as J_}from"node:fs";import{tmpdir as Z_}from"node:os";import{join as Y_}from"node:path";var oo=class extends Pt{framework="codex";authMethodId;codexHomeDir;cleanupCodexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Vr("codex",e.command,i),l=e.isolateCodexHome?e.codexHomeDir??V_(Y_(Z_(),"coze-bridge-codex-home-")):void 0,u=!!l&&!e.codexHomeDir;l&&e.codexHomeDir&&$_(l,{recursive:!0});let x=l?{...e.env??{},CODEX_HOME:l}:e.env,p={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...x?{env:x}:{}};super(p),this.authMethodId=e.authMethodId,this.codexHomeDir=l,this.cleanupCodexHomeDir=u}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&&this.cleanupCodexHomeDir)try{J_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var X_=3e4,Tr=class extends Pt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},X_))}get acpSessionName(){return this.sessionName}};Ke();ne();Oe();function $c(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();var En=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var ao=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new En,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Oi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Oi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();ne();import{constants as ef}from"node:fs";import{access as Q_}from"node:fs/promises";import{delimiter as ey,join as ty}from"node:path";var bt=G("framework-detector"),tf={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ny=[".exe",".cmd",".bat",".ps1"],Gn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??dt,access:e.access??Q_}}async detect(e){let r=tf[e],i=await this.which(r);if(!i)return bt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(tf).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(ey).filter(Boolean),i=this.env.platform==="win32"?["",...ny]:[""];for(let o of r)for(let c of i){let l=ty(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?ef.F_OK:ef.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return bt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return bt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return bt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return bt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(bt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(bt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return bt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return bt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||bt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){bt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(iy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),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)}})}},ry=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function iy(t){return t.replace(ry,"")}import{homedir as sy}from"node:os";import{join as oy}from"node:path";yn();Ke();Jr();ne();async function sf(){let t=oy(sy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var nf=G("openclaw.config"),ay=[0,5e3,5e3],rf="models.providers.",co="agents.defaults.models",lo=class{command;env;retryDelaysMs;queue=new En;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??ay}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,nf.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=dt(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){nf.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",`${rf}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${rf}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${co}[${e}]`,()=>this.runCli(["config","set",co,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${co}[${e}]`,`${co}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var pe=G("agent-manager"),xy=(t,e,r,i,o,c,l,u,x,p)=>{switch(t){case"claude-code":{let w={...o?{...Au(o),...Cu(o,l,u)}:{},...x??{},IS_SANDBOX:"1"};return new so({cwd:r,env:w,agentId:i})}case"codex":{let _=[...o?[...Iu(o),...Ru(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],I={...o?Tu(o):{},...x??{}},E=!!o;return new oo({cwd:r,agentId:i,..._.length>0?{extraArgs:_}:{},...Object.keys(I).length>0?{env:I}:{},...E?{authMethodId:"openai-api-key",isolateCodexHome:!0,codexHomeDir:p}:{}})}case"openclaw":return new Tr({command:e,cwd:r,agentId:i,...c?{sessionName:$c(c)}:{}})}};function Jc(t){return t==="claude-code"||t==="codex"}function hy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(py(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
96
96
|
`)}
|
|
97
|
-
`}function
|
|
98
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var py={path:"",version:"cloud-deployed"},s0="openclaw_gateway_unavailable",gy="openclaw_default_agent_missing";function o0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var my={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},wy=6e4,lo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fy,this.createTimeoutMs=e.createTimeoutMs??wy,this.detectorFactory=e.detectorFactory??(()=>new Fn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new ao({command:r})),this.openclawConfigDir=e.openclawConfigDir??i0(uy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new 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=>{he.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=i0(e,".env");if(await dy(r).then(c=>c.isFile()).catch(()=>!1)){he.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await co(e,{recursive:!0});let o=hy({...process.env,...jc(this.paths.agentEnvFile)});if(await ly(r,o,"utf8"),process.platform!=="win32")try{await ay(r,384)}catch(c){he.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}he.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),he.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=vi(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")he.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>he.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){he.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await Ge(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Je(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){he.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await Ge(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Je(S,this.paths))}return he.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=Ve(e.agentId,this.paths),u=vi(e._meta),h=e.framework==="openclaw"&&u==="local",x;h&&!r?.revive&&(x=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=x??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),m=e.workspace??_??l.workspace,A=new AbortController,y=setTimeout(()=>A.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&Kc(e.framework)&&await Xn(e.framework,A.signal);let S=()=>{if(A.signal.aborted)throw A.signal.reason instanceof Error?A.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await co(l.root,{recursive:!0}),await co(m,{recursive:!0}),await co(l.logs,{recursive:!0}),S(),h||await tr(m,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await wl(m),S();let R=await Ge(e.agentId,this.paths).catch(()=>null),P=bf({model:e.model??R?.model}),w=xf(e._meta)??R?.accountId,C=e.patToken??R?.patToken,D=u==="cloud"?e.modelInfo??R?.modelInfo:void 0;if(v=new so({agentId:e.agentId,framework:e.framework,workspace:m,model:P.model??wt,deployType:u,...w?{accountId:w}:{},...C?{patToken:C}:{},...D?{modelInfo:D}:{}}),v.status="ok",R?.sessions){for(let[J,ee]of Object.entries(R.sessions))v.sessions.set(J,{acpSessionId:ee.acpSessionId,modelToken:ee.modelToken,tokenGeneratedAt:ee.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let V=Object.keys(R.sessions).length;V>0&&he.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:V})}this.registry.register(v),I=!0;let L={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:R?.createdAt??Date.now(),sessions:R?.sessions??{},model:P.model};u==="cloud"&&(L.deployType="cloud"),w&&(L.accountId=w),C&&(L.patToken=C),D&&(L.modelInfo=D),R?.skills&&(L.skills=R.skills),R?.agentName&&(L.agentName=R.agentName),R?.description&&(L.description=R.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,m)):he.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let V=[...L.skills??[]],J=new Map(V.map((_e,fe)=>[_e.skillId,fe])),ee=await Promise.allSettled(B.map(_e=>Gc({agentId:e.agentId,workspace:m,framework:e.framework,skill:_e}))),X=0;for(let[_e,fe]of ee.entries()){let k=B[_e];k&&(fe.status==="fulfilled"?(Hc(V,J,fe.value),X++):he.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:k.skillId,skillName:k.skillName,err:String(fe.reason)}))}X>0&&(L.skills=V,he.info("initialSkills installed",{agentId:e.agentId,installed:X,requested:B.length}))}return await Je(L,this.paths),he.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(S){throw he.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await cy(l.root,{recursive:!0,force:!0}).catch(R=>he.warn("rm agent dir failed (ignored)",{err:String(R)})),S instanceof T?S:new T("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&Kc(e.framework))u=py;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);Kc(e.framework)&&!ts(e.framework)&&(he.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await Xn(e.framework));let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;e.framework==="openclaw"?x=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):x=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await x.start(),await x.initialize(my),x}catch(_){let m=x instanceof Dt?x.getStderrTail():[];throw m.length>0&&he.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof T?_.code:"unknown",recentStderr:m}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,_)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",o0(o),{cause:{reason:s0}})}catch(o){he.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};he.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 he.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:gy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",o0(r),{cause:{reason:s0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=Wc(o);if(r.deployType==="local"){let A=await this.ensureOpenclawDefaultAgent();return new Ir({command:u,cwd:A.workspace,agentId:A.id,sessionName:h})}let x=await r0(),_=i?Rf(i,c,l):null,m;if(_){let A=Nc(o),v=_.models[0]?.id??wt,I=`${A}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(A,_),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}m=I}return new Ir({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...x?{gatewayToken:x}:{},...m?{slashModelOnStart:m}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Nc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,he.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,he.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as u0}from"node:crypto";import{promises as Ay}from"node:fs";import{basename as f0}from"node:path";je();te();import{promises as yy}from"node:fs";import{basename as Ey}from"node:path";var a0=U("file-upload"),by="/api/coze_claw/file/agent_upload",vy=6e4;async function c0(t,e={}){let i=`${Zs(Xs(e.handshakeBase))}${by}`,o=e.timeoutMs??vy,c=await yy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",..._r(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,x=setTimeout(()=>h.abort(),o);a0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(i,{method:"POST",headers:u,body:l,signal:h.signal}),m=_.headers.get("x-tt-logid")??"";if(!_.ok){let v=await _.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${m}: ${v.slice(0,200)}`)}let A=await _.json();if(A.code!==void 0&&A.code!==0)throw new T("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${m}`);let y=A.data?.file?.file_url;if(!y)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${m}: ${JSON.stringify(A).slice(0,200)}`);return a0.info("file upload ok",{uri:y,logid:m}),{uri:y}}catch(_){throw _ instanceof T?_:_.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Ey(t.path)}`):new T("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(x)}}je();te();import{extname as Sy}from"node:path";var Iy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function d0(t){let e=Sy(t).toLowerCase();return Iy[e]??"application/octet-stream"}De();var uo=U("agent-send"),l0=50*1024*1024;function h0(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 x0(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){u=x,h<2&&(uo.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(x)}),await new Promise(_=>setTimeout(_,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function p0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!await Jr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ay.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>l0)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${l0}`);let c=await d0(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??f0(t.path),u;try{u=await c0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw uo.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:u0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),uo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function g0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new 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??f0(t.path),c={sessionUpdate:"group_file",messageId:u0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),uo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function m0(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}Qt();mn();te();var kt=U("coze-cli-installer"),w0="@coze/cli@latest",Ty="coze",_0="0.1.8",Ry=5e3,Cy=5e3,Dy=9e4,y0=1e4,Oi=null,fo=!1;async function $c(t,e={}){if(fo)return;if(Oi)return Oi;let r=e.exec??Vf;return Oi=(async()=>{try{let i=await ky(Ty,r),o=!1;if(i){let l=await Oy(r);if(l===void 0)kt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(m0(l,_0))kt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:_0}),o=!0;else{kt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),fo=!0;return}}let c=o?"upgrade-only":"full";kt.info("coze-cli install start",{package:w0,mode:c});try{await r("npm",["i","-g","--prefer-online",w0],{timeout:Dy,maxBuffer:10*1024*1024}),kt.info("coze-cli install ok")}catch(l){kt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){fo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:y0}),kt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){kt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:y0}),kt.info("coze auth login ok")}catch(l){kt.warn("coze auth login failed",{err:String(l)});return}fo=!0}finally{Oi=null}})(),Oi}async function ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Ry});return _a(i)}catch{return}}async function Oy(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Cy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Vr();De();var Py=10*6e4;function E0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Py:e}function ho(t){return Qn(t??Y().configFile)}function Pi(t,e){return er(e??Y().configFile,t)}import{randomBytes as Qy}from"node:crypto";Zi();je();te();import{createReadStream as Ny}from"node:fs";import{mkdir as Ly,readFile as My,realpath as By,stat as zy,writeFile as Fy}from"node:fs/promises";import{basename as Uy,dirname as Vc,isAbsolute as Gy,join as Hy,relative as qy,resolve as b0,sep as jy}from"node:path";import{createInterface as Wy}from"node:readline";var S0=U("fs-rpc"),Ni=Mt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function I0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ni)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ni} bytes`);let i=await T0(t.path,e);return await Ly(Vc(i),{recursive:!0}),await Fy(i,t.content,"utf8"),S0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function A0(t,e){let r=await T0(t.path,e),i=await zy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ni&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ni} bytes`);let c;if(o&&i.size>Ni)c=await Ky(r,t.line??1,t.limit);else{let l=await My(r,"utf8");if(o){let u=l.split(`
|
|
99
|
-
`),
|
|
100
|
-
`)}else c=l}return
|
|
101
|
-
`)}async function T0(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(b0(e)),v0(b0(t))]),o=qy(r,i);if($y(o,jy,Gy(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function $y(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function v0(t){let e=[],r=t;for(;r!==Vc(r);)try{let i=await By(r);return e.length?Hy(i,...e.reverse()):i}catch{e.push(Uy(r)),r=Vc(r)}return t}te();var R0=U("prompt-multimodal"),C0=10*1024*1024,Vy=15e3,Jy=6;async function D0(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await Zy(l))}}let o=Array.from({length:Math.min(Jy,t.length)},()=>i());return await Promise.all(o),e}function k0(t){return t.some(e=>e.type==="image")}async function Zy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Js(e.uri))return t;try{let{buf:r,contentType:i}=await Xy(e.uri),o=e.mimeType||Yy(i)||"application/octet-stream";return R0.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return R0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Yy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Xy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Vy);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>C0)throw new Error(`image too large: ${o.byteLength} bytes (max ${C0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}en();je();te();var $=U("core"),eE=3e4,tE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",rE="\u5BA1\u6279\u5DF2\u8D85\u65F6",iE=3e4,xo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Sr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=E0(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),ki(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(gn(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>$.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(to(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&tE.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(vr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(vr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(vr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(gn(r,Di(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let h=o.sessions.get(c);if(h?.pendingPermission){let x=r._meta?.cozeTriggerMsgId,_=Cc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,h,c,nE,x,_)}}let l=Date.now(),u=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,h}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=pf(i);switch(r){case"session/new":{let c=sE();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(u.acpSessionId,h):e.activeTriggers.delete(u.acpSessionId);let x=Cc(i._meta);if(x?e.activeGroupIds.set(u.acpSessionId,x):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&k0(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await D0(c.prompt);try{let m=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:_});return u.lastActiveAt=Date.now(),m}catch(m){if(m instanceof T&&m.code==="AGENT_APPROVAL_TIMEOUT"){let A=u.pendingPermission;A&&(A.downstream.respondAgentRequest(A.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(A.upstreamId),u.pendingPermission=void 0);let y=u.acpSessionId,v=y?e.activeTriggers.get(y):void 0,I=y?e.activeGroupIds.get(y):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,rE,v,I)}throw m}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let m=u.downstream;m&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),m.stop("reload-after-turn").catch(A=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(A)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(mt.GEN_MODEL_TOKEN,i,iE);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(ki(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let _=await h.sessionNew({cwd:e.workspace});i.acpSessionId=_.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)}h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(ki(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(br("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(br("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(h=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(h)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(cE(r)){$.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(br("session/update",{...r,sessionId:o,_meta:l})).catch(x=>$.warn("forward update failed",{agentId:e.agentId,err:String(x)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await I0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await A0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Di(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 _=u?e.activeGroupIds.get(u):void 0;_&&(x.cozeGroupId=_);let m=u?this.reverseSessionId(e,u):void 0,A=m?e.sessions.get(m):void 0;A&&(A.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...m?{sessionId:m}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:m}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:m,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ri(o,"session/request_permission",y)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&oE(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new eo(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=eE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new 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(Ri(o,e,r)).catch(h=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Zr(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(gn(e,{code:r,message:i,data:{bridgeVersion:Er}}))}};function sE(){return Qy(16).toString("hex")}function oE(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var aE=["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 cE(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 aE.some(c=>o.startsWith(c))}te();De();import{randomBytes as dE}from"node:crypto";import{chmod as lE,mkdir as uE,writeFile as O0}from"node:fs/promises";import{createServer as fE}from"node:http";import{dirname as hE}from"node:path";var xE=1e6,Jc=U("ipc"),po=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??Y()}async start(){this.token=dE(32).toString("hex");let e=fE((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(),Jc.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 uE(hE(this.paths.portFile),{recursive:!0}),await O0(this.paths.portFile,String(this.port),"utf8"),await O0(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await lE(this.paths.tokenFile,384)}catch(e){Jc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Li(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Li(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await pE(e)}catch(u){Li(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Li(r,200,u??{ok:!0})}catch(u){Jc.error("IPC handler failed",{key:o,err:String(u)}),Li(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Li(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function pE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>xE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ex=bt(q0(),1);var Jb=bt(zh(),1),Zb=bt(ko(),1),Yb=bt(Rr(),1),Xb=bt(cd(),1),Qb=bt(ud(),1),e1=bt(md(),1),$h=bt(Lo(),1),t1=bt(Kh(),1);var Vh=$h.default;je();te();var Re=U("upstream.frontier"),Zh="application/json",Yh="none",r1=15e3;function i1(t){class e extends Vh{constructor(i){super(i,mf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Re.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(nl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var ji=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:wf,..._r(this.opts.ppeOverride)},r=i1(e),i=yf(this.opts.urlOverride),o={url:i,ws:r,fpID:gf,aID:Ys,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Zh,force:!0},payloadEncoding:{encoding:Yh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ex.FWS(o),l=!1,u=null,h,x,_=new Promise((y,v)=>{h=y,x=v}),m=y=>{l||(l=!0,u&&(clearTimeout(u),u=null),y?x(y):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&m();for(let v of this.connectHandlers)Promise.resolve(v({initial:y})).catch(I=>Re.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=y=>{this.opened=!1,Re.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Re.warn("frontier error",{code:y.code,msg:y.message}),m(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let A=this.opts.openTimeoutMs??r1;u=setTimeout(()=>{m(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await _}catch(y){try{c.close(1e3,"open failed")}catch(v){Re.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Re.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Xh(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Zh,payloadEncoding:Yh})}catch(u){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=a1(e);if(!i){Re.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Re.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Re.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Xh(c)||Re.info("frontier frame in",{logid:o1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:s1(i)}),Promise.resolve(this.handler(o)).catch(l=>Re.warn("frontier frame handler threw",{err:String(l)}))}};function Xh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Qh=2e3;function s1(t){return t.length<=Qh?t:`${t.slice(0,Qh)}...<truncated, total ${t.length} chars>`}function o1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function a1(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 _d=U("upstream.switchable"),Bo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;_d.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 _d.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>_d.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 yd=U("upstream"),Nr=class{handler=null;async start(){yd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){yd.info("NoopUpstream stopped",{reason:e})}async send(e){yd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};je();te();te();De();import{promises as Ed}from"node:fs";import{dirname as c1}from"node:path";var d1=U("pat-token-store");async function zo(t=Y()){try{let r=(await Ed.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&d1.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Wi(t,e=Y()){if(!t)throw new Error("writePatToken: empty patToken");await Ed.mkdir(c1(e.patTokenFile),{recursive:!0}),await Ed.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}De();De();import{promises as Fo}from"node:fs";import{join as l1}from"node:path";function u1(t,e){return`#!/bin/sh
|
|
97
|
+
`}function py(t){if(t.includes(`
|
|
98
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var gy={path:"",version:"cloud-deployed"},of="openclaw_gateway_unavailable",my="openclaw_default_agent_missing";function af(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 wy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},_y=6e4,fo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??xy,this.createTimeoutMs=e.createTimeoutMs??_y,this.detectorFactory=e.detectorFactory??(()=>new Gn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new lo({command:r})),this.openclawConfigDir=e.openclawConfigDir??Vc(fy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{pe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=Vc(e,".env");if(await ly(r).then(c=>c.isFile()).catch(()=>!1)){pe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await uo(e,{recursive:!0});let o=hy({...process.env,...Kc(this.paths.agentEnvFile)});if(await uy(r,o,"utf8"),process.platform!=="win32")try{await cy(r,384)}catch(c){pe.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}pe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),pe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=Si(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>pe.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await He(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Ye(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await He(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Ye(S,this.paths))}return pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=$e(e.agentId,this.paths),u=Si(e._meta),x=e.framework==="openclaw"&&u==="local",p;x&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let w=p??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),_=e.workspace??w??l.workspace,I=new AbortController,E=setTimeout(()=>I.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,A=!1;try{i&&Jc(e.framework)&&await er(e.framework,I.signal);let S=()=>{if(I.signal.aborted)throw I.signal.reason instanceof Error?I.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await uo(l.root,{recursive:!0}),await uo(_,{recursive:!0}),await uo(l.logs,{recursive:!0}),S(),x||await rr(_,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await yl(_),S();let C=await He(e.agentId,this.paths).catch(()=>null),P=vu({model:e.model??C?.model}),y=pu(e._meta)??C?.accountId,D=e.patToken??C?.patToken,k=u==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new ao({agentId:e.agentId,framework:e.framework,workspace:_,model:P.model??Et,deployType:u,...y?{accountId:y}:{},...D?{patToken:D}:{},...k?{modelInfo:k}:{}}),v.status="ok",C?.sessions){for(let[V,te]of Object.entries(C.sessions))v.sessions.set(V,{acpSessionId:te.acpSessionId,modelToken:te.modelToken,tokenGeneratedAt:te.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let $=Object.keys(C.sessions).length;$>0&&pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:$})}this.registry.register(v),A=!0;let M={agentId:e.agentId,framework:e.framework,workspace:_,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:P.model};u==="cloud"&&(M.deployType="cloud"),y&&(M.accountId=y),D&&(M.patToken=D),k&&(M.modelInfo=k),C?.skills&&(M.skills=C.skills),C?.agentName&&(M.agentName=C.agentName),C?.description&&(M.description=C.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,_)):pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let $=[...M.skills??[]],V=new Map($.map((Ee,he)=>[Ee.skillId,he])),te=await Promise.allSettled(B.map(Ee=>Hc({agentId:e.agentId,workspace:_,framework:e.framework,skill:Ee}))),Q=0;for(let[Ee,he]of te.entries()){let O=B[Ee];O&&(he.status==="fulfilled"?(jc($,V,he.value),Q++):pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(he.reason)}))}Q>0&&(M.skills=$,pe.info("initialSkills installed",{agentId:e.agentId,installed:Q,requested:B.length}))}return await Ye(M,this.paths),pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:_,framework:e.framework}}catch(S){throw pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),A&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await dy(l.root,{recursive:!0,force:!0}).catch(C=>pe.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof T?S:new T("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&Jc(e.framework))u=gy;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);Jc(e.framework)&&!rs(e.framework)&&(pe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),e.framework==="codex"&&e.deployType==="cloud"?Vc($e(e.agentId,this.paths).root,"codex-home"):void 0);try{return await p.start(),await p.initialize(wy),p}catch(w){let _=p instanceof Pt?p.getStderrTail():[];throw _.length>0&&pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof T?w.code:"unknown",recentStderr:_}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,w)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",af(o),{cause:{reason:of}})}catch(o){pe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};pe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return pe.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:my}})}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",af(r),{cause:{reason:of}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,x=$c(o);if(r.deployType==="local"){let I=await this.ensureOpenclawDefaultAgent();return new Tr({command:u,cwd:I.workspace,agentId:I.id,sessionName:x})}let p=await sf(),w=i?Du(i,c,l):null,_;if(w){let I=Mc(o),v=w.models[0]?.id??Et,A=`${I}/${v}`;if(!this.ensuredProviders.has(A)){let S=this.getOpenclawConfig();await S.ensureProvider(I,w),await S.addModelToAllowlist(A),this.ensuredProviders.add(A)}_=A}return new Tr({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=Mc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as ff}from"node:crypto";import{promises as Ty}from"node:fs";import{basename as xf}from"node:path";Ke();ne();import{promises as Ey}from"node:fs";import{basename as by}from"node:path";var cf=G("file-upload"),vy="/api/coze_claw/file/agent_upload",Sy=6e4;async function df(t,e={}){let i=`${Xs(eo(e.handshakeBase))}${vy}`,o=e.timeoutMs??Sy,c=await Ey.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Er(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);cf.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(i,{method:"POST",headers:u,body:l,signal:x.signal}),_=w.headers.get("x-tt-logid")??"";if(!w.ok){let v=await w.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${_}: ${v.slice(0,200)}`)}let I=await w.json();if(I.code!==void 0&&I.code!==0)throw new T("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${_}`);let E=I.data?.file?.file_url;if(!E)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(I).slice(0,200)}`);return cf.info("file upload ok",{uri:E,logid:_}),{uri:E}}catch(w){throw w instanceof T?w:w.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${by(t.path)}`):new T("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}Ke();ne();import{extname as Ay}from"node:path";var Iy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function lf(t){let e=Ay(t).toLowerCase();return Iy[e]??"application/octet-stream"}Oe();var xo=G("agent-send"),uf=50*1024*1024;function hf(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 pf(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&&(xo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function gf(t,e){let{session:r,runtime:i}=hf(e.core,t.agentId,t.sessionId);if(!await Zr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ty.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>uf)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${uf}`);let c=await lf(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??xf(t.path),u;try{u=await df({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw xo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof T?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:ff(),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 pf(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),xo.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 mf(t,e){let{session:r,runtime:i}=hf(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??xf(t.path),c={sessionUpdate:"group_file",messageId:ff(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await pf(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),xo.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 wf(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}nn();yn();ne();var Lt=G("coze-cli-installer"),_f="@coze/cli@latest",Cy="coze",yf="0.1.8",Dy=5e3,Ry=5e3,ky=9e4,Ef=1e4,Pi=null,ho=!1;async function Zc(t,e={}){if(ho)return;if(Pi)return Pi;let r=e.exec??Ju;return Pi=(async()=>{try{let i=await Oy(Cy,r),o=!1;if(i){let l=await Py(r);if(l===void 0)Lt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(wf(l,yf))Lt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:yf}),o=!0;else{Lt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),ho=!0;return}}let c=o?"upgrade-only":"full";Lt.info("coze-cli install start",{package:_f,mode:c});try{await r("npm",["i","-g","--prefer-online",_f],{timeout:ky,maxBuffer:10*1024*1024}),Lt.info("coze-cli install ok")}catch(l){Lt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){ho=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Ef}),Lt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Lt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Ef}),Lt.info("coze auth login ok")}catch(l){Lt.warn("coze auth login failed",{err:String(l)});return}ho=!0}finally{Pi=null}})(),Pi}async function Oy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Dy});return Ea(i)}catch{return}}async function Py(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Ry});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Jr();Oe();var Ly=10*6e4;function bf(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ly:e}function po(t){return tr(t??X().configFile)}function Li(t,e){return nr(e??X().configFile,t)}import{randomBytes as eE}from"node:crypto";Xi();Ke();ne();import{createReadStream as Ny}from"node:fs";import{mkdir as My,readFile as By,realpath as zy,stat as Fy,writeFile as Uy}from"node:fs/promises";import{basename as Gy,dirname as Yc,isAbsolute as qy,join as Hy,relative as jy,resolve as vf,sep as Wy}from"node:path";import{createInterface as Ky}from"node:readline";var Af=G("fs-rpc"),Ni=Ft("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function If(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ni)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ni} bytes`);let i=await Cf(t.path,e);return await My(Yc(i),{recursive:!0}),await Uy(i,t.content,"utf8"),Af.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Tf(t,e){let r=await Cf(t.path,e),i=await Fy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ni&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ni} bytes`);let c;if(o&&i.size>Ni)c=await $y(r,t.line??1,t.limit);else{let l=await By(r,"utf8");if(o){let u=l.split(`
|
|
99
|
+
`),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,p).join(`
|
|
100
|
+
`)}else c=l}return Af.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function $y(t,e,r){let i=Ky({input:Ny(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],u=0;try{for await(let x of i)if(u>=o&&u<c&&l.push(x),u++,u>=c)break}finally{i.close()}return l.join(`
|
|
101
|
+
`)}async function Cf(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([Sf(vf(e)),Sf(vf(t))]),o=jy(r,i);if(Vy(o,Wy,qy(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function Vy(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Sf(t){let e=[],r=t;for(;r!==Yc(r);)try{let i=await zy(r);return e.length?Hy(i,...e.reverse()):i}catch{e.push(Gy(r)),r=Yc(r)}return t}ne();var Df=G("prompt-multimodal"),Rf=10*1024*1024,Jy=15e3,Zy=6;async function kf(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await Yy(l))}}let o=Array.from({length:Math.min(Zy,t.length)},()=>i());return await Promise.all(o),e}function Of(t){return t.some(e=>e.type==="image")}async function Yy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ys(e.uri))return t;try{let{buf:r,contentType:i}=await Qy(e.uri),o=e.mimeType||Xy(i)||"application/octet-stream";return Df.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 Df.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Xy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Qy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Jy);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Rf)throw new Error(`image too large: ${o.byteLength} bytes (max ${Rf})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();Ke();ne();var K=G("core"),tE=3e4,nE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,rE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",iE="\u5BA1\u6279\u5DF2\u8D85\u65F6",sE=3e4,go=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ir;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=bf(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(),K.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){K.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),K.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){K.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)&&K.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)=>{K.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Oi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){K.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(_n(o,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>K.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){K.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(ro(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&nE.test(i)?this.currentCozeEnv=i:i&&K.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):K.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ar(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ar(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ar(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):K.warn("drop unknown notification",{method:e.method})}catch(o){K.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,ki(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,w=kc(r._meta);return K.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,rE,p,w)}}let l=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{K.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}=gu(i);switch(r){case"session/new":{let c=oE();return K.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return K.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let p=kc(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Of(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await kf(c.prompt);try{let _=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),_}catch(_){if(_ instanceof T&&_.code==="AGENT_APPROVAL_TIMEOUT"){let I=u.pendingPermission;I&&(I.downstream.respondAgentRequest(I.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(I.upstreamId),u.pendingPermission=void 0);let E=u.acpSessionId,v=E?e.activeTriggers.get(E):void 0,A=E?e.activeGroupIds.get(E):void 0;return K.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,iE,v,A)}throw _}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let _=u.downstream;_&&(u.downstream=void 0,K.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),_.stop("reload-after-turn").catch(I=>K.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(I)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(K.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(yt.GEN_MODEL_TOKEN,i,sE);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(Oi(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 x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(K.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),K.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){K.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Oi(i),this.isRuntimeBusy(e,i)){K.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)){K.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}K.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=>K.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>K.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){K.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){K.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(dE(r)){K.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(p=>K.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}K.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:ee.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await If(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Tf(c,o);r.respondAgentRequest(i.id,l)}}catch(o){K.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,ki(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let w=u?e.activeGroupIds.get(u):void 0;w&&(p.cozeGroupId=w);let _=u?this.reverseSessionId(e,u):void 0,I=_?e.sessions.get(_):void 0;I&&(I.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let E={...c,..._?{sessionId:_}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:_}),K.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(Di(o,"session/request_permission",E)).catch(v=>{this.pendingUpstream.delete(o),K.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:ee.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(K.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"&&aE(e.result,o),K.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new no(e.error)):i.value.resolve(e.result);return}K.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 K.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=tE){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(Di(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Yr(e.agentId,r,this.paths)}catch(r){K.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(_n(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function oE(){return eE(16).toString("hex")}function aE(t,e){if(!t||typeof t!="object"){K.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){K.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"){K.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")&&K.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var cE=["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 dE(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 cE.some(c=>o.startsWith(c))}ne();Oe();import{randomBytes as lE}from"node:crypto";import{chmod as uE,mkdir as fE,writeFile as Pf}from"node:fs/promises";import{createServer as xE}from"node:http";import{dirname as hE}from"node:path";var pE=1e6,Xc=G("ipc"),mo=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=lE(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(),Xc.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 fE(hE(this.paths.portFile),{recursive:!0}),await Pf(this.paths.portFile,String(this.port),"utf8"),await Pf(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await uE(this.paths.tokenFile,384)}catch(e){Xc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Mi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Mi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await gE(e)}catch(u){Mi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Mi(r,200,u??{ok:!0})}catch(u){Xc.error("IPC handler failed",{key:o,err:String(u)}),Mi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Mi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function gE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>pE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var nh=At(jf(),1);var Zb=At(Ux(),1),Yb=At(Po(),1),Xb=At(Rr(),1),Qb=At(ud(),1),ev=At(hd(),1),tv=At(yd(),1),Jx=At(Bo(),1),nv=At(Vx(),1);var Zx=Jx.default;Ke();ne();var Re=G("upstream.frontier"),Xx="application/json",Qx="none",iv=15e3;function sv(t){class e extends Zx{constructor(i){super(i,wu,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Re.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(il("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Wi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:_u,...Er(this.opts.ppeOverride)},r=sv(e),i=Eu(this.opts.urlOverride),o={url:i,ws:r,fpID:mu,aID:Qs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Xx,force:!0},payloadEncoding:{encoding:Qx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new nh.FWS(o),l=!1,u=null,x,p,w=new Promise((E,v)=>{x=E,p=v}),_=E=>{l||(l=!0,u&&(clearTimeout(u),u=null),E?p(E):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&_();for(let v of this.connectHandlers)Promise.resolve(v({initial:E})).catch(A=>Re.warn("onConnect handler threw (ignored)",{err:String(A)}))},c.onclose=E=>{this.opened=!1,Re.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},c.onerror=E=>{Re.warn("frontier error",{code:E.code,msg:E.message}),_(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},c.onmessage=E=>this.handleMessage(E),this.fws=c;let I=this.opts.openTimeoutMs??iv;u=setTimeout(()=>{_(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${I}ms (handshake or upgrade slow)`))},I),await c.connect();try{await w}catch(E){try{c.close(1e3,"open failed")}catch(v){Re.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,E}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Re.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method: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;eh(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Xx,payloadEncoding:Qx})}catch(u){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=cv(e);if(!i){Re.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Re.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Re.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;eh(c)||Re.info("frontier frame in",{logid:av(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:ov(i)}),Promise.resolve(this.handler(o)).catch(l=>Re.warn("frontier frame handler threw",{err:String(l)}))}};function eh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var th=2e3;function ov(t){return t.length<=th?t:`${t.slice(0,th)}...<truncated, total ${t.length} chars>`}function av(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function cv(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ne();var bd=G("upstream.switchable"),Fo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;bd.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 bd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>bd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var vd=G("upstream"),Mr=class{handler=null;async start(){vd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){vd.info("NoopUpstream stopped",{reason:e})}async send(e){vd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Ke();ne();ne();Oe();import{promises as Sd}from"node:fs";import{dirname as dv}from"node:path";var lv=G("pat-token-store");async function Uo(t=X()){try{let r=(await Sd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&lv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ki(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await Sd.mkdir(dv(e.patTokenFile),{recursive:!0}),await Sd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Oe();Oe();import{promises as Go}from"node:fs";import{join as uv}from"node:path";function fv(t,e){return`#!/bin/sh
|
|
102
102
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
103
|
-
`}function
|
|
103
|
+
`}function xv(t,e){return`@echo off\r
|
|
104
104
|
"${e}" "${t}" %*\r
|
|
105
|
-
`}async function tx(t,e=Y()){let r=e.binDir;await Fo.mkdir(r,{recursive:!0});let i=l1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?f1(t,o):u1(t,o);return await Fo.readFile(i,"utf8").catch(()=>null)===c||(await Fo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Fo.chmod(i,493)),r}te();De();import{execSync as nx}from"node:child_process";import{readFileSync as rx,unlinkSync as h1}from"node:fs";import{mkdir as x1,readFile as ix,unlink as sx,writeFile as p1}from"node:fs/promises";import{dirname as g1}from"node:path";function Uo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var m1=U("single-instance"),Go=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Y().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(m1.warn("removing stale pid file",{stalePid:e}),await sx(this.pidFile).catch(()=>{})),await x1(g1(this.pidFile),{recursive:!0}),await p1(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await ix(this.pidFile,"utf8")).trim()===String(process.pid)&&await sx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await ix(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Uo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=rx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=nx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=nx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{rx(this.pidFile,"utf8").trim()===String(process.pid)&&h1(this.pidFile)}catch{}})}};Ho();te();var Wn=U("daemon.upstream-watchdog"),I1=12e4,A1=9e5,T1=3e4;function vd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var qo=class{constructor(e){this.opts=e;this.softMs=e.softMs??vd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",I1),this.hardMs=e.hardMs??vd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",A1),this.intervalMs=e.intervalMs??vd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",T1),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?.(),Wn.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&&Wn.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&&Wn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Wn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Wn.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,Wn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Wn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var q=U("daemon"),R1="coze-bridge-daemon";async function cx(){let t=Y();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&el({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:k=>Ve(k,t).logs,listAgentIds:()=>ns(t)});let e=new Go({processTitle:R1}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await ho(),o=i??{};es({pid:process.pid}),q.info(i?"loaded bridge config":"initialized bridge config");try{let k=new Fn;o.frameworksCache=await k.detectAll(),q.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(k){q.warn("framework detection failed",{err:String(k)})}await Pi(o);let c=new Bo(new Nr),l=null,u=new xo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(k,H,j,re)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(k,H,j,re)}});await D1(t,u);let h=new lo({paths:t,config:o,registry:u});l=h;let x,_,m=null,A={},y,v=null,I=null,S=null,R=new wn;function P(k,H){return R.enqueue(()=>C(k,H))}function w(){I||(I=new qo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?P(S,{force:!0}):void 0,onFatal:k=>{if(process.env[Ki]==="1"){q.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:k});return}q.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:k}),process.exit(1)}})),I.start()}async function C(k,H){let j=k,re=j?.privatecode;if(!re)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ke=Ii(j.env),de=j.handshake_url,le=j.frontier_url,Et=ax(j.env,de,le);if(S=j,!H?.force&&x===re&&_===Et){let pe=await C1(t);return u.agents.size===0&&pe?(q.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Wo(t,h).catch(Se=>q.warn("connect-noop auto-revive error (ignored)",{err:String(Se)}))):q.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let dt=!!x&&x!==re,Jt=_!==void 0&&_!==Et,Lt=dt||Jt,Zt=await Dc({privatecode:re,...de?{endpoint:de}:{},ppeOverride:Ke});if(Lt){q.warn("connect config switched, resetting agents",{pcChanged:dt,envChanged:Jt,previousPc:x?jo(x):"",nextPc:jo(re)});for(let pe of[...u.agents.values()])await pe.dispose("connect config switch").catch(()=>{}),u.agents.delete(pe.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Nr,"connect switch").catch(()=>{})}m=Zt.deviceId,es({deviceId:m,pid:process.pid}),$c({patToken:re,env:j.env}).catch(pe=>q.warn("coze-cli setup error (ignored)",{err:String(pe)}));let Fr=new ji({handshake:Zt,privatecode:re,...le?{urlOverride:le}:{},ppeOverride:Ke,getPatTokenForAgent:pe=>u.agents.get(pe)?.patToken});return await c.swap(Fr,"connect"),x=re,_=Et,A=Ke,y=de,j.mock_scenario!==void 0&&(u.setMockScenario(j.mock_scenario),q.info("mock scenario set",{scenario:j.mock_scenario})),v||(v=new Ti({core:u,getDeviceId:()=>m??"",onTickEnd:()=>B.retryPending().catch(pe=>q.warn("detailSync.retryPending failed (ignored)",{err:String(pe)})),onAuthFailures:V})),v.start(),w(),Lt&&Wo(t,h).catch(pe=>q.warn("post-connect-switch auto-revive error (ignored)",{err:String(pe)})),Wi(re,t).catch(pe=>q.warn("writePatToken after /connect failed (ignored)",{err:String(pe)})),q.info("/connect: WS established",{deviceId:m}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async k=>h.createAgent(k.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let D={},L=new Qs({agents:u.agents,disposeAndMarkDisconnected:async(k,H)=>{let j=u.agents.get(k);if(j){await h.cleanupOpenclawSessionProviders(j).catch(Ke=>q.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(Ke)}));let re=!0;try{await j.dispose(`disconnect: ${H}`)}catch(Ke){re=!1,q.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:k,err:String(Ke)}),j.status="error"}re&&(j.status="disconnected",u.unregister(k),u.disconnectedAgents.add(k))}else u.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await h.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,H)=>{await h.openclawRepair(k,H)},isRuntimePendingPermission:k=>u.hasPendingPermissionFor(k)});u.registerExtension("_agent/listSkills",k=>L.listSkills(k.params)),u.registerExtension("_agent/addSkills",k=>L.addSkills(k.params)),u.registerExtension("_agent/removeSkills",k=>L.removeSkills(k.params)),u.registerExtension("_agent/getFileTree",k=>L.getFileTree(k.params)),u.registerExtension("_agent/getFileContent",k=>L.getFileContent(k.params)),u.registerExtension("_agent/update",k=>L.updateAgent(k.params)),u.registerExtension("_agent/disconnect",k=>L.disconnectAgent(k.params)),u.registerExtension("_agent/switchModel",k=>L.switchModel(k.params)),u.registerExtension("_agent/reset",k=>L.resetAgent(k.params)),u.registerExtension("_agent/repair",k=>L.repairAgent(k.params));let B=new os({paths:t,handlers:L,sendDetail:k=>u.sendRequest("_agent/detail",k)});D.ref=B;let V=async k=>{await Promise.allSettled(k.map(async H=>{try{await L.disconnectAgent({agentId:H.agentId,reason:`auth_failure: code=${H.code} ${H.message}`}),q.info("agent disconnected due to auth failure from heartbeat response",{agentId:H.agentId,code:H.code,message:H.message})}catch(j){q.warn("disconnect during authFailure handling failed (ignored)",{agentId:H.agentId,err:String(j)})}}))};c.onConnect(({initial:k})=>{q.info("frontier upstream connected, triggering detail sync",{initial:k}),B.syncAll(k?"initial-connect":"reconnect").catch(H=>q.warn("detail sync top-level error (ignored)",{err:String(H)}))});let J=new po({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let k=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Ki]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:m??"",frameworksCache:o.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let H=k,j=H?.privatecode,re=H?.pairing_code;if(!j||!re)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ke=Ii(H.env),de=H.handshake_url,le=H.frontier_url,Et=ax(H.env,de,le),dt=!!x&&x!==j,Jt=_!==void 0&&_!==Et,Lt=dt||Jt,Zt=await Dc({privatecode:j,...de?{endpoint:de}:{},ppeOverride:Ke});if(Lt){q.warn("pair config switched, resetting agents",{pcChanged:dt,envChanged:Jt,previousPc:x?jo(x):"",nextPc:jo(j),previousEnvKey:_??"",nextEnvKey:Et});for(let Se of[...u.agents.values()])await Se.dispose("pair config switch").catch(()=>{}),u.agents.delete(Se.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Nr,"pair switch").catch(()=>{})}m=Zt.deviceId,es({deviceId:m,pid:process.pid}),$c({patToken:j,env:H.env}).catch(Se=>q.warn("coze-cli setup error (ignored)",{err:String(Se)}));let Fr=new ji({handshake:Zt,privatecode:j,...le?{urlOverride:le}:{},ppeOverride:Ke,getPatTokenForAgent:Se=>u.agents.get(Se)?.patToken});await c.swap(Fr,"pair");try{let Se=new Fn;o.frameworksCache=await Se.detectAll(),await Pi(o),q.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Se){q.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Se)})}let pe=Object.keys(o.frameworksCache??{});try{let Se=await u.sendRequest("_agent/pair",{pairCode:re,patToken:j,frameworks:pe,_meta:{cozeDeviceId:m}});q.info("_agent/pair ok",{pairResult:Se}),x=j,_=Et,A=Ke,y=de,H.mock_scenario!==void 0&&(u.setMockScenario(H.mock_scenario),q.info("mock scenario set",{scenario:H.mock_scenario})),Wi(j,t).catch(Ce=>q.warn("writePatToken after /pair failed (ignored)",{err:String(Ce)})),v||(v=new Ti({core:u,getDeviceId:()=>m??"",onTickEnd:()=>B.retryPending().catch(Ce=>q.warn("detailSync.retryPending failed (ignored)",{err:String(Ce)})),onAuthFailures:V})),v.start(),w(),Lt&&Wo(t,h).catch(Ce=>q.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ce)}));let Kn;return H.agent_id&&(Kn=await k1(H.agent_id,t,h,Ce=>u.sendRequest("_agent/detail",Ce),j).catch(Ce=>(q.error("--agent-id ensureAgent failed",{agentId:H.agent_id,err:String(Ce)}),{ok:!1,agentId:H.agent_id??"",note:String(Ce)}))),{ok:!0,note:"paired with cloud",...Kn?{agent:Kn}:{}}}catch(Se){return q.error("_agent/pair failed",{err:String(Se)}),{ok:!1,note:`pair failed: ${String(Se)}`}}}},{method:"POST",path:"/connect",handler:k=>P(k)},{method:"POST",path:"/_agent/create",handler:async k=>{let H=k;return{ok:!0,result:await h.createAgent(H)}}},{method:"POST",path:"/agent/send",handler:async k=>{let H=k;if(!H?.agentId||!H?.sessionId||!H?.kind||!H?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let j=H;return await(j.groupFile?g0:p0)(j,{core:u,patToken:x,handshakeBase:y,ppeOverride:A})}catch(j){if(j instanceof T)return{ok:!1,code:j.code,message:j.message};throw j}}},{method:"POST",path:"/reload",handler:async k=>{let H=k?.agent_id,j=await u.reloadAgents(H);return q.info("IPC /reload: recycled agent subprocesses",{agentId:H??"(all)",recycled:j}),{ok:!0,recycled:j}}},{method:"POST",path:"/shutdown",handler:async()=>(q.info("IPC /shutdown received"),setImmediate(()=>{fe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await J.start();try{await tx(t.libEntry,t)}catch(k){q.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await u.start(),Wo(t,h).catch(k=>q.warn("auto-revive top-level error (ignored)",{err:String(k)})),ll().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(Qt(),cl));for(let H of["claude-code","codex"]){let j=await k(H);j&&q.info("acp wrapper version",{framework:H,version:j})}}).catch(k=>q.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let _e=null,fe={port:ee,token:X,core:u,ipc:J,shutdown(k){return _e||(q.info("daemon shutdown",{reason:k}),_e=(async()=>{v?.stop(),I?.stop(),await u.stop(k),await J.stop(),await e.release()})(),_e)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{fe.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{q.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{q.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name});try{process.stderr.write(`FATAL uncaughtException: ${k.stack??k.message}
|
|
106
|
-
`)}catch{}process.exit(1)}),
|
|
107
|
-
`;await
|
|
108
|
-
`).filter(l=>l.length>0).filter(l=>
|
|
109
|
-
`)}async function
|
|
110
|
-
`),1;for(let
|
|
111
|
-
`);return 0}let o=t.date??
|
|
105
|
+
`}async function rh(t,e=X()){let r=e.binDir;await Go.mkdir(r,{recursive:!0});let i=uv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?xv(t,o):fv(t,o);return await Go.readFile(i,"utf8").catch(()=>null)===c||(await Go.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Go.chmod(i,493)),r}ne();Oe();import{execSync as ih}from"node:child_process";import{readFileSync as sh,unlinkSync as hv}from"node:fs";import{mkdir as pv,readFile as oh,unlink as ah,writeFile as gv}from"node:fs/promises";import{dirname as mv}from"node:path";function qo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var wv=G("single-instance"),Ho=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(wv.warn("removing stale pid file",{stalePid:e}),await ah(this.pidFile).catch(()=>{})),await pv(mv(this.pidFile),{recursive:!0}),await gv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await oh(this.pidFile,"utf8")).trim()===String(process.pid)&&await ah(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await oh(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return qo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=sh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=ih(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=ih(`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{sh(this.pidFile,"utf8").trim()===String(process.pid)&&hv(this.pidFile)}catch{}})}};jo();ne();var $n=G("daemon.upstream-watchdog"),Iv=12e4,Tv=9e5,Cv=3e4;function Id(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Wo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Id("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Iv),this.hardMs=e.hardMs??Id("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Tv),this.intervalMs=e.intervalMs??Id("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Cv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var H=G("daemon"),Dv="coze-bridge-daemon";async function lh(){let t=X();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&nl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>$e(O,t).logs,listAgentIds:()=>is(t)});let e=new Ho({processTitle:Dv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await po(),o=i??{};ns({pid:process.pid}),H.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Gn;o.frameworksCache=await O.detectAll(),H.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){H.warn("framework detection failed",{err:String(O)})}await Li(o);let c=new Fo(new Mr),l=null,u=new go({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,q,j,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,q,j,ie)}});await kv(t,u);let x=new fo({paths:t,config:o,registry:u});l=x;let p,w,_=null,I={},E,v=null,A=null,S=null,C=new En;function P(O,q){return C.enqueue(()=>D(O,q))}function y(){A||(A=new Wo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?P(S,{force:!0}):void 0,onFatal:O=>{if(process.env[$i]==="1"){H.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}H.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),A.start()}async function D(O,q){let j=O,ie=j?.privatecode;if(!ie)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Je=Ii(j.env),le=j.handshake_url,ue=j.frontier_url,St=dh(j.env,le,ue);if(S=j,!q?.force&&p===ie&&w===St){let me=await Rv(t);return u.agents.size===0&&me?(H.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),$o(t,x).catch(Ie=>H.warn("connect-noop auto-revive error (ignored)",{err:String(Ie)}))):H.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ft=!!p&&p!==ie,Xt=w!==void 0&&w!==St,zt=ft||Xt,Qt=await Oc({privatecode:ie,...le?{endpoint:le}:{},ppeOverride:Je});if(zt){H.warn("connect config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:p?Ko(p):"",nextPc:Ko(ie)});for(let me of[...u.agents.values()])await me.dispose("connect config switch").catch(()=>{}),u.agents.delete(me.agentId);u.disconnectedAgents.size>0&&(H.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"connect switch").catch(()=>{})}_=Qt.deviceId,ns({deviceId:_,pid:process.pid}),Zc({patToken:ie,env:j.env}).catch(me=>H.warn("coze-cli setup error (ignored)",{err:String(me)}));let Gr=new Wi({handshake:Qt,privatecode:ie,...ue?{urlOverride:ue}:{},ppeOverride:Je,getPatTokenForAgent:me=>u.agents.get(me)?.patToken});return await c.swap(Gr,"connect"),p=ie,w=St,I=Je,E=le,j.mock_scenario!==void 0&&(u.setMockScenario(j.mock_scenario),H.info("mock scenario set",{scenario:j.mock_scenario})),v||(v=new Ci({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(me=>H.warn("detailSync.retryPending failed (ignored)",{err:String(me)})),onAuthFailures:$})),v.start(),y(),zt&&$o(t,x).catch(me=>H.warn("post-connect-switch auto-revive error (ignored)",{err:String(me)})),Ki(ie,t).catch(me=>H.warn("writePatToken after /connect failed (ignored)",{err:String(me)})),H.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async O=>x.createAgent(O.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let k={},M=new to({agents:u.agents,disposeAndMarkDisconnected:async(O,q)=>{let j=u.agents.get(O);if(j){await x.cleanupOpenclawSessionProviders(j).catch(Je=>H.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Je)}));let ie=!0;try{await j.dispose(`disconnect: ${q}`)}catch(Je){ie=!1,H.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Je)}),j.status="error"}ie&&(j.status="disconnected",u.unregister(O),u.disconnectedAgents.add(O))}else u.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,q)=>{await x.openclawRepair(O,q)},isRuntimePendingPermission:O=>u.hasPendingPermissionFor(O)});u.registerExtension("_agent/listSkills",O=>M.listSkills(O.params)),u.registerExtension("_agent/addSkills",O=>M.addSkills(O.params)),u.registerExtension("_agent/removeSkills",O=>M.removeSkills(O.params)),u.registerExtension("_agent/getFileTree",O=>M.getFileTree(O.params)),u.registerExtension("_agent/getFileContent",O=>M.getFileContent(O.params)),u.registerExtension("_agent/update",O=>M.updateAgent(O.params)),u.registerExtension("_agent/disconnect",O=>M.disconnectAgent(O.params)),u.registerExtension("_agent/switchModel",O=>M.switchModel(O.params)),u.registerExtension("_agent/reset",O=>M.resetAgent(O.params)),u.registerExtension("_agent/repair",O=>M.repairAgent(O.params));let B=new cs({paths:t,handlers:M,sendDetail:O=>u.sendRequest("_agent/detail",O)});k.ref=B;let $=async O=>{await Promise.allSettled(O.map(async q=>{try{await M.disconnectAgent({agentId:q.agentId,reason:`auth_failure: code=${q.code} ${q.message}`}),H.info("agent disconnected due to auth failure from heartbeat response",{agentId:q.agentId,code:q.code,message:q.message})}catch(j){H.warn("disconnect during authFailure handling failed (ignored)",{agentId:q.agentId,err:String(j)})}}))};c.onConnect(({initial:O})=>{H.info("frontier upstream connected, triggering detail sync",{initial:O}),B.syncAll(O?"initial-connect":"reconnect").catch(q=>H.warn("detail sync top-level error (ignored)",{err:String(q)}))});let V=new mo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[$i]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let q=O,j=q?.privatecode,ie=q?.pairing_code;if(!j||!ie)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=Ii(q.env),le=q.handshake_url,ue=q.frontier_url,St=dh(q.env,le,ue),ft=!!p&&p!==j,Xt=w!==void 0&&w!==St,zt=ft||Xt,Qt=await Oc({privatecode:j,...le?{endpoint:le}:{},ppeOverride:Je});if(zt){H.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:Xt,previousPc:p?Ko(p):"",nextPc:Ko(j),previousEnvKey:w??"",nextEnvKey:St});for(let Ie of[...u.agents.values()])await Ie.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ie.agentId);u.disconnectedAgents.size>0&&(H.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"pair switch").catch(()=>{})}_=Qt.deviceId,ns({deviceId:_,pid:process.pid}),Zc({patToken:j,env:q.env}).catch(Ie=>H.warn("coze-cli setup error (ignored)",{err:String(Ie)}));let Gr=new Wi({handshake:Qt,privatecode:j,...ue?{urlOverride:ue}:{},ppeOverride:Je,getPatTokenForAgent:Ie=>u.agents.get(Ie)?.patToken});await c.swap(Gr,"pair");try{let Ie=new Gn;o.frameworksCache=await Ie.detectAll(),await Li(o),H.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ie){H.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:j,frameworks:me,_meta:{cozeDeviceId:_}});H.info("_agent/pair ok",{pairResult:Ie}),p=j,w=St,I=Je,E=le,q.mock_scenario!==void 0&&(u.setMockScenario(q.mock_scenario),H.info("mock scenario set",{scenario:q.mock_scenario})),Ki(j,t).catch(ke=>H.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),v||(v=new Ci({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(ke=>H.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:$})),v.start(),y(),zt&&$o(t,x).catch(ke=>H.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let Vn;return q.agent_id&&(Vn=await Ov(q.agent_id,t,x,ke=>u.sendRequest("_agent/detail",ke),j).catch(ke=>(H.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",...Vn?{agent:Vn}:{}}}catch(Ie){return H.error("_agent/pair failed",{err:String(Ie)}),{ok:!1,note:`pair failed: ${String(Ie)}`}}}},{method:"POST",path:"/connect",handler:O=>P(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let q=O;return{ok:!0,result:await x.createAgent(q)}}},{method:"POST",path:"/agent/send",handler:async O=>{let q=O;if(!q?.agentId||!q?.sessionId||!q?.kind||!q?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let j=q;return await(j.groupFile?mf:gf)(j,{core:u,patToken:p,handshakeBase:E,ppeOverride:I})}catch(j){if(j instanceof T)return{ok:!1,code:j.code,message:j.message};throw j}}},{method:"POST",path:"/reload",handler:async O=>{let q=O?.agent_id,j=await u.reloadAgents(q);return H.info("IPC /reload: recycled agent subprocesses",{agentId:q??"(all)",recycled:j}),{ok:!0,recycled:j}}},{method:"POST",path:"/shutdown",handler:async()=>(H.info("IPC /shutdown received"),setImmediate(()=>{he.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:te,token:Q}=await V.start();try{await rh(t.libEntry,t)}catch(O){H.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await u.start(),$o(t,x).catch(O=>H.warn("auto-revive top-level error (ignored)",{err:String(O)})),fl().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(nn(),ll));for(let q of["claude-code","codex"]){let j=await O(q);j&&H.info("acp wrapper version",{framework:q,version:j})}}).catch(O=>H.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let Ee=null,he={port:te,token:Q,core:u,ipc:V,shutdown(O){return Ee||(H.info("daemon shutdown",{reason:O}),Ee=(async()=>{v?.stop(),A?.stop(),await u.stop(O),await V.stop(),await e.release()})(),Ee)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{he.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{H.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{H.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
+
`)}catch{}process.exit(1)}),H.info("daemon ready",{port:te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),Pv({cliSpawned:process.env[$i]==="1",readPatToken:()=>Uo(t),connect:P}).catch(O=>H.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(O)})),he}async function Rv(t){return is(t).length>0}function Ko(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function dh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function kv(t,e){let r=is(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),as));for(let c of r){await o(c,t).catch(l=>H.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),H.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){H.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Ov(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),as)),l=await c(t,e);if(l){H.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let w={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}H.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 x={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function $o(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(),as));H.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let x;try{x=await o(u,t)}catch(p){H.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){H.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{H.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let p=Lv(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...p?{_meta:p}:{}},{revive:!0}),c+=1}catch(p){H.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(p)}),l+=1}}return H.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function Pv(t){let e=t.logger??H;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 Lv(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}jo();Oe();import{readFile as uh}from"node:fs/promises";var Yt=class{paths;constructor(e){this.paths=e??X()}async probe(e=1e3){let r=await Vo(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:Mv(i)}}}async request(e){let r=await Vo(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}),x=await u.text();return{status:u.status,body:Nv(x)}}finally{clearTimeout(l)}}};async function Vo(t){try{let[e,r]=await Promise.all([uh(t.portFile,"utf8"),uh(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 Nv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Mv(t){return t instanceof Error?t.message:String(t)}yn();ne();Oe();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}nn();import{chmod as Bv,copyFile as fh,mkdir as hh,readFile as Jo,rename as xh,rm as Td,stat as ph,writeFile as zv}from"node:fs/promises";import{homedir as pD}from"node:os";import{dirname as Fv,join as Br,resolve as Cd,sep as Vi}from"node:path";import{fileURLToPath as Uv}from"node:url";yn();ne();Oe();var Dd=G("dist-install");function Gv(t){let e=Uv(t),r=Fv(e),i=`${Vi}src${Vi}`;if(r.includes(i)||r.endsWith(`${Vi}src${Vi}cli`))return null;let o=Cd(r,"index.js"),c=Cd(r,"..","package.json");return{dist:o,pkgJson:c}}async function kd(t={}){let e=t.paths??X(),r=Gv(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let I=JSON.parse(await Jo(o,"utf8"));c=I.version??"unknown",l=I.dependencies??{}}catch(I){return Dd.warn("cannot read source package.json,skip dist install",{err:String(I)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(I)}`}}let u=$r.map(I=>`${I}@${l[I]??"latest"}`),x=await po(e.configFile)??{},p=x.libVersion,w=await Jo(e.libEntry).then(()=>!0).catch(()=>!1),_=p===c;if(_&&w&&await Rd(e))return{kind:"already-current",libVersion:c};if(!_||!w){await hh(e.libDir,{recursive:!0}),await fh(i,e.libEntry),await fh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let I=Cd(e.libDir,"package.json"),E=`${JSON.stringify({type:"module"},null,2)}
|
|
107
|
+
`;await Jo(I,"utf8").catch(()=>null)!==E&&await zv(I,E)}return(!_||!await Rd(e))&&await(t.installWrappers??qv)(e,u),x.libVersion=c,await Li(x,e.configFile),Dd.info("dist installed",{libEntry:e.libEntry,fromVersion:p,toVersion:c}),_&&w?{kind:"already-current",libVersion:c}:p?{kind:"version-changed",fromVersion:p,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Rd(t){for(let e of $r){let r=Br(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await ph(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function qv(t,e){await Wv(t.installLock,async()=>{if(await Rd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Vi}.staging-${process.pid}-${r}`,o=Br(i,"node_modules"),c=Br(t.libDir,"node_modules");try{await hh(i,{recursive:!0}),await Hv(e,i),await jv(o);let l=`${c}.trash-${r}`;await xh(c,l).catch(()=>{}),await xh(o,c),await Td(l,{recursive:!0,force:!0}).catch(()=>{}),Dd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Td(i,{recursive:!0,force:!0}).catch(()=>{})}})}function Hv(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=dt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",x=>{l.length<8192&&(l+=x.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(u),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${l.trim().slice(0,2e3)}`))})})}async function jv(t){for(let e of $r){let r=Br(t,...e.split("/")),i=JSON.parse(await Jo(Br(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Br(t,".bin",o),l=await ph(c);process.platform!=="win32"&&!(l.mode&73)&&await Bv(c,l.mode|73).catch(()=>{})}}async function Wv(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 Td(t,{force:!0}).catch(()=>{})}}ma();ne();Oe();import{closeSync as mh,fstatSync as wh,openSync as _h,readFileSync as Kv,readSync as $v,readdirSync as Vv,statSync as Jv}from"node:fs";import{join as Zo}from"node:path";var Zv=new Set(["debug","info","warn","error"]);function yh(t){let e=t,r=Sn(e,"--agent-id");e=r.rest;let i=Sn(e,"--date");e=i.rest;let o=Sn(e,"-n","--lines");e=o.rest;let c=Sn(e,"--level");e=c.rest;let l=Sn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),x=Number.isInteger(u)&&u>=0?u:200,p=c.value&&Zv.has(c.value)?c.value:void 0,w={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(w.agentId=r.value),i.value&&(w.date=i.value),p&&(w.level=p),l.value&&(w.grep=l.value),w}function Yv(t,e){return t.agentId?Zo($e(t.agentId,e).logs,Xn("agent",t.date)):Zo(e.bridgeLogsDir,Xn("bridge",t.date))}function Xv(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function Qv(t,e){let r;try{r=Vv(t)}catch{return[]}let i=[];for(let o of r){let c=ga(o,e);if(!c)continue;let l=0;try{l=Jv(Zo(t,o)).size}catch{}i.push({file:Zo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function Eh(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"&&!sl(r,e.level))return!1}return!0}var gh={debug:"90",info:"36",warn:"33",error:"31"},eS=new Set(["ts","level","module","msg"]);function tS(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function bh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=tS(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&gh[o]&&(c=`\x1B[${gh[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([p])=>!eS.has(p)).map(([p,w])=>` ${p}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${l} ${u}${x}`}function nS(t,e,r){let c=Kv(t,"utf8").split(`
|
|
108
|
+
`).filter(l=>l.length>0).filter(l=>Eh(l,{level:e.level,grep:e.grep}));for(let l of Xv(c,e.lines))process.stdout.write(`${bh(l,{raw:e.raw,color:r})}
|
|
109
|
+
`)}async function vh(t,e){let r=e.paths??X(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?$e(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",x=Qv(l,u);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
110
|
+
`),1;for(let p of x)process.stdout.write(`${p.date} ${(p.size/1024).toFixed(1)}KB ${p.file}
|
|
111
|
+
`);return 0}let o=t.date??In(new Date),c=Yv({agentId:t.agentId,date:o},r);try{nS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
112
112
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
113
113
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
114
|
-
`),1}return t.follow&&await
|
|
115
|
-
`);o=
|
|
116
|
-
`)}await new Promise(
|
|
114
|
+
`),1}return t.follow&&await sS(c,t,i),0}var rS=500;function iS(t){try{let e=_h(t,"r");try{return wh(e).size}finally{mh(e)}}catch{return 0}}async function sS(t,e,r){let i=iS(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let x=_h(t,"r");try{let p=wh(x).size;if(p>i){let w=Buffer.allocUnsafe(p-i),_=$v(x,w,0,w.length,i);u=w.subarray(0,_).toString("utf8"),i+=_}}finally{mh(x)}}catch{}if(u){let x=(o+u).split(`
|
|
115
|
+
`);o=x.pop()??"";for(let p of x)p.length>0&&Eh(p,{level:e.level,grep:e.grep})&&process.stdout.write(`${bh(p,{raw:e.raw,color:r})}
|
|
116
|
+
`)}await new Promise(x=>setTimeout(x,rS))}}finally{process.off("SIGINT",l)}}import{basename as oS,resolve as aS}from"node:path";Oe();var cS=9e4,dS={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function lS(t){return dS[t]??1}async function Sh(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>
|
|
117
117
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
118
|
-
`),3;let i=await
|
|
119
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
118
|
+
`),3;let i=await Vo(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
119
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:aS(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 uS(i,"/agent/send",o,cS)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
120
120
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
121
|
-
`),
|
|
122
|
-
`);else{let l=t.name??
|
|
123
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${
|
|
124
|
-
`)}return 0}async function
|
|
125
|
-
`)}function
|
|
121
|
+
`),lS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
122
|
+
`);else{let l=t.name??oS(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${u})
|
|
123
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${fS(c.bytes)})
|
|
124
|
+
`)}return 0}async function uS(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(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function fS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Ph=G("cli");function qe(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function na(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
125
|
+
`)}function MS(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="reload"){let{value:C}=qe(e.slice(1),"--agent-id");return C?{mode:"reload",agentId:C}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return BS(e.slice(1));if(e[0]==="log")return{mode:"log",...yh(e.slice(1))};if(e[0]==="connect")return zS(e.slice(1));if(e.includes("--status"))return na("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return na("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return na("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return na("--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}=qe(r,"--pat-token");r=o;let{value:c,rest:l}=qe(r,"--pair-code");r=l;let{value:u,rest:x}=qe(r,"--env");r=x;let{value:p,rest:w}=qe(r,"--handshake-url");r=w;let{value:_,rest:I}=qe(r,"--frontier-url");r=I;let{value:E,rest:v}=qe(r,"--mock-scenario");r=v;let{value:A}=qe(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return u&&(S.env=u),p&&(S.handshakeUrl=p),_&&(S.frontierUrl=_),E&&(S.mockScenario=E),A&&(S.agentId=A),S}function BS(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}=qe(i,"--caption");i=c;let{value:l,rest:u}=qe(i,"--name");i=u;let{value:x,rest:p}=qe(i,"--agent-id");i=p;let{value:w,rest:_}=qe(i,"--session-id");i=_;let{value:I,rest:E}=qe(i,"--mime");i=E;let v=i.includes("--group-file");i=i.filter(C=>C!=="--group-file");let A=i.includes("--json"),S={mode:"send",kind:e,path:r,json:A};return o&&(S.caption=o),l&&(S.name=l),x&&(S.agentId=x),w&&(S.sessionId=w),v&&(S.groupFile=!0),I&&(S.mimeType=I),S}function zS(t){let e=t,{value:r,rest:i}=qe(e,"--pat-token");e=i;let{value:o,rest:c}=qe(e,"--env");e=c;let{value:l,rest:u}=qe(e,"--handshake-url");e=u;let{value:x,rest:p}=qe(e,"--frontier-url");e=p;let{value:w,rest:_}=qe(e,"--mock-scenario");e=_;let I={mode:"connect"};return r&&(I.privatecode=r),o&&(I.env=o),l&&(I.handshakeUrl=l),x&&(I.frontierUrl=x),w&&(I.mockScenario=w),I}var FS=`
|
|
126
126
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
127
127
|
|
|
128
128
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -201,56 +201,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
201
201
|
|
|
202
202
|
Internal:
|
|
203
203
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
204
|
-
`.trimStart();async function
|
|
205
|
-
`),0;case"daemon":{try{await
|
|
206
|
-
`),1;if(i.kind==="stale")return await
|
|
204
|
+
`.trimStart();async function Lh(t=process.argv,e={}){let r=MS(t);switch(r.mode){case"help":return process.stdout.write(FS),0;case"version":return process.stdout.write(`${vr}
|
|
205
|
+
`),0;case"daemon":{try{await lh()}catch(i){return Ph.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return US(e);case"stop":return Mh(e);case"reload":return HS(r.agentId,e);case"log":return vh(r,e);case"update":return GS(e);case"purge":return jS(e);case"service-install":return WS(e);case"service-uninstall":return KS(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),$S(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),VS(r.privatecode,e,i)}case"send":return Sh({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 Nh(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 US(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
|
|
206
|
+
`),1;if(i.kind==="stale")return await Nh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
207
207
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
208
208
|
${JSON.stringify(o.body,null,2)}
|
|
209
|
-
`),0}async function
|
|
209
|
+
`),0}async function Mh(t){let e=t.paths??X(),r=new Yt(e),i=await Zi(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
210
210
|
`)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
211
211
|
`:`coze-bridge: not running
|
|
212
|
-
`),0;if(c.kind==="stale")return await
|
|
212
|
+
`),0;if(c.kind==="stale")return await Nh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
213
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
214
214
|
`),0}catch(l){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
215
215
|
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
|
|
216
|
-
`),1)}}async function
|
|
217
|
-
`),e(1)})})}async function
|
|
216
|
+
`),1)}}async function GS(t){return await Mh(t),(t.spawnNpx??qS)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function qS(t){return new Promise(e=>{let r=dt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
217
|
+
`),e(1)})})}async function HS(t,e){let r=new Yt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
218
218
|
`),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
219
219
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
220
220
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
221
221
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
222
|
-
`),1}}async function
|
|
222
|
+
`),1}}async function Zi(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(()=>(kh(),Rh)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Bh(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??ch,o=t.waitTimeoutMs??15e3,c=t.sleep??ZS,l=t.paths??X(),u=await Zi(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let x=await Oh(e,o,c);if(x.kind==="connected")return x;Wr(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){Wr(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}await u.uninstall().catch(()=>{}),await JS(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
|
|
223
223
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
224
|
-
`),await i({paths:t.paths}),
|
|
224
|
+
`),await i({paths:t.paths}),Oh(e,o,c)}async function jS(t){let e=new Yt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
225
225
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
226
|
-
`)}await new Promise(l=>setTimeout(l,500))}let i=await
|
|
226
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await Zi(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
227
227
|
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
228
|
-
`)}let o=t.paths??
|
|
228
|
+
`)}let o=t.paths??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}
|
|
229
229
|
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
230
230
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
231
|
-
`),0}async function
|
|
231
|
+
`),0}async function WS(t){let e=await Zi(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
232
232
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
233
233
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
234
|
-
`),1}}async function
|
|
234
|
+
`),1}}async function KS(t){let e=await Zi(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
235
235
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
236
|
-
`),1}}async function
|
|
237
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
238
|
-
`)}let u=await
|
|
239
|
-
`),1;let
|
|
236
|
+
`),1}}async function $S(t,e,r,i={},o){let c=new Yt(r.paths),l=r.paths??X();if(await Wc(l).catch(p=>Wr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(p)})),!r.skipDistInstall){let p=await kd({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
237
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
238
|
+
`)}let u=await Bh(r,c);if(u.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
239
|
+
`),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let p=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let w=p.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
|
|
240
240
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
241
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
242
|
-
`),1}catch(
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
245
|
-
`)}let l=await
|
|
246
|
-
`),1;let u={privatecode:o};r.env&&(u.env=r.env),r.handshakeUrl&&(u.handshake_url=r.handshakeUrl),r.frontierUrl&&(u.frontier_url=r.frontierUrl),r.mockScenario&&(u.mock_scenario=r.mockScenario);try{let
|
|
247
|
-
`),await
|
|
248
|
-
`),1)}catch(
|
|
249
|
-
`),1}}async function
|
|
241
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
|
|
242
|
+
`),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
|
|
243
|
+
`),1}}async function VS(t,e,r={}){let i=e.paths??X(),o=t??await Uo(i);if(!o)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Yt(e.paths);if(await Wc(i).catch(x=>Wr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!e.skipDistInstall){let x=await kd({paths:e.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
244
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
245
|
+
`)}let l=await Bh(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
246
|
+
`),1;let u={privatecode:o};r.env&&(u.env=r.env),r.handshakeUrl&&(u.handshake_url=r.handshakeUrl),r.frontierUrl&&(u.frontier_url=r.frontierUrl),r.mockScenario&&(u.mock_scenario=r.mockScenario);try{let x=await c.request({method:"POST",path:"/connect",body:u,timeoutMs:35e3});return x.status===200&&x.body?.ok?(process.stdout.write(`coze-bridge: connected (${x.body.note??"ok"})
|
|
247
|
+
`),await Ki(o,i).catch(p=>Ph.warn("writePatToken after connect failed (ignored)",{err:String(p)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
|
|
248
|
+
`),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
|
|
249
|
+
`),1}}async function Oh(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 JS(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!qo(u))return;await e(i)}}function ZS(t){return new Promise(e=>setTimeout(e,t))}ne();function YS(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 zh(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=YS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
|
|
250
250
|
`),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
251
251
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
252
252
|
npx -y coze-bridge@latest stop
|
|
253
253
|
npx -y coze-bridge@latest connect
|
|
254
254
|
|
|
255
|
-
`)}
|
|
255
|
+
`)}zh();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&rl("warn");Lh(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
256
256
|
`),process.exit(1)});
|