coze-bridge 0.1.104-alpha.21 → 0.1.104-alpha.22
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 +87 -85
- package/package.json +2 -2
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 mg=Object.create;var va=Object.defineProperty;var wg=Object.getOwnPropertyDescriptor;var _g=Object.getOwnPropertyNames;var yg=Object.getPrototypeOf,bg=Object.prototype.hasOwnProperty;var le=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var rt=(t,e)=>()=>(t&&(e=t(t=0)),e);var oe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Sa=(t,e)=>{for(var r in e)va(t,r,{get:e[r],enumerable:!0})},Eg=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _g(e))!bg.call(t,o)&&o!==r&&va(t,o,{get:()=>e[o],enumerable:!(i=wg(e,o))||i.enumerable});return t};var Gt=(t,e,r)=>(r=t!=null?mg(yg(t)):{},Eg(e||!t||!t.__esModule?va(r,"default",{value:t,enumerable:!0}):r,t));function Ze(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var or=rt(()=>{"use strict"});import{createWriteStream as vg,mkdirSync as Sg,readdirSync as Ig,unlinkSync as Ag}from"node:fs";import{join as wl}from"node:path";function On(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function ar(t,e){return`${t}-${e}.log`}function Ia(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Tg(t,e,r){let i=c=>{let[d,u,f]=c.split("-").map(Number);return Date.UTC(d??0,(u??1)-1,f??1)};return Math.floor((i(e)-i(t))/864e5)>r}function ds(t,e,r,i){let o;try{o=Ig(t)}catch{return}for(let c of o){let d=Ia(c,e);if(d&&Tg(d,r,i))try{Ag(wl(t,c))}catch{}}}var ti,Aa=rt(()=>{"use strict";ti=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>On(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{Sg(this.dir,{recursive:!0});let r=vg(wl(this.dir,ar(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function
|
|
14
|
-
`,r)}var dn=et(()=>{"use strict"});import{promises as Il,readdirSync as Fg}from"node:fs";import{homedir as Ug}from"node:os";import{sep as qg,join as Ce,resolve as Cl}from"node:path";function Q(t){let e=t??Ug(),r=Ce(e,".coze"),i=Ce(r,"bridge"),o=Ce(i,"lib"),c=Ce(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ce(o,"index.js"),binDir:Ce(i,"bin"),pidFile:Ce(i,"bridge.pid"),portFile:Ce(i,"bridge.port"),tokenFile:Ce(i,"bridge.token"),patTokenFile:Ce(i,"pat-token"),agentEnvFile:Ce(i,"agent-env.json"),logFile:Ce(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ce(c,"daemon-stdio.log"),installLock:Ce(i,"install.lock"),configFile:Ce(i,"config.json"),agentsRoot:Ce(r,"agents")}}function nt(t,e=Q()){let r=Ce(e.agentsRoot,t);return{root:r,config:Ce(r,"config.json"),workspace:Ce(r,"workspace"),logs:Ce(r,"logs")}}function gs(t=Q()){try{return Fg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ai(t,e){let r=await Il.realpath(Cl(t)).catch(()=>null);if(!r)return!1;let i=await Il.realpath(Cl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+qg)}var Le=et(()=>{"use strict"});var _s={};va(_s,{AGENT_CONFIG_FILE_MODE:()=>ms,enforceAgentConfigMode:()=>jg,loadAgentConfig:()=>Fe,persistAgentSessions:()=>ci,persistAgentSkills:()=>ws,saveAgentConfig:()=>rt});import{chmod as Gg,stat as Hg}from"node:fs/promises";function Fe(t,e){return lr(nt(t,e).config)}function rt(t,e){return ur(nt(t.agentId,e).config,t,{mode:ms})}async function jg(t,e){if(process.platform==="win32")return;let r=nt(t,e).config;try{let i=await Hg(r);if(!i.isFile())return;let o=i.mode&511;o!==ms&&(await Gg(r,ms),Tl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Tl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ci(t,e,r){let i=await Fe(t,r);i&&(i.sessions=Object.fromEntries(e),await rt(i,r))}async function ws(t,e,r){let i=await Fe(t,r);i&&(i.skills=e,await rt(i,r))}var Tl,ms,ln=et(()=>{"use strict";dn();re();Le();Tl=H("agent-config"),ms=384});var Pa=ce((L1,kl)=>{kl.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var bs=ce(Ol=>{var Pl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Jg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Pl))Ol[t]=Jg(Pl[t])});var zl=ce((M1,Bl)=>{var Xg=fe("fs"),Ne=fe("path"),Ll=Pa(),Yg=bs(),Qg=typeof process=="object"&&process.platform==="win32",Nl=t=>typeof t=="object"&&t!==null,Ml=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ee(t){this.sep=Ne.sep,this.fs=Xg,Nl(t)&&Nl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Bl.exports=Ee;Ee.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw Yg.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=Ne.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,x){if(l&&x.isDirectory())return o(!1);var h=Ne.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(E,S){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let x=Ne.join(i,u),h=e.fs.statSync(x);(!o||o.test(x))&&l.push(Ne.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};Ee.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Ne.join(t,u),r.fs.stat(u,function(x,h){if(x)return e(x);h&&(i.push(Ne.normalize(u)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(u,function(m,E){if(m)return e(m);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Ml[(t^e)&255]^t>>>8};Ee.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ee.crc32update(r,t[i++]);return~r>>>0};Ee.methodToString=function(t){switch(t){case Ll.STORED:return"STORED ("+t+")";case Ll.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.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=Ne.resolve(Ne.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ne.normalize(Ne.join(t,r.slice(i,o).join(Ne.sep)));if(c.indexOf(t)===0)return c}return Ne.normalize(Ne.join(t,Ne.basename(e)))};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=Qg;Ee.crcTable=Ml});var Ul=ce((B1,Fl)=>{var em=fe("path");Fl.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=em.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Gl=ce((z1,ql)=>{ql.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var hr=ce((F1,xr)=>{xr.exports=zl();xr.exports.Constants=Pa();xr.exports.Errors=bs();xr.exports.FileAttr=Ul();xr.exports.decoder=Gl()});var jl=ce((U1,Hl)=>{var un=hr(),q=un.Constants;Hl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,x=0,h=0,m=0,E=0,S=0,_=0,v=0;t|=un.isWin?2560:768,r|=q.FLG_EFS;let A={extraLen:0},I=y=>Math.max(0,y)>>>0,D=y=>Math.max(0,y)&65535,O=y=>Math.max(0,y)&255;return o=un.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(y){y?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(y){y?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return i},set method(y){switch(y){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}i=y},get time(){return un.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=un.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=I(y)},get timeHighByte(){return O(o>>>8)},get crc(){return c},set crc(y){c=I(y)},get compressedSize(){return l},set compressedSize(y){l=I(y)},get size(){return u},set size(y){u=I(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return h},set extraLength(y){h=y},get extraLocalLength(){return A.extraLen},set extraLocalLength(y){A.extraLen=y},get commentLength(){return m},set commentLength(y){m=y},get diskNumStart(){return E},set diskNumStart(y){E=I(y)},get inAttr(){return S},set inAttr(y){S=I(y)},get attr(){return _},set attr(y){_=I(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return v},set offset(y){v=I(y)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+m},get realDataOffset(){return v+q.LOCHDR+A.fnameLen+A.extraLen},get localHeader(){return A},loadLocalHeaderFromBinary:function(y){var k=y.slice(v,v+q.LOCHDR);if(k.readUInt32LE(0)!==q.LOCSIG)throw un.Errors.INVALID_LOC();A.version=k.readUInt16LE(q.LOCVER),A.flags=k.readUInt16LE(q.LOCFLG),A.flags_desc=(A.flags&q.FLG_DESC)>0,A.method=k.readUInt16LE(q.LOCHOW),A.time=k.readUInt32LE(q.LOCTIM),A.crc=k.readUInt32LE(q.LOCCRC),A.compressedSize=k.readUInt32LE(q.LOCSIZ),A.size=k.readUInt32LE(q.LOCLEN),A.fnameLen=k.readUInt16LE(q.LOCNAM),A.extraLen=k.readUInt16LE(q.LOCEXT);let L=v+q.LOCHDR+A.fnameLen,U=L+A.extraLen;return y.slice(L,U)},loadFromBinary:function(y){if(y.length!==q.CENHDR||y.readUInt32LE(0)!==q.CENSIG)throw un.Errors.INVALID_CEN();t=y.readUInt16LE(q.CENVEM),e=y.readUInt16LE(q.CENVER),r=y.readUInt16LE(q.CENFLG),i=y.readUInt16LE(q.CENHOW),o=y.readUInt32LE(q.CENTIM),c=y.readUInt32LE(q.CENCRC),l=y.readUInt32LE(q.CENSIZ),u=y.readUInt32LE(q.CENLEN),x=y.readUInt16LE(q.CENNAM),h=y.readUInt16LE(q.CENEXT),m=y.readUInt16LE(q.CENCOM),E=y.readUInt16LE(q.CENDSK),S=y.readUInt16LE(q.CENATT),_=y.readUInt32LE(q.CENATX),v=y.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(q.LOCHDR);return y.writeUInt32LE(q.LOCSIG,0),y.writeUInt16LE(e,q.LOCVER),y.writeUInt16LE(r,q.LOCFLG),y.writeUInt16LE(i,q.LOCHOW),y.writeUInt32LE(o,q.LOCTIM),y.writeUInt32LE(c,q.LOCCRC),y.writeUInt32LE(l,q.LOCSIZ),y.writeUInt32LE(u,q.LOCLEN),y.writeUInt16LE(x,q.LOCNAM),y.writeUInt16LE(A.extraLen,q.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(q.CENHDR+x+h+m);return y.writeUInt32LE(q.CENSIG,0),y.writeUInt16LE(t,q.CENVEM),y.writeUInt16LE(e,q.CENVER),y.writeUInt16LE(r,q.CENFLG),y.writeUInt16LE(i,q.CENHOW),y.writeUInt32LE(o,q.CENTIM),y.writeUInt32LE(c,q.CENCRC),y.writeUInt32LE(l,q.CENSIZ),y.writeUInt32LE(u,q.CENLEN),y.writeUInt16LE(x,q.CENNAM),y.writeUInt16LE(h,q.CENEXT),y.writeUInt16LE(m,q.CENCOM),y.writeUInt16LE(E,q.CENDSK),y.writeUInt16LE(S,q.CENATT),y.writeUInt32LE(_,q.CENATX),y.writeUInt32LE(v,q.CENOFF),y},toJSON:function(){let y=function(k){return k+" bytes"};return{made:t,version:e,flags:r,method:un.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(x),extraLength:y(h),commentLength:y(m),diskNumStart:E,inAttr:S,attr:_,offset:v,centralHeaderSize:y(q.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Kl=ce((q1,Wl)=>{var pr=hr(),_e=pr.Constants;Wl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return _e.ENDHDR+o},loadFromBinary:function(c){if((c.length!==_e.ENDHDR||c.readUInt32LE(0)!==_e.ENDSIG)&&(c.length<_e.ZIP64HDR||c.readUInt32LE(0)!==_e.ZIP64SIG))throw pr.Errors.INVALID_END();c.readUInt32LE(0)===_e.ENDSIG?(t=c.readUInt16LE(_e.ENDSUB),e=c.readUInt16LE(_e.ENDTOT),r=c.readUInt32LE(_e.ENDSIZ),i=c.readUInt32LE(_e.ENDOFF),o=c.readUInt16LE(_e.ENDCOM)):(t=pr.readBigUInt64LE(c,_e.ZIP64SUB),e=pr.readBigUInt64LE(c,_e.ZIP64TOT),r=pr.readBigUInt64LE(c,_e.ZIP64SIZE),i=pr.readBigUInt64LE(c,_e.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(_e.ENDHDR+o);return c.writeUInt32LE(_e.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,_e.ENDSUB),c.writeUInt16LE(e,_e.ENDTOT),c.writeUInt32LE(r,_e.ENDSIZ),c.writeUInt32LE(i,_e.ENDOFF),c.writeUInt16LE(o,_e.ENDCOM),c.fill(" ",_e.ENDHDR),c},toJSON:function(){let c=function(l,u){let 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 La=ce(Oa=>{Oa.EntryHeader=jl();Oa.MainHeader=Kl()});var Vl=ce((H1,$l)=>{$l.exports=function(t){var e=fe("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 h=0;h<c.length;h++){var m=c[h];m.copy(u,x),x+=m.length}i&&i(u)}),o.end(t)}}}});var Jl=ce((j1,Zl)=>{var tm=+(process.versions?process.versions.node:"").split(".")[0]||0;Zl.exports=function(t,e){var r=fe("zlib");let i=tm>=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),h=0;x.fill(0);for(var m=0;m<l.length;m++){var E=l[m];E.copy(x,h),h+=E.length}o&&o(x)}),c.end(t)}}}});var tu=ce((W1,eu)=>{"use strict";var{randomFillSync:Xl}=fe("crypto"),nm=bs(),rm=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Ql=(t,e)=>Math.imul(t,e)>>>0,Yl=(t,e)=>rm[(t^e)&255]^t>>>8,di=()=>typeof Xl=="function"?Xl(Buffer.alloc(12)):di.node();di.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 Es={genSalt:di};function vs(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])}vs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Yl(e[0],t),e[1]+=e[0]&255,e[1]=Ql(e[1],134775813)+1,e[2]=Yl(e[2],e[1]>>>24),t};vs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ql(t,t^1)>>8&255};function im(t){let e=new vs(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 sm(t){let e=new vs(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 om(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=im(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw nm.WRONG_PASSWORD();return i(t.slice(12))}function am(t){Buffer.isBuffer(t)&&t.length>=12?Es.genSalt=function(){return t.slice(0,12)}:t==="node"?Es.genSalt=di.node:Es.genSalt=di}function cm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=sm(r),c=Es.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}eu.exports={decrypt:om,encrypt:cm,_salter:am}});var nu=ce(Ss=>{Ss.Deflater=Vl();Ss.Inflater=Jl();Ss.ZipCrypto=tu()});var Ma=ce(($1,ru)=>{var de=hr(),dm=La(),ve=de.Constants,Na=nu();ru.exports=function(t,e){var r=new dm.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:de.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(de.crc32(y)!==r.localHeader.crc)return!1}else{let k={},L=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(L)==ve.LOCSIG||e.readUInt32LE(L)==ve.CENSIG)throw de.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==ve.EXTSIG)k.crc=e.readUInt32LE(L+ve.EXTCRC),k.compressedSize=e.readUInt32LE(L+ve.EXTSIZ),k.size=e.readUInt32LE(L+ve.EXTLEN);else if(e.readUInt16LE(L+12)===19280)k.crc=e.readUInt32LE(L+ve.EXTCRC-4),k.compressedSize=e.readUInt32LE(L+ve.EXTSIZ-4),k.size=e.readUInt32LE(L+ve.EXTLEN-4);else throw de.Errors.DESCRIPTOR_UNKNOWN();if(k.compressedSize!==r.compressedSize||k.size!==r.size||k.crc!==r.crc)throw de.Errors.DESCRIPTOR_FAULTY();if(de.crc32(y)!==k.crc)return!1}return!0}function v(y,k,L){if(typeof k>"u"&&typeof y=="string"&&(L=y,y=void 0),c)return y&&k&&k(Buffer.alloc(0),de.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var U=S();if(U.length===0)return y&&k&&k(U),U;if(r.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw de.Errors.INVALID_PASS_PARAM();U=Na.ZipCrypto.decrypt(U,r,L)}var z=Buffer.alloc(r.size);switch(r.method){case de.Constants.STORED:if(U.copy(z),_(z))return y&&k&&k(z),z;throw y&&k&&k(z,de.Errors.BAD_CRC()),de.Errors.BAD_CRC();case de.Constants.DEFLATED:var Z=new Na.Inflater(U,r.size);if(y)Z.inflateAsync(function(V){V.copy(V,0),k&&(_(V)?k(V):k(V,de.Errors.BAD_CRC()))});else{if(Z.inflate(z).copy(z,0),!_(z))throw de.Errors.BAD_CRC(`"${E.decode(i)}"`);return z}break;default:throw y&&k&&k(Buffer.alloc(0),de.Errors.UNKNOWN_METHOD()),de.Errors.UNKNOWN_METHOD()}}function A(y,k){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&k&&k(S()),S();if(l.length&&!c){var L;switch(r.method){case de.Constants.STORED:return r.compressedSize=r.size,L=Buffer.alloc(l.length),l.copy(L),y&&k&&k(L),L;default:case de.Constants.DEFLATED:var U=new Na.Deflater(l);if(y)U.deflateAsync(function(Z){L=Buffer.alloc(Z.length),r.compressedSize=Z.length,Z.copy(L),k&&k(L)});else{var z=U.deflate();return r.compressedSize=z.length,z}U=null;break}}else if(y&&k)k(Buffer.alloc(0));else return Buffer.alloc(0)}function I(y,k){return de.readBigUInt64LE(y,k)}function D(y){try{for(var k=0,L,U,z;k+4<y.length;)L=y.readUInt16LE(k),k+=2,U=y.readUInt16LE(k),k+=2,z=y.slice(k,k+U),k+=U,ve.ID_ZIP64===L&&O(z)}catch{throw de.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(y){var k,L,U,z;y.length>=ve.EF_ZIP64_SCOMP&&(k=I(y,ve.EF_ZIP64_SUNCOMP),r.size===ve.EF_ZIP64_OR_32&&(r.size=k)),y.length>=ve.EF_ZIP64_RHO&&(L=I(y,ve.EF_ZIP64_SCOMP),r.compressedSize===ve.EF_ZIP64_OR_32&&(r.compressedSize=L)),y.length>=ve.EF_ZIP64_DSN&&(U=I(y,ve.EF_ZIP64_RHO),r.offset===ve.EF_ZIP64_OR_32&&(r.offset=U)),y.length>=ve.EF_ZIP64_DSN+4&&(z=y.readUInt32LE(ve.EF_ZIP64_DSN),r.diskNumStart===ve.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(y){i=de.toBuffer(y,E.encode);var k=i[i.length-1];c=k===47||k===92,r.fileNameLength=i.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,D(y)},get comment(){return E.decode(o)},set comment(y){if(o=de.toBuffer(y,E.encode),r.commentLength=o.length,o.length>65535)throw de.Errors.COMMENT_TOO_LONG()},get name(){var y=E.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return A(!1,null)},getCompressedDataAsync:function(y){A(!0,y)},setData:function(y){l=de.toBuffer(y,de.decoder.encode),!c&&l.length?(r.size=l.length,r.method=de.Constants.DEFLATED,r.crc=de.crc32(y),r.changed=!0):r.method=de.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,k){r.changed?y(l):v(!0,y,k)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),k=de.Constants.CENHDR;return i.copy(y,k),k+=i.length,u.copy(y,k),k+=r.extraLength,o.copy(y,k),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let k=r.localHeaderToBinary(),L=Buffer.alloc(k.length+i.length+r.extraLocalLength);return k.copy(L,y),y+=k.length,i.copy(L,y),y+=i.length,x.copy(L,y),y+=x.length,L},toJSON:function(){let y=function(k){return"<"+(k&&k.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ou=ce((V1,su)=>{var iu=Ma(),lm=La(),$e=hr();su.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new lm.MainHeader,l=!1,u=null;let x=new Set,h=e,{noSort:m,decoder:E}=h;t?v(h.readEntries):l=!0;function S(){let I=new Set;for(let D of Object.keys(i)){let O=D.split("/");if(O.pop(),!!O.length)for(let y=0;y<O.length;y++){let k=O.slice(0,y+1).join("/")+"/";I.add(k)}}for(let D of I)if(!(D in i)){let O=new iu(h);O.entryName=D,O.attr=16,O.temporary=!0,r.push(O),i[O.entryName]=O,x.add(O)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/$e.Constants.CENHDR)throw $e.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,D=0;D<r.length;D++){var O=I,y=new iu(h,t);y.header=t.slice(O,O+=$e.Constants.CENHDR),y.entryName=t.slice(O,O+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(O,O+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(O,O+y.header.commentLength)),I+=y.header.centralHeaderSize,r[D]=y,i[y.entryName]=y}x.clear(),S()}function v(I){var D=t.length-$e.Constants.ENDHDR,O=Math.max(0,D-65535),y=O,k=t.length,L=-1,U=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(O=0),D;D>=y;D--)if(t[D]===80){if(t.readUInt32LE(D)===$e.Constants.ENDSIG){L=D,U=D,k=D+$e.Constants.ENDHDR,y=D-$e.Constants.END64HDR;continue}if(t.readUInt32LE(D)===$e.Constants.END64SIG){y=O;continue}if(t.readUInt32LE(D)===$e.Constants.ZIP64SIG){L=D,k=D+$e.readBigUInt64LE(t,D+$e.Constants.ZIP64SIZE)+$e.Constants.ZIP64LEAD;break}}if(L==-1)throw $e.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,k)),c.commentLength&&(o=t.slice(U+$e.Constants.ENDHDR)),I&&_()}function A(){r.length>1&&!m&&r.sort((I,D)=>I.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(I=>!x.has(I))},get comment(){return E.decode(o)},set comment(I){o=$e.toBuffer(I,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return l||_(),i[I]||null},setEntry:function(I){l||_(),r.push(I),i[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,D=!0){l||_();let O=i[I];this.getEntryChildren(O,D).map(k=>k.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){l||_();let D=i[I],O=r.indexOf(D);O>=0&&(r.splice(O,1),delete i[I],c.totalEntries=r.length)},getEntryChildren:function(I,D=!0){if(l||_(),typeof I=="object")if(I.isDirectory&&D){let O=[],y=I.entryName;for(let k of r)k.entryName.startsWith(y)&&O.push(k);return O}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let D=this.getEntryChildren(I);return D.includes(I)?D.length-1:D.length}return 0},compressToBuffer:function(){l||_(),A();let I=[],D=[],O=0,y=0;c.size=0,c.offset=0;let k=0;for(let z of this.entries){let Z=z.getCompressedData();z.header.offset=y;let V=z.packLocalHeader(),ne=V.length+Z.length;y+=ne,I.push(V),I.push(Z);let X=z.packCentralHeader();D.push(X),c.size+=X.length,O+=ne+X.length,k++}O+=c.mainHeaderSize,c.offset=y,c.totalEntries=k,y=0;let L=Buffer.alloc(O);for(let z of I)z.copy(L,y),y+=z.length;for(let z of D)z.copy(L,y),y+=z.length;let U=c.toBinary();return o&&o.copy(U,$e.Constants.ENDHDR),U.copy(L,y),t=L,l=!1,L},toAsyncBuffer:function(I,D,O,y){try{l||_(),A();let k=[],L=[],U=0,z=0,Z=0;c.size=0,c.offset=0;let V=function(ne){if(ne.length>0){let X=ne.shift(),se=X.entryName+X.extra.toString();O&&O(se),X.getCompressedDataAsync(function(ae){y&&y(se),X.header.offset=z;let N=X.packLocalHeader(),j=N.length+ae.length;z+=j,k.push(N),k.push(ae);let $=X.packCentralHeader();L.push($),c.size+=$.length,U+=j+$.length,Z++,V(ne)})}else{U+=c.mainHeaderSize,c.offset=z,c.totalEntries=Z,z=0;let X=Buffer.alloc(U);k.forEach(function(ae){ae.copy(X,z),z+=ae.length}),L.forEach(function(ae){ae.copy(X,z),z+=ae.length});let se=c.toBinary();o&&o.copy(se,$e.Constants.ENDHDR),se.copy(X,z),t=X,l=!1,I(X)}};V(Array.from(this.entries))}catch(k){D(k)}}}}});var du=ce((Z1,cu)=>{var be=hr(),ye=fe("path"),um=Ma(),fm=ou(),Nn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),au=(...t)=>be.findLast(t,e=>typeof e=="string"),xm=(...t)=>be.findLast(t,e=>typeof e=="function"),hm={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};cu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),hm);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=be.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new be(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=be.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=be.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw be.Errors.INVALID_FILENAME();let c=new fm(r,i),{canonical:l,sanitize:u,zipnamefix:x}=be;function h(_){if(_&&c){var v;if(typeof _=="string"&&(v=c.getEntry(ye.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(v=c.getEntry(_.entryName)),v)return v}return null}function m(_){let{join:v,normalize:A,sep:I}=ye.posix;return v(ye.isAbsolute(_)?"/":".",A(I+_.split("\\").join(I)+I))}function E(_){return _ instanceof RegExp?(function(v){return function(A){return v.test(A)}})(_):typeof _!="function"?()=>!0:_}let S=(_,v)=>{let A=v.slice(-1);return A=A===o.sep?o.sep:"",ye.relative(_,v)+A};return{readFile:function(_,v){var A=h(_);return A&&A.getData(v)||null},childCount:function(_){let v=h(_);if(v)return c.getChildCount(v)},readFileAsync:function(_,v){var A=h(_);A?A.getDataAsync(v):v(null,"getEntry failed for:"+_)},readAsText:function(_,v){var A=h(_);if(A){var I=A.getData();if(I&&I.length)return I.toString(v||"utf8")}return""},readAsTextAsync:function(_,v,A){var I=h(_);I?I.getDataAsync(function(D,O){if(O){v(D,O);return}D&&D.length?v(D.toString(A||"utf8")):v("")}):v("")},deleteFile:function(_,v=!0){var A=h(_);A&&c.deleteFile(A.entryName,v)},deleteEntry:function(_){var v=h(_);v&&c.deleteEntry(v.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,v){var A=h(_);A&&(A.comment=v)},getZipEntryComment:function(_){var v=h(_);return v&&v.comment||""},updateFile:function(_,v){var A=h(_);A&&A.setData(v)},addLocalFile:function(_,v,A,I){if(o.fs.existsSync(_)){v=v?m(v):"";let D=ye.win32.basename(ye.win32.normalize(_));v+=A||D;let O=o.fs.statSync(_),y=O.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);O.isDirectory()&&(v+=o.sep),this.addFile(v,y,I,O)}else throw be.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,v){_=typeof _=="object"?_:{localPath:_};let A=ye.resolve(_.localPath),{comment:I}=_,{zipPath:D,zipName:O}=_,y=this;o.fs.stat(A,function(k,L){if(k)return v(k,!1);D=D?m(D):"";let U=ye.win32.basename(ye.win32.normalize(A));if(D+=O||U,L.isFile())o.fs.readFile(A,function(z,Z){return z?v(z,!1):(y.addFile(D,Z,I,L),setImmediate(v,void 0,!0))});else if(L.isDirectory())return D+=o.sep,y.addFile(D,Buffer.alloc(0),I,L),setImmediate(v,void 0,!0)})},addLocalFolder:function(_,v,A){if(A=E(A),v=v?m(v):"",_=ye.normalize(_),o.fs.existsSync(_)){let I=o.findFiles(_),D=this;if(I.length)for(let O of I){let y=ye.join(v,S(_,O));A(y)&&D.addLocalFile(O,ye.dirname(y))}}else throw be.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,v,A,I){I=E(I),A=A?m(A):"",_=ye.normalize(_);var D=this;o.fs.open(_,"r",function(O){if(O&&O.code==="ENOENT")v(void 0,be.Errors.FILE_NOT_FOUND(_));else if(O)v(void 0,O);else{var y=o.findFiles(_),k=-1,L=function(){if(k+=1,k<y.length){var U=y[k],z=S(_,U).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?o.fs.stat(U,function(Z,V){Z&&v(void 0,Z),V.isFile()?o.fs.readFile(U,function(ne,X){ne?v(void 0,ne):(D.addFile(A+z,X,"",V),L())}):(D.addFile(A+z+"/",Buffer.alloc(0),"",V),L())}):process.nextTick(()=>{L()})}else v(!0,void 0)};L()}})},addLocalFolderAsync2:function(_,v){let A=this;_=typeof _=="object"?_:{localPath:_},localPath=ye.resolve(m(_.localPath));let{zipPath:I,filter:D,namefix:O}=_;D instanceof RegExp?D=(function(L){return function(U){return L.test(U)}})(D):typeof D!="function"&&(D=function(){return!0}),I=I?m(I):"",O=="latin1"&&(O=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=L=>L);let y=L=>ye.join(I,O(S(localPath,L))),k=L=>ye.win32.basename(ye.win32.normalize(O(L)));o.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?v(void 0,be.Errors.FILE_NOT_FOUND(localPath)):L?v(void 0,L):o.findFilesAsync(localPath,function(U,z){if(U)return v(U);z=z.filter(Z=>D(y(Z))),z.length||v(void 0,!1),setImmediate(z.reverse().reduce(function(Z,V){return function(ne,X){if(ne||X===!1)return setImmediate(Z,ne,!1);A.addLocalFileAsync({localPath:V,zipPath:ye.dirname(y(V)),zipName:k(V)},Z)}},v))})})},addLocalFolderPromise:function(_,v){return new Promise((A,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},v),(D,O)=>{D&&I(D),O&&A(this)})})},addFile:function(_,v,A,I){_=x(_);let D=h(_),O=D!=null;O||(D=new um(i),D.entryName=_),D.comment=A||"";let y=typeof I=="object"&&I instanceof o.fs.Stats;y&&(D.header.time=I.mtime);var k=D.isDirectory?16:0;let L=D.isDirectory?16384:32768;return y?L|=4095&I.mode:typeof I=="number"?L|=4095&I:L|=D.isDirectory?493:420,k=(k|L<<16)>>>0,D.attr=k,D.setData(v),O||c.setEntry(D),D},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,v,A,I,D,O){I=Nn(!1,I),D=Nn(!1,D),A=Nn(!0,A),O=au(D,O);var y=h(_);if(!y)throw be.Errors.NO_ENTRY();var k=l(y.entryName),L=u(v,O&&!y.isDirectory?O:A?k:ye.basename(k));if(y.isDirectory){var U=c.getEntryChildren(y);return U.forEach(function(V){if(V.isDirectory)return;var ne=V.getData();if(!ne)throw be.Errors.CANT_EXTRACT_FILE();var X=l(V.entryName),se=u(v,A?X:ye.basename(X));let ae=D?V.header.fileAttr:void 0;o.writeFileTo(se,ne,I,ae)}),!0}var z=y.getData(c.password);if(!z)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(L)&&!I)throw be.Errors.CANT_OVERRIDE();let Z=D?_.header.fileAttr:void 0;return o.writeFileTo(L,z,I,Z),!0},test:function(_){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var A=c.entries[v].getData(_);if(!A)return!1}catch{return!1}return!0},extractAllTo:function(_,v,A,I){if(A=Nn(!1,A),I=au(A,I),v=Nn(!1,v),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(D){var O=u(_,l(D.entryName));if(D.isDirectory){o.makeDir(O);return}var y=D.getData(I);if(!y)throw be.Errors.CANT_EXTRACT_FILE();let k=A?D.header.fileAttr:void 0;o.writeFileTo(O,y,v,k);try{o.fs.utimesSync(O,D.header.time,D.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,v,A,I){if(I=xm(v,A,I),A=Nn(!1,A),v=Nn(!1,v),!I)return new Promise((L,U)=>{this.extractAllToAsync(_,v,A,function(z){z?U(z):L(this)})});if(!c){I(be.Errors.NO_ZIP());return}_=ye.resolve(_);let D=L=>u(_,ye.normalize(l(L.entryName))),O=(L,U)=>new Error(L+': "'+U+'"'),y=[],k=[];c.entries.forEach(L=>{L.isDirectory?y.push(L):k.push(L)});for(let L of y){let U=D(L),z=A?L.header.fileAttr:void 0;try{o.makeDir(U),z&&o.fs.chmodSync(U,z),o.fs.utimesSync(U,L.header.time,L.header.time)}catch{I(O("Unable to create folder",U))}}k.reverse().reduce(function(L,U){return function(z){if(z)L(z);else{let Z=ye.normalize(l(U.entryName)),V=u(_,Z);U.getDataAsync(function(ne,X){if(X)L(X);else if(!ne)L(be.Errors.CANT_EXTRACT_FILE());else{let se=A?U.header.fileAttr:void 0;o.writeFileToAsync(V,ne,v,se,function(ae){ae||L(O("Unable to write file",V)),o.fs.utimes(V,U.header.time,U.header.time,function(N){N?L(O("Unable to set times",V)):L()})})}})}}},I)()},writeZip:function(_,v){if(arguments.length===1&&typeof _=="function"&&(v=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var A=c.compressToBuffer();if(A){var I=o.writeFileTo(_,A,!0);typeof v=="function"&&v(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,v){let{overwrite:A,perm:I}=Object.assign({overwrite:!0},v);return new Promise((D,O)=>{!_&&i.filename&&(_=i.filename),_||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let k=L=>L?D(L):O("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,A,I,k)},O)})},toBufferPromise:function(){return new Promise((_,v)=>{c.toAsyncBuffer(_,v)})},toBuffer:function(_,v,A,I){return typeof _=="function"?(c.toAsyncBuffer(_,v,A,I),null):c.compressToBuffer()}}}});import{execFile as y_,spawn as b_,spawnSync as xI}from"node:child_process";import{promisify as E_}from"node:util";function S_(t){if(process.platform!=="win32")return!1;if(Rf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Rf,"").toLowerCase();return v_.has(r)}function Df(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return S_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function st(t,e=[],r={}){return b_(t,e,Df(t,r))}function kf(t,e=[],r={}){return A_(t,e,Df(t,r))}var v_,Rf,A_,Vt=et(()=>{"use strict";v_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Rf=/\.(cmd|bat|ps1)$/i;A_=E_(y_)});var Jt=ce((JR,lx)=>{"use strict";var cx=["nodebuffer","arraybuffer","fragments"],dx=typeof Blob<"u";dx&&cx.push("blob");lx.exports={BINARY_TYPES:cx,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:dx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ji=ce((XR,Do)=>{"use strict";var{EMPTY_BUFFER:oE}=Jt(),ld=Buffer[Symbol.species];function aE(t,e){if(t.length===0)return oE;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 ld(r.buffer,r.byteOffset,i):r}function ux(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function fx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function cE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ud(t){if(ud.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new ld(t):ArrayBuffer.isView(t)?e=new ld(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ud.readOnly=!1),e}Do.exports={concat:aE,mask:ux,toArrayBuffer:cE,toBuffer:ud,unmask:fx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=fe("bufferutil");Do.exports.mask=function(e,r,i,o,c){c<48?ux(e,r,i,o,c):t.mask(e,r,i,o,c)},Do.exports.unmask=function(e,r){e.length<32?fx(e,r):t.unmask(e,r)}}catch{}});var px=ce((YR,hx)=>{"use strict";var xx=Symbol("kDone"),fd=Symbol("kRun"),xd=class{constructor(e){this[xx]=()=>{this.pending--,this[fd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[fd]()}[fd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[xx])}}};hx.exports=xd});var qr=ce((QR,yx)=>{"use strict";var Xi=fe("zlib"),gx=Ji(),dE=px(),{kStatusCode:mx}=Jt(),lE=Buffer[Symbol.species],uE=Buffer.from([0,0,255,255]),Po=Symbol("permessage-deflate"),Xt=Symbol("total-length"),Fr=Symbol("callback"),Rn=Symbol("buffers"),Ur=Symbol("error"),ko,hd=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,!ko){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ko=new dE(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[Fr];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){ko.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){ko.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"?Xi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Xi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Po]=this,this._inflate[Xt]=0,this._inflate[Rn]=[],this._inflate.on("error",xE),this._inflate.on("data",_x)}this._inflate[Fr]=i,this._inflate.write(e),r&&this._inflate.write(uE),this._inflate.flush(()=>{let c=this._inflate[Ur];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=gx.concat(this._inflate[Rn],this._inflate[Xt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Xt]=0,this._inflate[Rn]=[],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"?Xi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Xi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Xt]=0,this._deflate[Rn]=[],this._deflate.on("data",fE)}this._deflate[Fr]=i,this._deflate.write(e),this._deflate.flush(Xi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=gx.concat(this._deflate[Rn],this._deflate[Xt]);r&&(c=new lE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Fr]=null,this._deflate[Xt]=0,this._deflate[Rn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};yx.exports=hd;function fE(t){this[Rn].push(t),this[Xt]+=t.length}function _x(t){if(this[Xt]+=t.length,this[Po]._maxPayload<1||this[Xt]<=this[Po]._maxPayload){this[Rn].push(t);return}this[Ur]=new RangeError("Max payload size exceeded"),this[Ur].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ur][mx]=1009,this.removeListener("data",_x),this.reset()}function xE(t){if(this[Po]._inflate=null,this[Ur]){this[Fr](this[Ur]);return}t[mx]=1007,this[Fr](t)}});var Gr=ce((e3,Oo)=>{"use strict";var{isUtf8:bx}=fe("buffer"),{hasBlob:hE}=Jt(),pE=[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 pd(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 mE(t){return hE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Oo.exports={isBlob:mE,isValidStatusCode:gE,isValidUTF8:pd,tokenChars:pE};if(bx)Oo.exports.isValidUTF8=function(t){return t.length<24?pd(t):bx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=fe("utf-8-validate");Oo.exports.isValidUTF8=function(e){return e.length<32?pd(e):t(e)}}catch{}});var yd=ce((t3,Tx)=>{"use strict";var{Writable:wE}=fe("stream"),Ex=qr(),{BINARY_TYPES:_E,EMPTY_BUFFER:vx,kStatusCode:yE,kWebSocket:bE}=Jt(),{concat:gd,toArrayBuffer:EE,unmask:vE}=Ji(),{isValidStatusCode:SE,isValidUTF8:Sx}=Gr(),Lo=Buffer[Symbol.species],xt=0,Ax=1,Ix=2,Cx=3,md=4,wd=5,No=6,_d=class extends wE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||_E[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[bE]=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=xt}_write(e,r,i){if(this._opcode===8&&this._state==xt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Lo(i.buffer,i.byteOffset+e,i.length-e),new Lo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Lo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case xt:this.getInfo(e);break;case Ax:this.getPayloadLength16(e);break;case Ix:this.getPayloadLength64(e);break;case Cx:this.getMask();break;case md:this.getData(e);break;case wd:case No: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[Ex.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=Ix:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Cx:this._state=md}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=md}getData(e){let r=vx;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=wd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[Ex.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let l=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===xt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=xt;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=gd(i,r):this._binaryType==="arraybuffer"?o=EE(gd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=xt):(this._state=No,setImmediate(()=>{this.emit("message",o,!0),this._state=xt,this.startLoop(e)}))}else{let o=gd(i,r);if(!this._skipUTF8Validation&&!Sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===wd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=xt):(this._state=No,setImmediate(()=>{this.emit("message",o,!1),this._state=xt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,vx),this.end();else{let i=e.readUInt16BE(0);if(!SE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Lo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=xt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=xt):(this._state=No,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=xt,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[yE]=o,l}};Tx.exports=_d});var vd=ce((r3,kx)=>{"use strict";var{Duplex:n3}=fe("stream"),{randomFillSync:AE}=fe("crypto"),{types:{isUint8Array:IE}}=fe("util"),Rx=qr(),{EMPTY_BUFFER:CE,kWebSocket:TE,NOOP:RE}=Jt(),{isBlob:Hr,isValidStatusCode:DE}=Gr(),{mask:Dx,toBuffer:Jn}=Ji(),ht=Symbol("kByteLength"),kE=Buffer.alloc(4),Mo=8*1024,Xn,jr=Mo,At=0,PE=1,OE=2,bd=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=At,this.onerror=RE,this[TE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||kE,r.generateMask?r.generateMask(i):(jr===Mo&&(Xn===void 0&&(Xn=Buffer.alloc(Mo)),AE(Xn,0,Mo),jr=0),i[0]=Xn[jr++],i[1]=Xn[jr++],i[2]=Xn[jr++],i[3]=Xn[jr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ht]!==void 0?u=r[ht]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(o?u+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(u,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(u,4,6)),r.mask?(h[1]|=128,h[c-4]=i[0],h[c-3]=i[1],h[c-2]=i[2],h[c-1]=i[3],l?[h,e]:o?(Dx(e,i,h,c,u),[h]):(Dx(e,i,e,0,u),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=CE;else{if(typeof e!="number"||!DE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(IE(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let l={[ht]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==At?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):Hr(e)?(o=e.size,c=!1):(e=Jn(e),o=e.length,c=Jn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==At?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):Hr(e)?(o=e.size,c=!1):(e=Jn(e),o=e.length,c=Jn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==At?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Rx.extensionName],c=r.binary?2:1,l=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Hr(e)?(u=e.size,x=!1):(e=Jn(e),u=e.length,x=Jn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[ht]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==At?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ht],this._state=OE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Ed,this,u,o);return}this._bufferedBytes-=i[ht];let l=Jn(c);r?this.dispatch(l,r,i,o):(this._state=At,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(LE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Rx.extensionName];this._bufferedBytes+=i[ht],this._state=PE,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Ed(this,x,o);return}this._bufferedBytes-=i[ht],this._state=At,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===At&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ht],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ht],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};kx.exports=bd;function Ed(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function LE(t,e,r){Ed(t,e,r),t.onerror(e)}});var Ux=ce((i3,Fx)=>{"use strict";var{kForOnEventAttribute:Yi,kListener:Sd}=Jt(),Px=Symbol("kCode"),Ox=Symbol("kData"),Lx=Symbol("kError"),Nx=Symbol("kMessage"),Mx=Symbol("kReason"),Wr=Symbol("kTarget"),Bx=Symbol("kType"),zx=Symbol("kWasClean"),Yt=class{constructor(e){this[Wr]=null,this[Bx]=e}get target(){return this[Wr]}get type(){return this[Bx]}};Object.defineProperty(Yt.prototype,"target",{enumerable:!0});Object.defineProperty(Yt.prototype,"type",{enumerable:!0});var Yn=class extends Yt{constructor(e,r={}){super(e),this[Px]=r.code===void 0?0:r.code,this[Mx]=r.reason===void 0?"":r.reason,this[zx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Px]}get reason(){return this[Mx]}get wasClean(){return this[zx]}};Object.defineProperty(Yn.prototype,"code",{enumerable:!0});Object.defineProperty(Yn.prototype,"reason",{enumerable:!0});Object.defineProperty(Yn.prototype,"wasClean",{enumerable:!0});var Kr=class extends Yt{constructor(e,r={}){super(e),this[Lx]=r.error===void 0?null:r.error,this[Nx]=r.message===void 0?"":r.message}get error(){return this[Lx]}get message(){return this[Nx]}};Object.defineProperty(Kr.prototype,"error",{enumerable:!0});Object.defineProperty(Kr.prototype,"message",{enumerable:!0});var Qi=class extends Yt{constructor(e,r={}){super(e),this[Ox]=r.data===void 0?null:r.data}get data(){return this[Ox]}};Object.defineProperty(Qi.prototype,"data",{enumerable:!0});var NE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Yi]&&o[Sd]===e&&!o[Yi])return;let i;if(t==="message")i=function(c,l){let u=new Qi("message",{data:l?c:c.toString()});u[Wr]=this,Bo(e,this,u)};else if(t==="close")i=function(c,l){let u=new Yn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Wr]=this,Bo(e,this,u)};else if(t==="error")i=function(c){let l=new Kr("error",{error:c,message:c.message});l[Wr]=this,Bo(e,this,l)};else if(t==="open")i=function(){let c=new Yt("open");c[Wr]=this,Bo(e,this,c)};else return;i[Yi]=!!r[Yi],i[Sd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Sd]===e&&!r[Yi]){this.removeListener(t,r);break}}};Fx.exports={CloseEvent:Yn,ErrorEvent:Kr,Event:Yt,EventTarget:NE,MessageEvent:Qi};function Bo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var zo=ce((s3,qx)=>{"use strict";var{tokenChars:es}=Gr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ME(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,x=-1,h=-1,m=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),l===void 0)if(m===-1&&es[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);h===44?(Bt(e,_,r),r=Object.create(null)):l=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(m===-1&&es[h]===1)x===-1&&(x=E);else if(h===32||h===9)m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Bt(r,t.slice(x,m),!0),h===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)u=t.slice(x,E),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(es[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:i||(i=!0),o=!1}else if(c)if(es[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,m=E;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&es[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))m===-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);i&&(_=_.replace(/\\/g,""),i=!1),Bt(r,u,_),h===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),u=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let S=t.slice(x,m);return l===void 0?Bt(e,S,r):(u===void 0?Bt(r,S,!0):i?Bt(r,u,S.replace(/\\/g,"")):Bt(r,u,S),Bt(e,l,r)),e}function BE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}qx.exports={format:BE,parse:ME}});var Go=ce((c3,Qx)=>{"use strict";var zE=fe("events"),FE=fe("https"),UE=fe("http"),jx=fe("net"),qE=fe("tls"),{randomBytes:GE,createHash:HE}=fe("crypto"),{Duplex:o3,Readable:a3}=fe("stream"),{URL:Ad}=fe("url"),Dn=qr(),jE=yd(),WE=vd(),{isBlob:KE}=Gr(),{BINARY_TYPES:Gx,CLOSE_TIMEOUT:$E,EMPTY_BUFFER:Fo,GUID:VE,kForOnEventAttribute:Id,kListener:ZE,kStatusCode:JE,kWebSocket:je,NOOP:Wx}=Jt(),{EventTarget:{addEventListener:XE,removeEventListener:YE}}=Ux(),{format:QE,parse:ev}=zo(),{toBuffer:tv}=Ji(),Kx=Symbol("kAborted"),Cd=[8,13],Qt=["CONNECTING","OPEN","CLOSING","CLOSED"],nv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,me=class t extends zE{constructor(e,r,i){super(),this._binaryType=Gx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Fo,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]),$x(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Gx.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 jE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new WE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[je]=this,c[je]=this,e[je]=this,o.on("conclude",sv),o.on("drain",ov),o.on("error",av),o.on("message",cv),o.on("ping",dv),o.on("pong",lv),c.onerror=uv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Jx),e.on("data",qo),e.on("end",Xx),e.on("error",Yx),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[Dn.extensionName]&&this._extensions[Dn.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){dt(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())}),Zx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Td(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Fo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Td(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Fo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Td(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Dn.extensionName]||(o.compress=!1),this._sender.send(e||Fo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(me,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(me.prototype,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(me,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(me.prototype,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(me,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(me.prototype,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(me,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});Object.defineProperty(me.prototype,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(me.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(me.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Id])return e[ZE];return null},set(e){for(let r of this.listeners(t))if(r[Id]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Id]:!0})}})});me.prototype.addEventListener=XE;me.prototype.removeEventListener=YE;Qx.exports=me;function $x(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:$E,protocolVersion:Cd[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Cd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Cd.join(", ")})`);let c;if(e instanceof Ad)c=e;else try{c=new Ad(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;Uo(t,A);return}let h=l?443:80,m=GE(16).toString("base64"),E=l?FE.request:UE.request,S=new Set,_;if(o.createConnection=o.createConnection||(l?iv:rv),o.defaultPort=o.defaultPort||h,o.port=c.port||h,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new Dn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=QE({[Dn.extensionName]:_.offer()})),r.length){for(let A of r){if(typeof A!="string"||!nv.test(A)||S.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.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[I,D]of Object.entries(A))i.headers[I.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let A=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!A||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{dt(t,v,"Opening handshake has timed out")}),v.on("error",A=>{v===null||v[Kx]||(v=t._req=null,Uo(t,A))}),v.on("response",A=>{let I=A.headers.location,D=A.statusCode;if(I&&o.followRedirects&&D>=300&&D<400){if(++t._redirects>o.maxRedirects){dt(t,v,"Maximum redirects exceeded");return}v.abort();let O;try{O=new Ad(I,e)}catch{let k=new SyntaxError(`Invalid URL: ${I}`);Uo(t,k);return}$x(t,O,r,i)}else t.emit("unexpected-response",v,A)||dt(t,v,`Unexpected server response: ${A.statusCode}`)}),v.on("upgrade",(A,I,D)=>{if(t.emit("upgrade",A),t.readyState!==me.CONNECTING)return;v=t._req=null;let O=A.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){dt(t,I,"Invalid Upgrade header");return}let y=HE("sha1").update(m+VE).digest("base64");if(A.headers["sec-websocket-accept"]!==y){dt(t,I,"Invalid Sec-WebSocket-Accept header");return}let k=A.headers["sec-websocket-protocol"],L;if(k!==void 0?S.size?S.has(k)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":S.size&&(L="Server sent no subprotocol"),L){dt(t,I,L);return}k&&(t._protocol=k);let U=A.headers["sec-websocket-extensions"];if(U!==void 0){if(!_){dt(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=ev(U)}catch{dt(t,I,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(z);if(Z.length!==1||Z[0]!==Dn.extensionName){dt(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[Dn.extensionName])}catch{dt(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Dn.extensionName]=_}t.setSocket(I,D,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Uo(t,e){t._readyState=me.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function rv(t){return t.path=t.socketPath,jx.connect(t)}function iv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=jx.isIP(t.host)?"":t.host),qE.connect(t)}function dt(t,e,r){t._readyState=me.CLOSING;let i=new Error(r);Error.captureStackTrace(i,dt),e.setHeader?(e[Kx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Uo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Td(t,e,r){if(e){let i=KE(e)?e.size:tv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Qt[t.readyState]})`);process.nextTick(r,i)}}function sv(t,e){let r=this[je];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[je]!==void 0&&(r._socket.removeListener("data",qo),process.nextTick(Vx,r._socket),t===1005?r.close():r.close(t,e))}function ov(){let t=this[je];t.isPaused||t._socket.resume()}function av(t){let e=this[je];e._socket[je]!==void 0&&(e._socket.removeListener("data",qo),process.nextTick(Vx,e._socket),e.close(t[JE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Hx(){this[je].emitClose()}function cv(t,e){this[je].emit("message",t,e)}function dv(t){let e=this[je];e._autoPong&&e.pong(t,!this._isServer,Wx),e.emit("ping",t)}function lv(t){this[je].emit("pong",t)}function Vx(t){t.resume()}function uv(t){let e=this[je];e.readyState!==me.CLOSED&&(e.readyState===me.OPEN&&(e._readyState=me.CLOSING,Zx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Zx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Jx(){let t=this[je];if(this.removeListener("close",Jx),this.removeListener("data",qo),this.removeListener("end",Xx),t._readyState=me.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[je]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Hx),t._receiver.on("finish",Hx))}function qo(t){this[je]._receiver.write(t)||this.pause()}function Xx(){let t=this[je];t._readyState=me.CLOSING,t._receiver.end(),this.end()}function Yx(){let t=this[je];this.removeListener("error",Yx),this.on("error",Wx),t&&(t._readyState=me.CLOSING,this.destroy())}});var rh=ce((l3,nh)=>{"use strict";var d3=Go(),{Duplex:fv}=fe("stream");function eh(t){t.emit("close")}function xv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function th(t){this.removeListener("error",th),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function hv(t,e){let r=!0,i=new fv({...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(eh,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(eh,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",xv),i.on("error",th),i}nh.exports=hv});var Rd=ce((u3,ih)=>{"use strict";var{tokenChars:pv}=Gr();function gv(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&&pv[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}ih.exports={parse:gv}});var uh=ce((x3,lh)=>{"use strict";var mv=fe("events"),Ho=fe("http"),{Duplex:f3}=fe("stream"),{createHash:wv}=fe("crypto"),sh=zo(),Qn=qr(),_v=Rd(),yv=Go(),{CLOSE_TIMEOUT:bv,GUID:Ev,kWebSocket:vv}=Jt(),Sv=/^[+/0-9A-Za-z]{22}==$/,oh=0,ah=1,dh=2,Dd=class extends mv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:bv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:yv,...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=Ho.createServer((i,o)=>{let c=Ho.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=Av(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=oh}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===dh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ts,this);return}if(e&&this.once("close",e),this._state!==ah)if(this._state=ah,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(ts,this):process.nextTick(ts,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{ts(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",ch);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){er(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){er(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Sv.test(c)){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ns(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=_v.parse(x)}catch{er(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let S=new Qn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=sh.parse(m);_[Qn.extensionName]&&(S.accept(_[Qn.extensionName]),E[Qn.extensionName]=S)}catch{er(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(_,v,A,I)=>{if(!_)return ns(r,v||401,A,I);this.completeUpgrade(E,c,h,e,r,i,o)});return}if(!this.options.verifyClient(S))return ns(r,401)}this.completeUpgrade(E,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[vv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>oh)return ns(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${wv("sha1").update(r+Ev).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[Qn.extensionName]){let E=e[Qn.extensionName].params,S=sh.format({[Qn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${S}`),m._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&ds(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 kg,mkdirSync as Cg}from"node:fs";import{join as Rg}from"node:path";function yl(t){let e=t.retentionDays??Og,r=t.clock??(()=>On(new Date));us={bridgeSink:new ti(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new ti(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();ds(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])ds(t.agentLogsDir(o),"agent",i,e)}function Lg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function bl(t){Ta=t}function El(t){return cr[Ta]<=cr[t]}function vl(t,e){let r=cr[t];return r===void 0?!0:r>=cr[e]}function fs(t){_l={...t}}function Sl(t){let e=(u,f=2)=>String(u).padStart(f,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),d=e(o%60);return`${On(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${d}`}function kt(t,e,r,i,o){try{let c=`${JSON.stringify({ts:Sl(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;Cg(t,{recursive:!0}),kg(Rg(t,ar("bridge",On(new Date))),c)}catch{}}function Ng(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function ls(t,e,r,i,o){if(cr[t]<cr[Ta])return;let c=`${JSON.stringify({ts:Sl(new Date),level:t,module:e,msg:r,..._l,...i})}
|
|
12
|
+
`;if(us){let d=Ng(o,i),u=d?Lg(us,d):us.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Pg.write(c):Dg.write(c)}function H(t,e){return{debug:(r,i)=>ls("debug",t,r,i,e),info:(r,i)=>ls("info",t,r,i,e),warn:(r,i)=>ls("warn",t,r,i,e),error:(r,i)=>ls("error",t,r,i,e),child:r=>H(`${t}.${r}`,e),forAgent:r=>H(t,r)}}var cr,Ta,Dg,Pg,_l,Og,us,te=rt(()=>{"use strict";or();Aa();cr={debug:10,info:20,warn:30,error:40},Ta=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Dg=process.stdout,Pg=process.stderr,_l={},Og=Ze("COZE_BRIDGE_LOG_RETENTION_DAYS",30),us=null});var T,$e=rt(()=>{"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 kl={};Sa(kl,{ACP_WRAPPER_NPM_PACKAGES:()=>ri,_resetAcpInstallerForTests:()=>qg,_setBinaryPathCacheForTests:()=>Gg,buildAcpSpawn:()=>ii,ensureAcpInstalled:()=>dr,getAcpBinaryPath:()=>hs,pickWhichLine:()=>Ra,probeAcpVersion:()=>Ug,resolveAcpCommand:()=>Tl});import{readFileSync as Il}from"node:fs";import{createRequire as Mg}from"node:module";import{dirname as Bg,resolve as Fg}from"node:path";function Ra(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 zg(t){let e=Al.resolve(`${t.npmPackage}/package.json`),r=Bg(e),i=JSON.parse(Il(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 Fg(r,o)}async function dr(t,e){let r=Ca[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=ni.get(t);if(i)return i;try{let o=zg(r);return ni.set(t,o),ka.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw ka.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 Ug(t){let e=Ca[t];if(e)try{let r=Al.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(Il(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){ka.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function hs(t){return ni.get(t)}function Tl(t,e){if(e)return e;let r=hs(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 ii(t,e,r){if(e)return{command:e,args:[...r]};let i=Tl(t);return{command:process.execPath,args:[i,...r]}}function qg(){ni.clear()}function Gg(t,e){ni.set(t,e)}var ka,Ca,ri,Al,ni,an=rt(()=>{"use strict";$e();te();ka=H("agents.acp-installer"),Ca={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@agentclientprotocol/codex-acp",binary:"codex-acp"}},ri=Object.values(Ca).filter(t=>t!==void 0).map(t=>t.npmPackage),Al=Mg(import.meta.url),ni=new Map});import{chmod as jg,mkdir as Kg,readFile as Wg,rename as $g,rm as Vg,writeFile as Jg}from"node:fs/promises";import{dirname as Zg}from"node:path";async function lr(t){try{let e=await Wg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function cn(t,e,r){await Kg(Zg(t),{recursive:!0});let i=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{await Jg(i,e,{encoding:"utf8",mode:r?.mode}),await $g(i,t),r?.mode!==void 0&&await jg(t,r.mode)}catch(o){throw await Vg(i,{force:!0}).catch(()=>{}),o}}async function ur(t,e,r){await cn(t,`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,r)}var dn=rt(()=>{"use strict"});import{promises as Dl,readdirSync as Yg}from"node:fs";import{homedir as Xg}from"node:os";import{sep as Qg,join as Re,resolve as Pl}from"node:path";function Q(t){let e=t??Xg(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function Ye(t,e=Q()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function xs(t=Q()){try{return Yg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function si(t,e){let r=await Dl.realpath(Pl(t)).catch(()=>null);if(!r)return!1;let i=await Dl.realpath(Pl(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+Qg)}var Me=rt(()=>{"use strict"});var gs={};Sa(gs,{AGENT_CONFIG_FILE_MODE:()=>ps,enforceAgentConfigMode:()=>nm,loadAgentConfig:()=>De,persistAgentSessions:()=>oi,persistAgentSkills:()=>ai,saveAgentConfig:()=>Ue});import{chmod as em,stat as tm}from"node:fs/promises";function De(t,e){return lr(Ye(t,e).config)}function Ue(t,e){return ur(Ye(t.agentId,e).config,t,{mode:ps})}async function nm(t,e){if(process.platform==="win32")return;let r=Ye(t,e).config;try{let i=await tm(r);if(!i.isFile())return;let o=i.mode&511;o!==ps&&(await em(r,ps),Ol.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Ol.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function oi(t,e,r){let i=await De(t,r);i&&(i.sessions=Object.fromEntries(e),await Ue(i,r))}async function ai(t,e,r){let i=await De(t,r);i&&(i.skills=e,await Ue(i,r))}var Ol,ps,ln=rt(()=>{"use strict";dn();te();Me();Ol=H("agent-config"),ps=384});var Oa=oe((WI,Ml)=>{Ml.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 ws=oe(Fl=>{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 cm(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))Fl[t]=cm(Bl[t])});var Hl=oe((VI,Gl)=>{var dm=le("fs"),Be=le("path"),zl=Oa(),lm=ws(),um=typeof process=="object"&&process.platform==="win32",Ul=t=>typeof t=="object"&&t!==null,ql=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ie(t){this.sep=Be.sep,this.fs=dm,Ul(t)&&Ul(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Gl.exports=Ie;Ie.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var d;try{d=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(d&&d.isFile())throw lm.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ie.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var d=Be.dirname(t);o.fs.existsSync(d)||o.makeDir(d);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};Ie.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!r)return o(!1);c.fs.stat(t,function(u,f){if(d&&f.isDirectory())return o(!1);var x=Be.dirname(t);c.fs.exists(x,function(g){g||c.makeDir(x),c.fs.open(t,"w",438,function(m,v){m?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,S){c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):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)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ie.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let d=[];return e.fs.readdirSync(i).forEach(function(u){let f=Be.join(i,u),x=e.fs.statSync(f);(!o||o.test(f))&&d.push(Be.normalize(f)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(d=d.concat(r(f,o,c)))}),d}return r(t,void 0,!0)};Ie.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let d=c.length;if(!d)return e(null,i);c.forEach(function(u){u=Be.join(t,u),r.fs.stat(u,function(f,x){if(f)return e(f);x&&(i.push(Be.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(g,m){if(g)return e(g);i=i.concat(m),--d||e(null,i)}):--d||e(null,i))})})})};Ie.prototype.getAttributes=function(){};Ie.prototype.setAttributes=function(){};Ie.crc32update=function(t,e){return ql[(t^e)&255]^t>>>8};Ie.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ie.crc32update(r,t[i++]);return~r>>>0};Ie.methodToString=function(t){switch(t){case zl.STORED:return"STORED ("+t+")";case zl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ie.canonical=function(t){if(!t)return"";let e=Be.posix.normalize("/"+t.split("\\").join("/"));return Be.join(".",e)};Ie.zipnamefix=function(t){if(!t)return"";let e=Be.posix.normalize("/"+t.split("\\").join("/"));return Be.posix.join(".",e)};Ie.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ie.sanitize=function(t,e){t=Be.resolve(Be.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Be.normalize(Be.join(t,r.slice(i,o).join(Be.sep)));if(c.indexOf(t)===0)return c}return Be.normalize(Be.join(t,Be.basename(e)))};Ie.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ie.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ie.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Ie.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Ie.isWin=um;Ie.crcTable=ql});var Kl=oe((JI,jl)=>{var fm=le("path");jl.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=fm.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 $l=oe((ZI,Wl)=>{Wl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var xr=oe((YI,hr)=>{hr.exports=Hl();hr.exports.Constants=Oa();hr.exports.Errors=ws();hr.exports.FileAttr=Kl();hr.exports.decoder=$l()});var Jl=oe((XI,Vl)=>{var un=xr(),z=un.Constants;Vl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,d=0,u=0,f=0,x=0,g=0,m=0,v=0,_=0,S=0;t|=un.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},A=E=>Math.max(0,E)>>>0,k=E=>Math.max(0,E)&65535,P=E=>Math.max(0,E)&255;return o=un.fromDate2DOS(new Date),{get made(){return t},set made(E){t=E},get version(){return e},set version(E){e=E},get flags(){return r},set flags(E){r=E},get flags_efs(){return(r&z.FLG_EFS)>0},set flags_efs(E){E?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(E){E?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(E){switch(E){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=E},get time(){return un.fromDOS2Date(this.timeval)},set time(E){E=new Date(E),this.timeval=un.fromDate2DOS(E)},get timeval(){return o},set timeval(E){o=A(E)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(E){c=A(E)},get compressedSize(){return d},set compressedSize(E){d=A(E)},get size(){return u},set size(E){u=A(E)},get fileNameLength(){return f},set fileNameLength(E){f=E},get extraLength(){return x},set extraLength(E){x=E},get extraLocalLength(){return I.extraLen},set extraLocalLength(E){I.extraLen=E},get commentLength(){return g},set commentLength(E){g=E},get diskNumStart(){return m},set diskNumStart(E){m=A(E)},get inAttr(){return v},set inAttr(E){v=A(E)},get attr(){return _},set attr(E){_=A(E)},get fileAttr(){return(_||0)>>16&4095},get offset(){return S},set offset(E){S=A(E)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+f+x+g},get realDataOffset(){return S+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(E){var R=E.slice(S,S+z.LOCHDR);if(R.readUInt32LE(0)!==z.LOCSIG)throw un.Errors.INVALID_LOC();I.version=R.readUInt16LE(z.LOCVER),I.flags=R.readUInt16LE(z.LOCFLG),I.flags_desc=(I.flags&z.FLG_DESC)>0,I.method=R.readUInt16LE(z.LOCHOW),I.time=R.readUInt32LE(z.LOCTIM),I.crc=R.readUInt32LE(z.LOCCRC),I.compressedSize=R.readUInt32LE(z.LOCSIZ),I.size=R.readUInt32LE(z.LOCLEN),I.fnameLen=R.readUInt16LE(z.LOCNAM),I.extraLen=R.readUInt16LE(z.LOCEXT);let O=S+z.LOCHDR+I.fnameLen,F=O+I.extraLen;return E.slice(O,F)},loadFromBinary:function(E){if(E.length!==z.CENHDR||E.readUInt32LE(0)!==z.CENSIG)throw un.Errors.INVALID_CEN();t=E.readUInt16LE(z.CENVEM),e=E.readUInt16LE(z.CENVER),r=E.readUInt16LE(z.CENFLG),i=E.readUInt16LE(z.CENHOW),o=E.readUInt32LE(z.CENTIM),c=E.readUInt32LE(z.CENCRC),d=E.readUInt32LE(z.CENSIZ),u=E.readUInt32LE(z.CENLEN),f=E.readUInt16LE(z.CENNAM),x=E.readUInt16LE(z.CENEXT),g=E.readUInt16LE(z.CENCOM),m=E.readUInt16LE(z.CENDSK),v=E.readUInt16LE(z.CENATT),_=E.readUInt32LE(z.CENATX),S=E.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var E=Buffer.alloc(z.LOCHDR);return E.writeUInt32LE(z.LOCSIG,0),E.writeUInt16LE(e,z.LOCVER),E.writeUInt16LE(r,z.LOCFLG),E.writeUInt16LE(i,z.LOCHOW),E.writeUInt32LE(o,z.LOCTIM),E.writeUInt32LE(c,z.LOCCRC),E.writeUInt32LE(d,z.LOCSIZ),E.writeUInt32LE(u,z.LOCLEN),E.writeUInt16LE(f,z.LOCNAM),E.writeUInt16LE(I.extraLen,z.LOCEXT),E},centralHeaderToBinary:function(){var E=Buffer.alloc(z.CENHDR+f+x+g);return E.writeUInt32LE(z.CENSIG,0),E.writeUInt16LE(t,z.CENVEM),E.writeUInt16LE(e,z.CENVER),E.writeUInt16LE(r,z.CENFLG),E.writeUInt16LE(i,z.CENHOW),E.writeUInt32LE(o,z.CENTIM),E.writeUInt32LE(c,z.CENCRC),E.writeUInt32LE(d,z.CENSIZ),E.writeUInt32LE(u,z.CENLEN),E.writeUInt16LE(f,z.CENNAM),E.writeUInt16LE(x,z.CENEXT),E.writeUInt16LE(g,z.CENCOM),E.writeUInt16LE(m,z.CENDSK),E.writeUInt16LE(v,z.CENATT),E.writeUInt32LE(_,z.CENATX),E.writeUInt32LE(S,z.CENOFF),E},toJSON:function(){let E=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:un.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:E(d),size:E(u),fileNameLength:E(f),extraLength:E(x),commentLength:E(g),diskNumStart:m,inAttr:v,attr:_,offset:S,centralHeaderSize:E(z.CENHDR+f+x+g)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Yl=oe((QI,Zl)=>{var pr=xr(),Ee=pr.Constants;Zl.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 Ee.ENDHDR+o},loadFromBinary:function(c){if((c.length!==Ee.ENDHDR||c.readUInt32LE(0)!==Ee.ENDSIG)&&(c.length<Ee.ZIP64HDR||c.readUInt32LE(0)!==Ee.ZIP64SIG))throw pr.Errors.INVALID_END();c.readUInt32LE(0)===Ee.ENDSIG?(t=c.readUInt16LE(Ee.ENDSUB),e=c.readUInt16LE(Ee.ENDTOT),r=c.readUInt32LE(Ee.ENDSIZ),i=c.readUInt32LE(Ee.ENDOFF),o=c.readUInt16LE(Ee.ENDCOM)):(t=pr.readBigUInt64LE(c,Ee.ZIP64SUB),e=pr.readBigUInt64LE(c,Ee.ZIP64TOT),r=pr.readBigUInt64LE(c,Ee.ZIP64SIZE),i=pr.readBigUInt64LE(c,Ee.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(Ee.ENDHDR+o);return c.writeUInt32LE(Ee.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,Ee.ENDSUB),c.writeUInt16LE(e,Ee.ENDTOT),c.writeUInt32LE(r,Ee.ENDSIZ),c.writeUInt32LE(i,Ee.ENDOFF),c.writeUInt16LE(o,Ee.ENDCOM),c.fill(" ",Ee.ENDHDR),c},toJSON:function(){let c=function(d,u){let f=d.toString(16).toUpperCase();for(;f.length<u;)f="0"+f;return"0x"+f};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Na=oe(La=>{La.EntryHeader=Jl();La.MainHeader=Yl()});var Ql=oe((tA,Xl)=>{Xl.exports=function(t){var e=le("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],d=0;o.on("data",function(u){c.push(u),d+=u.length}),o.on("end",function(){var u=Buffer.alloc(d),f=0;u.fill(0);for(var x=0;x<c.length;x++){var g=c[x];g.copy(u,f),f+=g.length}i&&i(u)}),o.end(t)}}}});var tu=oe((nA,eu)=>{var hm=+(process.versions?process.versions.node:"").split(".")[0]||0;eu.exports=function(t,e){var r=le("zlib");let i=hm>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),d=[],u=0;c.on("data",function(f){d.push(f),u+=f.length}),c.on("end",function(){var f=Buffer.alloc(u),x=0;f.fill(0);for(var g=0;g<d.length;g++){var m=d[g];m.copy(f,x),x+=m.length}o&&o(f)}),c.end(t)}}}});var ou=oe((rA,su)=>{"use strict";var{randomFillSync:nu}=le("crypto"),xm=ws(),pm=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}),iu=(t,e)=>Math.imul(t,e)>>>0,ru=(t,e)=>pm[(t^e)&255]^t>>>8,ci=()=>typeof nu=="function"?nu(Buffer.alloc(12)):ci.node();ci.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 _s={genSalt:ci};function ys(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])}ys.prototype.updateKeys=function(t){let e=this.keys;return e[0]=ru(e[0],t),e[1]+=e[0]&255,e[1]=iu(e[1],134775813)+1,e[2]=ru(e[2],e[1]>>>24),t};ys.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return iu(t,t^1)>>8&255};function gm(t){let e=new ys(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 mm(t){let e=new ys(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let d=e.next();i[o++]=c^d,e.updateKeys(c)}return i}}function wm(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=gm(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw xm.WRONG_PASSWORD();return i(t.slice(12))}function _m(t){Buffer.isBuffer(t)&&t.length>=12?_s.genSalt=function(){return t.slice(0,12)}:t==="node"?_s.genSalt=ci.node:_s.genSalt=ci}function ym(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=mm(r),c=_s.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return o(c,d),o(t,d,12)}su.exports={decrypt:wm,encrypt:ym,_salter:_m}});var au=oe(bs=>{bs.Deflater=Ql();bs.Inflater=tu();bs.ZipCrypto=ou()});var Ba=oe((sA,cu)=>{var ae=xr(),bm=Na(),Ae=ae.Constants,Ma=au();cu.exports=function(t,e){var r=new bm.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),f=Buffer.alloc(0),x=!0;let g=t,m=typeof g.decoder=="object"?g.decoder:ae.decoder;x=m.hasOwnProperty("efs")?m.efs:!1;function v(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(f=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(E){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ae.crc32(E)!==r.localHeader.crc)return!1}else{let R={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Ae.LOCSIG||e.readUInt32LE(O)==Ae.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Ae.EXTSIG)R.crc=e.readUInt32LE(O+Ae.EXTCRC),R.compressedSize=e.readUInt32LE(O+Ae.EXTSIZ),R.size=e.readUInt32LE(O+Ae.EXTLEN);else if(e.readUInt16LE(O+12)===19280)R.crc=e.readUInt32LE(O+Ae.EXTCRC-4),R.compressedSize=e.readUInt32LE(O+Ae.EXTSIZ-4),R.size=e.readUInt32LE(O+Ae.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(E)!==R.crc)return!1}return!0}function S(E,R,O){if(typeof R>"u"&&typeof E=="string"&&(O=E,E=void 0),c)return E&&R&&R(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=v();if(F.length===0)return E&&R&&R(F),F;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw ae.Errors.INVALID_PASS_PARAM();F=Ma.ZipCrypto.decrypt(F,r,O)}var N=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(F.copy(N),_(N))return E&&R&&R(N),N;throw E&&R&&R(N,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var J=new Ma.Inflater(F,r.size);if(E)J.inflateAsync(function(V){V.copy(V,0),R&&(_(V)?R(V):R(V,ae.Errors.BAD_CRC()))});else{if(J.inflate(N).copy(N,0),!_(N))throw ae.Errors.BAD_CRC(`"${m.decode(i)}"`);return N}break;default:throw E&&R&&R(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function I(E,R){if((!d||!d.length)&&Buffer.isBuffer(e))return E&&R&&R(v()),v();if(d.length&&!c){var O;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(d.length),d.copy(O),E&&R&&R(O),O;default:case ae.Constants.DEFLATED:var F=new Ma.Deflater(d);if(E)F.deflateAsync(function(J){O=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(O),R&&R(O)});else{var N=F.deflate();return r.compressedSize=N.length,N}F=null;break}}else if(E&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function A(E,R){return ae.readBigUInt64LE(E,R)}function k(E){try{for(var R=0,O,F,N;R+4<E.length;)O=E.readUInt16LE(R),R+=2,F=E.readUInt16LE(R),R+=2,N=E.slice(R,R+F),R+=F,Ae.ID_ZIP64===O&&P(N)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(E){var R,O,F,N;E.length>=Ae.EF_ZIP64_SCOMP&&(R=A(E,Ae.EF_ZIP64_SUNCOMP),r.size===Ae.EF_ZIP64_OR_32&&(r.size=R)),E.length>=Ae.EF_ZIP64_RHO&&(O=A(E,Ae.EF_ZIP64_SCOMP),r.compressedSize===Ae.EF_ZIP64_OR_32&&(r.compressedSize=O)),E.length>=Ae.EF_ZIP64_DSN&&(F=A(E,Ae.EF_ZIP64_RHO),r.offset===Ae.EF_ZIP64_OR_32&&(r.offset=F)),E.length>=Ae.EF_ZIP64_DSN+4&&(N=E.readUInt32LE(Ae.EF_ZIP64_DSN),r.diskNumStart===Ae.EF_ZIP64_OR_16&&(r.diskNumStart=N))}return{get entryName(){return m.decode(i)},get rawEntryName(){return i},set entryName(E){i=ae.toBuffer(E,m.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(E){u=E,r.extraLength=E.length,k(E)},get comment(){return m.decode(o)},set comment(E){if(o=ae.toBuffer(E,m.encode),r.commentLength=o.length,o.length>65535)throw ae.Errors.COMMENT_TOO_LONG()},get name(){var E=m.decode(i);return c?E.substr(E.length-1).split("/").pop():E.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(E){I(!0,E)},setData:function(E){d=ae.toBuffer(E,ae.decoder.encode),!c&&d.length?(r.size=d.length,r.method=ae.Constants.DEFLATED,r.crc=ae.crc32(E),r.changed=!0):r.method=ae.Constants.STORED},getData:function(E){return r.changed?d:S(!1,null,E)},getDataAsync:function(E,R){r.changed?E(d):S(!0,E,R)},set attr(E){r.attr=E},get attr(){return r.attr},set header(E){r.loadFromBinary(E)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var E=r.centralHeaderToBinary(),R=ae.Constants.CENHDR;return i.copy(E,R),R+=i.length,u.copy(E,R),R+=r.extraLength,o.copy(E,R),E},packLocalHeader:function(){let E=0;r.flags_efs=this.efs,r.extraLocalLength=f.length;let R=r.localHeaderToBinary(),O=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(O,E),E+=R.length,i.copy(O,E),E+=i.length,f.copy(O,E),E+=f.length,O},toJSON:function(){let E=function(R){return"<"+(R&&R.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:E(e),data:E(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var uu=oe((oA,lu)=>{var du=Ba(),Em=Na(),Ve=xr();lu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Em.MainHeader,d=!1,u=null;let f=new Set,x=e,{noSort:g,decoder:m}=x;t?S(x.readEntries):d=!0;function v(){let A=new Set;for(let k of Object.keys(i)){let P=k.split("/");if(P.pop(),!!P.length)for(let E=0;E<P.length;E++){let R=P.slice(0,E+1).join("/")+"/";A.add(R)}}for(let k of A)if(!(k in i)){let P=new du(x);P.entryName=k,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,f.add(P)}}function _(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/Ve.Constants.CENHDR)throw Ve.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,k=0;k<r.length;k++){var P=A,E=new du(x,t);E.header=t.slice(P,P+=Ve.Constants.CENHDR),E.entryName=t.slice(P,P+=E.header.fileNameLength),E.header.extraLength&&(E.extra=t.slice(P,P+=E.header.extraLength)),E.header.commentLength&&(E.comment=t.slice(P,P+E.header.commentLength)),A+=E.header.centralHeaderSize,r[k]=E,i[E.entryName]=E}f.clear(),v()}function S(A){var k=t.length-Ve.Constants.ENDHDR,P=Math.max(0,k-65535),E=P,R=t.length,O=-1,F=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(P=0),k;k>=E;k--)if(t[k]===80){if(t.readUInt32LE(k)===Ve.Constants.ENDSIG){O=k,F=k,R=k+Ve.Constants.ENDHDR,E=k-Ve.Constants.END64HDR;continue}if(t.readUInt32LE(k)===Ve.Constants.END64SIG){E=P;continue}if(t.readUInt32LE(k)===Ve.Constants.ZIP64SIG){O=k,R=k+Ve.readBigUInt64LE(t,k+Ve.Constants.ZIP64SIZE)+Ve.Constants.ZIP64LEAD;break}}if(O==-1)throw Ve.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,R)),c.commentLength&&(o=t.slice(F+Ve.Constants.ENDHDR)),A&&_()}function I(){r.length>1&&!g&&r.sort((A,k)=>A.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return d||_(),r.filter(A=>!f.has(A))},get comment(){return m.decode(o)},set comment(A){o=Ve.toBuffer(A,m.encode),c.commentLength=o.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return d||_(),i[A]||null},setEntry:function(A){d||_(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,k=!0){d||_();let P=i[A];this.getEntryChildren(P,k).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){d||_();let k=i[A],P=r.indexOf(k);P>=0&&(r.splice(P,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,k=!0){if(d||_(),typeof A=="object")if(A.isDirectory&&k){let P=[],E=A.entryName;for(let R of r)R.entryName.startsWith(E)&&P.push(R);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let k=this.getEntryChildren(A);return k.includes(A)?k.length-1:k.length}return 0},compressToBuffer:function(){d||_(),I();let A=[],k=[],P=0,E=0;c.size=0,c.offset=0;let R=0;for(let N of this.entries){let J=N.getCompressedData();N.header.offset=E;let V=N.packLocalHeader(),ne=V.length+J.length;E+=ne,A.push(V),A.push(J);let Y=N.packCentralHeader();k.push(Y),c.size+=Y.length,P+=ne+Y.length,R++}P+=c.mainHeaderSize,c.offset=E,c.totalEntries=R,E=0;let O=Buffer.alloc(P);for(let N of A)N.copy(O,E),E+=N.length;for(let N of k)N.copy(O,E),E+=N.length;let F=c.toBinary();return o&&o.copy(F,Ve.Constants.ENDHDR),F.copy(O,E),t=O,d=!1,O},toAsyncBuffer:function(A,k,P,E){try{d||_(),I();let R=[],O=[],F=0,N=0,J=0;c.size=0,c.offset=0;let V=function(ne){if(ne.length>0){let Y=ne.shift(),ie=Y.entryName+Y.extra.toString();P&&P(ie),Y.getCompressedDataAsync(function(se){E&&E(ie),Y.header.offset=N;let D=Y.packLocalHeader(),U=D.length+se.length;N+=U,R.push(D),R.push(se);let K=Y.packCentralHeader();O.push(K),c.size+=K.length,F+=U+K.length,J++,V(ne)})}else{F+=c.mainHeaderSize,c.offset=N,c.totalEntries=J,N=0;let Y=Buffer.alloc(F);R.forEach(function(se){se.copy(Y,N),N+=se.length}),O.forEach(function(se){se.copy(Y,N),N+=se.length});let ie=c.toBinary();o&&o.copy(ie,Ve.Constants.ENDHDR),ie.copy(Y,N),t=Y,d=!1,A(Y)}};V(Array.from(this.entries))}catch(R){k(R)}}}}});var xu=oe((aA,hu)=>{var Se=xr(),ve=le("path"),vm=Ba(),Sm=uu(),Ln=(...t)=>Se.findLast(t,e=>typeof e=="boolean"),fu=(...t)=>Se.findLast(t,e=>typeof e=="string"),Im=(...t)=>Se.findLast(t,e=>typeof e=="function"),Am={noSort:!1,readEntries:!1,method:Se.Constants.NONE,fs:null};hu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Am);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=Se.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new Se(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=Se.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=Se.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw Se.Errors.INVALID_FILENAME();let c=new Sm(r,i),{canonical:d,sanitize:u,zipnamefix:f}=Se;function x(_){if(_&&c){var S;if(typeof _=="string"&&(S=c.getEntry(ve.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(S=c.getEntry(_.entryName)),S)return S}return null}function g(_){let{join:S,normalize:I,sep:A}=ve.posix;return S(ve.isAbsolute(_)?"/":".",I(A+_.split("\\").join(A)+A))}function m(_){return _ instanceof RegExp?(function(S){return function(I){return S.test(I)}})(_):typeof _!="function"?()=>!0:_}let v=(_,S)=>{let I=S.slice(-1);return I=I===o.sep?o.sep:"",ve.relative(_,S)+I};return{readFile:function(_,S){var I=x(_);return I&&I.getData(S)||null},childCount:function(_){let S=x(_);if(S)return c.getChildCount(S)},readFileAsync:function(_,S){var I=x(_);I?I.getDataAsync(S):S(null,"getEntry failed for:"+_)},readAsText:function(_,S){var I=x(_);if(I){var A=I.getData();if(A&&A.length)return A.toString(S||"utf8")}return""},readAsTextAsync:function(_,S,I){var A=x(_);A?A.getDataAsync(function(k,P){if(P){S(k,P);return}k&&k.length?S(k.toString(I||"utf8")):S("")}):S("")},deleteFile:function(_,S=!0){var I=x(_);I&&c.deleteFile(I.entryName,S)},deleteEntry:function(_){var S=x(_);S&&c.deleteEntry(S.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,S){var I=x(_);I&&(I.comment=S)},getZipEntryComment:function(_){var S=x(_);return S&&S.comment||""},updateFile:function(_,S){var I=x(_);I&&I.setData(S)},addLocalFile:function(_,S,I,A){if(o.fs.existsSync(_)){S=S?g(S):"";let k=ve.win32.basename(ve.win32.normalize(_));S+=I||k;let P=o.fs.statSync(_),E=P.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);P.isDirectory()&&(S+=o.sep),this.addFile(S,E,A,P)}else throw Se.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,S){_=typeof _=="object"?_:{localPath:_};let I=ve.resolve(_.localPath),{comment:A}=_,{zipPath:k,zipName:P}=_,E=this;o.fs.stat(I,function(R,O){if(R)return S(R,!1);k=k?g(k):"";let F=ve.win32.basename(ve.win32.normalize(I));if(k+=P||F,O.isFile())o.fs.readFile(I,function(N,J){return N?S(N,!1):(E.addFile(k,J,A,O),setImmediate(S,void 0,!0))});else if(O.isDirectory())return k+=o.sep,E.addFile(k,Buffer.alloc(0),A,O),setImmediate(S,void 0,!0)})},addLocalFolder:function(_,S,I){if(I=m(I),S=S?g(S):"",_=ve.normalize(_),o.fs.existsSync(_)){let A=o.findFiles(_),k=this;if(A.length)for(let P of A){let E=ve.join(S,v(_,P));I(E)&&k.addLocalFile(P,ve.dirname(E))}}else throw Se.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,S,I,A){A=m(A),I=I?g(I):"",_=ve.normalize(_);var k=this;o.fs.open(_,"r",function(P){if(P&&P.code==="ENOENT")S(void 0,Se.Errors.FILE_NOT_FOUND(_));else if(P)S(void 0,P);else{var E=o.findFiles(_),R=-1,O=function(){if(R+=1,R<E.length){var F=E[R],N=v(_,F).split("\\").join("/");N=N.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(N)?o.fs.stat(F,function(J,V){J&&S(void 0,J),V.isFile()?o.fs.readFile(F,function(ne,Y){ne?S(void 0,ne):(k.addFile(I+N,Y,"",V),O())}):(k.addFile(I+N+"/",Buffer.alloc(0),"",V),O())}):process.nextTick(()=>{O()})}else S(!0,void 0)};O()}})},addLocalFolderAsync2:function(_,S){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=ve.resolve(g(_.localPath));let{zipPath:A,filter:k,namefix:P}=_;k instanceof RegExp?k=(function(O){return function(F){return O.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),A=A?g(A):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let E=O=>ve.join(A,P(v(localPath,O))),R=O=>ve.win32.basename(ve.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?S(void 0,Se.Errors.FILE_NOT_FOUND(localPath)):O?S(void 0,O):o.findFilesAsync(localPath,function(F,N){if(F)return S(F);N=N.filter(J=>k(E(J))),N.length||S(void 0,!1),setImmediate(N.reverse().reduce(function(J,V){return function(ne,Y){if(ne||Y===!1)return setImmediate(J,ne,!1);I.addLocalFileAsync({localPath:V,zipPath:ve.dirname(E(V)),zipName:R(V)},J)}},S))})})},addLocalFolderPromise:function(_,S){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},S),(k,P)=>{k&&A(k),P&&I(this)})})},addFile:function(_,S,I,A){_=f(_);let k=x(_),P=k!=null;P||(k=new vm(i),k.entryName=_),k.comment=I||"";let E=typeof A=="object"&&A instanceof o.fs.Stats;E&&(k.header.time=A.mtime);var R=k.isDirectory?16:0;let O=k.isDirectory?16384:32768;return E?O|=4095&A.mode:typeof A=="number"?O|=4095&A:O|=k.isDirectory?493:420,R=(R|O<<16)>>>0,k.attr=R,k.setData(S),P||c.setEntry(k),k},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return x(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,S,I,A,k,P){A=Ln(!1,A),k=Ln(!1,k),I=Ln(!0,I),P=fu(k,P);var E=x(_);if(!E)throw Se.Errors.NO_ENTRY();var R=d(E.entryName),O=u(S,P&&!E.isDirectory?P:I?R:ve.basename(R));if(E.isDirectory){var F=c.getEntryChildren(E);return F.forEach(function(V){if(V.isDirectory)return;var ne=V.getData();if(!ne)throw Se.Errors.CANT_EXTRACT_FILE();var Y=d(V.entryName),ie=u(S,I?Y:ve.basename(Y));let se=k?V.header.fileAttr:void 0;o.writeFileTo(ie,ne,A,se)}),!0}var N=E.getData(c.password);if(!N)throw Se.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!A)throw Se.Errors.CANT_OVERRIDE();let J=k?_.header.fileAttr:void 0;return o.writeFileTo(O,N,A,J),!0},test:function(_){if(!c)return!1;for(var S in c.entries)try{if(S.isDirectory)continue;var I=c.entries[S].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,S,I,A){if(I=Ln(!1,I),A=fu(I,A),S=Ln(!1,S),!c)throw Se.Errors.NO_ZIP();c.entries.forEach(function(k){var P=u(_,d(k.entryName));if(k.isDirectory){o.makeDir(P);return}var E=k.getData(A);if(!E)throw Se.Errors.CANT_EXTRACT_FILE();let R=I?k.header.fileAttr:void 0;o.writeFileTo(P,E,S,R);try{o.fs.utimesSync(P,k.header.time,k.header.time)}catch{throw Se.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,S,I,A){if(A=Im(S,I,A),I=Ln(!1,I),S=Ln(!1,S),!A)return new Promise((O,F)=>{this.extractAllToAsync(_,S,I,function(N){N?F(N):O(this)})});if(!c){A(Se.Errors.NO_ZIP());return}_=ve.resolve(_);let k=O=>u(_,ve.normalize(d(O.entryName))),P=(O,F)=>new Error(O+': "'+F+'"'),E=[],R=[];c.entries.forEach(O=>{O.isDirectory?E.push(O):R.push(O)});for(let O of E){let F=k(O),N=I?O.header.fileAttr:void 0;try{o.makeDir(F),N&&o.fs.chmodSync(F,N),o.fs.utimesSync(F,O.header.time,O.header.time)}catch{A(P("Unable to create folder",F))}}R.reverse().reduce(function(O,F){return function(N){if(N)O(N);else{let J=ve.normalize(d(F.entryName)),V=u(_,J);F.getDataAsync(function(ne,Y){if(Y)O(Y);else if(!ne)O(Se.Errors.CANT_EXTRACT_FILE());else{let ie=I?F.header.fileAttr:void 0;o.writeFileToAsync(V,ne,S,ie,function(se){se||O(P("Unable to write file",V)),o.fs.utimes(V,F.header.time,F.header.time,function(D){D?O(P("Unable to set times",V)):O()})})}})}}},A)()},writeZip:function(_,S){if(arguments.length===1&&typeof _=="function"&&(S=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(_,I,!0);typeof S=="function"&&S(A?null:new Error("failed"),"")}}},writeZipPromise:function(_,S){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},S);return new Promise((k,P)=>{!_&&i.filename&&(_=i.filename),_||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(E=>{let R=O=>O?k(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,E,I,A,R)},P)})},toBufferPromise:function(){return new Promise((_,S)=>{c.toAsyncBuffer(_,S)})},toBuffer:function(_,S,I,A){return typeof _=="function"?(c.toAsyncBuffer(_,S,I,A),null):c.compressToBuffer()}}}});import{execFile as P_,spawn as O_,spawnSync as I2}from"node:child_process";import{promisify as L_}from"node:util";function M_(t){if(process.platform!=="win32")return!1;if(Lf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Lf,"").toLowerCase();return N_.has(r)}function Nf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return M_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function st(t,e=[],r={}){return O_(t,e,Nf(t,r))}function Mf(t,e=[],r={}){return B_(t,e,Nf(t,r))}var N_,Lf,B_,Jt=rt(()=>{"use strict";N_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Lf=/\.(cmd|bat|ps1)$/i;B_=L_(P_)});var Yt=oe((fR,yh)=>{"use strict";var wh=["nodebuffer","arraybuffer","fragments"],_h=typeof Blob<"u";_h&&wh.push("blob");yh.exports={BINARY_TYPES:wh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:_h,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ji=oe((hR,ko)=>{"use strict";var{EMPTY_BUFFER:gE}=Yt(),hd=Buffer[Symbol.species];function mE(t,e){if(t.length===0)return gE;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 hd(r.buffer,r.byteOffset,i):r}function bh(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Eh(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function wE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function xd(t){if(xd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new hd(t):ArrayBuffer.isView(t)?e=new hd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),xd.readOnly=!1),e}ko.exports={concat:mE,mask:bh,toArrayBuffer:wE,toBuffer:xd,unmask:Eh};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");ko.exports.mask=function(e,r,i,o,c){c<48?bh(e,r,i,o,c):t.mask(e,r,i,o,c)},ko.exports.unmask=function(e,r){e.length<32?Eh(e,r):t.unmask(e,r)}}catch{}});var Ih=oe((xR,Sh)=>{"use strict";var vh=Symbol("kDone"),pd=Symbol("kRun"),gd=class{constructor(e){this[vh]=()=>{this.pending--,this[pd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[pd]()}[pd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[vh])}}};Sh.exports=gd});var qr=oe((pR,Ch)=>{"use strict";var Zi=le("zlib"),Ah=Ji(),_E=Ih(),{kStatusCode:Th}=Yt(),yE=Buffer[Symbol.species],bE=Buffer.from([0,0,255,255]),Ro=Symbol("permessage-deflate"),Xt=Symbol("total-length"),zr=Symbol("callback"),Cn=Symbol("buffers"),Ur=Symbol("error"),Co,md=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,!Co){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Co=new _E(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[zr];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){Co.add(o=>{this._decompress(e,r,(c,d)=>{o(),i(c,d)})})}compress(e,r,i){Co.add(o=>{this._compress(e,r,(c,d)=>{o(),i(c,d)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Zi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[Ro]=this,this._inflate[Xt]=0,this._inflate[Cn]=[],this._inflate.on("error",vE),this._inflate.on("data",kh)}this._inflate[zr]=i,this._inflate.write(e),r&&this._inflate.write(bE),this._inflate.flush(()=>{let c=this._inflate[Ur];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=Ah.concat(this._inflate[Cn],this._inflate[Xt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Xt]=0,this._inflate[Cn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,d)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Zi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Zi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[Xt]=0,this._deflate[Cn]=[],this._deflate.on("data",EE)}this._deflate[zr]=i,this._deflate.write(e),this._deflate.flush(Zi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Ah.concat(this._deflate[Cn],this._deflate[Xt]);r&&(c=new yE(c.buffer,c.byteOffset,c.length-4)),this._deflate[zr]=null,this._deflate[Xt]=0,this._deflate[Cn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Ch.exports=md;function EE(t){this[Cn].push(t),this[Xt]+=t.length}function kh(t){if(this[Xt]+=t.length,this[Ro]._maxPayload<1||this[Xt]<=this[Ro]._maxPayload){this[Cn].push(t);return}this[Ur]=new RangeError("Max payload size exceeded"),this[Ur].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ur][Th]=1009,this.removeListener("data",kh),this.reset()}function vE(t){if(this[Ro]._inflate=null,this[Ur]){this[zr](this[Ur]);return}t[Th]=1007,this[zr](t)}});var Gr=oe((gR,Do)=>{"use strict";var{isUtf8:Rh}=le("buffer"),{hasBlob:SE}=Yt(),IE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function AE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function wd(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 TE(t){return SE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Do.exports={isBlob:TE,isValidStatusCode:AE,isValidUTF8:wd,tokenChars:IE};if(Rh)Do.exports.isValidUTF8=function(t){return t.length<24?wd(t):Rh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Do.exports.isValidUTF8=function(e){return e.length<32?wd(e):t(e)}}catch{}});var vd=oe((mR,Bh)=>{"use strict";var{Writable:kE}=le("stream"),Dh=qr(),{BINARY_TYPES:CE,EMPTY_BUFFER:Ph,kStatusCode:RE,kWebSocket:DE}=Yt(),{concat:_d,toArrayBuffer:PE,unmask:OE}=Ji(),{isValidStatusCode:LE,isValidUTF8:Oh}=Gr(),Po=Buffer[Symbol.species],xt=0,Lh=1,Nh=2,Mh=3,yd=4,bd=5,Oo=6,Ed=class extends kE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||CE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[DE]=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=xt}_write(e,r,i){if(this._opcode===8&&this._state==xt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Po(i.buffer,i.byteOffset+e,i.length-e),new Po(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 Po(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 xt:this.getInfo(e);break;case Lh:this.getPayloadLength16(e);break;case Nh:this.getPayloadLength64(e);break;case Mh:this.getMask();break;case yd:this.getData(e);break;case bd:case Oo: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[Dh.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=Lh:this._payloadLength===127?this._state=Nh: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=Mh:this._state=yd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=yd}getData(e){let r=Ph;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&&OE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=bd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[Dh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let d=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===xt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=xt;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=_d(i,r):this._binaryType==="arraybuffer"?o=PE(_d(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=xt):(this._state=Oo,setImmediate(()=>{this.emit("message",o,!0),this._state=xt,this.startLoop(e)}))}else{let o=_d(i,r);if(!this._skipUTF8Validation&&!Oh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===bd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=xt):(this._state=Oo,setImmediate(()=>{this.emit("message",o,!1),this._state=xt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Ph),this.end();else{let i=e.readUInt16BE(0);if(!LE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Po(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Oh(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=xt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=xt):(this._state=Oo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=xt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let d=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[RE]=o,d}};Bh.exports=Ed});var Ad=oe((_R,Uh)=>{"use strict";var{Duplex:wR}=le("stream"),{randomFillSync:NE}=le("crypto"),{types:{isUint8Array:ME}}=le("util"),Fh=qr(),{EMPTY_BUFFER:BE,kWebSocket:FE,NOOP:zE}=Yt(),{isBlob:Hr,isValidStatusCode:UE}=Gr(),{mask:zh,toBuffer:Zn}=Ji(),pt=Symbol("kByteLength"),qE=Buffer.alloc(4),Lo=8*1024,Yn,jr=Lo,At=0,GE=1,HE=2,Sd=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=At,this.onerror=zE,this[FE]=void 0}static frame(e,r){let i,o=!1,c=2,d=!1;r.mask&&(i=r.maskBuffer||qE,r.generateMask?r.generateMask(i):(jr===Lo&&(Yn===void 0&&(Yn=Buffer.alloc(Lo)),NE(Yn,0,Lo),jr=0),i[0]=Yn[jr++],i[1]=Yn[jr++],i[2]=Yn[jr++],i[3]=Yn[jr++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[pt]!==void 0?u=r[pt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!d);let f=u;u>=65536?(c+=8,f=127):u>125&&(c+=2,f=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]=f,f===126?x.writeUInt16BE(u,2):f===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],d?[x,e]:o?(zh(e,i,x,c,u),[x]):(zh(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=BE;else{if(typeof e!="number"||!UE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(ME(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let d={[pt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==At?this.enqueue([this.dispatch,c,!1,d,o]):this.sendFrame(t.frame(c,d),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Hr(e)?(o=e.size,c=!1):(e=Zn(e),o=e.length,c=Zn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[pt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Hr(e)?(o=e.size,c=!1):(e=Zn(e),o=e.length,c=Zn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[pt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}send(e,r,i){let o=this._extensions[Fh.extensionName],c=r.binary?2:1,d=r.compress,u,f;typeof e=="string"?(u=Buffer.byteLength(e),f=!1):Hr(e)?(u=e.size,f=!1):(e=Zn(e),u=e.length,f=Zn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=o._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[pt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:f,rsv1:d};Hr(e)?this._state!==At?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==At?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[pt],this._state=HE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Id,this,u,o);return}this._bufferedBytes-=i[pt];let d=Zn(c);r?this.dispatch(d,r,i,o):(this._state=At,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(jE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Fh.extensionName];this._bufferedBytes+=i[pt],this._state=GE,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");Id(this,f,o);return}this._bufferedBytes-=i[pt],this._state=At,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===At&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][pt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][pt],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)}};Uh.exports=Sd;function Id(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 jE(t,e,r){Id(t,e,r),t.onerror(e)}});var Jh=oe((yR,Vh)=>{"use strict";var{kForOnEventAttribute:Yi,kListener:Td}=Yt(),qh=Symbol("kCode"),Gh=Symbol("kData"),Hh=Symbol("kError"),jh=Symbol("kMessage"),Kh=Symbol("kReason"),Kr=Symbol("kTarget"),Wh=Symbol("kType"),$h=Symbol("kWasClean"),Qt=class{constructor(e){this[Kr]=null,this[Wh]=e}get target(){return this[Kr]}get type(){return this[Wh]}};Object.defineProperty(Qt.prototype,"target",{enumerable:!0});Object.defineProperty(Qt.prototype,"type",{enumerable:!0});var Xn=class extends Qt{constructor(e,r={}){super(e),this[qh]=r.code===void 0?0:r.code,this[Kh]=r.reason===void 0?"":r.reason,this[$h]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[qh]}get reason(){return this[Kh]}get wasClean(){return this[$h]}};Object.defineProperty(Xn.prototype,"code",{enumerable:!0});Object.defineProperty(Xn.prototype,"reason",{enumerable:!0});Object.defineProperty(Xn.prototype,"wasClean",{enumerable:!0});var Wr=class extends Qt{constructor(e,r={}){super(e),this[Hh]=r.error===void 0?null:r.error,this[jh]=r.message===void 0?"":r.message}get error(){return this[Hh]}get message(){return this[jh]}};Object.defineProperty(Wr.prototype,"error",{enumerable:!0});Object.defineProperty(Wr.prototype,"message",{enumerable:!0});var Xi=class extends Qt{constructor(e,r={}){super(e),this[Gh]=r.data===void 0?null:r.data}get data(){return this[Gh]}};Object.defineProperty(Xi.prototype,"data",{enumerable:!0});var KE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Yi]&&o[Td]===e&&!o[Yi])return;let i;if(t==="message")i=function(c,d){let u=new Xi("message",{data:d?c:c.toString()});u[Kr]=this,No(e,this,u)};else if(t==="close")i=function(c,d){let u=new Xn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Kr]=this,No(e,this,u)};else if(t==="error")i=function(c){let d=new Wr("error",{error:c,message:c.message});d[Kr]=this,No(e,this,d)};else if(t==="open")i=function(){let c=new Qt("open");c[Kr]=this,No(e,this,c)};else return;i[Yi]=!!r[Yi],i[Td]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Td]===e&&!r[Yi]){this.removeListener(t,r);break}}};Vh.exports={CloseEvent:Xn,ErrorEvent:Wr,Event:Qt,EventTarget:KE,MessageEvent:Xi};function No(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Mo=oe((bR,Zh)=>{"use strict";var{tokenChars:Qi}=Gr();function Ft(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function WE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,d,u,f=-1,x=-1,g=-1,m=0;for(;m<t.length;m++)if(x=t.charCodeAt(m),d===void 0)if(g===-1&&Qi[x]===1)f===-1&&(f=m);else if(m!==0&&(x===32||x===9))g===-1&&f!==-1&&(g=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);g===-1&&(g=m);let _=t.slice(f,g);x===44?(Ft(e,_,r),r=Object.create(null)):d=_,f=g=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(u===void 0)if(g===-1&&Qi[x]===1)f===-1&&(f=m);else if(x===32||x===9)g===-1&&f!==-1&&(g=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);g===-1&&(g=m),Ft(r,t.slice(f,g),!0),x===44&&(Ft(e,d,r),r=Object.create(null),d=void 0),f=g=-1}else if(x===61&&f!==-1&&g===-1)u=t.slice(f,m),f=g=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){if(Qi[x]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);f===-1?f=m:i||(i=!0),o=!1}else if(c)if(Qi[x]===1)f===-1&&(f=m);else if(x===34&&f!==-1)c=!1,g=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(g===-1&&Qi[x]===1)f===-1&&(f=m);else if(f!==-1&&(x===32||x===9))g===-1&&(g=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);g===-1&&(g=m);let _=t.slice(f,g);i&&(_=_.replace(/\\/g,""),i=!1),Ft(r,u,_),x===44&&(Ft(e,d,r),r=Object.create(null),d=void 0),u=void 0,f=g=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(f===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");g===-1&&(g=m);let v=t.slice(f,g);return d===void 0?Ft(e,v,r):(u===void 0?Ft(r,v,!0):i?Ft(r,u,v.replace(/\\/g,"")):Ft(r,u,v),Ft(e,d,r)),e}function $E(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(d=>d===!0?o:`${o}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Zh.exports={format:$E,parse:WE}});var Uo=oe((SR,cx)=>{"use strict";var VE=le("events"),JE=le("https"),ZE=le("http"),Qh=le("net"),YE=le("tls"),{randomBytes:XE,createHash:QE}=le("crypto"),{Duplex:ER,Readable:vR}=le("stream"),{URL:kd}=le("url"),Rn=qr(),ev=vd(),tv=Ad(),{isBlob:nv}=Gr(),{BINARY_TYPES:Yh,CLOSE_TIMEOUT:rv,EMPTY_BUFFER:Bo,GUID:iv,kForOnEventAttribute:Cd,kListener:sv,kStatusCode:ov,kWebSocket:Ke,NOOP:ex}=Yt(),{EventTarget:{addEventListener:av,removeEventListener:cv}}=Jh(),{format:dv,parse:lv}=Mo(),{toBuffer:uv}=Ji(),tx=Symbol("kAborted"),Rd=[8,13],en=["CONNECTING","OPEN","CLOSING","CLOSED"],fv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,_e=class t extends VE{constructor(e,r,i){super(),this._binaryType=Yh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bo,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]),nx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Yh.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 ev({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new tv(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ke]=this,c[Ke]=this,e[Ke]=this,o.on("conclude",pv),o.on("drain",gv),o.on("error",mv),o.on("message",wv),o.on("ping",_v),o.on("pong",yv),c.onerror=bv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",sx),e.on("data",zo),e.on("end",ox),e.on("error",ax),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[Rn.extensionName]&&this._extensions[Rn.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){dt(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())}),ix(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){Dd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Bo,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){Dd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Bo,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){Dd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Rn.extensionName]||(o.compress=!1),this._sender.send(e||Bo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(_e,"CONNECTING",{enumerable:!0,value:en.indexOf("CONNECTING")});Object.defineProperty(_e.prototype,"CONNECTING",{enumerable:!0,value:en.indexOf("CONNECTING")});Object.defineProperty(_e,"OPEN",{enumerable:!0,value:en.indexOf("OPEN")});Object.defineProperty(_e.prototype,"OPEN",{enumerable:!0,value:en.indexOf("OPEN")});Object.defineProperty(_e,"CLOSING",{enumerable:!0,value:en.indexOf("CLOSING")});Object.defineProperty(_e.prototype,"CLOSING",{enumerable:!0,value:en.indexOf("CLOSING")});Object.defineProperty(_e,"CLOSED",{enumerable:!0,value:en.indexOf("CLOSED")});Object.defineProperty(_e.prototype,"CLOSED",{enumerable:!0,value:en.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(_e.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(_e.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Cd])return e[sv];return null},set(e){for(let r of this.listeners(t))if(r[Cd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Cd]:!0})}})});_e.prototype.addEventListener=av;_e.prototype.removeEventListener=cv;cx.exports=_e;function nx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:rv,protocolVersion:Rd[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Rd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Rd.join(", ")})`);let c;if(e instanceof kd)c=e;else try{c=new kd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",f;if(c.protocol!=="ws:"&&!d&&!u?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?f="The URL's pathname is empty":c.hash&&(f="The URL contains a fragment identifier"),f){let I=new SyntaxError(f);if(t._redirects===0)throw I;Fo(t,I);return}let x=d?443:80,g=XE(16).toString("base64"),m=d?JE.request:ZE.request,v=new Set,_;if(o.createConnection=o.createConnection||(d?xv:hv),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":g,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new Rn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=dv({[Rn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!fv.test(I)||v.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");v.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 S;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,k]of Object.entries(I))i.headers[A.toLowerCase()]=k}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!d)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),S=t._req=m(o),t._redirects&&t.emit("redirect",t.url,S)}else S=t._req=m(o);o.timeout&&S.on("timeout",()=>{dt(t,S,"Opening handshake has timed out")}),S.on("error",I=>{S===null||S[tx]||(S=t._req=null,Fo(t,I))}),S.on("response",I=>{let A=I.headers.location,k=I.statusCode;if(A&&o.followRedirects&&k>=300&&k<400){if(++t._redirects>o.maxRedirects){dt(t,S,"Maximum redirects exceeded");return}S.abort();let P;try{P=new kd(A,e)}catch{let R=new SyntaxError(`Invalid URL: ${A}`);Fo(t,R);return}nx(t,P,r,i)}else t.emit("unexpected-response",S,I)||dt(t,S,`Unexpected server response: ${I.statusCode}`)}),S.on("upgrade",(I,A,k)=>{if(t.emit("upgrade",I),t.readyState!==_e.CONNECTING)return;S=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){dt(t,A,"Invalid Upgrade header");return}let E=QE("sha1").update(g+iv).digest("base64");if(I.headers["sec-websocket-accept"]!==E){dt(t,A,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],O;if(R!==void 0?v.size?v.has(R)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":v.size&&(O="Server sent no subprotocol"),O){dt(t,A,O);return}R&&(t._protocol=R);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){dt(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let N;try{N=lv(F)}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(N);if(J.length!==1||J[0]!==Rn.extensionName){dt(t,A,"Server indicated an extension that was not requested");return}try{_.accept(N[Rn.extensionName])}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Rn.extensionName]=_}t.setSocket(A,k,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,t):S.end()}function Fo(t,e){t._readyState=_e.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function hv(t){return t.path=t.socketPath,Qh.connect(t)}function xv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Qh.isIP(t.host)?"":t.host),YE.connect(t)}function dt(t,e,r){t._readyState=_e.CLOSING;let i=new Error(r);Error.captureStackTrace(i,dt),e.setHeader?(e[tx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Fo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Dd(t,e,r){if(e){let i=nv(e)?e.size:uv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${en[t.readyState]})`);process.nextTick(r,i)}}function pv(t,e){let r=this[Ke];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ke]!==void 0&&(r._socket.removeListener("data",zo),process.nextTick(rx,r._socket),t===1005?r.close():r.close(t,e))}function gv(){let t=this[Ke];t.isPaused||t._socket.resume()}function mv(t){let e=this[Ke];e._socket[Ke]!==void 0&&(e._socket.removeListener("data",zo),process.nextTick(rx,e._socket),e.close(t[ov])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Xh(){this[Ke].emitClose()}function wv(t,e){this[Ke].emit("message",t,e)}function _v(t){let e=this[Ke];e._autoPong&&e.pong(t,!this._isServer,ex),e.emit("ping",t)}function yv(t){this[Ke].emit("pong",t)}function rx(t){t.resume()}function bv(t){let e=this[Ke];e.readyState!==_e.CLOSED&&(e.readyState===_e.OPEN&&(e._readyState=_e.CLOSING,ix(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function ix(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function sx(){let t=this[Ke];if(this.removeListener("close",sx),this.removeListener("data",zo),this.removeListener("end",ox),t._readyState=_e.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[Ke]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Xh),t._receiver.on("finish",Xh))}function zo(t){this[Ke]._receiver.write(t)||this.pause()}function ox(){let t=this[Ke];t._readyState=_e.CLOSING,t._receiver.end(),this.end()}function ax(){let t=this[Ke];this.removeListener("error",ax),this.on("error",ex),t&&(t._readyState=_e.CLOSING,this.destroy())}});var fx=oe((AR,ux)=>{"use strict";var IR=Uo(),{Duplex:Ev}=le("stream");function dx(t){t.emit("close")}function vv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function lx(t){this.removeListener("error",lx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Sv(t,e){let r=!0,i=new Ev({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(dx,i);return}let d=!1;t.once("error",function(f){d=!0,c(f)}),t.once("close",function(){d||c(o),process.nextTick(dx,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,d){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,d)});return}t.send(o,d)},i.on("end",vv),i.on("error",lx),i}ux.exports=Sv});var Pd=oe((TR,hx)=>{"use strict";var{tokenChars:Iv}=Gr();function Av(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let d=t.charCodeAt(o);if(i===-1&&Iv[d]===1)r===-1&&(r=o);else if(o!==0&&(d===32||d===9))i===-1&&r!==-1&&(i=o);else if(d===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}hx.exports={parse:Av}});var bx=oe((CR,yx)=>{"use strict";var Tv=le("events"),qo=le("http"),{Duplex:kR}=le("stream"),{createHash:kv}=le("crypto"),xx=Mo(),Qn=qr(),Cv=Pd(),Rv=Uo(),{CLOSE_TIMEOUT:Dv,GUID:Pv,kWebSocket:Ov}=Yt(),Lv=/^[+/0-9A-Za-z]{22}==$/,px=0,gx=1,_x=2,Od=class extends Tv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Dv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Rv,...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=qo.createServer((i,o)=>{let c=qo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=Nv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,d)=>{this.handleUpgrade(o,c,d,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=px}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===_x){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(es,this);return}if(e&&this.once("close",e),this._state!==gx)if(this._state=gx,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(es,this):process.nextTick(es,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{es(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",mx);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){er(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){er(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Lv.test(c)){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ts(r,400);return}let f=e.headers["sec-websocket-protocol"],x=new Set;if(f!==void 0)try{x=Cv.parse(f)}catch{er(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let g=e.headers["sec-websocket-extensions"],m={};if(this.options.perMessageDeflate&&g!==void 0){let v=new Qn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=xx.parse(g);_[Qn.extensionName]&&(v.accept(_[Qn.extensionName]),m[Qn.extensionName]=v)}catch{er(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let v={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(v,(_,S,I,A)=>{if(!_)return ts(r,S||401,I,A);this.completeUpgrade(m,c,x,e,r,i,o)});return}if(!this.options.verifyClient(v))return ts(r,401)}this.completeUpgrade(m,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[Ov])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>px)return ts(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${kv("sha1").update(r+Pv).digest("base64")}`],g=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}`),g._protocol=m)}if(e[Qn.extensionName]){let m=e[Qn.extensionName].params,v=xx.format({[Qn.extensionName]:[m]});x.push(`Sec-WebSocket-Extensions: ${v}`),g._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",mx),g.setSocket(c,d,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(g),g.on("close",()=>{this.clients.delete(g),this._shouldEmitClose&&!this.clients.size&&process.nextTick(es,this)})),u(g,o)}};yx.exports=Od;function Nv(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function es(t){t._state=_x,t.emit("close")}function mx(){this.destroy()}function ts(t,e,r,i){r=r||qo.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} ${qo.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 er(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,er),t.emit("wsClientError",l,r,e)}else ns(r,i,o,c)}});var Sh=ce(Be=>{"use strict";var M=G;function $o(){let t=["C2v0y3vYC28","uuH2Cw4","ywjVCNq","DuP2zhO","yMXVy2TLza","AKHJqNC","vLHXy2u","v2zmvNm","ENPIDhi","qvLkA3i","z3vKB2i","zgjqru4","wfvKvKq","zxnMs2u","DMLlu2y","y3jLyxrLtwu","Bhm6ia","mxW2Fdn8mte","ENPfvwu","wvjjAuW","twTKBKW","D2PmvgS","A2v5","x2HHBMrSzvi","qLDZshy","s2HUzgy","mNWXFdb8m3W","qNjPzgDL","zwrPyxrLBhK","BhrPCgXLihq","AxPnDMi","y3jLyxrLrwW","CeLMqxO","BMvJDa","DgHAtuS","wNL4CwO","EvzADue","CKvntwG","vfHcyvK","C0zmug8","rhfNzxm","z2v0q3vYCMu","EvLpyuO","rKHcCMi","CNnVCL9Uyw0","AKjsqMW","ENb2tue","DfLkzuq","Bg9N","ChjVDg9JB2W","BwvZC2fNzq","ywrKrxzLBNq","qwrKvwq","x2LZqNjVD3m","sfLQuhq","C3rYAw5N","zKrevLC","B09qzey","B3nLrxzLBNq","B25LCNjVCG","B25TzxnZywC","uMjtv0G","veD5uNG","ywnRx2nVzgu","lcbTyxGGCMu","zcbLCNjVCI4","o2nOyxjZzxq","zw50tgLZDgu","zvjwyxi","uvPkt3q","EMvyEeW","x2rItMfTzq","yNL0zxm","Dg9tDhjPBMC","yurhuu0","BKHXsgq","q09oveLovuu","DM9QBfK","x21PBMLoyxy","zgvSzxrL","v29bsve","y2fSBa","tgLZDgvUzxi","whn0t1a","sgXXwgy","t1bftG","B2fK","sevntLC","wNbbvMC","v2THBvy","C2nYAxb0","v2jgrxi","ihjLy29UBMu","yNvMzMvYzwq","tKrutLC","yxv0BW","rLjArxG","t1zouue","CezpqNO","AwzTwMi","DgHHBIbSB2m","r1DUD3O","B250vNa","Efrurw52","vwvYEvy","ChbL","rvjst1i","BgLZDgvUtMu","BM9Uzv9UB24","Aw5KzxHpzG","B1vfD0u","t21oB2m","wgLmzKy","zgvS","zNHrqwu","tM5nzuq","z2vjBMzVu3K","ChjVDg90Exa","mJyXsg11sLnP","B2v4svy","BMDLza","wvDksMO","CMfTugfYyw0","Auf4Axa","EhfJqMe","B25VCgvU","AxjLza","BeXPDw8","D3jPDgvvAw4","zw50","veP1C2m","s2ryyuW","z3nsy0i","zgj4tg0","ufDcC0W","qK1Nvxa","zMvY","uNvdDeu","B2fAEuG","CLPZsNm","CxvnDg4","zMLUza","B25ozxr3B3i","qML2sfO","CgLUz09Uy2u","D2fyq2O","ENjnq0m","CKXcz1a","Ec1TC2CTy3u","z0fLvLm","rwDyy1a","BNfzsvG","A3npv24","tuX3uKm","CM92AwrLige","qvflzgO","CMvQzwn0","vgfN","B3bLBG","vgTKy0O","x2nSzwfYvgK","v2n1Axy","whrnsxa","q29Kzq","zNjVBuHHC2G","AK5oB0S","x2LZv29YA2u","AenSB3nLrxy","ueTOzxa","vLvLsg8","yKvfAKq","zM9Yy2u","CMzIz0W","qunvywC","quHit24","Cg9PBNrbBMq","zNjVBuj5Dgu","sK9IzLe","zNvkyxy","z2v0qwXSs2u","q1rLCfm","C2vYDMLJzq","BML0AwfSAxO","zMHzvhu","DhLWzq","y2XLyxi","ELHiCw4","yNL0zuXLBMC","A1n0yxr1C0m","s3rAy04","D2jRAMq","CMvJzxzPzwq","z3zTzwi","u3HOD2e","zw5HyMXLqxu","ihrVihjLDhi","DwPMvw8","B3bLCNr5","sNfguLi","yMHVtwW","EfH4z1e","sMPAvuG","ywLKAeK","z2v0u3rVCMe","y0v2qKi","rhHIyLG","zMzmAw5L","rwnJz2u","txrwCee","Dgf0tLG","tg9JAW","s0jUqKi","tuTyBu4","AwzAwNe","q05Rzwu","CMDmCuS","Aw50zwDLCIa","DxnLCKLW","DNniqLa","B3bLBIa","x3jLy29UBMu","A2Dlq1e","x2n1CNnVCK0","yw1Lu3bHy2u","AunfCvu","DgfYz2v0","DfnAwxG","Dw50","AxnrB1nby2S","q0fhs0q","x3nVy2TLDa","Dw5KzwzPBMu","z09lvhK","Ec1TC2CTCw8","EwvHug4","AMvJDfn0B3i","z2v0q3vYC28","Bwf4uMv0CMK","B2jQzwn0u3q","weXut1a","AgfUz2u","Dg9cExrLC0W","EePXC3C","zw50zwqGDhK","svPHCwC","rMTxveK","rLv6DvG","B2zM","A2v0ignVBNm","B3vUDa","sMn4vMW","Dhj1y3rVCIa","zgrjrcWGzgu","CuXdvNG","ChrVCG","B2LUDfjLywm","zgjsse4","C2DPza","AM9PBG","Aw5Lza","rLHYC24","AuzAq1q","zxrxB3jRq2G","svjJDwS","zufOuwq","zw5RyxG","AKXwr0C","uMLVCMO","ywXSq3vYC28","venlwKy","C3vIyxjYyxK","r2HzENa","vKLPC0W","uK5hswW","Ae9Wzw5fDMu","zvvYBa","C0fpzMG","yMHmExK","CgfYC2u","zNjVBunOyxi","Curcrvy","vvD3AgK","DhLsvfG","Ae1LC3nHz2u","y3vZDg9Tshq","CNPlsLq","DurQAgG","C2vUza","zuP2sgO","CLLmqwG","zKXtvxG","vfvvuKq","qMrpvuq","EhfNEw8","rNLhANi","AgfZ","CgT3ENO","vxzHBeG","rg5Vwwi","s0nxENa","sevTBw8","Bu9YELi","zfj2Auy","uKjctw8","Bg1Mwue","swrgt0S","BgL5tvm","BNvTyMvY","Bg9JyKm","DufOEum","ww50uhy","uMvwuKG","qwnbDeu","z29PBMCGyxC","zwvUu3e","zfLny0C","tMXdrfG","AhrMy0e","t3bLBKv2zw4","suvtx0vsuK8","x0vysvnu","tLHfrvi","swX0vNm","CMvWBgfJzq","AhjQBK0","BuDHr1O","wxL5tgG","ze1st0W","zgvMAw5Luhi","B25fCNjVCG","v3zcwhy","ywXSzwqGBxu","y2rQreC","CNnVCL92ywW","yxnZAwDU","C25HvwW","y1vkt1u","wvbHANC","mNWZFdb8nhW","AK5OtxG","sLjYAKe","vLjuEMO","zfrrz20","x29WDgLVBNm","BMnVzgLUzW","v3PIEeC","Cgfxsvq","BgLUzw5V","zxjFDhrS","x2zVCM1HDeu","wuX6AK8","C29YDa","txDwwfu","AKTuwKi","t2jKyLK","t0ngveS","rMrSvu0","qMLOBKS","u2z1y1a","y2XVC2veqG","Cw9Z","B3nLza","EM1oDfy","CgXLyxnLiha","x2rPC3bHDgm","v2LoEKy","qK9ND3m","Cg93","zNDZxZeUmc4","BxnN","yNL0zu9MzNm","yMfSrxzLBNq","zhHQAuK","sxbUAva","AwDmt1a","CIb0DhDjra","DgvmB2Djre4","rwnXug0","DKnzv0i","A1PbAhm","qw1VDw50","yvHjteK","uLbsEKC","zKrOuLG","rhvMrxu","vuvQC04","DfDmq3e","DMvY","AwXLtMfTzq","wKHvtuC","BhnfCuS","vvnVsei","CMvWBgfJzui","v1nzCgi","t1ntzKG","DgHLBG","y09Wzw4","D2LSBfjLy28","B3jpBMXPBMu","z3vNEhq","AMXzCwy","zwDzBLq","r0rPwMO","s0HrD08","CuLZBfC","CYbWyxjHBxm","Dxrjza","Dg9mB3DLCKm","Dhbtqxu","vxjkBhO","Dg9iyxnO","D0n6sxm","rMvqu04","y29UBMvJDca","BNz1u3K","sw5uyxO","tKDFrvjst1i","wM1gBvu","C3rVCcbPBw0","ihrPBwvZ","Bg9IywXty28","AevYCM9Yrxy","tM55Chm","yuHMDvG","BgrnBwq","Bwf4twvZC2e","vNPKBKe","tMzgz0S","CM9pwMG","wLHqtu4","zfDVCMTLCKC","B2zMBgLUzq","qMj4tgC","CMvHC29U","CfvkqKe","zvjhrKi","y3jLyxrLq2W","ywr2yw5Jzq","BgL0C0G","DMvYC2LVBG","FdD8nxW0Fde","zhfRtLC","BKXZDuu","q1rWBu4","vM9rDuW","q1frtgK","zsbHihn0CMK","uxHmuLC","y3ruAw1LB3u","mte2mtKZmMjxvwvKEq","A3DIsfy","zw5JB2rPBMC","Cu9xzfG","u29ptvy","Ef9MCM9UDgK","zKXjqxa","y3vYCMvUDeK","x2LUAxrhBg8","zKDMCxO","D1Dwvhq","yw5Nzq","DwHLyMy","Cg9gzNC","v1nTCxC","wuLdzuq","qNjsvge","q0LXvLe","vhnlCuq","x3bPBMDqB24","x3jLBw92zvC","Dev2zw50","wMj1r3G","yMLUyxj5vhK","CMvJB25Uzwm","t2viAgm","DhjPzxm","t1PWEMO","whPeAxe","yw5XDgu","x3bYzwzPEa","DxbKyxrLq3u","r2jvDM8","rMfyCwG","DMvUDa","twvZC2fNzuu","r3fstLa","ALzqwLO","u2HHCMvKv28","v3nUBg0","zuXHv0O","AxviAgy","CMvUDevUzha","Ce5yr0O","zxjFCw9Zx2e","ywnRx2LK","BfDAvvi","qKvPDu8","DKrYyMK","Ag1ZAum","D0f5CNa","rgvKAwnHDgu","x2rLC3rYB3K","CMvZzxruCMK","BMrWB2LUDfq","AwDHDg9Yt24","B2nRzxrtDwm","C0rzzhu","x2DLDeLUDgu","icSG","BezSDxnO","DcbVzIbYyw4","v3vOAgO","B3L0rg4","BgLUzq","ywfnDKC","Dfbtufa","B3bOuwG","s2r3shC","ywnOzwqSihC","y3bZsMy","yu9nBNq","veDWsKq","v1fOvM8","x2nVBM5Ly3q","zgvJB2rLzey","Ee5OthK","CMvHzhDYAxq","AejVthC","uKfPB3u","rMz5DeS","A3jRwfC","B25nzxnZywC","vgvbrfK","u1jcv1m","BKLwug0","y3vYC29Yx24","ANb1uMq","uhPKwLy","rgHhEMe","u2vXsuq","Dxf6Bhm","C0rJwuS","C2vYDMLJzs0","x3jLywr5q2W","reXku2K","CvzTrgm","tNPZB1q","uNPxALq","ignVzgu6ia","vw1jDxG","C2XPy2u","rKr3C0q","whvPC1e","x2LZtM9Kzq","A2XpsuC","x25HDMLNyxq","zMLgue0","ig1LC3nHz2u","BKv5q3C","x2DLBMvYyxq","s0XOvuG","rMDbAgW","CejxwKW","CLzHBhvLCW","x29UugfNzu4","AgzRtLK","CLvkyLy","x2HHBMrSzva","sffjtfu","q3jcC3e","Buzovfu","tg9Nsuq","q291BNq","zw5KCg9PBNq","B0LsrMm","zMLSDgvY","Bun2u1m","CNHVqM8","BwLZzq","sxv4BNa","Dw5ZAwDUzwq","Cuvotvi","tfznAg8","Ber3vxe","q2nPsLy","rvjOvwW","yLDcC20","nti5mefUAMXTqG","BMv3vMvYC2K","uxbereC","B0v2Eum","CML4Cva","mdaWmdaWmda","vgPmtwO","quTnDNC","shDXz08","BwLUzW","tNPkA1G","EhvNvKm","BMrLEa","zLvOuvC","vvfzzxK","yxKSig5LDhC","y291BNq","CgPyBeG","CxLLD2i","tLfuteC","mNWWFdr8mxW","z2vrDwv1zuW","r05ktLa","AwXK","yxGGCMv0CMK","q1PgwgW","yKfSENa","tfP3AhC","ywXSB2nvBNm","EvnhCMC","CuvvAK4","AxmGDw5Kzwy","BwvZC2fNzv8","zg9Uzq","yMfoweO","yxDWsgy","z0jTEwG","uuHxB3e","vKH3Bwe","zgvSzxrLrge","tMj5v0y","m3WYFdr8mhW","x3bYB3rVy28","y2XVC2uSihC","BMv4DcGPigm","D3nZoI8V","CMfUzg9T","twH5C2S","AuvIuwe","z1bKs3y","yw1LoIa","u0XAvuK","z3nAwLq","EMDxBLi","yxrLq291BNq","EvLos3u","zNjVBujPDhm","q0Xpu0ve","x2LZsw5PDa","rKzpr1u","C2v0q3vYC28","CMTsyLG","BgLTAxq","AeLjuLq","B1L1BMm","C3vJy2vZCW","vvndqLy","yMLUyxj5","wunxCMq","ihzHBgLKigq","DxrVuMvJB24","CMvHzfvjBNq","rLzut0C","AwHJDg4","yw5Hz2vY","Chv0","DeLK","C3bSAxq","B25tDg9Wsw0","x2LUDgvYDMe","ALjWz3G","vujVA2O","BvzVC0m","z2HkvLa","yw51Ce1LC3m","yvrewMO","zxrmAMS","rvvpz00","v3jrr24","rwfAAu4","DhDVCMTdAge","ve9XzLK","z2v0","qMreA0W","sNzzt2q","tuTArxm","q09Ys20","DMDstNu","Exzms2y","zMzLCG","x3bHDgHlzxK","BeLTBxu","x2LZtwLUAvC","zxjFAxnFywm","A2v5CW","Cg9PBNrdB24","C2HPzNq","vLL0Deu","uwfXs3u","wNHcv0K","r0Tzy0i","C0nVDw50zxi","zv9ZDwnJzxm","zxjFywnRx20","zeXkwu0","BwDPuue","C0XMDgO","q1DMq2i","B0XWr28","Du1kyuS","tgrMEuy","wvP6Bw4","BM5Ly3q","t2jQzwn0","u05Lyxu","yNvMzMvY","q2DsvwC","wvzwv2O","CgLUz19VBMm","rwLXswS","uu9gree","EgPksui","AvzAq3a","sgnODKS","z2Pwv2C","BxvUsKe","ChvZAa","u1ruq2m","AgvHzgvYCW","z2v0s2v5","igXHCMDLCIa","vMrqB1m","B053zgi","y2PNtLq","CMvZzxrfBMq","q2LSAhu","C2vUzf9Hy2S","BKXPBMu","vwTRENi","BgTsENy","yM9L","x3bPBMC","yMfSu2nVCgu","Bwu6ia","x29UtwvZC2e","AvjYCKy","t0vRCfC","rNjVBNrPzxi","qLfVrw8","vvrlrhm","tK9QBe4","sNLVtgC","CwnKBfm","Aw5N","BMCGzMfPBgu","B3jtEgS","Aw5KzxGGB3u","t25zsMe","y29Uy2f0","yxbWBgLJyxq","Dg9cExrLC0i","q3vtANG","vNjlCw0","zuHjwNi","ruvRChy","uwfoEvu","sfDqAui","q01RquS","DuvRu3C","yKjdEhy","BwfW","t2nstLi","x29Uq2XVC2u","reLQqNy","zNvUy3rPB24","yxKSihrYEsa","q3jMAw4","DvDts0C","zufJAW","CgfNzxnOB3C","yxbmz3O","tuTbExe","C3rVCMu","C29QB0K","CgvYC2LZDgu","C3nHz2vfDMu","vevLwuO","CNzHBfzHBhu","x2rLyNvN","ywDLu2HVDW","tLLhCLG","BwHjtxO","ALrezNu","wK9KsKK","tgvVrKG","ywrKq291BNq","BvLfCxG","y3jLyxrLt3a","mty0ndGXmeH1A3jSrW","C0XPC3rLBMu","tKfbBwm","uKLnqK4","twLZC2LUzYa","x2nSzwfYugK","B3bLBKrc","q3fevMy","u21JALm","yNrQvKS","reXotwS","CfvfCKm","ywnR","C0ryAKi","x3vYBa","x2fKzfDZtgK","D1fZDLi","BeHHBMrSzxi","y1r4y2e","BfrPBwvVDxq","mdaWma","C3rYAw5NAwy","EfvZzuvUDG","z3zYAgW","B3v0sw50zxi","x2LUAxrqCM8","qwn4Ehi","sM9gDuS","y29UC3rYDwm","DxrMofDYAxq","B0nyv1y","z2v0qwXS","D2DAuue","zMX1C2HfEha","CMzor3C","B3jLtMfTzxm","z0v4uxO","y1rxu2y","ysbTDxn0igi","C2H6r1q","qK5irKu","vKfHqwm","vfjIq00","y3r4","z2PSB0i","q3vZDg9Trxi","tuTPr20","vNzUC0q","AwXSihvZzsa","AwL3Cxe","whndwem","zLHNz3C","yLrnsLO","zxjYtM8","rMPiu2W","wxbgBK0","ruXnAK4","CMvHzhLtDge","u2vovwm","DgfIyxnL","CMLLC0nVDw4","mJeWnti4nNPbAKDJDG","zgPXt2u","jMPZy2fSBgi","zM9YrwfJAa","AuPlq0W","B2nRzxq","Cfz1uLy","yxbWBhK","CMvZDwX0","DMfSDwu","ywrK","x3nLCuLK","DMvYC2LVBMm","uKHiq1i","yMrFzgLK","rM5LshK","EsbJBg9Zzwq","C2vYDMvYvgK","CwDwz3C","AefJA01LC3m","tg9NsurozxC","EKjcDfi","wuvYvum","wK50zhu","BLHTse4","CYbHBhjLywq","Bvngz04","x194x21Zz18","CMvTB3zLq2G","s2fgAg0","BgvY","quvIA2K","zcWGDw5RBM8","sLbnEgK","wM9HEMS","vLDbu0K","AuHur1K","zfvZvfe","zw1Zvg8","zxH0ugf5Bg8","y2HnyxHuCMK","Bwv0Ag9K","Cu5JrwC","yxDAAwu","t01ur3a","qKPlwK8","EMDoExq","wg9dtwG","yNPzz1q","v0viEMO","EKLJzuq","nteWntzxDMfbqM8","ENzyr08","Dw1MDhm","ruHtq3C","x2rPC2nVBM4","zw5HyMXLuw8","EvfoCKm","rNf6quO","y2Tgv0C","Ahfmuwu","uwD5rKC","CvfdCxC","x2TLEvbHDgG","rLHvBui","yNbqCuG","BMnICfO","y2HLy2Tszwe","DMfSDwvZ","CLnLyNO","Eerwzge","ywX3yxLZ","CeDMuu0","CgfNzwHPzgu","tfvRvu0","x3DZsw5ZDge","qu1ywfq","CvfLAxe","qwjVCNrfCNi","BMrWB2LUDca","x2XPC3rLBMu","x3bPBMDmB3m","CMvJzwL2zwq","zxmGCMvHy2G","A3D4vhu","Axnby2TdBgu","yMzhD0y","q1nlrLu","tKfusvzfx0u","CgLSEgi","AgzWswq","AuzjruW","su5iz0q","AxnmB25N","uLjpuG","yw5ZzM9YBvq","Cvbcr0K","q1rTreu","rfjAsve","z3zOreq","v0ftrva","A0vjCfa","Dgv4Dc9Qyxy","uhHQs3O","Aw9U","v01pDwK","De1HBMfNzxi","rfn0Euu","C0H6qNO","uLL2vgy","zw5HyMXLvhi","uxvLDwu","CMfTzq","Aw5L","B3jRig9MzMW","B0XoDeq","rxHlqNO","u0rZvfO","q3DPq0q","BuzUDMu","CfrzCKG","x21LC3nHz2u","DhjHBNnHy3q","uwvkuwy","v1DVDxa","AxnAzxjV","u2TPCcbWyxm","zw5JB2rLrNi","CgLUz0XVC3m","Cev0vNm","D1LXzNy","y3v4Bfe","yLjezve","ve1OB2q","x2rYB3bhBg8","tNngrLq","rMPbCva","Aw9UvgLTzw8","sxn1rMi","AxnbCNjHEq","wePwC04","CMvXDwLYzwq","shnOEMK","x3nLBMrby2S","ywnRtxnNswq","igfYCMf5yNu","ugLXDe8","ywjTsxm","zu96wMi","CM9YrxzLBNq","ruD6vfC","zezhDNO","BK5Lu2C","zxLfy3m","ruDSqKq","ihrYEsbYzwm","ve93uNi","yxjYyxLIDwy","B25mAw5L","rKfmAeq","BfDJEuO","z0vLueO","zcWG","y2vZC0HHBMq","vLDty3y","Aw1LCYbPBIa","uMvHzcbWyxm","uvjKCLm","reHhz2q","Ec11C2uT","vhnMsgG","Cgfbrey","qM5VD1e","weXdrLy","DgvZDa","y3nlDNO","v2vPEgLUsLm","vKvIrhe","EvjLy29UBMu","vg5UvMK","AxnszwfKEq","DKLkr2K","BM5kD3G","y29UBMvJDfm","nhW1FdD8mW","zxHWB3j0CW","BIWGAg9ZDg4","s3L4wfC","rLPfAfO","y29UBMvJDeu","reX5C3i","Bg9NsurozxC","zgL1Cg0","vwrTEeS","C21gA0G","x3fVC0rc","zNjVBNrPzxi","Cgf5Bg9Hzeu","AxjjAuu","t0jOtLq","BwvY","AgLNAa","rejnqKS","rM1qCKC","ywnOzwq","BhnHsum","y2HHCKnVzgu","A3jjshe","tw9KDwXL","EeLjzg0","zwv2Awi","CfbiwK8","ExbL","BwfUDwfSihi","BKPNu2q","qwrMvxe","ihn1y2nLC3m","nxW5FdeWFda","ru1rufu","vNHhChG","twvNq2S","Evr6zNK","DuTWBNq","rNvizhi","BgnoA0i","C2vUDa","D3bNAfq","wvfVufG","BNrLCG","zeTQz0y","DxjS","ywzOBeq","tufyx1jfvfi","vw5PBxbSzw0","r0zPrfG","x3DZ","twzysNi","wvr2u3q","qLPhAvm","uvrqvxC","ze96r20","zxH0zw5ZAw8","B2TVquK","vg9Vvxm","z2vY","CxfsuKq","CfHszg0","r0rHtu8","Dg9VigXHCMC","qxPpDgi","ywDLsgLKzq","rNj5vxq","zMjtCM8","ywD4yMu","C29Tzq","x2LUAxq","zxjFBxnNAwq","su54EgW","DLLPCwm","u3vqwMK","DhjPzxmGCMu","B0HIqK4","EKjNzgm","q29UzMLN","qLnhEwK","qxv4Dge","u2fHwxm","y2f0y2G","CgLUz1rPBwu","wuT4r04","zxq9DxrMltG","DKD5CfO","BMnLq2XVC2u","AezIwum","DwXvwKy","vuf2Cei","A3zAzuO","BNnVrMW","y0vlzhG","D01QBKy","EKPvA2C","txDNt3a","BMLjAve","EwzKqK0","EwrcBKm","rNHXBvm","x2n1CNnVCKy","v2vIu29JA2u","C2fNzq","B25tDgfYDfi","y3vYCMvUDeu","vevNsvi","y21JEhi","tvjKwMC","x3DHAxq","zMzMzG","BvLdEMK","wNrYAfm","DfPizMy","BNPeseq","tuvtu0fhrv8","AhLlBNe","lcbOB3n0BMe","vNz4D1q","D3jPDgu","zeLit0e","qvrlthK","wNzIChm","qLvtu3C","vuXTAM0","A0fkDgm","CNjyqKe","CwjlwLi","rvDOsMu","l3DZl3yY","verhB00","BgvUz3rO","uhHQB1q","rw1sweq","uvDeuuW","CezAs0O","AwrWqLG","C3rLBMvYCW","r3PSt04","BxnNsuq","CKHRyMi","ywrKt25L","uKHMALC","uKXjEMC","AvPRse8","zxj2AwnL","ChjVy2vZCW","ANvkAKG","quzjAxG","CNzHBa","DwfWzhm","CMzTzfm","AvjOt2K","DNPLs2u","qMXQuue","vfjRtM4","rw1QAuS","DNz3yNu","x2LZtwLUAvq","Cgu6ia","x29Ut3bLBG","t0f3B1y","CMvKDwnL","ywH0Du4","ihbYB3rVy28","A1PQr2y","uu5gtu8","AgHMuNi","u0zuEe8","t0nTwgC","zMLN","vNPIrha","yvbcv0i","AerhCLK","CNjVCK1LC3m","rhfXsvC","ywXPzcb1CMW","ExrMD0C","rgvlqNK","wwHbuxm","CMvTB3zLrxy","ruDStuS","tMfTzq","Dhr3Awq","s3vjwhy","EKzjug8","CKTks3u","z3H2wMS","zfj3uw4","B25szwnLAxy","x2vUzhbVAw4","Ahbmy2m","y3jLyxrLuMu","BuzcC28","ze9bBfK","zxjLDuS","AxnrB1nnzxm","zw1PDa","x29UrxjYB3i","zvH5r2i","CffOu1e","ywXS","r3HTt20","sxPMCLq","Ahr0Ca","Ae5AAhO","v0XRt28","q056weG","zgv1vKS","vuT0Avu","uMvJB25Uzwm","CffisfC","txvHA3O","CwLuC04","y29UDgLUDwu","wKDRAgm","vKzcDxe","vw5Oyw5KBgu","Bg93","x2nYzwf0zvm","z2DJCLG","wM16De0","uLPLBuO","yM9KEq","seTOqNe","CM92AwrLigi","B25dBg9Zzq","Dg9oDw1Izxi","y3jLyxrLrxi","uw9ZvNm","x19LC01Vzhu","Cff1BMm","C0Ljtha","qvjgzKu","uuPbz0y","u1jKAeS","ihrPBwvVDxq","BNruCMLLC0m","A1nIs04","BNrfBMrWB2K","BgLtrfK","D3m6lY8","zwn0","ENv0Eee","zgvIDwC","uurdwuO","ywXty29Wzq","EMz3B1O","rufTB2y","Dgv4Dc9WBge","EhvizMq","D24GCMvHC28","AenKrwW","ALLsBLq","wMPNtKS","tMHuqKi","yvHqqNK","tevcz1q","x1fVu01HBMe","y29UBMvJDgK","sMPYCfa","tvbIELG","zMLSzw5HBwu","ywvIBK8","BLP1BLy","ywDLrxzLBNq","Bwf4tg9ZC0m","C3Pewe0","Dg9Y","zwHbzgi","ywTyq0K","v3Pkr1O","rfvxvvO","r1fkEMO","CMXwt2C","sfLou0S","EuHWAxu","DNnhv2S","rxjYB3jdB2q","zxjYB3i","zxjFCw9Z","qKDUrei","zw1LBNq","q3vZDg9Tq2W","Afryrvi","Efjuqum","Exbwze8","yMfJA3vWigu","uNnYueu","C3rHCNq","rgPKv2q","qwjmvum","Ce9NCMK","EuXlqLe","vhfjr1i","sLLqwMC","DgLTzw91DcW","rfvishG","v2DlB2C","CgrrqxK","yKHtAwu","r1z3Bfq","BMfTzq","D2fZq2XLyw4","su5tvefova","DgLLCKPtt04","ywzL","igzPzwXKoIa","B25SAw5L","BwvZC2fNztO","yMTOtwS","weH2qwC","tuzqyuO","CuTWsxO","wM9dr00","tgjOu3q","z2Xquw4","B2LVAxG","AvLVDgy","q05tA2O","ru9ntxa","Dxbrtwu","B3jRzxjhBg8","y29SBM8","s0Liz3y","EvvpDhK","CKHLsuO","ue5nsNa","AgHzC2e","tMTKrxu","vKjND20","AgfZt3DUuhi","zgTSufa","CgjICdi","B1vdD3u","AM9lyxO","B2rLwwO","CMvZzxrdB3u","AeXYq0m","tuHIr2K","q0D4AeW","EKXKz3G","q09otKvdveK","y3vYC29Yx2y","qw9uwKK","AwrI","vvfNqw0","C3vgq0O","z1rPBwvVDxq","qNnNq0O","zgf0yq","z2v0sxrLBq","wvnHt3e","BfjmvNy","yw1L","yNjvExe","BwvKAwf0zwW","y29TCgXLDgu","rKfWEum","twD1rwm","rK1jsM0","yvb5Cgy","qM9Kr0C","ChDkz0C","x2HHBMrSzu8","CKvVDem","rMvrB0e","veHYENC","r2LPrxm","yvndBMO","DwngCNG","ywnRpwzYB24","sgzzzwu","tMLfsuy","tMLfAMe","EunnBfO","y0Tjveq","CgLUz0LUDgu","yxrHlcbKyxq","A3LWC0O","D0nzzwS","DhjlzMy","DNfUqvO","qvHhu2m","q3rQrw0","rwr6u1C","zKvgwKK","B2nRzxrgywK","zgTjB2e","zKXsAeO","BunfDKe","BfLbB2K","zfrSrxO","zxjYtxnN","DwHlBgm","C2v0sxrLBq","x0rctMfTzq","vhbdy0e","zxzZqLe","mZG3me5XtuDqua","rNjSvLq","DerzueC","y0T1u3a","EurAEgi","B2vmzuq","D0vLrgC","y2uGBM90igK","zxzru1K","rePqAfO","y2XVC2u","Dfjsy1C","yMLUza","CNnVCKzPBgu","mZvxrNr1sfy","zwTjrvm","sMf6uMO","Aw5PDcbrB1m","C3vIC3rYAw4","u1fVueC","qNDzteS","rw93tfa","BMvY","rhPWD0K","wfDHvey","rLDt","CM92AwrLihC","C2v0u3rVCMe","sLD6wLm","B25JBg9Zzq","tLHkywy","uM9xD2y","AgDYvKy","txvKBfi","Aw9Ul2PZB24","DNrTD2i","Avnbv3K","C1nvzxq","uKr2Ewu","tNnkrMS","wvnhv1q","zwvKzwq","y2HnyxHdB3u","qKDut1q","sfrtvuy","ugvivum","zw5fDMvUDa","vgvgz2y","Bg9Nsurhzw4","qMrdDLq","DvHnrKu","Dg9cExrLCW","BMXtuLC","tK1kyxG","Dg9hzw5LCMe","EM9VvMS","Cu14C0G","q1LeD1O","C0Xf","shPtwui","vNfJB1e","DwTWs3u","qK9orMW","zv90Aw1LB3u","vgLTzw91Da","EePlCxi","wffXz3C","CNPlC3a","BM93","DefHBM4","v3vzrgy","B0rArKe","BKvIuui","q0fpDfm","DfvZvNq","DwPjAxC","s1HKtLi","zMXVB3i","uu12EgG","Dgv4DfbHEwW","EvbVEuu","C1POrLe","C2H2AuK","tMLfqLC","rxzLBNq","DMfS","wwTUDKK","BMvLzf9Hy2S","AK1WDeq","B2zMC2v0","zvvJreC","y29Kzq","suXNvvu","BM52Avi","tg1jCKC","qwfHwuG","B25vtxi","BuniDhC","uKXeEhq","CMvHzg9UBhK","B3bLCNr5tMe","z0PkvNK","igzHAwWSig0","Cgf5Bg9Hza","zwnVBM5Ly3q","t1bftL9fuLi","zMLABNy","yMLyAxi","ufD1v3q","q0j6Dvm","vKXut20","qKT1Du0","zNjHBwvuExa","vxzZAvy","sKDdEge","sNfbEhy","uNrTAu8","x2jPBMfYEvq","BMDuAw1LCG","CNfSuwO","zNjVBu51Bwi","z2vtEw5J","AvDQqM0","B25Uzwn0Aw4","sNbiqNO","DfjLsMy","uhjPBwfYEuS","AxbgBvm","wvvzzM4","ELLoAe4","uuTLy0S","m3W1","CNfVzLG","Aw5KzxG","BLHgBhO","BejdAM0","t3nAyKm","mtmZmJLNuwHMAwu","wNPyBhm","DM1vuKi","C0jf","sLnptLa","vxjTseC","DhjPuhG","t2LvAwK","u0fcqxa","v1nLvu8","Afj2Awm","Dw5RBM93BIa","BwvZ","sKXvCNq","v2fjsgq","Aw5JBhvKzxm","B2XKvMvYC2K","B3jL","DeLUDgvYy2u","BNrbBMrvCgq","x29UvgLTzw8","A1jcyLG","Dhf5EfG","Cgf5Bg9Hzfq","EKXpz2K","ywnRDxbfBMq","y3vYC29Y","t3rTA3y","yKr6DgW","tu9xqva","B1HZDgO","yxnL","AgH2s2u","uMP4BeC","AxnFywnR","zNvyvxK","AwXLx25HBwu","CuXxq1m","qxfAzgK","y29UDgv4Da","DLH2Exm","DMrQu0e","veLADMO","zxf1ywXZ","uKj6CNO","u1LpzLm","v3rAwgO","r1n5Cwy","z1bhtwe","v0XWDe8","AuDJwvO","sKPTy24","u2vYDMLJzvC","CMvZB2X2zq","ywDL","A1vRwKy","mtm3otu3uLnzvhnq","AgT5qK8","C3bbALG","BgrxBeS","DNbTDgO","y2rRtMG","uK15EhO","DM5rEKO","rw1mDei","C2v0","m3WXFdH8mNW","DgLUzYbZzxi","tujrA00","wNHkAwu","q1jkuha","yuXsyLK","ENbAy1y","y29UBMvJDa","yxv0B21HDgK","rMLnvwW"];return $o=function(){return t},$o()}(function(t,e){let r=G,i=t();for(;;)try{if(parseInt(r(1821))/1+parseInt(r(775))/2*(-parseInt(r(1959))/3)+-parseInt(r(637))/4+-parseInt(r(983))/5+parseInt(r(1044))/6+-parseInt(r(1642))/7*(-parseInt(r(1095))/8)+parseInt(r(1765))/9*(parseInt(r(1628))/10)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})($o,244335);var Ov=Object[M(516)+"operty"],Lv=Object["getOwnPr"+M(1728)+M(1777)],_h=(t,e)=>function(){return t&&(e=(0,t[{nJgSd:function(c,l){return c(l)}}[M(1258)](Lv,t)[0]])(t=0)),e},Nv=(t,e)=>{let r={HZgbg:function(o,c,l,u){return o(c,l,u)}};for(var i in e)r.HZgbg(Ov,t,i,{get:e[i],enumerable:!0})};function Mv(){return hh||(hh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Bv(){let t=M;return ph||(ph=[IDBCursor[t(1958)+"e"][t(625)],IDBCursor.prototype[t(1443)],IDBCursor[t(1958)+"e"][t(1443)+t(1754)+"ey"]])}function zv(t){let e=M,r={nBJSv:function(o,c){return o||c},ZjgNK:"success",odeYj:e(1508),hFbYC:function(o,c){return o(c)},zHXrY:function(o){return o()},OBhNT:function(o,c){return o===c},uIXQF:e(918),YSaOq:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={zrMCC:r[l(1483)],CBvQH:r.odeYj,jNNoK:function(x,h){return r[l(1317)](x,h)},jKTZB:function(x,h){return x(h)},QHvqn:function(x){return r.zHXrY(x)},Wuhhj:function(x,h){return x(h)}};if(r[l(1243)](r.uIXQF,l(918))){let x=()=>{let E=l;t[E(1409)+E(1908)+E(1650)](u[E(1987)],h),t[E(1409)+E(1908)+E(1650)](u.CBvQH,m)},h=()=>{let E=l;u[E(2006)](o,u[E(541)](Ft,t[E(1052)])),u[E(1842)](x)},m=()=>{let E=l;u[E(699)](c,t[E(1508)]),x()};t[l(1892)+l(1923)](r[l(1483)],h),t[l(1892)+l(1923)](r[l(1565)],m)}else{let x=this[l(1239)][l(2044)+l(1749)](this._prefix),h=_0x64ee8f[l(2119)](r.nBJSv(x,"{}"));return h[_0x28be0d||_0x5494d8[this[l(875)]]]=_0x39c574,this[l(1239)]["setStora"+l(1749)](this[l(667)],_0x5bf1c2[l(1004)+"y"](h)),_0xb452e8||_0x4376a8[this[l(875)]]}});return i.then(o=>{let c=e;r[c(1581)](o,IDBCursor)&&Pd[c(1830)](o,t)})[e(1311)](()=>{}),Zo[e(1830)](i,t),i}function Fv(t){let e=M,r={SRBWS:e(1643),CSKFU:function(o){return o()},lYAoi:e(1586),CqDVf:e(1508),UtPFA:e(1122)+"or",glPQn:function(o,c){return o!==c},kwxTu:"Myhpd",YknvI:"abort"};if(Vo.has(t))return;let i=new Promise((o,c)=>{let l=e,u={fUhQW:r[l(1620)],IZaqg:r[l(990)],gBmyh:function(x,h){return x(h)},diupm:r.UtPFA,zfwoZ:function(x){return r[l(1131)](x)}};if(r[l(1545)](r[l(1128)],l(498))){let x=()=>{let E=l;t["removeEv"+E(1908)+E(1650)](u[E(788)],h),t[E(1409)+"entListe"+E(1650)](u[E(2085)],m),t["removeEv"+E(1908)+E(1650)](E(1843),m)},h=()=>{let E=l;if(r.SRBWS===r[E(721)])r[E(1131)](o),r[E(1131)](x);else return this[E(1239)]?.isReady},m=()=>{let E=l;u[E(811)](c,t[E(1508)]||new DOMException(u[E(1236)],u[E(1236)])),u[E(1476)](x)};t[l(1892)+l(1923)](l(1586),h),t[l(1892)+"Listener"](l(1508),m),t[l(1892)+l(1923)](r[l(1714)],m)}else this[l(1016)+l(1967)]()});Vo[e(1830)](t,i)}function Uv(t){Jo={umCUB:function(r,i){return r(i)}}.umCUB(t,Jo)}function qv(t){let e=M,r={DUHHx:function(i,o){return i(o)},ggcrX:function(i,o){return i===o},lvnZW:e(1833),MOWAP:"MHMRX",eyEcs:function(i,o){return i>>>o},PNMJp:function(i,o){return i|o},XstOP:function(i,o){return i>>>o},xNhLy:function(i,o){return i===o},dRviF:function(i,o){return i<o},hRvic:function(i,o){return i<o},oOPdF:function(i,o){return i<o},NlCDX:function(i,o,c){return i(o,c)},DzpwI:function(i,o){return i&o},liyMS:function(i,o){return i>>>o},IpniP:function(i,o){return i!==o},JRrjA:function(i,o){return i+o},WaIHd:function(i,o){return i!==o},NkdEu:function(i,o){return i>>>o},dFGvz:function(i,o){return i&o},ySGrg:function(i,o){return i>>>o},aHfuX:function(i,o){return i|o},qLWCS:function(i,o){return i&o},hLrCC:function(i,o){return i|o},ncUOQ:function(i,o){return i&o},AbLUC:function(i,o){return i>>>o},zeXxL:function(i,o){return i!==o},QaqKu:function(i,o){return i|o},OaUqV:function(i,o){return i+o},rqlQj:function(i,o){return i!==o},UmIux:function(i,o){return i|o},KqWqK:function(i,o){return i>>>o},bpPqH:function(i,o){return i>>>o},poFfw:function(i,o){return i!==o},DhGza:function(i,o){return i|o},BOvbc:function(i,o){return i(o)},mFBso:function(i,o){return i(o)},evQSY:function(i,o){return i===o},awpHf:e(2079)+"oreNames",JqAxv:function(i){return i()},jBRBl:function(i,o){return i===o},vDrbi:"OdnLp"};if(r[e(1636)](t,IDBDatabase[e(1958)+"e"].transaction)&&!(r[e(810)]in IDBTransaction.prototype))return function(i,...o){let c=e,l=t[c(1922)](rs(this),i,...o);return kd[c(1830)](l,i[c(539)]?i[c(539)]():[i]),r[c(1526)](Ft,l)};if(r[e(1743)](Bv)[e(1780)](t)){if(r[e(1886)](r[e(685)],r[e(685)]))return function(...i){let o=e;if(r[o(1449)](r.lvnZW,r[o(1794)]))_0x4ea912[o(1818)]().then(()=>{this[o(998)+"steners"]()});else return t.apply(r.DUHHx(rs,this),i),Ft(Pd[o(867)](this))};{let i=r[e(1197)](_0x3dc61d[e(1447)],0),o=r.eyEcs(r.PNMJp(r.XstOP(_0xdac9d[e(1447)],28),_0x4eebf2[e(1245)]<<4),0),c=r[e(1924)](_0x44694d[e(1245)],24),l=r[e(1449)](0,c)?r[e(713)](0,o)?r.dRviF(i,16384)?i<128?1:2:r[e(490)](i,2097152)?3:4:r[e(1775)](o,16384)?o<128?5:6:o<2097152?7:8:r[e(1898)](c,128)?9:10,u=r[e(504)](_0x153118,_0x279b37,l),x=_0x2ace18[e(1913)];switch(l){case 10:x[u+9]=r[e(1651)](r.liyMS(c,7),1);case 9:x[u+8]=r.IpniP(9,l)?r[e(1556)](128,c):127&c;case 8:x[r[e(528)](u,7)]=r[e(1779)](8,l)?r[e(1558)](o,21)|128:r[e(1195)](r[e(804)](o,21),127);case 7:x[r[e(528)](u,6)]=r[e(561)](7,l)?r[e(1556)](r[e(494)](o,14),128):r[e(494)](o,14)&127;case 6:x[r[e(528)](u,5)]=r[e(1779)](6,l)?r[e(611)](r.eyEcs(o,7),128):r[e(1802)](o>>>7,127);case 5:x[u+4]=r[e(561)](5,l)?r[e(1567)](128,o):r.ncUOQ(127,o);case 4:x[r[e(528)](u,3)]=l!==4?r[e(1520)](i,21)|128:r.eyEcs(i,21)&127;case 3:x[u+2]=r[e(1911)](3,l)?r[e(883)](i>>>14,128):i>>>14&127;case 2:x[r.OaUqV(u,1)]=r[e(1747)](2,l)?r[e(737)](r.KqWqK(i,7),128):r[e(1109)](i,7)&127;case 1:x[u]=r[e(650)](1,l)?r[e(726)](128,i):r[e(1802)](127,i)}}}return function(...i){let o=e;return r.BOvbc(Ft,t[o(1051)](r[o(1422)](rs,this),i))}}function Gv(t){let e=M,r={rKJKu:function(i,o){return i===o},BmMCj:"function",jHEvV:function(i,o){return i(o)},mYEqx:function(i,o){return i instanceof o},FjHSl:function(i,o){return i(o)},NLqMr:function(i){return i()}};return r[e(1415)](typeof t,r.BmMCj)?r.jHEvV(qv,t):(r[e(981)](t,IDBTransaction)&&r[e(1037)](Fv,t),yh(t,r.NLqMr(Mv))?new Proxy(t,Jo):t)}function Ft(t){let e=M,r={yTzfy:function(o,c){return o instanceof c},NfFgK:function(o,c){return o(c)},RsrPE:function(o,c){return o!==c}};if(r[e(1265)](t,IDBRequest))return r[e(615)](zv,t);if(Wo[e(483)](t))return Wo[e(867)](t);let i=r[e(615)](Gv,t);return r[e(1517)](i,t)&&(Wo.set(t,i),Zo[e(1830)](i,t)),i}var yh,hh,ph,Pd,Vo,kd,Wo,Zo,Jo,rs,gh=_h({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={BsgCJ:function(r,i){return r instanceof i},deuVK:function(r,i){return r===i},DRZIQ:t(808),cmcxr:"objectSt"+t(1018),RPRzG:"store",dklPP:function(r,i){return r(i)},cdjDG:function(r,i){return r instanceof i},HwpkO:function(r,i){return r in i}};yh=(r,i)=>i[t(1298)](o=>r instanceof o),Pd=new WeakMap,Vo=new WeakMap,kd=new WeakMap,Wo=new WeakMap,Zo=new WeakMap,Jo={get(r,i,o){let c=t;if(e[c(1578)](r,IDBTransaction)){if(e[c(1437)](i,e[c(1142)]))return Vo.get(r);if(e[c(1437)](i,e[c(1336)]))return r[c(2079)+c(1018)]||kd[c(867)](r);if(e[c(1437)](i,e.RPRzG))return o[c(2079)+c(1018)][1]?void 0:o["objectSt"+c(1782)](o[c(2079)+c(1018)][0])}return e[c(1561)](Ft,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(520)](r,IDBTransaction)&&(i===o(808)||e.deuVK(i,e[o(570)]))?!0:e.HwpkO(i,r)}},rs=r=>Zo[t(867)](r)}}),bh={};function G(t,e){t=t-469;let r=$o(),i=r[t];if(G.LFNLLY===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let S=0,_,v,A=0;v=x.charAt(A++);~v&&(_=S%4?_*64+v:v,S++%4)?m+=String.fromCharCode(255&_>>(-2*S&6)):0)v=h.indexOf(v);for(let S=0,_=m.length;S<_;S++)E+="%"+("00"+m.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(E)};G.jAMxzs=o,G.abNwZz={},G.LFNLLY=!0}let c=r[0],l=t+c,u=G.abNwZz[l];return u?i=u:(i=G.jAMxzs(i),G.abNwZz[l]=i),i}Nv(bh,{deleteDB:()=>jv,openDB:()=>Hv,unwrap:()=>rs,wrap:()=>Ft});function Hv(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,u={XUdVD:function(m,E){return m(E)},wecqv:"close"},x=indexedDB[l(1999)](t,e),h=Ft(x);return i&&x["addEvent"+l(1923)]("upgraden"+l(1669),m=>{let E=l;i(u.XUdVD(Ft,x.result),m[E(1781)+"on"],m[E(776)+"on"],u[E(1853)](Ft,x[E(1166)+E(1148)]))}),r&&x[l(1892)+l(1923)](l(1845),()=>r()),h.then(m=>{let E=l;c&&m[E(1892)+"Listener"](u.wecqv,()=>c()),o&&m[E(1892)+"Listener"](E(1056)+E(2081),()=>o())}).catch(()=>{}),h}function jv(t,{blocked:e}={}){let r=M,i={rSebz:r(1845),YpFnM:function(c,l){return c(l)}},o=indexedDB[r(814)+r(1042)](t);return e&&o.addEventListener(i[r(1113)],()=>e()),i[r(1038)](Ft,o)[r(583)](()=>{})}function mh(t,e){let r=M,i={INxxl:function(x,h){return x!=h},BivHZ:function(x,h){return x instanceof h},Dfuse:"application/json",QWDQL:r(714)+"e",XuisQ:function(x,h){return x in h},RLIzg:function(x,h){return x===h},ArKKh:"string",viKSf:function(x,h){return x!==h},jMptD:r(2097)};if(!(i[r(1984)](t,IDBDatabase)&&!i[r(740)](e,t)&&i[r(1372)](typeof e,i.ArKKh)))return i[r(1855)](i[r(1716)],r(687))?void 0:i[r(1301)]("string",typeof _0x2f4193)&&(i[r(1984)](_0x2d1fe5,_0x205587)||_0x23795f[r(900)]&&i[r(1984)](_0xb642bb[r(900)],_0x3cd5b8))||i[r(1301)](r(1896),typeof _0x372cd0)?"":(_0x2a026b[r(2119)](_0x5592ee),i.Dfuse);if(Ko[r(867)](e))return Ko.get(e);let o=e[r(511)](/FromIndex$/,""),c=i[r(1855)](e,o),l=vh[r(1780)](o);if(!i.XuisQ(o,(c?IDBIndex:IDBObjectStore)[r(1958)+"e"])||!(l||Eh[r(1780)](o)))return;let u=async function(x,...h){let m=r,E=this[m(1166)+m(1148)](x,l?i[m(1363)]:m(1727)),S=E[m(967)];return c&&(S=S[m(1761)](h.shift())),(await Promise[m(1430)]([S[o](...h),l&&E[m(808)]]))[0]};return Ko[r(1830)](e,u),u}var Eh,vh,Ko,Wv=_h({"node_modules/idb/build/index.js"(){let t=M,e={mgiQA:function(r){return r()},CAGKD:t(867),eOzZb:t(914),uKpnt:t(2020)+"ys",RHHCR:"count",pIfAz:t(850),ARFfE:t(1054),vlvwN:"clear",sjEtK:function(r,i){return r(i)}};gh(),e[t(890)](gh),Eh=[e[t(2070)],e[t(1192)],t(1014),e[t(1266)],e[t(1057)]],vh=[e[t(1873)],e[t(1462)],t(1920),e.vlvwN],Ko=new Map,e.sjEtK(Uv,r=>({...r,get:(i,o,c)=>mh(i,o)||r.get(i,o,c),has:(i,o)=>!!mh(i,o)||r[t(483)](i,o)}))}}),Kv={idb:function(t){let e=M;t[e(1229)]=Promise.resolve()[e(583)](()=>(Wv(),bh))[e(583)](function(r){return r})}},wh={};function zt(t){let e=M,r={GDaMO:e(795)+"3"},i=r[e(1291)][e(852)]("|"),o=0;for(;;){switch(i[o++]){case"0":if(c!==void 0)return c[e(1229)];continue;case"1":Kv[t](l,l[e(1229)],zt);continue;case"2":var c=wh[t];continue;case"3":return l.exports;case"4":var l=wh[t]={exports:{}};continue}break}}zt.d=(t,e)=>{let r=G;for(var i in e)zt.o(e,i)&&!zt.o(t,i)&&Object[r(516)+r(2038)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;zt.o=(e,r)=>Object[t(1958)+"e"][t(1560)+t(2038)][t(1922)](e,r)})(),(()=>{let t=M,e={etLjk:function(r,i){return r!=i},FVTOG:t(1252),YErUC:t(1459)+"le"};zt.r=r=>{let i=t;e[i(861)]("undefined",typeof Symbol)&&Symbol["toString"+i(1998)]&&Object.defineProperty(r,Symbol[i(1914)+i(1998)],{value:e[i(847)]}),Object[i(516)+i(2038)](r,e[i(1066)],{value:!0})}})();var Re={};(()=>{let t=M,e={SHsjt:function(a,n){return a(n)},XLCFV:function(a,n){return a+n},nqYIX:function(a,n){return a>=n},MFPaJ:function(a,n,s){return a(n,s)},CciJV:function(a,n){return a|n},RBzrz:function(a,n){return a&n},GKYcB:function(a,n){return a===n},oUCwu:t(1306),Znenb:function(a,n){return a*n},NYGrX:function(a,n){return a+n},rxoBo:function(a,n){return a(n)},shzGT:function(a,n){return a+n},QNFMO:function(a,n){return a+n},oytDn:function(a,n){return a&n},BZGiS:function(a,n){return a<<n},jlYqf:function(a,n){return a|n},aXPBy:function(a,n){return a&n},szDXM:function(a,n){return a&n},OmNoc:function(a,n){return a<n},oUEmt:function(a,n){return a<=n},EGlBD:function(a,n){return a!==n},UTKDs:t(1423),yYOaJ:function(a,n){return a(n)},BrRTa:function(a,n){return a(n)},wjLTk:t(1003),OCmXg:function(a,n,s,d){return a(n,s,d)},sDcYK:t(1508),gxvZk:function(a,n){return a===n},uALcO:t(1623),QeJQf:"DzWbY",zFIPo:function(a,n){return a(n)},gExQz:function(a,n){return a(n)},vqnAZ:t(780)+t(780)+t(780)+t(780),nZunV:function(a,n){return a&n},rgLqK:function(a,n){return a<=n},DPpfg:t(819)+t(519)+t(1870)+t(1209)+t(1375),MwgOp:function(a,n){return a===n},FXrsn:function(a,n){return a<n},QRdrS:function(a,n){return a>n},eLaWJ:function(a,n){return a!==n},jVPZZ:function(a,n){return a-n},VqcoQ:function(a,n){return a===n},ELlrP:t(1590),rqofX:t(1369),XiLfF:"ZQSCm",cpsJf:"Umhny",upQMe:function(a,n){return a!==n},FaXqh:function(a,n){return a!==n},hfkNY:function(a,n,s){return a(n,s)},WzbxG:function(a,n){return a!==n},iWjBm:function(a,n,s){return a(n,s)},BGnDB:function(a,n){return a>>>n},FFOGU:function(a,n){return a(n)},dkIoa:function(a,n){return a===n},pOgri:t(987)+t(1185)+t(1536)+"value",oYunc:function(a){return a()},zIceD:function(a,n,s){return a(n,s)},tDYPG:function(a,n){return a(n)},KdXaL:function(a,n){return a-n},WEHzj:function(a,n){return a!==n},qEUjN:t(619),JjZUH:"timeout",aidhI:t(903)+t(887)+"s",BxqUd:function(a,n){return a(n)},FkWTI:t(840),NQTLG:function(a,n,s){return a(n,s)},Ukkzr:function(a,n,s){return a(n,s)},jpuRd:function(a,n){return a!==n},JJmcn:function(a,n){return a!==n},VrciG:t(1704),dTQgm:function(a,n,s){return a(n,s)},KyxXW:function(a,n,s){return a(n,s)},nnviR:function(a){return a()},nXFlz:function(a,n,s){return a(n,s)},CZFXl:function(a,n){return a(n)},abmIs:function(a,n){return a!==n},iFZCT:function(a,n){return a===n},vzeKe:t(582),TnnVi:t(1829),EGzTW:function(a,n,s){return a(n,s)},XvkPb:function(a,n){return a!==n},MLwRC:function(a,n){return a!==n},DxbbX:function(a,n,s){return a(n,s)},eJvHj:function(a,n,s){return a(n,s)},oCXWV:function(a,n){return a!==n},XLTOP:t(1866),lTUBm:t(1349),AzOtb:function(a,n,s){return a(n,s)},SABAp:function(a,n,s){return a(n,s)},UQYey:function(a,n){return a!==n},lQGnz:function(a,n,s){return a(n,s)},UvsiV:function(a,n){return a!==n},IsuFb:function(a,n){return a(n)},DUWUZ:t(1638),FneHy:function(a,n){return a!==n},gvhDD:t(2013),zgNyt:function(a,n){return a(n)},CTmDE:function(a,n,s){return a(n,s)},suFCJ:function(a,n,s){return a(n,s)},IRcuk:function(a,n){return a==n},TdrkI:function(a,n){return a!==n},LUkUM:t(578),bkhMk:t(1744),CNkee:function(a,n){return a===n},ACUag:t(1876),orSxk:function(a,n){return a(n)},baNXJ:function(a,n,s){return a(n,s)},kEIpP:function(a,n,s){return a(n,s)},iEbQa:function(a,n){return a(n)},UWwhi:function(a,n){return a(n)},anShy:function(a,n){return a(n)},SuPZi:function(a,n,s){return a(n,s)},oKozB:function(a,n){return a(n)},eevib:function(a,n){return a(n)},qiTsN:function(a,n,s){return a(n,s)},NMJax:t(987)+t(1185)+t(1536)+t(727),CTepS:t(987)+t(1185)+t(1536)+t(759),ZnhHW:t(987)+t(1185)+t(1536)+t(2022),dYVGu:function(a,n){return a===n},KRxUI:t(987)+t(1185)+t(1536)+t(1085),SPfWx:function(a,n){return a(n)},dRwQn:function(a,n){return a+n},KnsXM:function(a,n){return a&n},PiqtO:function(a,n){return a(n)},VHwma:function(a,n){return a(n)},LbhSt:t(1277)+t(2084)+t(1388),jYhOf:function(a,n){return a>>n},cUJOU:t(1546),ZtrhS:"Wotpr",TRkNn:t(1170)+"t limit",XsCXC:function(a,n){return a>=n},Muakz:function(a,n,s){return a(n,s)},RjxlG:t(961),AdfUq:function(a,n){return a>n},Cilhu:function(a,n){return a+n},kUkZF:"hitWL",pQhSQ:t(1844),lsaIC:function(a,n){return a+n},ldMmd:function(a,n){return a<n},pkwzz:function(a,n){return a+n},VBgwm:function(a,n){return a&n},VrKqm:function(a,n){return a===n},tSZYx:function(a,n){return a+n},hhYsa:function(a,n){return a&n},CGxhL:function(a,n){return a|n},yvLKf:function(a,n){return a<<n},fGfqz:function(a,n){return a&n},JObfQ:function(a,n){return a+n},kZjGf:function(a,n){return a+n},mCEvA:function(a,n){return a+n},psRaw:function(a,n){return a&n},zzEUe:function(a,n){return a<<n},zXHqn:function(a,n){return a|n},MwVXU:function(a,n){return a&n},NiEBW:function(a,n){return a(n)},TGyRx:function(a,n){return a&n},pNXGJ:function(a,n){return a+n},cWCrN:function(a,n){return a+n},DnoYb:function(a,n){return a!==n},OCFTK:function(a,n){return a|n},WSYpb:function(a,n){return a<<n},KHQwO:function(a,n){return a&n},AoTZI:function(a,n){return a&n},hrjnM:function(a,n){return a>n},cEKdx:function(a,n,s){return a(n,s)},RBBMo:function(a,n){return a>>n},kSbKN:function(a,n){return a+n},aPBWB:function(a,n){return a<n},KLhUH:function(a,n){return a<=n},cTWSf:function(a,n,s){return a(n,s)},YZzmn:function(a,n){return a<=n},lRLVv:function(a,n){return a+n},iZkHO:function(a,n){return a-n},zooVk:function(a,n){return a<<n},DhXsg:function(a,n){return a===n},mhIMz:t(1017),tatNX:function(a,n){return a&n},evsBQ:function(a,n){return a&n},CMkAK:function(a,n){return a|n},Zoazk:function(a,n){return a>>n},yLKBQ:function(a,n){return a>>n},zLdgx:function(a,n){return a|n},WkamV:function(a,n){return a<n},hmsiC:function(a,n){return a+n},daCFq:function(a,n,s){return a(n,s)},DgUkt:function(a,n){return a<<n},VWScv:function(a,n){return a<<n},afZyE:function(a,n){return a!==n},fDhRX:t(781),BWnZe:"zBBtR",UvalH:function(a,n){return a<n},GQJzj:function(a,n){return a&n},MRdZg:function(a,n){return a(n)},zYNhN:function(a,n){return a<n},uqzls:function(a){return a()},OZpzj:t(545),RLDxt:function(a,n){return a>=n},apLgz:t(1133),baGkz:"XMdym",kyLpd:function(a,n,s){return a(n,s)},ucFrx:function(a,n){return a|n},rUJbV:function(a,n,s){return a(n,s)},iFIEL:function(a,n){return a(n)},TOwRr:"0|2|9|8|"+t(1858)+t(628)+"0",LeoFH:function(a,n){return a>>>n},ZXPMN:function(a,n){return a&n},XoCMh:function(a,n){return a>>>n},QluyR:function(a,n){return a>>n},LZwhw:t(1799),qDBEV:function(a,n){return a&&n},qbKZR:t(682),vsGWk:function(a,n){return a||n},gMTUl:t(1904),nnJwx:function(a,n){return a>n},gOKTy:function(a,n){return a(n)},YWJJj:function(a,n){return a|n},iSAWy:function(a,n){return a===n},mCvSS:"gKAFX",bQQWY:function(a,n){return a&n},bllsZ:t(1991),cKITD:function(a,n){return a(n)},EAmof:function(a,n){return a&n},qKpIz:function(a,n){return a!==n},ujfUo:t(1342),hqLQe:function(a,n){return a(n)},lImmu:function(a,n){return a&n},BONFl:t(1672),ukpKu:function(a,n){return a(n)},kwbHV:function(a,n){return a<<n},QaNyU:function(a,n){return a&n},dqkNW:function(a,n){return a!==n},HpVeH:"alBsT",iCEqU:t(732),cEvBB:function(a,n){return a&n},XQqgw:function(a,n){return a&n},ypVdO:function(a,n){return a<<n},XuSUY:t(1718),vgRNu:t(1663),NxTyC:function(a,n){return a&n},TJusc:function(a,n){return a!==n},QxLRW:"SyIKz",hVxBk:function(a,n){return a&n},ghJVP:function(a,n){return a|n},YPajw:function(a,n){return a>>>n},ipFmS:function(a,n){return a>>>n},ZzXls:function(a,n){return a|n},gugxt:function(a,n){return a<<n},BEiuO:function(a,n){return a===n},vsHBP:function(a,n){return a<n},AddUd:function(a,n){return a<n},MfXJr:function(a,n){return a<n},vIJGi:function(a,n,s){return a(n,s)},OVNQA:function(a,n){return a+n},WSeUO:function(a,n){return a&n},afhlD:function(a,n){return a!==n},QKecK:function(a,n){return a+n},tUsVt:function(a,n){return a|n},USoHB:function(a,n){return a>>>n},hBoLw:function(a,n){return a>>>n},nNeSg:function(a,n){return a>>>n},pjXlH:function(a,n){return a>>>n},DLNMk:function(a,n){return a|n},ZkhQs:function(a,n){return a+n},BUSSw:function(a,n){return a!==n},BJKZO:function(a,n){return a|n},YICeD:function(a,n){return a>>>n},PNLFg:function(a,n){return a&n},JqFRR:function(a,n){return a|n},pPHZO:function(a,n){return a&n},HVCbD:function(a,n){return a>>>n},MKZEs:function(a,n){return a>>>n},oLpGo:function(a,n){return a>>>n},kypsJ:function(a,n){return a!==n},pEtVs:function(a,n){return a|n},gudob:function(a,n){return a|n},SQoPG:function(a,n){return a<<n},HKhBq:function(a,n){return a|n},ULmjm:function(a,n){return a<<n},AmwEm:function(a,n){return a|n},rYLAh:function(a,n){return a|n},YTvSt:function(a,n){return a<<n},yDZxb:function(a,n){return a===n},fxQAe:function(a,n){return a|n},fLSUx:function(a,n){return a<<n},RHfjW:function(a,n){return a|n},bTMJZ:function(a,n){return a<<n},qENMR:function(a,n){return a>>>n},PKhep:function(a,n){return a>>>n},vVNdo:function(a,n){return a%n},niIiQ:function(a,n){return a|n},AXGSc:function(a,n){return a/n},xIIdm:"PKIWB",USCBV:function(a,n){return a*n},gIMRE:function(a,n){return a(n)},btjVK:t(797),AYJkr:function(a,n){return a===n},iJKCL:function(a,n){return a===n},smFkH:function(a,n){return a&n},gJJVy:function(a,n){return a&n},JPMxi:function(a,n){return a+n},oAGGR:function(a,n){return a>>>n},SFTxO:function(a,n){return a>>>n},EMQPU:function(a,n){return a>>>n},QosVs:function(a,n){return a+n},QOFDA:function(a,n){return a|n},zNQMp:t(642)+t(1509),agxbe:t(642)+t(888)+t(2098),yPoyE:t(1464),lmfYA:function(a,n){return a===n},eXyGb:function(a,n){return a===n},oQVLP:function(a,n){return a===n},Otmkv:function(a,n){return a+n},ZHUMG:"AbortError",oIRFc:"complete",MyXBO:t(1767),BwYLK:function(a,n){return a&n},hDKlf:function(a,n){return a&n},VFBuq:function(a,n){return a&n},MMtMb:function(a,n){return a>>>n},wpghT:function(a,n){return a&n},ZpAVg:t(1132)+t(1138),RIMBN:t(1571)+t(604),tReJf:t(1276)+t(507)+"R",RTQDh:"MESSAGE_"+t(1947),CRfeY:t(1733)+"OR",ifmZb:function(a,n){return a(n)},InTaz:function(a,n){return a&n},ldWlK:function(a,n){return a&n},hpRnm:function(a,n){return a&n},CWfCb:t(1221),NhTBB:t(509),BSGyi:t(1424),snaUl:"bye",munJA:t(501)+t(790)+t(1158)+t(1157),MPbzX:function(a,n){return a!==n},kvZeJ:"jLVGG",wWVTt:function(a,n){return a>n},fiFPM:t(606)+t(1869)+" reconnect",oXstj:function(a,n){return a!==n},GiiEs:t(1797),zCQPD:t(1242),BodGG:t(808),SeNUc:function(a,n){return a===n},csKvz:function(a,n){return a===n},ifZZq:"rixqP",JWzZS:function(a,n){return a(n)},ZoCGM:t(708),ZxJie:function(a,n){return a===n},EUOgM:function(a,n){return a+n},JyoLg:t(1446)+t(1906),VWASI:function(a,n,s){return a(n,s)},DVyFK:function(a,n){return a===n},ckFWG:function(a,n){return a===n},roOZh:function(a,n){return a!==n},IzkgH:t(978),QDCYJ:function(a,n,s){return a(n,s)},bRDeQ:t(1999),rzKJT:t(1891),sDYdu:function(a,n,s){return a(n,s)},DECEz:function(a,n){return a===n},bxLED:"iwIaq",ZZIdm:function(a,n,s){return a(n,s)},MguEc:t(734),AEbki:function(a,n,s){return a(n,s)},oHbBN:t(895),BWsHv:function(a,n){return a instanceof n},xRTAC:function(a,n){return a+n},UrmHG:function(a,n){return a<=n},QgyFG:function(a,n){return a+n},WASEP:function(a,n){return a-n},lBCjm:function(a,n){return a+n},bAlzp:function(a,n){return a<<n},EowLP:t(985),THrzw:t(526)+"1",zzbtr:t(953),zmNtV:t(1523),WWoup:function(a,n){return a(n)},CBzuS:t(1268),OEkpW:t(1613),fhYTu:function(a,n){return a!=n},htfcA:"undefined",jYpvC:function(a,n){return a<=n},QEYNs:function(a,n){return a===n},mFnve:function(a,n){return a<n},nEyCw:function(a,n){return a===n},qLCVx:function(a,n){return a===n},XtMIp:function(a,n){return a&n},YKxGN:function(a,n){return a<n},HEMNW:function(a,n){return a-n},CRJPp:function(a,n){return a<n},kQWNM:function(a,n){return a&n},bWBsm:function(a,n){return a&n},FdlUM:function(a,n){return a>=n},VYgDG:function(a,n){return a<n},MHbGi:function(a,n){return a|n},tWNpb:function(a,n){return a>=n},CuSjx:function(a,n){return a&n},DStyE:function(a,n){return a&n},CYDwZ:function(a,n){return a&n},Ianrh:function(a,n){return a>>n},KPTvH:function(a,n){return a+n},BbxLg:function(a,n){return a&n},GhYzp:function(a,n){return a>>n},SNeau:function(a,n){return a===n},UQgAm:function(a,n){return a&n},NDTNW:"4|2|1|0|"+t(1759),juJjH:function(a,n){return a>>n},CakvD:function(a,n){return a|n},dLJYM:function(a,n){return a<<n},dKjgF:function(a,n){return a>>n},yCMlZ:function(a,n){return a|n},iHTGY:function(a,n){return a>>n},gPdKv:function(a,n){return a|n},xqgyo:function(a,n){return a||n},wyDkx:function(a,n){return a==n},HYNSK:t(767),DLysr:t(662),fcRDX:function(a,n){return a===n},tqDRg:t(1615),YSGWT:function(a,n){return a!=n},Acxxr:t(1896),Auxta:function(a,n){return a instanceof n},EmjiK:function(a,n){return a instanceof n},DMXeo:function(a,n){return a!=n},Hshzi:t(944)+t(1662),DjdWd:t(1478)+"in;chars"+t(1314),uMJaK:function(a,n,s){return a(n,s)},mYCzi:t(470),ytfwG:t(925),IdFOK:t(1946),zhPbr:function(a,n,s){return a(n,s)},HzSYB:t(1153),QTPUw:t(1879),HlqXf:function(a,n){return a(n)},LVMho:t(1776)+t(621),ZcIly:t(1931),Wzldy:t(1146)+"ascript",KHUOe:t(1046)+t(1600)+t(1534)+"P",ILgUU:t(1574),AqZdi:function(a,n){return a===n},VLoNr:t(1735),JpHBz:t(1680),CNSkj:function(a){return a()},QpDDG:function(a,n){return a(n)},vCYWB:function(a,n){return a===n},xPTSD:"PRhDS",BQoEo:"reconnect",rZsJs:t(1518),eQfrM:t(1895),JoFuK:t(1601),RoWwf:"UrJlz",PzdZV:function(a,n){return a<n},HujXf:function(a,n){return a!==n},uXTLu:function(a,n){return a-n},WoAIQ:"Riorj",WuYDf:function(a,n){return a(n)},KBnBB:function(a,n){return a===n},xJqsw:t(1736),ehAdb:t(548),YdBwd:"message_id",wQsvR:"kgUcB",NIOnf:function(a,n){return a||n},VAaAc:function(a,n){return a||n},RAiou:function(a,n){return a||n},EHSCw:t(1644),WzJGZ:function(a,n){return a===n},xLGLZ:t(1396),KuIXv:function(a,n){return a||n},JcxVl:function(a,n){return a!=n},yVZuA:t(1645)+"DB failed",iiwqq:function(a,n){return a>>>n},CIqVQ:function(a,n){return a>>>n},umfts:function(a,n){return a!==n},izMvb:t(1633),BnowQ:t(1269),paWIT:function(a,n){return a===n},nsoFl:t(1621),GqRNP:function(a,n){return a(n)},djqOe:function(a,n){return a+n},xJKqr:function(a,n){return a>>n},xqcBa:function(a,n){return a|n},iRhOi:function(a,n){return a!==n},vXvys:t(2015),XYeqo:"YcJRW",nXmHN:function(a,n){return a(n)},vojlY:function(a){return a()},eRVar:t(1665),VxGpx:t(1444),Mhysk:function(a,n,s,d){return a(n,s,d)},GbUvo:t(642)+t(878)+"k",VCxKj:t(1715),VzdnA:function(a,n){return a>>>n},UEjsN:function(a,n){return a>>>n},litsH:function(a,n){return a>>>n},FRZEx:function(a,n){return a(n)},sDXjB:function(a,n){return a(n)},VYttE:function(a,n){return a(n)},FgAhl:t(1162),ophQh:function(a,n){return a instanceof n},FXUmB:"applicat"+t(1662)+t(1907)+"=utf-8",TGpJD:function(a,n,s,d){return a(n,s,d)},TMhod:"aSCnj",QJAgF:function(a,n){return a!==n},NbyWF:t(1603),wCzIs:function(a,n){return a|n},iGcYZ:function(a,n){return a||n},mVosC:function(a,n){return a+n},CAOtS:function(a,n){return a+n},pVuRV:function(a,n){return a+n},mCHtw:t(941)+t(698)+"ge: ",gvrhl:t(696),fLIAp:" > ",FMIJm:t(2057)+t(1292)+"e",QLyyM:function(a,n){return a===n},VoQuL:t(1390),eHIZr:function(a,n,s,d){return a(n,s,d)},sojoI:function(a,n){return a+n},DHGgd:function(a,n){return a<n},GSyqf:function(a,n){return a>>>n},rlVOg:function(a,n){return a<<n},VdPoS:function(a,n){return a|n},RMyxz:function(a,n){return a&n},YUYfn:function(a,n){return a|n},OsZbC:function(a,n){return a&n},oggzC:t(513),klunZ:function(a,n){return a<n},GzlON:function(a,n){return a+n},qOWdX:function(a,n,s){return a(n,s)},cgaUp:t(1555),EcqPm:function(a,n){return a|n},ZoxjT:function(a,n){return a|n},RQTvb:function(a,n){return a|n},BGTOT:function(a,n){return a<<n},okoAI:function(a,n){return a+n},NiEIF:function(a,n){return a+n},TAyay:function(a,n){return a+n},TsKqD:function(a,n){return a+n},SoRVv:function(a,n){return a|n},FiMUl:function(a,n){return a|n},bDztl:function(a,n){return a<<n},vpmtj:function(a,n){return a<<n},TEgIR:function(a,n){return a+n},lWZUR:function(a,n){return a+n},ydBnC:function(a,n){return a>>>n},GVwlT:function(a,n){return a&n},olQFs:function(a,n){return a+n},QZJOt:function(a,n){return a&n},nvuSy:function(a,n){return a+n},EAMGN:function(a,n){return a>>>n},JvYOd:function(a,n){return a&n},tqyxX:function(a,n){return a>>>n},kZAhs:function(a,n){return a+n},GFiDX:function(a,n){return a|n},Nnyps:function(a,n){return a<<n},OcRNR:function(a,n){return a&n},bfGwF:function(a,n){return a|n},ObdbY:function(a,n){return a<<n},TIZvj:function(a,n){return a&n},xuHfd:function(a,n){return a>>>n},gEePJ:function(a,n){return a<n},SoOMV:function(a,n){return a>>>n},cTxca:function(a,n){return a&n},vYiqc:function(a,n){return a<n},RrPPS:function(a,n){return a|n},jRpgx:function(a,n){return a>n},aKOPN:function(a,n){return a<n},AcAtE:function(a,n){return a(n)},IzfrT:function(a,n){return a+n},pQunc:"cursor.s"+t(1374),thZMK:"header",triPx:t(730)+t(1531),tPSPP:t(1531),hkyBO:"curvalue",JYPZg:"cursor_f"+t(1801),Wcuiv:function(a,n,s){return a(n,s)},sIILp:function(a,n,s,d){return a(n,s,d)},yQNrC:function(a,n){return a!=n},FeQoA:function(a,n){return a!==n},NXJaf:t(733),gjVWg:"FILE_NOT"+t(508),zJUkg:"cursor_n"+t(1583),DYwFI:t(2109)+t(751),GDiZj:"ALL",FePSN:function(a,n,s,d){return a(n,s,d)},ZNtdu:t(1533),AKMvw:t(1917),BdCvT:function(a){return a()},FUzuX:function(a,n,s){return a(n,s)},vvwbu:t(959),YyyLh:function(a,n){return a instanceof n},hDGrY:function(a,n){return a(n)},spAjX:"JSWuW",sZhFQ:t(1629),qPBGI:"kntyY",CrBsq:t(1841)+"r",oexIV:function(a,n){return a===n},tAann:t(710),TRbCM:function(a,n){return a||n},VXqce:t(1719),BljQA:function(a,n,s){return a(n,s)},UQtEO:t(642)+t(1300),LsaeG:t(2074)+"s",oRQGw:t(1989)+t(1885)+"e",bEEjD:function(a){return a()},CQQLi:function(a,n){return a>n},paADF:function(a,n){return a===n},asyKz:t(1973),AFIix:function(a,n){return a+n},sLftj:t(871),aDGQM:function(a){return a()},LEwqX:function(a){return a()},fuXUy:function(a){return a()},tRRcW:t(2031),krIHq:function(a){return a()},xugVC:function(a,n){return a&&n},yeaPn:function(a,n){return a(n)},PxjKz:function(a,n,s){return a(n,s)},emsTo:t(1661),FfytK:function(a,n){return a<n},oaZyH:function(a,n,s){return a(n,s)},BdDkL:function(a){return a()},fPcHe:function(a,n){return a|n},FryUt:function(a,n){return a+n},pFOBz:function(a,n){return a+n},BdOUD:t(2e3),WSmqw:t(1831)+t(1261)+"|7|4|6",HwqgO:function(a,n){return a!==n},Dqges:t(1380),ZbuGx:function(a,n){return a===n},rEMMh:t(1115),CNzXH:t(1936),gvmeb:function(a,n){return a===n},nXPnm:function(a,n,s,d){return a(n,s,d)},YLzjO:t(1584),EaZiN:function(a,n){return a===n},mZKyT:function(a,n,s){return a(n,s)},DufEu:function(a,n){return a===n},QCOwB:function(a,n,s,d){return a(n,s,d)},RKJsa:function(a,n,s){return a(n,s)},kgKCQ:function(a,n){return a>=n},gPGMa:t(2105),mBXcL:t(622),HWPiB:function(a,n){return a!==n},trKff:t(1562),rEotC:function(a,n){return a===n},pTYrH:"please provide v"+t(1405),iuHhf:t(551)+t(1654)+t(593)+", WebSoc"+t(2089)+t(2092)+t(806)+t(2100),zpZcV:"XWozD",MegCk:t(1537),ncbpZ:t(1117),egYnT:t(964),DqqIW:t(499),selMk:function(a,n){return a!==n},RbSWH:"https:",PWBsL:t(820),akXCI:t(1058),pUErC:t(1412),rLBgP:"device_id",qQCqw:t(551)+t(1454)+t(2093)+"viceID o"+t(563),sFLPo:function(a,n){return a==n},epIKg:function(a){return a()},NnMeD:function(a,n,s){return a(n,s)},zKVrO:"web",qqRRD:t(556)+"0",mTLSK:function(a,n){return a!==n},JrtXR:"fMxuA",ATKLy:t(1489),HQILU:function(a,n,s){return a(n,s)},KCWzp:function(a,n){return a===n},INHgD:t(1116),hNZhz:function(a,n){return a>n},RccOP:function(a,n,s){return a(n,s)},DeKBy:function(a,n,s){return a(n,s)},zvXGO:"oqBci",qyewb:"FRONTIER>",awZie:function(a,n){return a===n},AaaYH:function(a,n,s){return a(n,s)},dQPZT:t(501)+t(960)+t(661)+t(1832)+t(575),aLRbY:function(a,n,s){return a(n,s)},TOqfY:t(921),pBWZL:t(816)+"1",QMvxh:function(a,n,s){return a(n,s)},FmPrG:t(1968),NsFFT:t(1943),nRNEW:function(a,n,s){return a(n,s)},IltVs:t(830),jTDfu:t(838),YRIiL:t(1637),YQoPX:function(a,n){return a<n},NOjlN:function(a,n){return a|n},EmRXD:function(a,n){return a&n},OiUii:t(1481),rHZgv:t(1684),PfCvD:function(a,n){return a+n},EErdJ:function(a,n){return a===n},TooUs:function(a,n){return a instanceof n},YhAQs:function(a,n){return a+n},wYqfv:t(1364),TkQOa:t(735),VEGPh:"6|2|1|0|"+t(1228),giTEd:t(818)+"s instan"+t(1635)+t(2023)+"ed",dYMcG:"close, w"+t(1069)+t(1060),QYSjW:function(a,n){return a==n},jzeSZ:t(551)+"rovide a"+t(844)+t(1607)+t(1021)+t(634)+"ng or an"+t(1189)+t(874),XzDiq:t(495),tYJeD:"BKuuM",FDwsD:function(a,n){return a||n},zpXjt:function(a,n){return a!==n},EEkpv:t(1257)+t(1732)+t(938),FIhLQ:t(1867)+"4",KHLSd:function(a,n){return a-n},EWhJe:function(a,n){return a<n},Sxhwa:function(a,n){return a|n},UKtiU:function(a,n){return a<<n},mOrzR:function(a,n){return a&n},dbxLm:function(a,n){return a&n},uAhyC:function(a,n){return a>=n},iNkUj:function(a,n){return a|n},TeADY:function(a,n){return a|n},vuEpX:function(a,n){return a<<n},igLOP:function(a,n){return a<<n},WANBY:function(a,n){return a&n},ExKBz:function(a,n){return a<<n},TDGoM:function(a,n){return a<<n},fLRhJ:function(a,n){return a&n},xjJIB:function(a,n){return a===n},uapds:t(1554),Eccge:t(722),jHcBw:function(a,n){return a||n},WLkOo:"IiIDL",qcdlS:"ping_onc"+t(1691)+"t",cdkNh:"\0\0\0\0\0\0\0\0",uzlVu:function(a,n){return a*n},tUMMH:function(a,n){return a/n},WLptO:function(a,n){return a!=n},fzMKx:"Window",UeryV:function(a,n){return a!=n},zzhHY:function(a,n){return a!=n},QZpLz:function(a,n){return a===n},WrQGn:t(688)+"dWorkerG"+t(608)+"pe",krkXW:function(a,n){return a===n},ihctn:t(898),YCWrd:function(a,n){return a==n},ziXOU:function(a,n){return a!=n},lDwUq:t(675)+"rkerGlob"+t(1475),ZmztM:function(a,n){return a===n},FyGjr:t(1817)+t(1551)+t(927),fiZnv:function(a,n){return a!=n},khDre:t(1071)+"qos__"};zt.r(Re),zt.d(Re,{FWS:()=>ig,CustomErrorEvent:()=>Xd,createCloseEvent:()=>gt,ReconnectEvent:()=>Jd,createErrorEvent:()=>lt,decodedFrame:()=>tn,createOpenEvent:()=>rl,CustomCloseEvent:()=>Yd,createReconnectEvent:()=>ha,FrontierMessageEvent:()=>el,encodeFrame:()=>Ut,createMessageEvent:()=>nl,OpenEvent:()=>tl,ErrorCode:()=>rn,Event:()=>rr,MessageEvent:()=>Qd});let r="";function i(a=""){let n=t,s="02",d=""+Date.now(),f=r||(r=e.SHsjt(x,a)),p=Math.random()[n(1914)](16)[n(738)](-6);return e[n(1217)](e.XLCFV(e.XLCFV(s,d),f),p)}function o(){let a=t,n={VNPyb:function(s,d){return e[G(1992)](s,d)},irzaH:function(s,d,f){return e[G(1541)](s,d,f)},klOIG:function(s,d){return e[G(772)](s,d)},iPytw:function(s,d){return e.RBzrz(s,d)}};if(e[a(885)](a(515),e[a(1563)])){for(_0x46a0bc>>>=0;n.VNPyb(_0xd4afda,128);)n.irzaH(_0x1d3e65,_0x386e0f,n[a(742)](n.iPytw(127,_0x4c1614),128)),_0xe22d29>>>=7;n.irzaH(_0xe4189d,_0x2611e8,_0x2ce057)}else return e.Znenb(1e4,Date[a(1696)]())+Math[a(1705)](e.Znenb(1e4,Math[a(821)]()))}function c(a){let n=t;return e[n(975)](e[n(765)](Array,8).join("0"),parseInt(a,10)[n(1914)](2))[n(738)](-8)}function l(a){let n=t;return(e[n(765)](Array,4)[n(2099)]("0")+e[n(1541)](parseInt,a,2)[n(1914)](16))[n(738)](-4)}function u(a){let n=t;if(e[n(1198)](e[n(934)],e[n(934)]))_0x2c2588=_0x54df33[e.shzGT(e[n(1022)](_0x11f21a,_0x26c730),1)],_0x3da382=_0xf15878[e[n(1395)](_0x197c70,_0xfb21f8)+2],e[n(700)](_0x1804fc|e[n(1282)](_0xa8a419,8),49344)!==32896?_0x5b26b0+=_0x51b9ec:(_0x1177ba=e.jlYqf(e[n(1282)](e.aXPBy(15,_0x8babd8),12)|e[n(1496)](63,_0x4efc4c)<<6,63&_0x1a68a2),e[n(1952)](_0x10ffdf,2048)||e[n(1992)](_0x342815,55296)&&e.oUEmt(_0x41760c,57343)?_0x1faf0c+=_0x1194c8:(_0x485965+=e.rxoBo(_0x3ecb1a,_0x11831b),_0x460220+=2));else{let s=a[n(852)](/\./)[n(955)](p=>c(p)),d=[];return d[0]=e[n(1883)](l,s[0]+s[1]),d[1]=e[n(653)](l,s[2]+s[3]),[e.wjLTk,e[n(1862)],e[n(1862)],n(1003),n(1003),n(1339),d[0],d[1]][n(2099)]("")}}function x(a){let n=t;if(e[n(1416)](e.uALcO,e[n(1167)]))try{e[n(1398)](_0x4fe599,this,_0x5e6778,[_0x59b00d,_0x181984,_0x12e26b])}catch(s){let d=e.MFPaJ(_0x41e257,e[n(729)],{message:s[n(1891)],code:_0x3ac50c.OPEN_ERROR,error:s});this[n(552)+"hErrorEv"+n(1970)](d)}else{let s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(1218)](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(1218)](a);return s?e[n(1414)](u,a):d?e[n(1019)](h,a):e[n(1611)]}}function h(a){let n=t,s="",d=[],f=0,p=0,w=!0,b=e[n(1862)];if(a[n(1950)]("::")>-1){let g=a[n(852)]("::");for(let R=0;e[n(2101)](R,g.length);R++){let P=g[R];if(e[n(1211)](P[n(1950)](":"),0)){let F=P[n(852)](":");w&&(f=F[n(1360)]),p+=F[n(1360)];for(let B=0;e[n(1952)](B,F[n(1360)]);B++)if(e[n(677)](4,F[B][n(1360)])){let te=b[n(1646)+"g"](0,4-F[B][n(1360)]),J=te[n(943)](F[B]);d[n(911)](J)}else d.push(F[B]);w=!1}else{if(P[n(1360)]!==4){let F=b[n(1646)+"g"](0,e[n(674)](4,P.length)),B=F[n(943)](P);d[n(911)](B)}else d[n(911)](P);w&&(f+=1),p+=1,w=!1}}let C="";for(let R=0;e[n(1952)](R,8-p);R++)C=C[n(943)](b);for(let R=0;e.OmNoc(R,d[n(1360)]);R++)if(e[n(1688)](R,f))if(e[n(1416)](e.ELlrP,"aPypf"))s=s[n(943)](C),s=s[n(943)](d[R]);else{let P=e.nZunV(255,_0x4e3a35);e[n(1398)](_0x3930e0,P,_0x129aeb,_0x249d7f+_0x3216c6),_0x31d96e>>>=8,_0x4627d8--}else s=s.concat(d[R]);return s}if(e[n(1760)]!==e[n(1953)]){let g=a[n(852)](":");for(let C=0;e[n(1952)](C,g[n(1360)]);C++){if(e[n(1198)](e[n(707)],e[n(707)]))return e[n(2056)](_0x2e7333,_0x566855)?_0x8d629b[n(1997)](new _0x54050f(e.DPpfg)):(_0x31f87f=_0x56462f,e.MwgOp(_0x4ae4d8,_0x47129c[n(1360)])?_0x5843c5[n(1818)]():_0x3d4bb9[_0x4f9720].bind(_0x4c9340)(_0x4b0d52,_0x21dc7c[n(1640)](null,_0x9d02be+1)));{let R=g[C];if(e[n(1550)](4,g[C][n(1360)])){let P=b[n(1646)+"g"](0,4-g[C][n(1360)]),F=P[n(943)](R);s=s[n(943)](F)}else s=s[n(943)](R)}}return s}else _0x1df409.d=(g,C)=>{let R=n;for(var P in C)_0x334d01.o(C,P)&&!_0x6c3ae1.o(g,P)&&_0x4ae4bc[R(516)+R(2038)](g,P,{enumerable:!0,get:C[P]})}}function m(a,n){let s=t,d=a[s(1863)];e.FaXqh(void 0,d)&&(e[s(1541)](pe,n,10),e[s(753)](j,n,d));let f=a[s(1053)];e[s(533)](void 0,f)&&(e.iWjBm(pe,n,18),e[s(753)](j,n,f))}function E(a){let n=t,s={};e:for(;!e.zFIPo(V,a);){let d=e[n(765)](he,a);switch(e.BGnDB(d,3)){case 0:break e;case 1:s[n(1863)]=N(a,e[n(834)](he,a));break;case 2:s[n(1053)]=N(a,e.FFOGU(he,a));break;default:e[n(1541)](D,a,7&d)}}if(s[n(1863)]===void 0)throw new Error(n(987)+n(1185)+" field: "+n(1863));if(e[n(1617)](void 0,s[n(1053)]))throw new Error(e[n(1521)]);return s}function S(a){let n=t,s=e.oYunc(k);return e[n(1094)](_,a,s),e[n(1630)](z,s)}function _(a,n){let s=t,d={wEeDg:function(Pe,Oe){return e.BxqUd(Pe,Oe)},kRBbX:e[s(2086)],KaFhm:e[s(2043)],oEvyC:"ping_onc"+s(1691)+"t"},f=a[s(727)];f!==void 0&&(e[s(794)](pe,n,8),e.Ukkzr(pt,n,f));let p=a[s(759)];e.FaXqh(void 0,p)&&(pe(n,16),e[s(1541)](pt,n,p));let w=a[s(2022)];e.FaXqh(void 0,w)&&(e[s(1750)](pe,n,24),e[s(923)](pt,n,O(w)));let b=a.method;if(e[s(724)](void 0,b))if(e[s(1816)](e.VrciG,s(1704))){let Pe=_0x5211b9[s(1646)+"g"](0,e[s(1972)](4,_0x341c4e[_0x3dea72][s(1360)])),Oe=Pe[s(943)](_0x53e38d[_0x3fffee]);_0x2d3b7c.push(Oe)}else pe(n,32),e[s(530)](pt,n,O(b));let g=a.headers;if(g!==void 0)for(let Pe of g){e[s(1231)](pe,n,42);let Oe=e.nnviR(k);m(Pe,Oe),e[s(1762)](pe,n,Oe[s(837)]),e.dTQgm($,n,Oe),e[s(800)](L,Oe)}let C=a["payloadE"+s(532)];e[s(1191)](void 0,C)&&(e.iFZCT(e[s(1382)],e[s(1223)])?(this["_navigat"+s(586)]()&&(!this[s(1279)]||e[s(1093)](this._ws[s(1040)+"te"],this.OPEN)||e[s(1550)](this[s(1279)][s(1040)+"te"],this.CONNECTING))&&this[s(1593)+"nLine"](),this[s(1894)+"er"]&&_0x448d32[s(1892)+s(1923)](s(1537),this["_handleO"+s(922)]),this._isBrowser&&_0x30630f[s(1892)+s(1923)](e.qEUjN,this[s(1593)+"ffLine"])):(e[s(1750)](pe,n,50),e[s(1194)](j,n,C)));let R=a[s(1788)+s(1256)];e.XvkPb(void 0,R)&&(pe(n,58),j(n,R));let P=a.payload;e[s(1994)](void 0,P)&&(e[s(2046)](pe,n,66),e[s(794)](pe,n,P[s(1360)]),e[s(476)](ae,n,P));let F=a[s(1064)];if(e[s(670)](void 0,F))if(e[s(1013)](e[s(2080)],e.lTUBm))e[s(1293)](pe,n,74),e[s(1773)](j,n,F);else{let Pe={VUeHo:function(Oe,on){return e[s(1883)](Oe,on)},UdmxK:e[s(2042)],nnprj:e.aidhI};return new _0x4bc2c1((Oe,on)=>{let Ke=s,ls={ulUZF:function(ze,ni){return d[G(1634)](ze,ni)},STPLp:d[Ke(1786)]};this[Ke(988)+"ngTimer"](),this[Ke(656)+Ke(1577)+"Id"]=_0x30eaee(this[Ke(926)][Ke(1640)](this),this[Ke(531)][Ke(1606)+Ke(1378)]);let On=()=>{let ze=Ke;ls[ze(1318)](Oe,ls.STPLp),this[ze(2088)](ze(903)+ze(887)+"s",On),this[ze(2088)]("ping_onc"+ze(1691)+"t",ti)},ti=()=>{let ze=Ke;Pe[ze(2010)](on,Pe[ze(1237)]),this.off(Pe.nnprj,On),this[ze(2088)](ze(903)+ze(1691)+"t",ti)};this.on(d[Ke(1073)],On),this.on(d[Ke(778)],ti),this._ping()})}let B=a[s(1061)+s(784)];e[s(789)](void 0,B)&&(e.lQGnz(pe,n,82),j(n,B));let te=a[s(1368)];e.MLwRC(void 0,te)&&(pe(n,90),e[s(1773)](j,n,te));let J=a.frameType;e[s(1741)](void 0,J)&&(e[s(794)](pe,n,96),e.hfkNY(pt,n,e.IsuFb(O,J)))}function v(a){let n=t,s={dOzGm:"error",mSFgN:function(d,f,p){return d(f,p)},XCftc:e[n(1501)]};if(e[n(1059)](e[n(1143)],n(2013)))_0x1c48fb.resolve().then(()=>{let d=n,f=_0x511942(s[d(1284)],{message:this[d(537)+d(1403)+"age"](_0x11f36e)});this[d(1426)](s[d(1284)],f);let p=s[d(1070)](_0x2ec3b0,s.XCftc,{reason:this["_formatE"+d(1403)+d(1819)](_0x47ef54)});this[d(1426)](s.XCftc,p)});else return e[n(1090)](A,e.gExQz(U,a))}function A(a){let n=t,s={SfucP:function(d,f){return e[G(2104)](d,f)},XwlwE:function(d,f){return d>f}};if(e.TdrkI(e[n(1118)],e[n(1539)])){let d={};e:for(;!V(a);)if(e.CNkee(n(1876),e[n(2014)])){let f=e[n(940)](he,a);switch(f>>>3){case 0:break e;case 1:d[n(727)]=e[n(809)](It,a,!0);break;case 2:d[n(759)]=e[n(1145)](It,a,!0);break;case 3:d[n(2022)]=he(a);break;case 4:d[n(1085)]=e[n(823)](he,a);break;case 5:{let p=e[n(469)](I,a);(d[n(913)]||(d[n(913)]=[])).push(e.anShy(E,a)),a[n(837)]=p;break}case 6:d["payloadE"+n(532)]=N(a,e[n(1182)](he,a));break;case 7:d[n(1788)+n(1256)]=e.baNXJ(N,a,e[n(823)](he,a));break;case 8:d.payload=e[n(794)](se,a,he(a));break;case 9:d[n(1064)]=e[n(1303)](N,a,e.oKozB(he,a));break;case 10:d[n(1061)+n(784)]=N(a,e.eevib(he,a));break;case 11:d[n(1368)]=e.NQTLG(N,a,he(a));break;case 12:d[n(1740)+"e"]=e.FFOGU(he,a);break;default:e[n(1442)](D,a,7&f)}}else{if(this[n(1419)+n(1150)]?.[n(1111)+n(1084)+"es"]()){let p=this._endpointManager?.[n(1882)+n(1468)+"nt"]();this[n(552)+n(2008)+n(1970)](e[n(1141)](_0x4cecdf,"close",{code:1006,reason:n(601)+p+(n(1465)+n(1905)+n(1304)+n(1248)),wasClean:!0}))}else{let p=this[n(531)][n(661)+n(1783)+n(2095)](_0x31ec44,_0x2a6e7e);this[n(552)+n(2008)+"ent"](e[n(1576)](_0x788314,"close",{code:_0x1d5936,reason:_0x4fac4c,wasClean:!0,willReconnect:p})),p&&this[n(711)]()}return}if(d.SeqID===void 0)throw new Error(e[n(1681)]);if(e[n(1416)](void 0,d.LogID))throw new Error(e[n(2021)]);if(e[n(2102)](void 0,d[n(2022)]))throw new Error(e.ZnhHW);if(e.dYVGu(void 0,d[n(1085)]))throw new Error(e.KRxUI);return d}else return s[n(546)](this[n(644)+"ndex"],this[n(761)+"s"][n(1360)])?!0:s.XwlwE(this[n(1334)+n(691)+n(1043)+"t"],this[n(2078)+"es"])}function I(a){let n=t,s=e.SPfWx(he,a),d=a.limit;return a[n(837)]=e[n(1417)](a[n(1717)],s),d}function D(a,n){let s=t;switch(n){case 0:for(;e.KnsXM(128,e[s(1190)](oe,a)););break;case 2:Z(a,e[s(813)](he,a));break;case 5:e[s(1750)](Z,a,4);break;case 1:e.KyxXW(Z,a,8);break;default:throw new Error(e[s(1544)]+n)}}function O(a){return a|=0,{low:a,high:e.jYhOf(a,31),unsigned:a>=0}}let y=[];function k(){let a=t,n=y.pop();return n?(n.offset=n[a(837)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(a){let n=t;if(e[n(1741)](e[n(524)],e[n(1341)]))y[n(911)](a);else return!!this._qosDB}function U(a){return{bytes:a,offset:0,limit:a[t(1360)]}}function z(a){let n=t,s=a[n(1913)],d=a.limit;return s[n(1360)]===d?s:s[n(2111)](0,d)}function Z(a,n){let s=t;if(e[s(1211)](e[s(975)](a[s(1717)],n),a.limit))throw new Error(e[s(1384)]);a[s(1717)]+=n}function V(a){let n=t;return e[n(1033)](a[n(1717)],a[n(837)])}function ne(a,n){let s=t;if(s(702)!==e[s(1798)]){let d=a[s(1913)],f=a[s(1717)],p=a.limit,w=e.XLCFV(f,n);if(e[s(1211)](w,d.length)){let b=new Uint8Array(2*w);b[s(1830)](d),a.bytes=b}return a[s(1717)]=w,w>p&&(a[s(837)]=w),f}else _0xc177da(_0x51fe43,74),e.Muakz(_0x113529,_0x2124ee,_0x1e9381)}function X(a,n){let s=t,d=a[s(1717)];if(e[s(1259)](e.Cilhu(d,n),a[s(837)]))throw new Error(s(1210)+"t limit");return a[s(1717)]+=n,d}function se(a,n){let s=t;if(e[s(1688)](e[s(1820)],e[s(1429)]))e[s(1541)](_0x33be00,_0x38ba7f,82),_0x111a4f(_0x3a910a,_0x483116);else{let d=X(a,n);return a[s(1913)][s(2111)](d,e.lsaIC(d,n))}}function ae(a,n){let s=t,d=e[s(1441)](ne,a,n.length);a[s(1913)].set(n,d)}function N(a,n){let s=t,d=e[s(1442)](X,a,n),f=String[s(2120)+s(2004)],p=a.bytes,w="\uFFFD",b="";for(let g=0;e[s(612)](g,n);g++){let C=p[e[s(484)](g,d)],R,P,F,B;e[s(2055)](e[s(1559)](128,C),0)?b+=e.oKozB(f,C):e.VrKqm(224&C,192)?e[s(1033)](e[s(2067)](g,1),n)?b+=w:(R=p[e.Cilhu(g+d,1)],e[s(1557)](192,R)!==128?b+=w:(B=e[s(1569)](e[s(873)](e[s(1485)](31,C),6),e[s(646)](63,R)),e[s(612)](B,128)?b+=w:(b+=e[s(1254)](f,B),g++))):e.IRcuk(240&C,224)?e[s(2018)](g,2)>=n?b+=w:(R=p[e.kZjGf(e.mCEvA(g,d),1)],P=p[e[s(1217)](g+d,2)],e[s(1191)](e.psRaw(e[s(772)](R,e[s(1859)](P,8)),49344),32896)?b+=w:(B=e[s(2027)](e.BZGiS(e.psRaw(15,C),12)|e[s(1282)](63&R,6),e[s(540)](63,P)),e.FXrsn(B,2048)||e[s(1992)](B,55296)&&B<=57343?b+=w:(b+=e[s(1711)](f,B),g+=2))):e[s(1903)](248,C)==240?e[s(1022)](g,3)>=n?b+=w:(R=p[e[s(1395)](g+d,1)],P=p[e[s(680)](e[s(484)](g,d),2)],F=p[e.cWCrN(g,d)+3],e[s(486)](e[s(1903)](e[s(1569)](R,e[s(1282)](P,8))|e[s(1859)](F,16),12632256),8421504)?b+=w:(B=e[s(588)](e[s(543)](e[s(581)](7&C,18)|e[s(1282)](e[s(591)](63,R),12),e[s(1859)](e[s(1573)](63,P),6)),63&F),B<65536||e[s(512)](B,1114111)?b+=w:(B-=65536,b+=e.cEKdx(f,e.kZjGf(e[s(491)](B,10),55296),e.kSbKN(e[s(1903)](1023,B),56320)),g+=3))):b+=w}return b}function j(a,n){let s=t,d=n[s(1360)],f=0;for(let b=0;e[s(1401)](b,d);b++){let g=n[s(1250)+"At"](b);g>=55296&&e[s(748)](g,56319)&&e[s(1467)](b,1)<d&&(g=e[s(1972)](e[s(2067)](g<<10,n[s(1250)+"At"](++b)),56613888)),f+=e[s(1952)](g,128)?1:e[s(1952)](g,2048)?2:e[s(1952)](g,65536)?3:4}pe(a,f);let p=e[s(1020)](ne,a,f),w=a[s(1913)];for(let b=0;e[s(1401)](b,d);b++){let g=n[s(1250)+"At"](b);e.XsCXC(g,55296)&&e[s(896)](g,56319)&&e[s(1952)](e[s(1582)](b,1),d)&&(g=e[s(1373)](e[s(1394)](e[s(1683)](g,10),n.charCodeAt(++b)),56613888)),g<128?w[p++]=g:e.DhXsg(s(1017),e[s(976)])?(e[s(1952)](g,2048)?w[p++]=e[s(2050)](g>>6,31)|192:(g<65536?w[p++]=e.evsBQ(g>>12,15)|224:(w[p++]=e[s(952)](e[s(1078)](g,18)&7,240),w[p++]=e[s(1569)](e.KHQwO(e[s(1522)](g,12),63),128)),w[p++]=e.zLdgx(e[s(1903)](g>>6,63),128)),w[p++]=e[s(1485)](63,g)|128):(this[s(552)+s(471)+s(1712)](_0x50e343),_0x56ccc2.set(_0x8908c6,_0x3f18fb,_0x37fa60[s(1891)][s(2022)]))}}function $(a,n){let s=t,d=e.suFCJ(ne,a,n[s(837)]),f=a.bytes,p=n[s(1913)];for(let w=0,b=n[s(837)];e[s(1930)](w,b);w++)f[e[s(686)](w,d)]=p[w]}function oe(a){return a[t(1913)][e.daCFq(X,a,1)]}function Qe(a,n){let s=t,d=e[s(1442)](ne,a,1);a[s(1913)][d]=n}function he(a){let n=t,s={wCYek:function(d,f){return e.zLdgx(d,f)},nLsuE:function(d,f){return d|f},aXILI:function(d,f){return e.DgUkt(d,f)},SmcjS:function(d,f){return e[G(772)](d,f)},CpbPj:function(d,f){return d<<f},oUEwE:function(d,f){return e[G(1683)](d,f)},VzbDp:function(d,f){return e.VWScv(d,f)}};if(e.afZyE("TjLMj",e[n(571)]))this[n(1239)]?.[n(1638)](),this._qosDB=void 0;else{let d=0,f=0,p;do{if(n(1065)!==e.BWnZe)return new _0x2712ea(s[n(1609)](s[n(1609)](s[n(630)](s[n(569)](_0x46c41b[4],24),s[n(569)](_0x4a88da[5],16)),_0x8a7541[6]<<8),_0x121c70[7]),s[n(991)](s.CpbPj(_0x3bf5d5[0],24)|s[n(1951)](_0x41bc8c[1],16)|s[n(1400)](_0x5f437f[2],8),_0x2fe209[3]),_0x427ea4);p=e.tDYPG(oe,a),e[n(485)](d,32)&&(f|=(127&p)<<d),d+=7}while(e[n(1502)](128,p));return f}}function pe(a,n){let s=t,d={pdQAy:function(f){return e.uqzls(f)}};if(e[s(885)](e[s(664)],e[s(664)])){for(n>>>=0;e[s(1726)](n,128);)if(e[s(965)]===e.baGkz){let f=this["_endpoin"+s(1150)]?.[s(1882)+"ntEndpoint"]();this[s(973)](s(2060)+f),d[s(1528)](_0x1bab8d)}else e.kyLpd(Qe,a,e[s(1599)](e[s(1485)](127,n),128)),n>>>=7;e[s(754)](Qe,a,n)}else{let f=0,p=0,w;do w=e[s(1337)](_0x4bc264,_0x1e0af5),e[s(1757)](f,32)&&(p|=e[s(1282)](127&w,f)),f+=7;while(128&w);return p}}function It(a,n){let s=t,d={jNhMx:function(f,p,w){return f(p,w)},gsZZT:e.sDcYK,hfpId:function(f,p){return e[G(1337)](f,p)},BNHFE:function(f,p){return f+p},iAxip:s(1003),FHBrb:s(1339)};if(e[s(1664)](e[s(764)],e.mCvSS)){let f=0,p=0,w=0,b;if(b=e.BrRTa(oe,a),f=e[s(1903)](127,b),e.bQQWY(128,b))if(e[s(670)](e.bllsZ,s(1267))){if(b=e[s(1605)](oe,a),f|=(127&b)<<7,e.EAmof(128,b)){if(e[s(1542)](e[s(2037)],e[s(2037)])){let g=d[s(527)](_0x2b7576,d[s(827)],{message:_0x2db6b4[s(1891)],code:_0x5edbb4[s(1344)+"ERROR"],error:_0x1b7c34});this[s(552)+s(609)+"ent"](g)}else if(b=e[s(1104)](oe,a),f|=(127&b)<<14,e[s(876)](128,b))if(e[s(1690)]===s(1672)){if(b=e[s(1689)](oe,a),f|=e[s(638)](127&b,21),e[s(950)](128,b))if(e[s(629)](e.HpVeH,e[s(2065)])){if(b=oe(a),p=e[s(1627)](127,b),e[s(2045)](128,b)&&(b=oe(a),p|=e[s(1694)](127,b)<<7,e.tatNX(128,b)&&(b=oe(a),p|=e[s(1515)](127&b,14),e[s(591)](128,b)))){if(e.XuSUY===e[s(872)])return e.Cilhu(e[s(1135)](_0x3de964,8)[s(2099)]("0"),e[s(1762)](_0x1e7192,_0x53b4ea,10).toString(2)).slice(-8);if(b=e[s(813)](oe,a),p|=e[s(1282)](e.NxTyC(127,b),21),e.psRaw(128,b)&&(b=e.CZFXl(oe,a),w=e.hhYsa(127,b),e.tatNX(128,b)))if(e[s(1971)](e[s(635)],s(666)))b=e[s(1414)](oe,a),w|=e.hVxBk(127,b)<<7;else{let g={svdFK:e[s(1200)],WfLVs:function(R,P){return e[s(979)](R,P)},KIHgv:function(R,P){return e[s(1573)](R,P)},MtVpA:function(R,P){return e.BGnDB(R,P)},gAeVS:function(R,P){return R|P},NsJFk:function(R,P){return R<<P},eenSq:function(R,P){return e[s(617)](R,P)},VoVTJ:function(R,P){return R<P},WtZXj:function(R,P){return e[s(1091)](R,P)},MFgOj:function(R,P){return e[s(540)](R,P)},qNcEg:function(R,P){return e[s(1599)](R,P)},BMgUp:function(R,P){return e[s(2050)](R,P)},mlHSH:function(R,P){return e[s(772)](R,P)},lSNxH:function(R,P){return e[s(1401)](R,P)}},C=4294967295;return function(R,P,F=!0){let B=s,te=g.svdFK[B(852)]("|"),J=0;for(;;){switch(te[J++]){case"0":C=g[B(1848)](g[B(1553)](127,R[P]),0);continue;case"1":C=g.MtVpA(g[B(1990)](C,g[B(1667)](g[B(502)](127,R[P]),14)),0);continue;case"2":if(g.VoVTJ(R[P++],128))return{value:F?C:g[B(1990)](0,C),offset:P};continue;case"3":C=g[B(2049)](C|g[B(1667)](g[B(502)](127,R[P]),21),0);continue;case"4":if((P+=5)>R.length)throw P=R[B(1360)],_0x31fa92(P,10,R[B(1360)]);continue;case"5":if(R[P++]<128)return{value:F?C:g[B(1990)](0,C),offset:P};continue;case"6":if(R[P++]<128)return{value:F?C:g.gAeVS(0,C),offset:P};continue;case"7":C=g[B(1811)](C|g[B(1667)](g.MFgOj(15,R[P]),28),0);continue;case"8":if(R[P++]<128)return{value:F?C:0|C,offset:P};continue;case"9":C=g[B(1086)](C,g[B(1976)](127,R[P])<<7)>>>0;continue;case"10":return{value:F?C:g.mlHSH(0,C),offset:P};case"11":if(g.lSNxH(R[P++],128))return{value:F?C:0|C,offset:P};continue}break}}}}}else _0x3d5e9c-=65536,_0x4992a4+=e[s(1441)](_0x309b6d,e[s(1394)](e.QluyR(_0x3a5041,10),55296),e[s(1217)](e[s(1903)](1023,_0x13e436),56320)),_0x5a92d8+=3}else{let{enableAutoAck:g}=this[s(531)],C=e.OCmXg(_0xa30a2b,_0x1c3d91.message[s(913)],"need_ack","1"),R=_0x35e9ae(_0x4b131c[s(1891)][s(913)],e.LZwhw,"1"),P=_0x3c6bbf.call(this,_0x4d08f6);if(e[s(2121)](g,C)){let{SeqID:F,LogID:B,service:te,LogIDNew:J,method:Pe}=_0x15edd1.message;this[s(1187)]({SeqID:F,LogID:B,LogIDNew:J,service:te,method:Pe,headers:[{key:e[s(802)],value:"1"},{key:e[s(1356)],value:e[s(1506)](J,"")},{key:e.gMTUl,value:"0"}]})}R&&!P.isQoSAck&&this[s(552)+s(1063)+s(1494)](_0x10f500),_0x2ab378()}}}else{let g=_0x4f8271.split(/\./).map(P=>_0x334aca(P)),C=[];return C[0]=NjYSIp[s(1134)](_0x389550,NjYSIp[s(1023)](g[0],g[1])),C[1]=NjYSIp[s(1134)](_0x3c1790,NjYSIp[s(1023)](g[2],g[3])),[NjYSIp.iAxip,s(1003),NjYSIp.iAxip,NjYSIp[s(1964)],NjYSIp[s(1964)],NjYSIp[s(1884)],C[0],C[1]][s(2099)]("")}return{low:e[s(858)](f,e[s(1683)](p,28)),high:e[s(543)](p>>>4,w<<24),unsigned:n}}else{let f={rzKsp:function(C,R){return e[s(1226)](C,R)},tpSAu:function(C,R){return e[s(2073)](C,R)},FALhD:function(C,R){return e[s(2067)](C,R)},RCLjC:function(C,R){return e[s(1962)](C,R)}},p=e[s(1506)](_0x1d9110,8192),w=e[s(1091)](p,1),b=null,g=p;return function(C){let R=s;if(C<1||f[R(1695)](C,w))return f.tpSAu(_0x3adea2,C);f[R(1203)](g,C)>p&&(b=f[R(596)](_0x23b8ac,p),g=0);let P=_0x196817[R(1922)](b,g,g+=C);return 7&g&&(g=f[R(1203)](f.RCLjC(7,g),1)),P}}}function pt(a,n){let s=t,d=e.YPajw(n.low,0),f=e[s(1755)](e[s(1766)](n[s(1447)]>>>28,e[s(587)](n.high,4)),0),p=e[s(525)](n[s(1245)],24),w=e[s(684)](0,p)?e[s(1617)](0,f)?e[s(1757)](d,16384)?d<128?1:2:d<2097152?3:4:e[s(485)](f,16384)?e[s(2059)](f,128)?5:6:e[s(1893)](f,2097152)?7:8:e[s(1280)](p,128)?9:10,b=e[s(1225)](ne,a,w),g=a[s(1913)];switch(w){case 10:g[e[s(1938)](b,9)]=e[s(1774)](e[s(525)](p,7),1);case 9:g[e[s(1619)](b,8)]=e[s(1275)](9,w)?128|p:e[s(1502)](127,p);case 8:g[e[s(1758)](b,7)]=e[s(533)](8,w)?e[s(1702)](f>>>21,128):e.KHQwO(e[s(1091)](f,21),127);case 7:g[e[s(2067)](b,6)]=w!==7?e[s(858)](e[s(579)](f,14),128):e[s(1477)](e[s(715)](f,14),127);case 6:g[b+5]=w!==6?e[s(1570)](e.nNeSg(f,7),128):e.pjXlH(f,7)&127;case 5:g[b+4]=w!==5?e[s(993)](128,f):127&f;case 4:g[e.ZkhQs(b,3)]=e[s(1352)](4,w)?e[s(1089)](e[s(652)](d,21),128):e.PNLFg(d>>>21,127);case 3:g[b+2]=e[s(1059)](3,w)?e[s(2039)](e[s(979)](d,14),128):e[s(1255)](e.HVCbD(d,14),127);case 2:g[e[s(1217)](b,1)]=e[s(677)](2,w)?e.MKZEs(d,7)|128:e.TGyRx(e[s(893)](d,7),127);case 1:g[b]=e[s(1608)](1,w)?e[s(858)](128,d):e[s(1485)](127,d)}}function tn(a){return e.CZFXl(v,a)}function Ut(a){return S(a)}let nn=65536,Yr=e[t(1826)],we=e.uzlVu(nn,nn),Ie=e[t(841)](we,we),nr=e.tUMMH(Ie,2),ke=String[t(1958)+"e"].charCodeAt;class xe{constructor(n,s,d){let f=t;this[f(1137)]=!0,this.low=e[f(1766)](0,n),this[f(1245)]=e[f(1962)](0,s),this.unsigned=!!d}static[t(1137)](n){let s=t;return n&&e[s(1416)](!0,n[s(1137)])}static[t(831)](n,s,d){return new xe(n,s,d)}static[t(2017)+"s"](n,s,d){let f=t;return d?xe[f(2017)+f(1686)](n,s):xe["fromByte"+f(1768)](n,s)}static[t(2017)+t(1686)](n,s){let d=t;return new xe(e.CMkAK(e[d(1173)](e[d(1851)](n[0],n[1]<<8),e[d(587)](n[2],16)),n[3]<<24),e[d(1962)](n[4]|e.SQoPG(n[5],8)|e[d(638)](n[6],16),n[7]<<24),s)}static[t(2017)+t(1768)](n,s){let d=t;return new xe(e[d(1453)](e[d(1599)](n[4]<<24,e[d(1353)](n[5],16)),n[6]<<8)|n[7],e.AmwEm(e.rYLAh(n[0]<<24,e.YTvSt(n[1],16)),n[2]<<8)|n[3],s)}static[t(2005)](n){let s=t;return e[s(1632)](n,Yr)?Zd:new xe(e[s(1955)](e[s(2039)](ke.call(n,0)|ke[s(1922)](n,1)<<8,e[s(478)](ke.call(n,2),16)),e[s(1281)](ke[s(1922)](n,3),24))>>>0,e.USoHB(e[s(1371)](e[s(1851)](ke.call(n,4),e[s(1647)](ke[s(1922)](n,5),8)),e.bTMJZ(ke[s(1922)](n,6),16))|ke[s(1922)](n,7)<<24,0),!0)}[t(598)](){let n=t;return String["fromChar"+n(2004)](255&this[n(1447)],e.VBgwm(e[n(1755)](this.low,8),255),e.lImmu(e[n(1091)](this[n(1447)],16),255),e[n(769)](this[n(1447)],24),255&this[n(1245)],this[n(1245)]>>>8&255,e[n(2009)](this.high,16)&255,this[n(1245)]>>>24)}static fromNumber(n,s=!0){let d=t;if(isNaN(n))return s?gp:Zd;if(s){if(n>=Ie)return wp}else{if(n<=-nr)return _p;if(n+1>=nr)return mp}return xe[d(831)](e.vVNdo(n,we)|0,e[d(1326)](e[d(1612)](n,we),0),s)}toNumber(){let n=t;if(e.upQMe(e[n(1253)],n(2019)))return this[n(768)]?e[n(525)](this[n(1245)],0)*we+(this[n(1447)]>>>0):e[n(841)](this[n(1245)],we)+e[n(525)](this.low,0);this._ws&&this[n(1279)][n(475)](_0x3797d1),this[n(1165)+n(1155)][_0xb1a92d]=null}[t(1169)](){let n=t,s={uhebf:function(d,f){return e.gIMRE(d,f)}};return e.dkIoa(e.btjVK,e[n(992)])?e[n(1850)](0,this[n(1245)])&&e[n(1048)](0,this[n(1447)]):(_0x525790[n(1051)](rrWPdi.uhebf(_0x3091af,this),_0x3348b7),rrWPdi[n(649)](_0x2d6013,_0x2cc737[n(867)](this)))}add(n){let s=t;xe[s(1137)](n)||(n=xe.fromNumber(n));let d=this[s(1245)]>>>16,f=e[s(1238)](65535,this[s(1245)]),p=e[s(579)](this.low,16),w=65535&this.low,b=e[s(792)](n[s(1245)],16),g=e.gJJVy(65535,n[s(1245)]),C=e[s(1510)](n[s(1447)],16),R=65535&n.low,P=0,F=0,B=0,te=0;return te+=e[s(1077)](w,R),B+=e.oAGGR(te,16),te&=65535,B+=p+C,F+=e[s(1397)](B,16),B&=65535,F+=e[s(1249)](f,g),P+=e[s(1262)](F,16),F&=65535,P+=e[s(1458)](d,b),P&=65535,xe[s(831)](e[s(905)](e[s(587)](B,16),te),e.ghJVP(e[s(478)](P,16),F),this[s(768)])}[t(1808)](n){let s=t,d={iRrrF:function(f,p,w,b){return e[G(1398)](f,p,w,b)},MKXmN:e.zNQMp,sHzBz:function(f,p,w,b){return e[G(1398)](f,p,w,b)},hgrVF:s(642)+s(681)+"ck",JGCxa:e[s(1297)]};if(e[s(885)](e[s(1708)],"TWeCH")){let f=!!this[s(531)][s(1100)+"S"];if(!f)return{enabled:f,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let p=d[s(930)](_0x1ef6ec,_0x1b434b[s(1891)].headers,d[s(2053)],"2"),w=p&&d[s(1152)](_0x181cc6,_0x1ed35f[s(1891)][s(913)],d[s(1660)],"1"),b=p&&d[s(930)](_0x578bac,_0x14398e.message[s(913)],s(642)+s(878)+"k","1"),g=b?_0x3668c4(_0x55a540.message[s(913)],d[s(1742)])?.split(",")[s(763)](_0x2294f7)||[]:[];return{enabled:f,isQoSMessage:p,isQoSAck:w,isAckCleanupMessage:b,ackMsgIds:g}}else return xe[s(1137)](n)||(n=xe.fromNumber(n)),this.unsigned!==n[s(768)]&&e[s(492)](e.MKZEs(this[s(1245)],31),1)&&e[s(1325)](e.qENMR(n[s(1245)],31),1)?!1:e[s(947)](this[s(1245)],n[s(1245)])&&e[s(1048)](this[s(1447)],n.low)}[t(1370)](){let n=t;return e[n(1428)](-1,this.low)&&e[n(1632)](-1,this[n(1245)])?xe[n(831)](0,0,this[n(768)]):e.oQVLP(-1,this[n(1447)])?xe[n(831)](0,e[n(1792)](this[n(1245)],1),this[n(768)]):xe[n(831)](this[n(1447)]+1,this[n(1245)],this[n(768)])}[t(1679)](n){let s=t;return n?this[s(2082)+"E"]():this[s(945)+"E"]()}[t(2082)+"E"](){let n=t,s={UAvpB:e.sDcYK,nzDHD:n(1843),mFNTU:function(d){return e[n(728)](d)},CgRUg:e[n(577)],fDDVW:function(d){return e[n(839)](d)},MKiGm:e[n(762)]};if(e.MyXBO===n(1767)){let d=this.high,f=this[n(1447)];return[e[n(1809)](255,f),e.bQQWY(e[n(1262)](f,8),255),e[n(1729)](e[n(1196)](f,16),255),f>>>24,e[n(1573)](255,d),e[n(1648)](d>>>8,255),d>>>16&255,e[n(2009)](d,24)]}else{let d={vGypZ:function(b,g){return b(g)},locbC:UhoWDN[n(901)],EGlMK:function(b){let g=n;return UhoWDN[g(1897)](b)}},f=()=>{let b=n;_0x34673a[b(1409)+"entListener"](b(1586),p),_0x433623[b(1409)+"entListe"+b(1650)](UhoWDN[b(1319)],w),_0x5005fe["removeEv"+b(1908)+b(1650)](UhoWDN[b(1343)],w)},p=()=>{let b=n;_0x796b84(),UhoWDN[b(758)](f)},w=()=>{let b=n;d[b(1315)](_0x1030ac,_0x330208.error||new _0x85ca19(d[b(496)],d[b(496)])),d[b(1410)](f)};_0x2095ee["addEvent"+n(1923)](UhoWDN[n(1029)],p),_0x5c9156[n(1892)+n(1923)](UhoWDN[n(1319)],w),_0x108bdd[n(1892)+n(1923)](UhoWDN[n(1343)],w)}}[t(945)+"E"](){let n=t,s=this[n(1245)],d=this[n(1447)];return[e[n(870)](s,24),e[n(979)](s,16)&255,e.hDKlf(e[n(1196)](s,8),255),e[n(617)](255,s),d>>>24,e[n(1445)](e.MMtMb(d,16),255),e.wpghT(d>>>8,255),e[n(1270)](255,d)]}}let Zd=new xe(0,0,!1),gp=new xe(0,0,!0),mp=xe.fromBits(-1,2147483647,!1),wp=xe[t(831)](-1,-1,!0),_p=xe[t(831)](0,-2147483648,!1);var rn=(function(a){let n=t;return a[a[e[n(1929)]]=5001]="NATIVE_E"+n(1138),a[a[e[n(986)]]=5002]="CONNECTI"+n(604),a[a[e[n(1753)]]=5003]=e[n(1753)],a[a[e.RTQDh]=5004]=n(1344)+n(1947),a[a[n(1733)+"OR"]=5005]=e.CRfeY,a})({});class rr{constructor(n){let s=t;this[s(2025)]=n,this[s(2066)]=null}}class Jd extends rr{constructor(n,s){let d=t;super(n),this[d(1891)]=s&&s[d(1891)]||null}}class Xd extends rr{constructor(n,s){let d=t;super(n),this[d(1508)]=s&&s[d(1508)]||null,this[d(1552)]=s&&s[d(1552)]||0,this[d(1491)]=s&&s.filename||"",this[d(535)]=s&&s.lineno||0,this.message=s&&s[d(1891)]||"",this[d(1719)]=s&&s[d(1719)]||5001}}class Yd extends rr{constructor(n,s){let d=t;super(n),this[d(1719)]=s&&s[d(1719)]||0,this[d(621)]=s&&s[d(621)]||"",this[d(1532)]=s&&s[d(1532)]||!1,this[d(585)+d(897)]=s&&s[d(585)+d(897)]||!1}}class Qd extends rr{constructor(n,s){let d=t;super(n),this[d(1579)]=s&&s[d(1579)]||null}}class el extends Qd{constructor(n,s){let d=t;super(n),this[d(1579)]=s&&s.data||null,this[d(1891)]=s&&s.message||null}}class tl extends rr{constructor(n,s){let d=t;super(n),this[d(1579)]=s&&s.data||null}}function lt(a,{message:n,code:s,error:d}){let f=t,p={bhLyy:function(w,b){return e[G(1940)](w,b)},XHvAg:function(w,b){return e[G(1282)](w,b)},Wsnlm:function(w,b){return e[G(1255)](w,b)},rrXBA:function(w,b){return e.InTaz(w,b)},lWcyJ:function(w,b){return e[G(1824)](w,b)},AMXXT:function(w,b){return e.hpRnm(w,b)},qQeiq:function(w,b){return e[G(1282)](w,b)},TEeYJ:function(w,b){return w&b}};if(f(1451)===e[f(892)])_0x6739ea=qiAEPS.bhLyy(_0x40b872,_0xcf0a22),_0x583705|=qiAEPS.XHvAg(qiAEPS[f(676)](127,_0x1e236c),14),qiAEPS.rrXBA(128,_0x10ff1e)&&(_0x5729cb=qiAEPS[f(2118)](_0x2b6fc2,_0x1f9198),_0x508c3b|=qiAEPS[f(1540)](qiAEPS[f(676)](127,_0x9bc058),21),qiAEPS[f(1204)](128,_0x2c2fc5)&&(_0x12354e=qiAEPS.bhLyy(_0x1726b9,_0x26723a),_0x562d5a=qiAEPS[f(1355)](127,_0xb4ec57),qiAEPS[f(1120)](128,_0x250bce)&&(_0x2985ae=qiAEPS[f(2118)](_0x201a29,_0x1c72fd),_0x237cd9|=qiAEPS[f(1121)](qiAEPS[f(971)](127,_0x2e3487),7))));else return new Xd(a,{message:n,code:s,error:d})}function gt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){let p=t;return e[p(1191)](e[p(1484)],e[p(1484)])?this[p(1239)]?.[p(1830)]({message_id:_0x146d15,timestamp:_0x48525c}):new Yd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function nl(a,{data:n,message:s}){return new el(a,{data:n,message:s})}function rl(a,{data:n}){let s=t;if(e[s(1308)]!==e[s(1308)]){let d=_0x476112(_0x3a8cc8,1);_0x637fb0.bytes[d]=_0xf916a3}else return new tl(a,{data:n})}function ha(a,{message:n}){return new Jd(a,{message:n})}class il{constructor(n,s){let d=t;this[d(761)+"s"]=n,this[d(2078)+"es"]=s,this[d(644)+d(787)]=0,this[d(1334)+d(691)+d(1043)+"t"]=0}[t(919)+t(880)+t(1399)](){let n=t;this.currentIndex=0,this[n(1334)+n(691)+n(1043)+"t"]=0}[t(690)+"es"](){let n=t;this[n(1334)+"ndpointT"+n(1043)+"t"]=0}[t(1882)+"ntEndpoint"](){let n=t;return this.endpoints[this[n(644)+n(787)]]}["getCurrentEndpoi"+t(1466)+t(2090)](){let n=t,s={Zvbps:e[n(1501)],TCKZF:e[n(523)],bzYgT:function(d,f,p){return d(f,p)},uXMFE:e.munJA};if(e[n(1490)](e[n(1320)],n(2107))){if(this[n(988)+n(1746)](),this[n(2001)+n(1244)](),this._removeWsListeners(),this["_wsInsta"+n(1316)](1e3,_0x29943d),this[n(711)+n(2051)]=!1,_0x4e5edb&&this[n(743)+n(586)]()&&!this[n(731)+n(549)]){if(this[n(1419)+n(1150)]?.["checkRea"+n(1084)+"es"]()){let f=this[n(1419)+n(1150)]?.["getCurre"+n(1468)+"nt"]();this[n(552)+n(2008)+n(1970)](_0x3d49db(s.Zvbps,{code:1006,reason:n(601)+f+(n(1465)+n(1905)+n(1304)+"ached"),wasClean:!0}))}else{let f=this[n(531)][n(661)+n(1783)+"ptor"](_0x149bc6,_0x5bbf5c);this[n(552)+n(2008)+n(1970)](_0x536502(s[n(1351)],{code:_0x49beb1,reason:_0x3eadb6,wasClean:!0,willReconnect:f})),f&&this._connect()}return}this[n(743)+n(586)]()||this._readyClosed?this[n(552)+n(2008)+n(1970)](_0x135103(s[n(1351)],{code:_0x1b385a,reason:s[n(2110)]})):this[n(552)+n(2008)+"ent"](s[n(1092)](_0x2f534f,s[n(1351)],{code:1006,reason:s[n(1678)]})),this[n(1279)]=null,this["_endpoin"+n(1150)]?.[n(919)+n(880)+"fig"](),this[n(1125)+n(886)]?.[n(1566)+n(1272)]()}else return this[n(1334)+n(691)+"riesCount"]}[t(1111)+t(1084)+"es"](){let n=t;return!!(e.XsCXC(this[n(644)+"ndex"],this[n(761)+"s"][n(1360)])||e[n(1688)](this[n(644)+"ndex"],e[n(674)](this[n(761)+"s"][n(1360)],1))&&this["currentE"+n(691)+n(1043)+"t"]===this[n(2078)+"es"])}["checkCurrentEndp"+t(2096)+"hedMaxRe"+t(663)](){let n=t;return this["currentI"+n(787)]==this.endpoints[n(1360)]?!0:e[n(647)](this[n(1334)+n(691)+"riesCount"],this[n(2078)+"es"])}[t(580)+t(1790)+t(2016)+"UpdateCo"+t(2068)](){let n=t,s={iYotf:e[n(744)]};if(e[n(1795)](e[n(1597)],e.zCQPD))return this[n(1334)+"ndpointT"+n(1043)+"t"]=1,this[n(644)+"ndex"]++,this[n(761)+"s"][this[n(644)+n(787)]];{this[n(689)+n(1331)+"t"]();let d=_0x1f3026(n(661)+"t",{message:s[n(1547)]});this[n(853)+n(1585)+n(1222)+"ct"]&&this[n(853)+"mediatel"+n(1222)+"ct"](d)}}["getCurre"+t(1468)+t(1784)+"ateCount"](){let n=t;if(e.csKvz(e[n(2054)],n(779)))return this["currentE"+n(691)+n(1043)+"t"]++,this["getCurre"+n(1468)+"nt"]();if(_0x46801e===xAOwxb[n(1591)])return _0x30b3a2[n(867)](_0x79139b);if(xAOwxb[n(1416)](_0x203f78,n(2079)+n(1018)))return _0x458d74[n(2079)+n(1018)]||_0x55d320[n(867)](_0x2aca10);if(xAOwxb[n(1041)](_0x5f3e78,"store"))return _0xf0f13b[n(2079)+n(1018)][1]?void 0:_0x4b49f3[n(2079)+n(1782)](_0x95ea05["objectSt"+n(1018)][0])}}let ir=(e.WLptO(t(2072)+"d",typeof globalThis)&&e[t(906)](e.fzMKx,globalThis[t(1011)+t(1497)][t(1531)])||e[t(1945)](e[t(505)],typeof window)&&e[t(2102)](e.fzMKx,window["construc"+t(1497)].name))&&e.zzhHY(e[t(505)],typeof document),Pn=e[t(505)]!=typeof globalThis&&(e.QZpLz(t(898),globalThis.constructor[t(1531)])||e[t(863)]===globalThis[t(1011)+"tor"].name)&&e[t(505)]!=typeof tt,Qr=(e.JcxVl(e[t(505)],typeof globalThis)&&e[t(718)](e[t(848)],globalThis["construc"+t(1497)][t(1531)])||e[t(843)](e[t(505)],typeof globalThis)||e[t(1668)](e[t(505)],typeof globalThis)&&!!globalThis[t(1220)+t(1868)])&&e.ziXOU("undefined",typeof wx),ei=e.htfcA!=typeof globalThis&&(e[t(1219)]("Dedicate"+t(618)+"lobalScope",globalThis[t(1011)+t(1497)][t(1531)])||e[t(771)]===globalThis.constructor[t(1531)]||e[t(1450)](e[t(482)],globalThis[t(1011)+"tor"][t(1531)]))&&e[t(1734)](e.htfcA,typeof self),yp=e[t(1814)](e[t(505)],typeof globalThis)&&e.EErdJ(t(898),globalThis["construc"+t(1497)][t(1531)])&&e[t(2091)](e[t(505)],typeof global)&&e.AqZdi(e[t(848)],global[t(1011)+t(1497)].name)&&e[t(2091)](e[t(505)],typeof process)&&!!process[t(627)];class pa{constructor(){this._listeners={}}[t(1426)](n,...s){let d=t;if(e[d(1543)]!==e[d(1543)]){if(e[d(1893)](_0x20323f,1)||_0x36c2e6>_0x2de055)return _0x5a7a13(_0x42db0c);e[d(1226)](e.JObfQ(_0x3431a4,_0x410f41),_0x4e0cb1)&&(_0x56a037=e[d(1656)](_0x48449c,_0x5d5f2d),_0x206eed=0);let f=_0x38e69d[d(1922)](_0x157a33,_0x526608,_0x61e4b8+=_0x4b1dd8);return e[d(1573)](7,_0x46a1d8)&&(_0x5b8d88=e.cWCrN(e[d(1089)](7,_0x1e17af),1)),f}else{let f=this._listeners[n];if(f)f[d(738)]()[d(1047)](p=>p.fn[d(1051)](p.ctx,s));else if(e[d(1834)](d(1508),n)&&!this[d(1900)]){let p=s[d(1360)]&&s[0];if(p instanceof Error)throw p;let w=new Error(e[d(862)](e.JyoLg,p?e[d(920)](e[d(1938)](" (",p[d(1891)]),")"):""));throw w[d(1804)]=p,p}return this}}[t(2088)](n,s){let d=t,f={PxjoT:function(p,w,b){return e[G(1079)](p,w,b)},bhoMl:e[d(1501)]};if(e.DVyFK(void 0,n))this[d(1124)+"rs"]={};else if(e[d(1103)](void 0,s))this[d(1124)+"rs"][n]=null;else if(e.roOZh(e.IzkgH,"ZOdJI"))this[d(1426)](d(1638),f[d(1361)](_0x222b34,f[d(2040)],{..._0x3f8afa}));else{let p=this[d(1124)+"rs"][n];if(p)for(let w=0;w<p[d(1360)];)e[d(1617)](p[w].fn,s)?p.splice(w,1):++w}return this}on(n,s,d){let f=t;return(this[f(1124)+"rs"][n]||(this[f(1124)+"rs"][n]=[]))[f(911)]({fn:s,ctx:d||this}),this}}class bp extends pa{[t(537)+t(1403)+t(1819)](n){let s=t;return n[s(1622)]||n[s(1036)]?(s(1538)+" "+(n[s(1622)]||"")+s(736)+(n[s(1036)]||"")).trim():JSON[s(1004)+"y"](n)}constructor(n,s,d){let f=t;super(),this[f(2071)]=null,Qr&&wx[f(1227)+f(1049)]&&(this[f(2071)]=wx[f(1227)+f(1049)]({url:n,protocols:s,header:d,fail:this._createSocketFailHandler[f(1640)](this),success:this[f(1448)+f(693)+"cessHand"+f(1074)].bind(this)})),Pn&&tt[f(1227)+"ocket"]&&(this[f(2071)]=tt["connectS"+f(1049)]({url:n,protocols:s,header:d,fail:this[f(1448)+f(1616)+"lHandler"][f(1640)](this),success:this[f(1448)+"ocketSuc"+f(1207)+f(1074)][f(1640)](this)}))}[t(1448)+t(693)+t(1207)+t(1074)](){let n=t;Promise.resolve()[n(583)](()=>{this["_addWsLi"+n(1366)]()})}["_createS"+t(1616)+t(1e3)](n){let s=t;Promise[s(1818)]()[s(583)](()=>{let d=s,f=e[d(1474)](lt,e[d(729)],{message:this[d(537)+"rrorMess"+d(1819)](n)});this[d(1426)](e[d(729)],f);let p=e[d(809)](gt,e.DUWUZ,{reason:this["_formatE"+d(1403)+d(1819)](n)});this[d(1426)](e[d(1501)],p)})}[t(998)+t(1366)](){let n=t,s={PeHUC:e[n(1588)],cKuSp:e[n(1501)],vdjSA:function(d,f,p){return e[n(1075)](d,f,p)}};this[n(2071)].onOpen(d=>{let f=n;this[f(1426)](e[f(1176)],e[f(1225)](rl,f(1999),{...d,data:d[f(1622)]||""}))}),this[n(2071)][n(1455)](d=>{let f=n;if(f(734)===s[f(1673)])this[f(1426)](s[f(1631)],s[f(1806)](gt,s.cKuSp,{...d}));else{let p=this._qosDB[f(2044)+f(1749)](this[f(667)]),w=_0x3c47db.parse(p||"{}");return w[_0x566a7d]=void 0,this[f(1239)].setStorageSync(this[f(667)],_0x14a4a7[f(1004)+"y"](w))}}),this[n(2071)][n(719)+"e"](d=>{let f=n;this.emit(e[f(473)],e[f(694)](nl,e.rzKJT,{...d}))}),this._socket[n(517)](d=>{let f=n;if(e.DECEz("iwIaq",e.bxLED))this.emit(e[f(729)],e.ZZIdm(lt,e.sDcYK,{...d,message:d[f(1622)]||""}));else return this[f(1419)+"tManager"]?.["getCurre"+f(1468)+f(1466)+"ount"]()||0})}send(n){let s=t,d={fbSro:function(f,p){return f!==p},ksOWn:e[s(1305)],EOMMp:e.sDcYK,wMjnF:function(f,p,w){return f(p,w)}};if(e[s(1865)](n,Uint8Array)){let f=n[s(900)][s(738)](n.byteOffset,e[s(1514)](n[s(2028)+"th"],n[s(558)+"et"]));this[s(2071)]&&this._socket.send({data:f,fail:p=>{let w=s;if(d[w(1296)](d[w(1993)],w(962)))this[w(1426)](d[w(1549)],d[w(1323)](lt,w(1508),{message:this[w(537)+w(1403)+"age"](p)}));else return this._socket[w(1890)]}})}else this[s(2071)]&&this[s(2071)][s(475)]({data:n,fail:f=>{let p=s;this.emit(p(1508),e[p(753)](lt,p(1508),{message:this[p(537)+p(1403)+p(1819)](f)}))}})}[t(1638)](n,s){let d=t;this._socket&&this[d(2071)][d(1638)]({code:n,reason:s})}[t(1892)+t(1923)](n,s){let d=t,f={kAJtc:function(p,w){return e.nqYIX(p,w)},mzpSd:function(p,w){return e[G(1770)](p,w)},dxjiI:function(p,w){return e[G(2101)](p,w)},nHqHd:function(p,w){return e[G(1105)](p,w)},OMTGp:function(p,w){return e.WASEP(p,w)},ItjPb:function(p,w){return e[G(1763)](p,w)},nXTaP:function(p,w){return e[G(801)](p,w)}};if(e.VrKqm("KqyHG",e[d(1649)])){let p=_0x27bd7.charCodeAt(_0x24c6cf);wItWYi[d(1354)](p,55296)&&wItWYi.mzpSd(p,56319)&&wItWYi.dxjiI(wItWYi[d(1916)](_0xc99c21,1),_0x22d92a)&&(p=wItWYi[d(1088)](wItWYi.ItjPb(wItWYi.nXTaP(p,10),_0x3358af[d(1250)+"At"](++_0x22ce63)),56613888)),_0xf145c3+=wItWYi[d(560)](p,128)?1:wItWYi.dxjiI(p,2048)?2:wItWYi[d(560)](p,65536)?3:4}else this.on(n,s)}[t(1409)+t(1908)+t(1650)](n,s){this.off(n,s)}get[t(1040)+"te"](){return this._socket.readyState}get binaryType(){let n=t;return this[n(2071)][n(660)+"pe"]}set binaryType(n){}get url(){return this[t(2071)].url}get[t(1890)](){return this[t(2071)].protocol}get[t(1285)+"ns"](){let n=t;return this[n(2071)][n(1285)+"ns"]}get[t(1934)+"Amount"](){let n=t,s={OnYJa:e[n(1596)]};if(e[n(1834)](e[n(1849)],e[n(550)])){let d=s[n(942)][n(852)]("|"),f=0;for(;;){switch(d[f++]){case"0":this[n(731)+"osed"]=!1;continue;case"1":this._connect();continue;case"2":this["_endpoin"+n(1150)]?.["resetEndpointCon"+n(1399)]();continue;case"3":this[n(1125)+n(886)]?.[n(1566)+n(1272)]();continue;case"4":this[n(833)]=!0;continue}break}}else return 0}}function Ep(a,n){let s=t;if(e[s(1737)]!==e[s(931)]){if(n)return new n(a[s(1274)],a.protocol);if(e[s(1506)](Qr,Pn))return new bp(a.url,a[s(1890)],a[s(913)]);if((ir||ei)&&e[s(2024)](e[s(505)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(1274)],a[s(1890)+"s"])}else _0x3fb939(this[s(656)+s(1577)+"Id"]),e[s(1168)](_0x49a085,this[s(2061)+s(636)+s(851)]),this[s(656)+"gTimeoutId"]=null,this[s(2061)+s(636)+s(851)]=null}function vp(a){let n=t;return!!(a||Qr&&wx[n(1227)+n(1049)]||Pn&&tt[n(1227)+n(1049)]||(ir||ei)&&typeof WebSocket<"u"&&WebSocket)}function sl(a,n,s){let d=t,f={VLTOm:function(b,g){return e.jYpvC(b,g)},lOhIS:d(819)+d(519)+d(1870)+d(1209)+d(1375),VIisL:function(b,g){return e.QEYNs(b,g)}},p=-1;async function w(b){let g=d;return f[g(1738)](b,p)?Promise.reject(new Error(f.lOhIS)):(p=b,f[g(2113)](b,s[g(1360)])?Promise.resolve():s[b].bind(a)(n,w[g(1640)](null,b+1)))}e[d(800)](w,0)}function ol(a){let n=t,s=0,d=0;for(let f=0;e[n(1163)](f,a[n(1360)]);++f)d=a[n(1250)+"At"](f),e[n(612)](d,128)?s+=1:e.vsHBP(d,2048)?s+=2:e[n(746)](e.gJJVy(64512,d),55296)&&e[n(2094)](e[n(2003)](64512,a[n(1250)+"At"](f+1)),56320)?(++f,s+=4):s+=3;return s}function al(a,n,s){let d=t;if(e.YKxGN(e[d(1928)](s,n),1))return"";let f="";for(let p=n;e[d(1952)](p,s);){let w=a[p++];if(e[d(1770)](w,127))f+=String[d(2120)+d(2004)](w);else if(w>=192&&e[d(1835)](w,224))f+=String.fromCharCode(e[d(1702)](e[d(1208)](e.kQWNM(31,w),6),e[d(774)](63,a[p++])));else if(e[d(544)](w,224)&&e.VYgDG(w,240))f+=String["fromChar"+d(2004)](e[d(1568)](e[d(588)](e[d(801)](e.TGyRx(15,w),12),e[d(873)](63&a[p++],6)),e[d(1502)](63,a[p++])));else if(e.tWNpb(w,240)){let b=(e.HKhBq(e.WSYpb(7&w,18)|e[d(946)](63,a[p++])<<12,e[d(1353)](e[d(1151)](63,a[p++]),6))|e[d(1685)](63,a[p++]))-65536;f+=String[d(2120)+d(2004)](55296+e.Ianrh(b,10)),f+=String[d(2120)+d(2004)](e.KPTvH(56320,e[d(620)](1023,b)))}}return f}function ga(a,n,s){let d=t,f=s,p,w;for(let b=0;e[d(1313)](b,a[d(1360)]);++b)if(p=a[d(1250)+"At"](b),e[d(1952)](p,128))n[s++]=p;else if(e[d(1952)](p,2048))n[s++]=e[d(2112)](p,6)|192,n[s++]=e[d(477)](63&p,128);else if(e[d(899)](e.UQgAm(64512,p),55296)&&e.csKvz(e[d(950)](64512,w=a[d(1250)+"At"](e[d(1022)](b,1))),56320)){let g=e[d(1935)][d(852)]("|"),C=0;for(;;){switch(g[C++]){case"0":n[s++]=p>>12&63|128;continue;case"1":n[s++]=e[d(543)](e[d(1376)](p,18),240);continue;case"2":++b;continue;case"3":n[s++]=e.CakvD(e[d(1557)](e[d(491)](p,6),63),128);continue;case"4":p=e[d(1395)](e[d(862)](65536,e[d(889)](1023&p,10)),e[d(1557)](1023,w));continue;case"5":n[s++]=e[d(1962)](63&p,128);continue}break}}else n[s++]=e.CciJV(e[d(1273)](p,12),224),n[s++]=e[d(1604)](e[d(1903)](e[d(1080)](p,6),63),128),n[s++]=e[d(824)](e[d(1445)](63,p),128);return e[d(1928)](s,f)}async function cl(a){let n=t,s={MXcmn:function(d,f){return e.xqgyo(d,f)}};if(e.wyDkx(n(1896),typeof a))if(e.oXstj(e[n(1504)],e[n(1234)])){let d=new Uint8Array(ol(a));return ga(a,d,0),d}else{let d=this._qosDB[n(2044)+"geInfoSync"](this[n(667)]),f=_0x4b74f8[n(2119)](s.MXcmn(d,"{}"));return _0x4bc13a[n(1112)](f)}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a[n(900)],a[n(558)+"et"],a.byteLength)}function Sp(a){let n=t,s={JrtMp:function(d,f,p,w){return d(f,p,w)}};try{if(e[n(724)]("fEFZI",e.tqDRg))s.JrtMp(_0x5b29e9,this,_0x496340,[_0x41596d,_0x3273db,_0x1d6326,_0x44d2e2,_0x36fd57,_0x54dab6]);else return e[n(1668)](e[n(1009)],typeof a)&&(e[n(1309)](a,ArrayBuffer)||a[n(900)]&&e.EmjiK(a[n(900)],ArrayBuffer))||e.DMXeo(e[n(1009)],typeof a)?"":(JSON.parse(a),e[n(1186)])}catch{return e[n(1041)](n(1852),n(1587))?e.fcRDX(-1,this[n(1447)])&&e[n(684)](-1,this[n(1245)])?_0x33b6ac.fromBits(0,0,this[n(768)]):this[n(1447)]===-1?_0x377300[n(831)](0,this[n(1245)]+1,this[n(768)]):_0x59d6a5[n(831)](e[n(1394)](this[n(1447)],1),this[n(1245)],this.unsigned):e[n(2104)](e[n(1009)],typeof a)?e[n(1519)]:""}}let Ap=(a,n)=>{let s=t;if(e[s(1325)](e[s(1340)],"tyRTX"))switch(a){case e[s(1406)]:case e[s(493)]:return{[s(1213)+a]:1,"x-tt-env":n};default:return{}}else _0x43503f(_0x51704b,90),e[s(894)](_0xa2ceb4,_0x3bfef8,_0xe0611b)};class Ip{constructor(n){let s=t;this[s(1495)+s(2090)]=n,this[s(791)]=0}[t(980)](){let n=t;e.csKvz(n(1153),e[n(1687)])?this[n(791)]++:e.zhPbr(_0x509db0,_0x54f001,this[n(695)+n(972)+"e"](_0x55de4f))}[t(1111)+t(1670)+"nt"](){let n=t;return e.QTPUw!==e[n(1283)]?new _0x4bd7ec(_0x406035,_0x502b69,_0x4b4d0c):e.XsCXC(this[n(791)],this[n(1495)+n(2090)])}[t(1566)+"nter"](n=0){let s=t;this[s(1495)+"ount"]=n,this.count=0}}async function Cp(a){let n={qgVgw:function(s,d){return e[G(1104)](s,d)}};return new Promise(s=>{let d=G;if(!ir)return e[d(1925)](s,e[d(770)]);try{let f=document[d(1872)+d(1511)](e.ZcIly);window[d(1240)+d(1769)]=p=>{let w=d;document[w(1452)][w(1072)+w(798)](f),window[w(1240)+w(1769)]=void 0,n[w(1062)](s,p&&p[w(557)]||w(1776)+w(621))},f[d(2025)]=e.Wzldy,f.src=e[d(1217)](a[d(511)](/^ws/,d(1433)),e.KHUOe);try{document.body.appendChild(f)}catch{document.body[d(1072)+d(798)](f)}}catch{window[d(1240)+"JSONP"]=void 0,e[d(1168)](s,e.LVMho)}})}function sn(a,n,s){let d=t;return!!a?.[d(1982)](f=>f.key===n&&f[d(1053)]===s)}function sr(a,n){let s=t;return a?.[s(1982)](d=>d.key===n)?.[s(1053)]}let ma=null;async function Tp(){let a=t;return ma||(ma=Promise[a(1818)]().then(zt[a(1640)](zt,e[a(1720)]))),ma}class Rp extends pa{constructor(n,s){let d=t;super(),this[d(1912)]=n,this._keyPath=s,this[d(1239)]=void 0,this[d(1008)+d(766)]=null}async openDB(){let n=t;if(e[n(1803)](e.VLoNr,e[n(1752)]))try{this[n(1279)]&&this[n(1279)][n(1638)](_0x1e9469,_0x42fcfb)}catch{}else await this[n(1299)]()}async[t(1299)](){let n=t;if(!this._qosDB){if(this["_initPro"+n(766)])return this[n(1008)+n(766)];try{let s=this[n(1912)],d=this[n(1107)];this[n(1008)+"mise"]=(async()=>{let f=n,{openDB:p}=await e[f(1548)](Tp);this[f(1239)]=await e[f(1398)](p,f(1240)+"_"+s,1,{upgrade(w){w["createOb"+f(2076)+"e"](s,{keyPath:d})}})})(),await this[n(1008)+"mise"]}catch(s){console[n(1889)](s)}finally{this[n(1008)+"mise"]=null}}}async get(n){let s=t;try{return await this[s(1299)](),this[s(1239)]?.[s(867)](this._dbName,n)}catch(d){console[s(1889)](d)}}async[t(1830)](n,s){let d=t;return await this._init(),this[d(1239)]?.put(this._dbName,n)}async del(n){let s=t,d={kMFXX:function(f,p,w){return f(p,w)},wgZQA:function(f,p){return e[G(777)](f,p)}};try{if(e[s(566)](e.xPTSD,s(1184)))mZSLDw.kMFXX(_0x27523b,_0x542faa,32),_0x4e6dc1(_0x3859d3,mZSLDw[s(1015)](_0x23bd38,_0xce0f56));else return await this[s(1299)](),this[s(1239)]?.delete(this[s(1912)],n)}catch(f){console[s(1889)](f)}}async[t(2026)](){let n=t;try{return await this[n(1299)](),this[n(1239)]?.[n(2026)](this._dbName)}catch(s){if(e.eQfrM!==e[n(1010)])console[n(1889)](s);else{let d=_0x341102(e[n(933)],{message:e[n(1980)]});this[n(1333)+"econnect"]&&this.onStartReconnect(d)}}}async keys(){let n=t;return await this[n(1299)](),this[n(1239)]?.[n(2020)+"ys"](this._dbName)}async getAll(){let n=t;return e[n(1659)]===n(597)?(await this[n(1299)](),this[n(1239)]?.[n(1014)](this._dbName)):this[n(1279)]?this[n(1279)][n(1040)+"te"]:this[n(531)][n(1839)+n(584)]?this.CONNECTING:this[n(832)]}async[t(547)](){let n=t;try{this[n(1239)]?.[n(1638)](),this._qosDB=void 0}catch(s){console[n(1889)](s)}}get isReady(){let n=t;try{return!!this[n(1239)]}catch(s){return console[n(1889)](s),!1}}}class Dp{constructor(n,s){let d=t;this[d(1625)]=n,this[d(875)]=s,this._qosDB=localStorage}async[t(989)](){}get[t(667)](){let n=t;return n(1240)+"_"+this[n(1625)]}async[t(867)](n){let s=t;if(s(2108)!==e[s(1921)]){let d=_0x31ba61.split(":");_0x326db2&&(_0x5c5276=d.length),_0x1b0cb8+=d[s(1360)];for(let f=0;e[s(725)](f,d[s(1360)]);f++)if(e.HujXf(4,d[f][s(1360)])){let p=_0x2c4873[s(1646)+"g"](0,e.uXTLu(4,d[f][s(1360)])),w=p[s(943)](d[f]);_0x4c55b9[s(911)](w)}else _0x22f9dc[s(911)](d[f]);_0x5599c2=!1}else{let d=this[s(1239)][s(1580)](this[s(667)]);return JSON[s(2119)](d||"{}")[n]}}async[t(1830)](n,s){let d=t;if(e[d(2052)](e[d(2083)],e[d(2083)])){let f=this._qosDB[d(1580)](this._prefix),p=JSON.parse(e[d(1506)](f,"{}"));return p[s||n[this[d(875)]]]=n,this._qosDB.setItem(this[d(667)],JSON[d(1004)+"y"](p)),s||n[this[d(875)]]}else _0x244317+=e[d(1698)](_0x4e888a,_0x5b3ea5),_0x320fe4+=2}async[t(1954)](n){let s=t,d=this._qosDB.getItem(this[s(667)]),f=JSON[s(2119)](e[s(1506)](d,"{}"));return f[n]=void 0,this._qosDB[s(1624)](this[s(667)],JSON[s(1004)+"y"](f))}async[t(2026)](){let n=t;return this[n(1239)][n(2026)]()}async[t(879)](){let n=t,s=this[n(1239)].getItem(this[n(667)]),d=JSON[n(2119)](e[n(1506)](s,"{}"));return Object[n(879)](d)}async[t(1014)](){let n=t;if(e[n(1608)](n(574),e[n(999)])){let s=this[n(1239)][n(1580)](this._prefix),d=JSON[n(2119)](e.NIOnf(s,"{}"));return Object[n(1112)](d)}else this._intervalTimeoutId=null,this._interval=36e5,this._qosDB=_0x516b6d(e[n(1498)],e.YdBwd)}[t(547)](){return Promise.resolve()}get[t(1224)](){return!!this[t(1239)]}}class kp{constructor(n,s){let d=t;this[d(1625)]=n,this[d(875)]=s,this[d(1239)]=Pn?tt:Qr?wx:null}async[t(989)](){}get[t(667)](){let n=t;return n(1240)+"_"+this[n(1625)]}async[t(867)](n){let s=t,d=this[s(1239)][s(2044)+s(1749)](this[s(667)]);return JSON[s(2119)](e[s(1024)](d,"{}"))[n]}async[t(1830)](n,s){let d=t,f=this._qosDB[d(2044)+"geSync"](this[d(667)]),p=JSON.parse(e[d(716)](f,"{}"));return p[s||n[this[d(875)]]]=n,this[d(1239)][d(1655)+d(1749)](this[d(667)],JSON[d(1004)+"y"](p)),s||n[this[d(875)]]}async del(n){let s=t;if(e.DhXsg("JazRj",e[s(1098)])){let d=this._qosDB[s(2044)+s(1749)](this[s(667)]),f=JSON[s(2119)](d||"{}");return f[n]=void 0,this._qosDB[s(1655)+s(1749)](this[s(667)],JSON[s(1004)+"y"](f))}else _0x165815[s(1830)](_0x536317,_0x194aab),_0x5ca58d[s(1830)](_0x5c8e49,_0x12c6f0)}async[t(2026)](){return this._qosDB.clearStorageSync()}async[t(879)](){let n=t,s={liSDY:function(d,f){return e[G(1664)](d,f)},sgBUv:function(d,f){return e.mFnve(d,f)},hYeCT:function(d,f){return e[G(1500)](d,f)}};if(e.xLGLZ!=="aOpOX"){let d=this[n(1239)][n(2044)+n(1957)+"nc"](this._prefix),f=JSON[n(2119)](e[n(481)](d,"{}"));return Object[n(879)](f)}else{if(owckPm[n(1469)](void 0,_0x14fc51))this._listeners={};else if(owckPm.liSDY(void 0,_0x323e0d))this[n(1124)+"rs"][_0x32a1ca]=null;else{let d=this[n(1124)+"rs"][_0x480afa];if(d)for(let f=0;owckPm.sgBUv(f,d[n(1360)]);)owckPm.hYeCT(d[f].fn,_0x63eea7)?d.splice(f,1):++f}return this}}async[t(1014)](){let n=t,s=this[n(1239)]["getStora"+n(1957)+"nc"](this[n(667)]),d=JSON.parse(s||"{}");return Object[n(1112)](d)}[t(547)](){return Promise.resolve()}get isReady(){return!!this[t(1239)]}}function dl(a,n){let s=t;if(Pn||Pn)return new kp(a,n);if((ir||ei)&&typeof indexedDB<"u")return new Rp(a,n);if(e[s(1413)](ir,ei)&&e.JcxVl(e[s(505)],typeof localStorage))return new Dp(a,n);throw new Error(e[s(1877)])}class Pp{constructor(){let n=t,s={TpCcA:function(d,f){return e[G(2003)](d,f)},zLOgi:function(d,f){return e[G(1262)](d,f)},zpvMA:function(d,f){return e[G(1032)](d,f)},DIjBv:function(d,f){return d&f},VvnsD:function(d,f){return e[G(654)](d,f)}};if(e[n(1097)](e[n(1871)],n(1633)))return _0x3c4a0c[n(2120)+n(2004)](qGErfW[n(1626)](255,this[n(1447)]),this.low>>>8&255,qGErfW[n(1789)](this[n(1447)],16)&255,qGErfW[n(1887)](this[n(1447)],24),255&this[n(1245)],qGErfW.DIjBv(qGErfW[n(1789)](this[n(1245)],8),255),qGErfW[n(958)](qGErfW[n(1789)](this[n(1245)],16),255),qGErfW[n(1030)](this.high,24));this[n(854)+n(1002)+"Id"]=null,this[n(854)+"l"]=36e5,this[n(1239)]=e[n(1773)](dl,n(548),e.YdBwd)}async _intervalFlush(){let n=t;e[n(534)](e[n(1321)],e[n(1321)])?(e[n(673)](clearInterval,this[n(854)+n(1002)+"Id"]),this[n(854)+n(1002)+"Id"]=setInterval(()=>{let s=n;this[s(1016)+s(1967)]()},this._interval)):(this._ws&&this[n(1279)][n(475)](_0x34277f),this._debug(e[n(1216)],_0x5ceefe))}async[t(989)](){let n=t;await this[n(1239)][n(989)]()[n(583)](()=>{let s=n;this[s(854)+s(697)]()})}async[t(1016)+t(1967)](){let n=t,s={waXCj:function(d,f){return d>=f},RNGIl:function(d,f){return e.YZzmn(d,f)},bHSie:function(d,f){return e[G(1045)](d,f)},EdzSW:function(d,f){return d-f},DBMBK:function(d,f){return e.VWScv(d,f)},RuCtE:function(d,f){return e.FXrsn(d,f)},lkRzv:function(d,f){return e[G(1693)](d,f)},oetdE:function(d,f){return d|f},VvxwT:function(d,f){return d&f},WMOui:function(d,f){return e[G(1965)](d,f)},oLNtD:function(d,f){return e[G(1702)](d,f)},FjAqP:function(d,f){return d>>f}};if(e[n(1381)](e[n(1805)],e.XYeqo))(await this[n(1239)]?.[n(1014)]()||[]).filter(({timestamp:p})=>p<Date[n(1696)]())[n(1047)](p=>{let w=n;this[w(1239)]?.[w(1954)](p[w(807)+"id"])});else{let d=_0x1022b9[n(1250)+"At"](_0x4ece4f);NuJLKx[n(1986)](d,55296)&&NuJLKx[n(2114)](d,56319)&&NuJLKx[n(1529)](_0x8dca9e,1)<_0x575749&&(d=NuJLKx[n(1614)](NuJLKx[n(1246)](d,10)+_0xe3a178[n(1250)+"At"](++_0x34fe99),56613888)),NuJLKx[n(1978)](d,128)?_0xd10e20[_0x2768a2++]=d:(NuJLKx[n(1978)](d,2048)?_0x3bfcf2[_0x160a36++]=NuJLKx[n(924)](d,6)&31|192:(NuJLKx[n(1978)](d,65536)?_0x12fb71[_0x3aa164++]=NuJLKx.oetdE(NuJLKx[n(1347)](d>>12,15),224):(_0x28bd04[_0x169aa4++]=NuJLKx[n(1149)](NuJLKx[n(1347)](NuJLKx[n(924)](d,18),7),240),_0x2e7259[_0x5a274c++]=NuJLKx[n(1159)](NuJLKx[n(1347)](NuJLKx[n(1180)](d,12),63),128)),_0x51f4cd[_0x330fa4++]=NuJLKx[n(1149)](d>>6&63,128)),_0xeba72b[_0x1a7754++]=NuJLKx[n(1159)](NuJLKx[n(1347)](63,d),128))}}async del(n){let s=t;return this._qosDB?.[s(1954)](n)}async set(n,s){let d=t;return this[d(1239)]?.[d(1830)]({message_id:n,timestamp:s})}async[t(867)](n){return this._qosDB?.get(n)}async closeDB(){let n=t;e[n(1068)](clearInterval,this["_interva"+n(1002)+"Id"]),await this[n(1239)]?.[n(547)]()}get[t(1224)](){let n=t;return this[n(1239)]?.[n(1224)]}}function wa(a){let n=t,s={mMYwz:function(d){return e[G(1918)](d)}};if(e[n(2055)](e[n(1909)],e[n(1263)]))_0x521f98(),eGXyhZ.mMYwz(_0xfd88c2);else{let d=!!this[n(531)].enableQoS;if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let f=e[n(822)](sn,a[n(1891)][n(913)],n(642)+"er_qos","2"),p=f&&e[n(822)](sn,a[n(1891)][n(913)],n(642)+n(681)+"ck","1"),w=f&&e[n(1398)](sn,a.message.headers,e[n(669)],"1"),b=w?e[n(894)](sr,a[n(1891)][n(913)],e[n(1297)])?.[n(852)](",")[n(763)](Boolean)||[]:[];return{enabled:d,isQoSMessage:f,isQoSAck:p,isAckCleanupMessage:w,ackMsgIds:b}}}async function ll(){let a=t;return this["_QoSMana"+a(1288)]||(this[a(1487)+a(1288)]=new Pp),this[a(1487)+"ger"].isReady||await this["_QoSMana"+a(1288)][a(989)](),this[a(1487)+a(1288)]}async function Op(a,n){let s=t,{enableAutoAck:d}=this[s(531)],f=e[s(1398)](sn,a[s(1891)][s(913)],e.VCxKj,"1"),p=sn(a[s(1891)].headers,"is_ack","1"),w=wa[s(1922)](this,a);if(e[s(2121)](d,f)){let{SeqID:b,LogID:g,service:C,LogIDNew:R,method:P}=a.message;this[s(1187)]({SeqID:b,LogID:g,LogIDNew:R,service:C,method:P,headers:[{key:e[s(802)],value:"1"},{key:e.qbKZR,value:e.vsGWk(R,"")},{key:e.gMTUl,value:"0"}]})}p&&!w[s(2069)]&&this["_dispatc"+s(1063)+"ageEvent"](a),n()}async function Lp(a,n){let s=t;this[s(973)](s(1126),a[s(1891)]),n()}async function Np(a,n){let s=t,d=e[s(882)](tn,await e.FRZEx(cl,a.data));try{if(e[s(1385)](d[s(1731)],Uint8Array))if(s(1162)===e[s(749)]){let f=e[s(704)](this._options[s(1241)+s(532)],Object)?{force:!!this[s(531)][s(1241)+"ncoding"][s(2012)],encoding:this[s(531)][s(1241)+s(532)].encoding?this[s(531)][s(1241)+s(532)][s(639)][s(511)](/\s/g,"")[s(595)+"ase"]():""}:{force:!1,encoding:this._options[s(1241)+s(532)]?this[s(531)][s(1241)+"ncoding"][s(511)](/\s/g,"")["toLowerC"+s(1796)]():""},p=d[s(1241)+s(532)]?d[s(1241)+s(532)][s(511)](/\s/g,"")[s(595)+"ase"]():"",w=e.EmjiK(this[s(531)][s(1788)+"ype"],Object)?{force:!!this[s(531)][s(1788)+s(1256)].force,type:this[s(531)][s(1788)+"ype"][s(2025)]?this._options["payloadT"+s(1256)][s(2025)].replace(/\s/g,"")["toLowerC"+s(1796)]():""}:{force:!1,type:this[s(531)][s(1788)+"ype"]?this[s(531)][s(1788)+s(1256)][s(511)](/\s/g,"")[s(595)+s(1796)]():""},b=d[s(1788)+s(1256)]?d[s(1788)+s(1256)][s(511)](/\s/g,"")[s(595)+s(1796)]():"",g=w.force?w[s(2025)]:b||w[s(2025)],C=f.force?f[s(639)]:p||f.encoding,R=[e.DjdWd,s(944)+s(1662),e[s(1108)],e[s(1009)]],P=[s(1949)+"e",s(842)];this[s(531)][s(1154)+s(1139)+s(1083)+"ad"]&&R[s(1780)](g)&&(!C||P[s(1780)](C))?d[s(1707)+s(1927)]=e[s(709)](al,d[s(1731)],0,d[s(1731)][s(2028)+"th"]):d[s(1707)+"oad"]=""}else{let f=this[s(1245)],p=this.low;return[f>>>24,e[s(614)](f,16)&255,e[s(540)](e[s(1262)](f,8),255),e[s(1493)](255,f),e[s(573)](p,24),e.XQqgw(p>>>16,255),e[s(1824)](e[s(626)](p,8),255),255&p]}else d[s(1707)+s(1927)]=""}catch(f){if(e[s(1816)](s(1598),e[s(1177)])){let p=_0x29e61c[s(1922)](xAOwxb[s(1937)](_0xce7b62,this),_0x55b714,..._0x455b68);return _0x2403d6[s(1830)](p,_0x2f39f1[s(539)]?_0x41f2f4.sort():[_0x114648]),xAOwxb[s(996)](_0x5ac675,p)}else d[s(1707)+"oad"]="",console[s(1889)](f)}a[s(1891)]=d,e[s(1548)](n)}function Mp(a,n,s){let d=t,f={aTDZj:function(C,R){return C<R},pCUKV:function(C,R){return e.wWVTt(C,R)},RDvye:function(C,R){return e[G(1463)](C,R)},quMtn:e[d(815)],dUsTQ:function(C,R){return e[d(1182)](C,R)},WgKog:function(C,R){return C&R},WvBXv:function(C,R){return e[d(1458)](C,R)},ahtuN:function(C,R){return e[d(599)](C,R)}},p=e[d(1815)](s,8192),w=p>>>1,b=null,g=p;return function(C){let R=d;if(f[R(860)](C,1)||C>w)return a(C);if(f.pCUKV(g+C,p)){if(f[R(1666)](f[R(1981)],f[R(1981)]))throw this[R(711)+R(2051)]=!1,_0x2a64e2;b=f[R(1081)](a,p),g=0}let P=n[R(1922)](b,g,g+=C);return f[R(1527)](7,g)&&(g=f[R(518)](f[R(1392)](7,g),1)),P}}let Bp=4294967295;function zp(a,n,s){let d=t;return e[d(940)](RangeError,e[d(857)](e[d(1701)](e[d(1417)](e[d(1050)](e[d(1725)],a)+e[d(1006)],e[d(1815)](n,1)),e[d(643)]),s))}function Fp(a,n,s){let d=t,f={pwJgG:function(w,b,g){return e.zIceD(w,b,g)}};if(s>Bp)throw new Error(e[d(1589)]);let p=3;for(;p>=0;)if(e.QLyyM(e[d(632)],e.VoQuL)){let w=255&s;e.eHIZr(ya,w,a,e[d(968)](n,p)),s>>>=8,p--}else Kbtkka.pwJgG(_0x28779a,_0xe65372,66),_0xc57c00(_0x36ce31,_0x391169.length),Kbtkka[d(1592)](_0x5753ce,_0x17e2d2,_0x242f61);return e[d(1758)](n,4)}function Up(a,n){let s=t,d=0,f=n,p=n+4;for(;e[s(1212)](f,p);){let{value:w,offset:b}=_a(a,f);f=b,d=e[s(1812)](e[s(1503)](d,8),0),d+=w}return{value:d,offset:p}}function qp(a,n,s){let d=t;if(e[d(1741)](e.oggzC,d(513)))_0x49e864[_0x302752++]=e[d(916)](e[d(1827)](e.RBBMo(_0x30f8c4,18),7),240),_0x1514bd[_0x377180++]=e[d(1756)](e[d(1764)](e.xJKqr(_0x52cbad,12),63),128);else return a?e.klunZ(a[d(1360)],40)?e[d(1758)](e[d(1398)](ga,a,n,s),s):n[d(1012)+"e"]?e.Cilhu(n.utf8Write(a,s),s):n[d(1348)]?e[d(1619)](n.write(a,s),s):e[d(1367)](e[d(822)](ga,a,n,s),s):s}function Gp(a,n){let s=t,d={XWaTF:e[s(2043)],ujIiw:e.FkWTI,ZmFmU:function(f,p,w){return e[s(640)](f,p,w)}};if(e[s(616)](s(1555),e.cgaUp))this[s(988)+s(1746)](),this[s(1426)](d[s(1652)],d[s(1703)]),this["_pingPon"+s(1577)+"Id"]=d[s(605)](_0x4c83b6,this._ping[s(1640)](this),_0x48cee9);else{let f=new xe(e.EcqPm(e.ZoxjT(e.RQTvb(e[s(1671)](a[e[s(1286)](n,4)],24),e[s(1035)](a[e[s(1602)](n,5)],16)),e[s(1035)](a[e.TAyay(n,6)],8)),a[e[s(655)](n,7)]),e.SoRVv(e[s(1840)](e[s(1793)](a[e.pVuRV(n,0)],24),e[s(1282)](a[e[s(1458)](n,1)],16)),e[s(1825)](a[e.QgyFG(n,2)],8))|a[e[s(1335)](n,3)],!0);return n+=8,{value:f,offset:e[s(683)](n,8)}}}function Hp(a,n,s){let d=t,f=a[d(1447)],p=a[d(1245)];return n[s]=e[d(1328)](p,24),n[e.TAyay(s,1)]=e[d(1530)](p>>>16,255),n[e.olQFs(s,2)]=e[d(1910)](p>>>8,255),n[s+3]=e[d(603)](255,p),n[e[d(602)](s,4)]=e.EAMGN(f,24),n[e[d(1763)](s,5)]=e[d(869)](e[d(1787)](f,16),255),n[s+6]=f>>>8&255,n[s+7]=255&f,s+=8,s}function _a(a,n){let s=t;return a.readUInt8?{value:a[s(846)+"8"](n),offset:e[s(567)](n,1)}:{value:e.ZXPMN(255,a[n]),offset:e.dRwQn(n,1)}}function ya(a,n,s){let d=t;return n[d(1969)+"t8"]?n[d(1969)+"t8"](a,s):n[s]=255&a,e[d(1792)](s,1)}let jp=function(a){return new Uint8Array(a)},Wp=e[t(1814)](e[t(505)],typeof Buffer)?Buffer[t(803)+t(1535)]:Mp(jp,Uint8Array[t(1958)+"e"][t(2111)]),Kp=16,ba=32;function $p(a){let n=t,s=0,d={};for(let f=0;e.aKOPN(f,a[n(1360)]);f++)d[a[f].cursor_name]=e[n(500)](ol,a[f]["cursor_n"+n(1583)]),s+=e[n(1432)](14,d[a[f][n(723)+"ame"]]);return[s,d]}function ul(a,n,s){let d=t,[f,p]=$p(a),w=Wp(f),b=0;return a[d(1047)](g=>{let C=d;console[C(1889)](e[C(1460)],g,g[C(2022)]),b=ya(0,w,b),console.log(e[C(1875)],b),b=Fp(w,b,g[C(2022)]||0),console[C(1889)](C(2022),b),b=e.Mhysk(ya,p[g[C(723)+C(1583)]],w,b),console[C(1889)](e[C(1771)],b),b=qp(g["cursor_n"+C(1583)],w,b),console[C(1889)](e[C(703)],b),b=e[C(948)](Hp,xe[C(1748)+"er"](g[C(1791)]||n),w,b),console[C(1889)](e.hkyBO,b)}),{frameType:ba,headers:[{key:e[d(1524)],value:s}],payload:w}}function Vp(a){let n=t,s=0,d=[];for(;e.aKOPN(s,a[n(2028)+"th"]);){let{offset:f}=_a(a,s);s=f;let p={cursor_name:"",cursor:0,service:0},{value:w,offset:b}=Up(a,s);p[n(2022)]=w,s=b;let{value:g,offset:C}=e[n(2002)](_a,a,s);s=C,p[n(723)+n(1583)]=e[n(1461)](al,a,s,s+g),s+=g;let{value:R,offset:P}=e[n(1145)](Gp,a,s);p[n(1791)]=R[n(1456)](),s=P,d[n(911)](p)}return d}function Zp(){let a=t,n={joKaz:function(s,d){return s||d},onUMr:function(s,d){return e[G(1101)](s,d)},KdwHw:e[a(505)]};return e[a(1595)](e[a(1658)],e[a(1658)])?!!(_0x29aeb9||_0x1e2d1c&&_0x4b5dcf[a(1227)+a(1049)]||_0x1b2364&&_0x85e73d[a(1227)+a(1049)]||eZtkSc[a(1564)](_0x44e0a9,_0x3d6804)&&eZtkSc[a(1724)](eZtkSc[a(705)],typeof _0x367da6)&&_0x4b4443):{frameType:ba,headers:[{key:a(1572)+a(1801),value:e[a(909)]}],payload:void 0}}class Jp{constructor(n,s,d){let f=t;this._cursorNameSpace=n,this["_cursorF"+f(576)]=s,this[f(1165)+"Strategy"]=d,this[f(1239)]=dl(this["_cursorN"+f(2064)],e[f(1324)])}async[t(989)](){let n=t;await this[n(1239)][n(989)]()}async[t(2077)+"rs"](){let n=t;if(!this[n(1239)].isReady)return;let s=this[n(1165)+"Strategy"],d=await this[n(1239)].getAll();switch(console[n(1889)](e.DYwFI,d),s){case e[n(590)]:return d&&d[n(1360)]?e.FePSN(ul,d,0,this[n(1330)+n(576)]):void 0;case e[n(1067)]:return;case e[n(782)]:return d&&d.length?e.OCmXg(ul,d,0,this["_cursorF"+n(576)]):e[n(1677)](Zp)}}async[t(1830)](n,s,d){let f=t;return console[f(1889)]("setdb",n,s,d),this[f(1239)][f(1830)]({cursor_name:n,cursor:s,service:d})}async[t(835)+"rs"](n){let s=t,d={hpLcc:function(f,p,w){return e[G(2087)](f,p,w)},NzJkX:function(f,p){return f|p},zutxA:function(f,p){return e[G(1764)](f,p)},TeFgf:e[s(1386)],pgOjC:function(f,p){return e[s(514)](f,p)},KtZcN:function(f,p){return e[s(1402)](f,p)}};if(e[s(1823)]!==e[s(1823)])IsoVnm[s(1420)](_0x43ad0c,_0x299728,IsoVnm[s(785)](IsoVnm[s(1472)](127,_0x3fdfda),128)),_0x23588d>>>=7;else{let f=Vp(n);for(let p of f)if(e.UvsiV(e[s(1709)],e[s(1140)]))console[s(1889)](e[s(757)],f),await this._qosDB[s(1830)](p);else return typeof _0x44d690===IsoVnm[s(1675)]?_0x11af9d(_0x465bd8):(IsoVnm.pgOjC(_0x450527,_0x1661c6)&&IsoVnm[s(2030)](_0x3d37f8,_0x3c356d),_0x4e0954(_0x2ef490,_0x1bfb53())?new _0x7ee16(_0x34de4e,_0x9c71ef):_0x572713)}}async[t(867)](n){let s=t;return(await this[s(1239)].get(n))?.[s(1791)]}async closeDB(){let n=t;await this[n(1239)][n(547)]()}[t(668)+t(1641)+t(1411)](n){let s=t;this[s(1330)+s(576)]=n}get[t(1224)](){let n=t,s={yfdBM:function(d,f){return d(f)}};if(e[n(1960)](e[n(1697)],e[n(1697)]))return this[n(1239)][n(1224)];_0x2b942a["frontier"+n(1769)]=void 0,xwWsby[n(1327)](_0x1596cf,n(1776)+n(621))}}let Xp=e.khDre;async function fl(a){let n=t;if(!this._options[n(1100)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(531)],p=e[n(1025)](a,Xp);try{return this[n(2063)+n(849)]?a&&this[n(2063)+n(849)][n(668)+n(1641)+n(1411)](a):this["_cursorM"+n(849)]=new Jp(d+"_"+s+"_"+p,p,f),this[n(2063)+n(849)][n(1224)]||await this["_cursorM"+n(849)][n(989)](),this[n(2063)+n(849)]}catch{return null}}async function Yp(a,n){let s=t,d=e[s(948)](sn,a[s(1891)][s(913)],e[s(1847)],"-1"),f=e[s(1461)](sn,a.message[s(913)],e[s(802)],"1"),p=e[s(1383)](sr,a[s(1891)][s(913)],e.UQtEO),w=Number(sr(a[s(1891)][s(913)],s(642)+s(536)))||0,b=wa[s(1922)](this,a),g=e[s(822)](sn,a[s(1891)][s(913)],e.LsaeG,"2"),C=sr(a.message[s(913)],e.oRQGw),R=Number(e[s(753)](sr,a[s(1891)][s(913)],s(1989)+s(521)+"ue"));if(b[s(2069)])return e[s(2011)](n);let P=b[s(1425)+s(1332)]?await ll.call(this):null;if(e[s(647)](a[s(1891)][s(2022)],0)&&f&&!d||e[s(633)](a[s(1891)].service,0)){if(e[s(1215)]("YouMt",e.asyKz))return 0;if(p&&b[s(1425)+"sage"]&&P)return!!!await P[s(867)](p)&&(this["_dispatc"+s(471)+s(1712)](a),await P.set(p,e[s(1377)](Date[s(1696)](),w))),e[s(1677)](n);if(g){if(e[s(891)]===s(1942))throw _0x31e631=_0x36f5da[s(1360)],_0xa5f685(_0x34b7b1,10,_0x4158c0[s(1360)]);{let F=await fl[s(1922)](this);if(!F)return this[s(552)+"hMessage"+s(1712)](a),e[s(1915)](n);let B=await F[s(867)](C)??-1;if(e[s(1163)](B,R))this[s(552)+s(471)+s(1712)](a),F[s(1830)](C,R,a[s(1891)].service);else throw new Error(s(2032)+s(745)+" cursor "+R+(s(915)+s(1941)+"al cursor ")+B);return e.LEwqX(n)}}return this["_dispatc"+s(471)+s(1712)](a),e[s(1800)](n)}}async function Qp(a,n){let s=t,d={oNwdb:function(f,p,w){return e.vIJGi(f,p,w)}};if(e[s(1639)]===e[s(1639)]){let f=wa[s(1922)](this,a);if(!f[s(1425)+s(1332)])return e[s(1251)](n);let p=await ll[s(1922)](this);if(f[s(1129)+s(859)+s(1819)]&&f[s(1188)+"s"].length)for(let w of f[s(1188)+"s"])await p[s(1954)](w);e[s(1677)](n)}else _0x3d63b1(_0x37b35a,58),jAUVyU[s(917)](_0x2ba856,_0x4fa828,_0x354da2)}async function eg(a,n){let s=t,d=e[s(1688)](a[s(1891)][s(1740)+"e"],Kp),f=e.GKYcB(a.message.frameType,ba);if(e[s(786)](!d,!f))return n();let p=e[s(1141)](sr,a[s(1891)][s(913)],s(1572)+s(1801));if(!p)return n();let w=await fl.call(this,p);if(!w)return e[s(1915)](n);if(d){let b=await w[s(2077)+"rs"](),g={frameType:b?.[s(1740)+"e"],SeqID:xe.fromNumber(this[s(1055)]++),LogID:xe[s(1748)+"er"](this[s(531)][s(1676)+"erator"]()),service:9e3,method:5,headers:b?.[s(913)],payload:b?.[s(1731)]},C=e[s(2075)](S,g);this[s(1279)]&&this[s(1279)].readyState&&this[s(1279)][s(475)](C)}if(f){let b=a.message[s(1731)];b&&w[s(835)+"rs"](b)}}let tg=async function(a,n){let s=t;if(e.emsTo===e[s(1082)])this[s(833)]=!1,e[s(1190)](clearTimeout,this[s(711)+s(1181)+s(594)]),n();else{if(this[s(1279)]&&this[s(1279)].readyState===this[s(1571)+"NG"]){this[s(988)+s(1746)](),this["_pingPon"+s(1577)+"Id"]=e.PxjKz(_0x47b841,this[s(926)].bind(this),this[s(531)].pingInterval);return}if(!this[s(1279)]||e[s(486)](this[s(1279)][s(1040)+"te"],this[s(1926)]))return void this[s(1864)+s(1732)]();this[s(1279)]&&this[s(1279)].send("hi"),this[s(2061)+s(636)+s(851)]=e[s(530)](_0x34556d,this[s(1864)+s(1732)+s(1692)].bind(this),this[s(531)]["pingTime"+s(1007)+s(1713)])}},ng=async function(a,n){let s=t;if(!this[s(1279)]||e.FaXqh(this[s(1279)][s(1040)+"te"],this[s(1926)]))return e[s(2011)](n);let{pingInterval:d}=this[s(531)];this[s(1419)+"tManager"]?.[s(919)+s(880)+s(1399)]();for(let p=0;e[s(717)](p,this[s(1165)+s(1155)][s(1360)]);p++){let w=this[s(1165)+s(1155)][p];if(this[s(1279)].readyState===this.OPEN&&w!==null)this[s(1279)]&&this[s(1279)][s(475)](w),this[s(1165)+s(1155)][p]=null;else break}this[s(1165)+s(1155)]=this[s(1165)+s(1155)][s(763)](p=>!!p),this._pingPongTimeoutId=e[s(1979)](setTimeout,()=>this[s(926)](),d),this[s(552)+"hOpenEvent"](a),this[s(1894)+"er"]&&this[s(1279)]&&(this[s(1279)][s(660)+"pe"]=this["_binaryT"+s(1256)]);let f=this[s(1419)+s(1150)]?.[s(1882)+s(1468)+"nt"]();this[s(973)]("open "+f+s(1260)),e[s(868)](n)},rg=async function(a,n){let s=t,d={aebnO:function(f,p){return e[G(1458)](f,p)},uDjhh:function(f,p){return f+p},CTpmN:function(f,p){return f!==p},SYOfS:function(f,p){return f&p},xXxgQ:function(f,p){return e[G(1130)](f,p)},JLUrt:function(f,p){return f<<p},iVZCp:function(f,p){return f<<p},rkRbX:function(f,p){return f|p},ERhUl:function(f,p){return e[G(1326)](f,p)},MKAyq:function(f,p){return e.fPcHe(f,p)},hyKnq:function(f,p){return e[G(1557)](f,p)},TsfHh:function(f,p){return f<p},oDZFA:function(f,p){return e[G(1295)](f,p)},UBokj:function(f,p){return e[G(1939)](f,p)}};if(e[s(684)](e[s(480)],e.BdOUD)){let f=this[s(1419)+s(1150)]?.["getCurre"+s(1468)+"nt"]();this._debug("open "+f),e[s(1721)](n)}else _0x31157b=_0x31dd5b[MRDZSc[s(1492)](_0x2dabf3,_0x1e4dab)+1],_0x5f0ac1=_0x366e38[MRDZSc[s(474)](MRDZSc[s(1492)](_0x34434a,_0x53dc13),2)],_0x162fc6=_0x5910fd[MRDZSc[s(474)](_0x58bd82+_0x2f234c,3)],MRDZSc[s(631)](MRDZSc[s(1810)](MRDZSc[s(2041)](_0x2383b6|MRDZSc[s(1778)](_0xe384e4,8),MRDZSc[s(907)](_0x15f9cb,16)),12632256),8421504)?_0x16b922+=_0x2269b1:(_0x525e86=MRDZSc[s(836)](MRDZSc[s(773)](MRDZSc[s(966)](MRDZSc[s(907)](MRDZSc[s(1345)](7,_0x15163c),18),MRDZSc.JLUrt(63&_0x223c0d,12)),MRDZSc[s(1778)](MRDZSc.hyKnq(63,_0x1eb497),6)),MRDZSc[s(1810)](63,_0xe5d236)),MRDZSc[s(1214)](_0x43c3f8,65536)||_0x22840e>1114111?_0x3d22e4+=_0x3ca576:(_0x493f61-=65536,_0x49bd75+=_0x5efef5(MRDZSc[s(1699)](_0x79a16b>>10,55296),MRDZSc[s(856)](MRDZSc.SYOfS(1023,_0x508fab),56320)),_0x5b8e84+=3))};class ig extends pa{constructor(n){let s=t,d={WiNzF:function(b,g){return e[G(572)](b,g)},jYRnT:function(b,g,C,R){return e.QCOwB(b,g,C,R)},ZxBWI:"nNFIH",TUURD:function(b,g,C){return e.RKJsa(b,g,C)},OyzbV:e[s(729)],pQHHW:function(b,g){return b(g)},sNQxs:function(b,g){return e[s(1302)](b,g)},idpBX:function(b,g){return b+g},bBCxv:function(b,g){return e[s(2062)](b,g)},zgWnR:e[s(1813)],ZvzUg:e.mBXcL,BOgws:function(b,g,C){return b(g,C)},FZEhZ:e[s(1501)],sAOfh:e[s(523)],hTXER:function(b,g){return e[s(951)](b,g)},SwdEv:function(b,g,C){return e.sDYdu(b,g,C)},fXggw:function(b,g,C){return e[s(1322)](b,g,C)}};super(),this[s(1919)+s(692)+s(701)]=!0,this[s(1894)+"er"]=ir,this[s(741)]=yp,this._isMiniTT=Pn,this[s(877)+"X"]=Qr,this[s(2007)+"r"]=ei,this[s(1165)+s(1155)]=[],this[s(1419)+"tManager"]=null,this[s(731)+"osed"]=!1,this["_binaryT"+s(1256)]=s(1201)+s(1977),this[s(711)+s(2051)]=!1,this[s(711)+"ionTimeo"+s(594)]=null,this[s(2061)+s(636)+s(851)]=null,this[s(656)+s(1577)+"Id"]=null,this[s(1055)]=0,this[s(833)]=!1,this[s(997)]="",this["_QoSMana"+s(1288)]=null,this[s(2063)+s(849)]=null,this["_pingLos"+s(886)]=null,this[s(817)+"ls"]=e[s(1610)],this[s(832)]=3,this.CONNECTING=0,this[s(1926)]=1,this.CLOSING=2,this[s(1389)]=b=>{let g=s;try{d[g(1482)](sl,this,b,[tg,ng,rg])}catch(C){if(d.WiNzF(g(529),d[g(884)]))return _0xfc59c1&&mHJqAS[g(553)](!0,_0x2d2fd0[g(1137)]);{let R=d.TUURD(lt,d.OyzbV,{message:C[g(1891)],code:rn[g(1733)+"OR"],error:C});this[g(552)+g(609)+"ent"](R)}}},this[s(929)+"ge"]=async b=>{let g=s,C={wWxdV:e[g(651)],nEbQB:function(R,P,F,B){return R(P,F,B)},esfKe:function(R,P,F,B){return R(P,F,B)},SLZUI:function(R,P,F,B){return e[g(948)](R,P,F,B)},GxmOm:e[g(1460)],WbFEr:g(2022),HchvK:e[g(1822)],plAGN:e[g(703)],HEmmo:e[g(1771)]};if(e[g(783)](e[g(1881)],g(1380))){let[R,P]=mHJqAS[g(1440)](_0x4c4874,_0x1b4ae2),F=mHJqAS[g(1440)](_0x55da07,R),B=0;return _0x962050.forEach(te=>{let J=g,Pe=JWnRwW.wWxdV.split("|"),Oe=0;for(;;){switch(Pe[Oe++]){case"0":B=JWnRwW[J(1700)](_0x291a19,te[J(723)+"ame"],F,B);continue;case"1":B=JWnRwW[J(1854)](_0x1f3a8a,0,F,B);continue;case"2":B=JWnRwW[J(826)](_0x716dc9,F,B,te[J(2022)]||0);continue;case"3":_0x1d2b92[J(1889)](JWnRwW[J(1431)],te,te[J(2022)]);continue;case"4":B=JWnRwW[J(1854)](_0x310bac,_0x308795.fromNumber(te[J(1791)]||_0x399fea),F,B);continue;case"5":_0x4758aa[J(1889)](JWnRwW[J(1932)],B);continue;case"6":_0x83af95[J(1889)](JWnRwW[J(908)],B);continue;case"7":_0x3d31b5.log(JWnRwW.plAGN,B);continue;case"8":_0x55315b.log("header",B);continue;case"9":B=JWnRwW.nEbQB(_0x3ebe99,P[te[J(723)+J(1583)]],F,B);continue;case"10":_0x291088[J(1889)](JWnRwW[J(488)],B);continue}break}}),{frameType:_0x490118,headers:[{key:g(1572)+g(1801),value:_0x519b67}],payload:F}}else{let{pingInterval:R,pingFrequency:P}=this[g(531)];if((e.WzJGZ("hi",b[g(1579)])&&e[g(659)](e[g(1878)],P)||e.SeNUc(e[g(1436)],P))&&(this[g(988)+"ngTimer"](),this[g(1426)](e[g(2043)],e[g(2086)]),this[g(656)+"gTimeoutId"]=e.kyLpd(setTimeout,this._ping[g(1640)](this),R)),e[g(2033)]("hi",b[g(1579)]))return;try{e.nXPnm(sl,this,b,[Np,Op,Qp,eg,Yp,Lp])}catch(F){let B=lt(e.sDcYK,{message:F.message,code:rn["MESSAGE_"+g(1947)],error:F});this[g(552)+"hErrorEv"+g(1970)](B)}}},this[s(1427)]=b=>{let g=s,C=this[g(1419)+g(1150)]?.[g(1111)+"chMaxTries"](),R=this[g(1419)+g(1150)]?.[g(1882)+g(1468)+"nt"]();if(C&&!b.message)if(e[g(1325)](g(812),e[g(538)])){let P=_0x303b6a(_0xe4b6b9,_0x795aaa.limit),F=_0x31b833[g(1913)],B=_0x7d723b[g(1913)];for(let te=0,J=_0x3210af[g(837)];mHJqAS.sNQxs(te,J);te++)F[mHJqAS[g(1365)](te,P)]=B[te]}else{let P="connect "+R+(g(1730)+g(799)+"es reached");this[g(552)+"hErrorEv"+g(1970)](e[g(1474)](lt,e[g(729)],{message:P,code:rn[g(1276)+"IES_ERROR"],error:b}));return}this[g(1279)]&&e[g(864)](this._ws.readyState,this[g(1926)])&&this._disconnect(),this[g(552)+g(609)+g(1970)](e.mZKyT(lt,g(1508),{message:b[g(1891)],code:rn[g(1132)+g(1138)],error:b}))},this[s(957)]=async b=>{let g=s,C={nmomU:function(P,F){return d[G(954)](P,F)}};this["_clearTi"+g(1244)](),this["_clearPi"+g(1746)](),this[g(657)+g(984)+"rs"](),this[g(1279)]=null,this[g(711)+g(2051)]=!1;let R=this._endpointManager?.["checkRea"+g(1084)+"es"]();if(!R&&this[g(743)+"orOnline"]()&&!this["_readyCl"+g(549)]){if(d[g(828)]===d.ZvzUg)return BxGjME.nmomU(this.count,this.maxLossCount);{let P=this[g(1419)+g(1150)]?.[g(1882)+g(1468)+"nt"](),F=this[g(531)][g(661)+g(1783)+"ptor"](b.code,b[g(621)]);this[g(552)+"hCloseEv"+g(1970)](d[g(554)](gt,d[g(1232)],{code:1006,reason:b.reason||"connecti"+g(939)+g(1076)+g(1480)+g(1230)+g(825)+P,willReconnect:F})),F&&this[g(711)]();return}}if(b[g(1719)]!==1e3&&this[g(731)+g(549)]){this[g(552)+"hCloseEv"+g(1970)](d[g(479)](gt,d.FZEhZ,{code:1e3,reason:d[g(2117)]})),this[g(1419)+g(1150)]?.[g(919)+g(880)+g(1399)](),this[g(1125)+"sCounter"]?.[g(1566)+g(1272)]();return}if(d[g(1513)](1e3,b[g(1719)])&&R){let P=this["_endpoin"+g(1150)]?.["getCurre"+g(1468)+"nt"](),F=b[g(621)];F||(F=await d[g(1440)](Cp,this._url)),F=g(1488)+g(939)+g(1206)+F+(g(1346)+g(928))+P+", max retries reached",this[g(552)+"hCloseEv"+g(1970)](d.SwdEv(gt,d[g(1232)],{code:b.code,reason:F}));let B=g(601)+P+(g(1730)+"ax retri"+g(1127)+"ed");this[g(552)+g(609)+"ent"](d[g(1034)](lt,g(1508),{message:B,code:rn[g(1276)+"IES_ERROR"]})),this[g(1419)+g(1150)]?.["resetEnd"+g(880)+"fig"](),this._pingLossCounter?.[g(1566)+g(1272)]();return}if(d.hTXER(1e3,b[g(1719)])&&!b[g(621)]){let P=this["_endpoin"+g(1150)]?.[g(1882)+g(1468)+"nt"]();this[g(552)+g(2008)+"ent"](d.fXggw(gt,d[g(1232)],{code:b[g(1719)],reason:g(1488)+g(939)+g(1076)+"wn reaso"+g(1230)+"ame: "+P})),this[g(1419)+g(1150)]?.[g(919)+"pointCon"+g(1399)](),this[g(1125)+g(886)]?.[g(1566)+g(1272)]();return}this[g(552)+g(2008)+g(1970)](b),this[g(1419)+"tManager"]?.[g(919)+"pointCon"+g(1399)](),this[g(1125)+g(886)]?.[g(1566)+g(1272)]()},this[s(1657)]=null,this.onerror=null,this[s(1901)+"e"]=null,this[s(1966)]=null,this[s(1333)+s(1732)]=null,this[s(1418)+s(963)]=null,this[s(853)+"mediatel"+s(1222)+"ct"]=null,this[s(1593)+s(922)]=this[s(1593)+s(922)][s(1640)](this),this["_handleO"+s(2047)]=this["_handleO"+s(2047)][s(1640)](this),this[s(755)+s(1294)]=this["_handleP"+s(1294)][s(1640)](this),this[s(755)+"ageShow"]=this["_handleP"+s(974)].bind(this),this[s(531)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:1/0,service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:s(1936),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:"CONTINUE",env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=n,w=Array[s(1183)](f)?f:e.wyDkx(e[s(1009)],typeof f)?[f]:[];if(!w||e[s(1594)](0,w[s(1360)]))throw new Error(e[s(1164)]);if(!vp(p))throw new Error(e[s(678)]);Object[s(522)](this[s(531)],n),this[s(1419)+"tManager"]=new il(w,this[s(531)][s(2078)+"es"]),this[s(1125)+s(886)]=new Ip(this[s(531)][s(1172)+s(760)]),this[s(531)][s(1839)+s(584)]&&(this[s(833)]=!0,this[s(711)]()),this._options[s(1948)+s(865)+s(1961)]&&(this[s(1387)+"T"]||this._isMiniWX?this[s(752)+s(2103)+s(648)]():this[s(1894)+"er"]&&this[s(645)+s(559)+s(1923)]())}[t(1593)+t(922)](){let n=t;this[n(531)]["disableA"+n(845)+n(1874)]||this[n(731)+"osed"]||this[n(1864)+n(1732)]()}[t(1593)+t(2047)](){let n=t;if(e.HWPiB(e[n(1837)],e[n(1837)]))_0x55f0fc[n(1707)+"oad"]="",_0x2f1ce3[n(1889)](_0x59d66f);else{this[n(689)+n(1331)+"t"]();let s=e[n(1147)](ha,e[n(933)],{message:n(606)+n(1869)+n(1933)+"ct"});this[n(853)+n(1585)+n(1222)+"ct"]&&this[n(853)+n(1585)+"yReconnect"](s)}}["_initGlo"+t(559)+t(1923)](){let n=t;this[n(1894)+"er"]&&window["addEvent"+n(1923)](e[n(1264)],this[n(1593)+n(922)]),this[n(1894)+"er"]&&window[n(1892)+"Listener"](e[n(805)],this["_handleO"+n(2047)]),this._isBrowser&&window[n(1892)+n(1923)](e[n(1110)],this[n(755)+n(1294)]),this[n(1894)+"er"]&&window["addEvent"+n(1923)](e.egYnT,this[n(755)+"ageShow"])}["_dropGlo"+t(559)+t(1923)](){let n=t;this[n(1894)+"er"]&&window[n(1409)+"entListe"+n(1650)](n(1537),this[n(1593)+"nLine"]),this[n(1894)+"er"]&&window[n(1409)+n(1908)+n(1650)](e.qEUjN,this[n(1593)+n(2047)]),this._isBrowser&&window[n(1409)+n(1908)+n(1650)](e[n(1110)],this[n(755)+"ageHide"]),this[n(1894)+"er"]&&window["removeEv"+n(1908)+n(1650)](e[n(589)],this[n(755)+n(974)])}[t(755)+"ageHide"](n){let s=t;if(!n[s(969)+"d"])if(e[s(1404)]===e[s(1404)])this[s(1894)+"er"]&&window["removeEv"+s(1908)+s(1650)](e[s(1110)],this["_handleP"+s(1294)]),this[s(1894)+"er"]&&window[s(1409)+s(1908)+s(1650)](e.egYnT,this[s(755)+s(974)]),this[s(1638)]();else return!!this._qosDB;this[s(1894)+"er"]&&window[s(1409)+s(1908)+s(1650)](e[s(1264)],this["_handleO"+s(922)]),this[s(1894)+"er"]&&window["removeEv"+s(1908)+"ner"](s(619),this[s(1593)+s(2047)])}_handlePageShow(n){let s=t;n[s(969)+"d"]&&(this._navigatorOnline()&&(!this[s(1279)]||e.selMk(this._ws[s(1040)+"te"],this[s(1926)])||e.WEHzj(this[s(1279)][s(1040)+"te"],this[s(1571)+"NG"]))&&this[s(1593)+s(922)](),this[s(1894)+"er"]&&window[s(1892)+"Listener"](e[s(1264)],this["_handleO"+s(922)]),this[s(1894)+"er"]&&window[s(1892)+"Listener"](s(619),this[s(1593)+"ffLine"]))}async["_generat"+t(2116)](n){let s=t,{fpID:d,deviceID:f,bddID:p,ttwID:w,accessKey:b,aID:g,customParams:C={},enableAutoAck:R,enableQoS:P,QoSLevel:F,env:B}=this._options,te,J,Pe;this[s(1894)+"er"]||this[s(877)+"X"]||this[s(1387)+"T"]?(te=location&&e[s(2104)](e[s(1902)],location[s(1890)])?e[s(1975)]:s(1470),J=n[s(511)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Pe=/^wss(.*:\/\/)/[s(1218)](n)?n:""+te+J):(te=e[s(1975)],J=n[s(511)](/(^http)((?:[s]*:\/\/))/,""),Pe=/(^ws)((?:[s]*:\/\/))/[s(1218)](J)?J:""+te+J);let Oe=p?e[s(1499)]:w?e[s(994)]:e[s(1988)],on=p||w||f;if(e[s(1413)](!on,!Oe))throw new Error(e[s(1106)]);let Ke=e[s(1880)](s(959),typeof C)?await e.epIKg(C):C,ls=B?e[s(1956)](Ap,B[s(1005)],B[s(1944)]):{},On=Object[s(522)]({device_platform:e.zKVrO,version_code:e[s(1289)],access_key:b,fpid:d,aid:g,[Oe]:on,xsack:R?1:0,xaack:R?1:0,xsqos:P?1:0,qos_level:P?F:void 0,qos_sdk_version:2,...ls},Ke),ti=Object[s(879)](On)[s(1391)]((ze,ni)=>On[ni]!==void 0?""+ze+(ze?"&":"?")+ni+"="+On[ni]:ze,"");return Pe+s(1358)+ti}async _connect(){let n=t;if(!(this[n(711)+n(2051)]||this[n(731)+n(549)])){this[n(711)+n(2051)]=!0;try{if(e.mTLSK(e.JrtXR,e[n(1350)])){let s=this[n(1419)+n(1150)]?.["checkCur"+n(679)+n(2096)+"hedMaxRe"+n(663)](),{timeoutInterval:d}=this[n(531)];if(s){let p=this[n(1419)+n(1150)]?.[n(1882)+n(1468)+"nt"](),w=this[n(1419)+n(1150)]?.[n(580)+n(1790)+n(2016)+"UpdateCo"+n(2068)](),b=this[n(1419)+n(1150)]?.[n(1882)+n(1468)+n(1466)+n(2090)]();if(w){let g=n(601)+p+(n(1465)+n(1905)+n(1304)+n(706)+n(1031)+n(1516)+n(1123))+w+(n(2036)+"y"),C=e[n(756)](lt,e[n(729)],{message:g,code:rn[n(1276)+n(507)+"R"]});this[n(973)](g),this[n(552)+n(609)+n(1970)](C),this[n(997)]=await this[n(747)+n(2116)](w),this._debug("connect "+w+" "+b+n(607)),this._removeWsListeners()}else{let g=n(601)+p+(" timeout, max re"+n(1304)+"ached");this[n(973)](g),this[n(552)+n(609)+n(1970)](e.RKJsa(lt,e[n(729)],{message:g,code:rn[n(1276)+"IES_ERROR"]}));return}}else{let p=this[n(1419)+n(1150)]?.[n(1882)+"ntEndpoi"+n(1784)+n(829)](),w=this[n(1419)+n(1150)]?.[n(1882)+n(1468)+n(1466)+n(2090)]();this[n(997)]=await this[n(747)+n(2116)](e[n(1024)](p,"")),this[n(973)](n(601)+p+" "+w+n(607)),this[n(657)+n(984)+"rs"]()}if(this._isInit)this._isInit=!1;else if(e[n(487)](n(1116),e[n(1136)])){let p=ha("reconnect",{message:e.rZsJs});this[n(1333)+n(1732)]&&this[n(1333)+n(1732)](p)}else{let p=e.SABAp(_0x3775c8,_0x19f064,_0x4123a8);return _0x32132d[n(1913)][n(2111)](p,e.nvuSy(p,_0x21a8d5))}let f=this["_endpoin"+n(1150)]?.[n(1882)+n(1468)+n(1466)+n(2090)]()||0;e[n(1434)](f,1)&&await this[n(1338)](f-1),this[n(973)](n(1488)+"ng url: "+this[n(997)]+(n(1393)+n(1857))+this._protocols),this._ws=e.RccOP(Ep,{url:this[n(997)],protocols:[this[n(817)+"ls"]],headers:this[n(531)]["miniProg"+n(1963)+"s"][n(472)+"tpHeader"]},this[n(531)].ws),(this._isBrowser||this[n(2007)+"r"])&&this[n(1279)]&&(this[n(1279)][n(660)+"pe"]=this[n(1745)+"ype"]),this[n(998)+n(1366)](),this[n(711)+"ionTimeo"+n(594)]=e[n(1407)](setTimeout,this._onTimeout[n(1640)](this),d)}else{if(e[n(670)](4,_0x39528b[n(1360)])){let s=_0x14115a[n(1646)+"g"](0,e.jVPZZ(4,_0x1c388f[n(1360)])),d=s[n(943)](_0x212ce2);_0x1646d9[n(911)](d)}else _0x3d93b7[n(911)](_0xa7f19);_0x7b88c3&&(_0xd26bd1+=1),_0x3fe7fd+=1,_0x235a87=!1}}catch(s){throw this[n(711)+n(2051)]=!1,s}}}[t(2001)+t(1244)](){let n=t;e[n(1605)](clearTimeout,this[n(711)+n(1181)+"utId"]),this[n(711)+n(1181)+n(594)]=null}[t(988)+t(1746)](){let n=t,s={FxqmS:function(d,f,p,w){return e[G(600)](d,f,p,w)}};e[n(1096)]===n(1861)?hEWkRX[n(1329)](_0x1e18df,this,_0x351346,[_0x41275d,_0x3a62e5,_0x1d58c5]):(clearTimeout(this[n(656)+"gTimeoutId"]),clearTimeout(this[n(2061)+n(636)+"tId"]),this[n(656)+n(1577)+"Id"]=null,this[n(2061)+"ctTimeoutId"]=null)}[t(973)](...n){let s=t;this[s(531)][s(1473)]&&console[s(1889)][s(1051)](console,[e[s(793)],...n])}["_getInte"+t(972)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:p}=this[s(531)],w=d*Math[s(555)](p,e.KdXaL(n,1));return e[s(1259)](w,f)?f:w}[t(926)](){let n=t;if(this[n(1279)]&&e[n(1087)](this[n(1279)][n(1040)+"te"],this.CONNECTING)){this["_clearPi"+n(1746)](),this[n(656)+"gTimeoutId"]=e[n(1020)](setTimeout,this._ping.bind(this),this._options["pingInte"+n(1378)]);return}if(!this[n(1279)]||e[n(1595)](this._ws.readyState,this[n(1926)]))return void this["_handleR"+n(1732)]();this[n(1279)]&&this[n(1279)][n(475)]("hi"),this["_reconne"+n(636)+n(851)]=e[n(1723)](setTimeout,this[n(1864)+n(1732)+n(1692)][n(1640)](this),this[n(531)][n(1312)+"outInterval"])}["_handleR"+t(1732)+"Timeout"](){let n=t;this[n(1125)+n(886)]?.[n(980)](),this[n(1426)]("ping_onc"+n(1691)+"t",e[n(2042)]),this["_pingLos"+n(886)]?.[n(1111)+n(1670)+"nt"]()?this[n(1864)+n(1732)]():this[n(926)]()}[t(743)+"orOnline"](){let n=t;return this[n(1387)+"T"]||this[n(877)+"X"]?this["_miniNav"+n(692)+n(701)]:(this._isBrowser||this._isWorker)&&this[n(531)]["listenNe"+n(865)+"nged"]?navigator[n(1202)]:!0}[t(1864)+t(1732)](){let n=t;!this[n(743)+"orOnline"]()||this["_readyCl"+n(549)]||(this["_endpoin"+n(1150)]?.[n(919)+n(880)+"fig"](),this[n(1125)+n(886)]?.[n(1566)+"nter"](),this[n(1279)]?this[n(1099)+n(1471)](1001,e.dQPZT,!0):this[n(711)]())}[t(752)+t(2103)+t(648)](){let n=t;this._isMiniTT?tt[n(1983)+n(2029)+"hange"](({isConnected:s})=>{let d=n;this[d(1919)+d(692)+"line"]=s,s?this[d(1593)+d(922)]():this["_handleO"+d(2047)]()}):this[n(877)+"X"]&&wx[n(1983)+"kStatusC"+n(2081)](({isConnected:s})=>{let d=n;this["_miniNav"+d(692)+d(701)]=s,s?this["_handleO"+d(922)]():this[d(1593)+d(2047)]()})}_wait(n){return new Promise(s=>{let d=G;e[d(1836)](setTimeout,s,this[d(695)+d(972)+"e"](n))})}["_disconn"+t(1471)](n=1e3,s="",d=!1){let f=t;this[f(1279)]&&this[f(689)+f(1331)+"t"](n,s,d)}[t(1785)+"ut"](){let n=t,s=this[n(1419)+n(1150)]?.[n(1882)+n(1468)+"nt"]();this._debug(n(601)+s+n(1465)),this["_disconn"+n(1471)](1001,n(1525)+n(1199)+n(1751)+"g",!0)}[t(1187)](n){let s=t,d=e[s(1254)](Ut,n);this[s(1279)]&&e.ZbuGx(this[s(1279)][s(1040)+"te"],this[s(1926)])&&(this[s(1279)]&&this[s(1279)][s(475)](d),this[s(973)](e[s(866)],n))}[t(657)+t(984)+"rs"](){let n=t;this[n(1279)]&&(this[n(1279)][n(1409)+n(1908)+n(1650)](e[n(1176)],this._onOpen),this[n(1279)][n(1409)+"entListe"+n(1650)](e.DUWUZ,this[n(957)]),this._ws[n(1409)+"entListener"](n(1891),this[n(929)+"ge"]),this[n(1279)][n(1409)+n(1908)+"ner"](e[n(729)],this[n(1427)]))}[t(998)+t(1366)](){let n=t,s=e[n(750)][n(852)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1279)][n(1892)+n(1923)](e.rzKJT,this[n(929)+"ge"]);continue;case"1":this._ws[n(1892)+n(1923)](e[n(729)],this[n(1427)]);continue;case"2":this[n(1279)]["addEvent"+n(1923)](e[n(1176)],this[n(1389)]);continue;case"3":if(!this[n(1279)])return;continue;case"4":this._ws[n(1892)+n(1923)](e[n(1501)],this[n(957)]);continue}break}}[t(1119)+t(1316)](n=1e3,s=""){let d=t;try{this[d(1279)]&&this[d(1279)][d(1638)](n,s)}catch{}}["_destroy"+t(1331)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(988)+f(1746)](),this[f(2001)+"mer"](),this._removeWsListeners(),this._wsInstanceClose(1e3,s),this[f(711)+"Lock"]=!1,d&&this["_navigat"+f(586)]()&&!this[f(731)+f(549)]){if(this["_endpoin"+f(1150)]?.["checkRea"+f(1084)+"es"]()){let w=this["_endpoin"+f(1150)]?.[f(1882)+f(1468)+"nt"]();this["_dispatc"+f(2008)+"ent"](e[f(1706)](gt,f(1638),{code:1006,reason:f(601)+w+(f(1465)+f(1905)+f(1304)+"ached"),wasClean:!0}))}else if(e[f(486)](e[f(1247)],e[f(1179)])){let w=this[f(531)][f(661)+f(1783)+f(2095)](n,s);this["_dispatc"+f(2008)+f(1970)](e[f(1303)](gt,e[f(1501)],{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this[f(711)]()}else try{return!!this[f(1239)]}catch(w){return _0x570a7d[f(1889)](w),!1}return}this["_navigat"+f(586)]()||this[f(731)+f(549)]?this[f(552)+"hCloseEvent"](e.nRNEW(gt,e[f(1501)],{code:n,reason:e[f(523)]})):this[f(552)+f(2008)+f(1970)](e[f(1075)](gt,e[f(1501)],{code:1006,reason:e[f(910)]})),this[f(1279)]=null,this[f(1419)+"tManager"]?.[f(919)+f(880)+f(1399)](),this[f(1125)+f(886)]?.[f(1566)+f(1272)]()}[t(552)+t(2115)+"nt"](n){let s=t,d={yIeeq:e[s(1110)]};e.JJmcn(e[s(510)],s(830))?(this._isBrowser&&_0x213832[s(1409)+s(1908)+s(1650)](s(1537),this._handleOnLine),this[s(1894)+"er"]&&_0x1c3e15[s(1409)+s(1908)+s(1650)]("offline",this[s(1593)+s(2047)]),this[s(1894)+"er"]&&_0x51afef["removeEv"+s(1908)+s(1650)](xQuggC.yIeeq,this[s(755)+s(1294)]),this[s(1894)+"er"]&&_0x5c7e1c["removeEv"+s(1908)+"ner"](s(964),this["_handleP"+s(974)])):(this[s(1426)](s(1999),n),this[s(1966)]&&this[s(1966)](n))}[t(552)+"hMessageEvent"](n){let s=t;this.emit(e[s(473)],n),this[s(1901)+"e"]&&this[s(1901)+"e"](n)}["_dispatc"+t(1063)+t(1494)](n){let s=t;if(e[s(977)]!==e[s(977)]){let d=this._endpointManager?.[s(1882)+"ntEndpoint"]();this[s(552)+"hCloseEv"+s(1970)](_0xc4da2e(e.DUWUZ,{code:1006,reason:s(601)+d+(s(1465)+s(1905)+s(1304)+s(1248)),wasClean:!0}))}else this[s(1426)](s(995),n),this[s(1418)+s(963)]&&this[s(1418)+s(963)](n)}[t(552)+t(609)+t(1970)](n){let s=t;if(e[s(1860)]===e.YRIiL)this[s(1426)]("error",n),this.onerror&&this[s(1900)](n);else return _0x48dad8|=0,{low:_0x54b280,high:_0x1b123b>>31,unsigned:e.tWNpb(_0x2c8766,0)}}["_dispatc"+t(2008)+t(1970)](n){let s=t;this[s(1426)]("close",n),this[s(1657)]&&this[s(1657)](n)}get[t(660)+"pe"](){let n=t;return this[n(1279)]?this[n(1279)][n(660)+"pe"]:this[n(1745)+n(1256)]}set[t(660)+"pe"](n){let s=t,d={eRGFB:function(f,p){return e[G(1271)](f,p)},LmIrG:function(f,p){return f<p},cuxlQ:function(f,p){return e[G(993)](f,p)},YVVWj:function(f,p){return e.OCFTK(f,p)},FqzAJ:function(f,p){return e[G(869)](f,p)},SDsTZ:function(f,p){return e[G(1522)](f,p)},dBevc:function(f,p){return f|p},SaaYs:function(f,p){return e[G(1729)](f,p)},ELMjN:function(f,p){return e[G(935)](f,p)},enkax:function(f,p){return e[G(1362)](f,p)}};e[s(1097)](e[s(1772)],e.rHZgv)?(this["_binaryT"+s(1256)]=n,this[s(1279)]&&(this[s(1279)].binaryType=n)):(wXSjSP[s(623)](_0x58287b,2048)?_0xf59710[_0x574871++]=_0x306b2b>>6&31|192:(wXSjSP[s(1722)](_0x414b37,65536)?_0x556b1f[_0x24bf3f++]=wXSjSP[s(1175)](_0x584f8f>>12&15,224):(_0x474288[_0x1e7379++]=wXSjSP[s(902)](wXSjSP[s(1102)](_0x4b8849>>18,7),240),_0x5d6090[_0x5af5de++]=wXSjSP[s(1175)](wXSjSP[s(1102)](wXSjSP[s(1161)](_0x5e9ecc,12),63),128)),_0x26cb80[_0x5f0492++]=wXSjSP.dBevc(wXSjSP[s(1310)](_0x5420db>>6,63),128)),_0x24e476[_0xb1057b++]=wXSjSP[s(1039)](wXSjSP[s(2106)](63,_0x5843d2),128))}get retryCount(){let n=t;return this[n(1419)+"tManager"]?.[n(1882)+n(1468)+n(1466)+"ount"]()||0}get[t(1934)+"Amount"](){let n=t,s=this[n(1165)+n(1155)][n(1391)]((d,f)=>(d+=f&&f[n(2028)+"th"]||0,d),0);return e.PfCvD(s,this._ws?this[n(1279)][n(1934)+n(568)]:0)}get[t(1285)+"ns"](){let n=t;return this[n(1279)]?this[n(1279)][n(1285)+"ns"]:""}get[t(1890)](){return this._ws?this._ws.protocol:""}get[t(1040)+"te"](){let n=t,s={EiqIk:function(d,f){return e.EErdJ(d,f)},pXRdm:e[n(729)],vnQzJ:function(d,f){return e[n(1287)](d,f)},iaGLo:function(d,f){return e[n(1408)](d,f)},shviI:e[n(936)]};if(e[n(1174)]!==e.TkQOa)return this[n(1279)]?this._ws[n(1040)+"te"]:this[n(531)][n(1839)+"cOpen"]?this[n(1571)+"NG"]:this[n(832)];{let d=this[n(1124)+"rs"][_0x360742];if(d)d[n(738)]()[n(1047)](f=>f.fn[n(1051)](f[n(1026)],_0x4e5557));else if(hdbwdj[n(904)](hdbwdj[n(1290)],_0x1148f0)&&!this[n(1900)]){let f=_0x22a4e0[n(1360)]&&_0xbf0e61[0];if(hdbwdj[n(1828)](f,_0x4b74c6))throw f;let p=new _0x54bbc4(hdbwdj.iaGLo(hdbwdj[n(1710)],f?hdbwdj.iaGLo(" ("+f.message,")"):""));throw p[n(1804)]=f,f}return this}}get[t(1274)](){let n=t;return this[n(1279)]?this[n(1279)].url:this[n(997)]}[t(1638)](n=1e3,s){let d=t,f=e.VEGPh[d(852)]("|"),p=0;for(;;){switch(f[p++]){case"0":this[d(1178)+d(559)+d(1923)]();continue;case"1":this._clearPingTimer();continue;case"2":this[d(2001)+"mer"]();continue;case"3":this[d(689)+d(1331)+"t"](n,s);continue;case"4":this[d(1487)+d(1288)]?.[d(547)]();continue;case"5":if(!this[d(1279)])return void this[d(973)](e.giTEd);continue;case"6":this[d(731)+d(549)]=!0;continue;case"7":if(e.lmfYA(this[d(1279)][d(1040)+"te"],this[d(832)])||e[d(1103)](this[d(1279)][d(1040)+"te"],this.CLOSING))return void this[d(973)](e[d(503)]);continue}break}}async[t(475)](n,s){let d=t,f={LEBgT:function(Pe,Oe,on){return e[G(1145)](Pe,Oe,on)}};if(e.QYSjW(null,n))throw new Error(e.jzeSZ);e[d(2104)](e[d(665)],typeof n)&&(n=JSON[d(1004)+"y"](n)),e[d(1009)]!=typeof n&&!e[d(1309)](n,ArrayBuffer)&&!(n.buffer&&n[d(900)]instanceof ArrayBuffer)&&(n=JSON[d(1004)+"y"](n));let p=await cl(n),w=e.anShy(Sp,n),{method:b=0,service:g=this[d(531)][d(2022)],logID:C=this[d(531)].logIDGenerator(),headers:R=this[d(531)][d(913)],payloadEncoding:P=this[d(531)][d(1241)+"ncoding"],payloadType:F=this[d(531)][d(1788)+d(1256)],logIDNew:B=this[d(531)].logIDNewConfig[d(2035)+d(1682)+d(564)+"ew"]?e[d(653)](i,this[d(531)][d(1235)+d(1307)][d(2058)]):""}=s||{};if(!g)throw new Error(d(551)+d(1995)+" valid s"+d(1374));let te={SeqID:xe[d(1748)+"er"](this[d(1055)]++),LogID:xe.fromNumber(C),service:g,method:b,headers:R,payloadEncoding:P instanceof Object?P[d(639)]?P.encoding:"":P,payloadType:F instanceof Object?F[d(2025)]?F[d(2025)]:w:F||w,payload:p,LogIDNew:B},J=e[d(1402)](Ut,te);return this[d(1279)]&&this._ws[d(1040)+"te"]===this.OPEN?(this[d(1279)]&&this._ws[d(475)](J),this[d(973)](e[d(1216)],te)):this[d(1165)+"Queue"][d(1360)]<this._options[d(613)+d(796)+"ength"]?e.BEiuO(d(1739),e[d(1888)])?(this["_message"+d(1155)][d(911)](J),this._debug("enqueue",te)):(ZGmwDS[d(1486)](_0x5df1be,_0x3d74b1,10),ZGmwDS[d(1486)](_0xb2cc59,_0x15d27f,_0x499c61)):(this[d(1165)+d(1155)][d(881)](),this[d(1165)+d(1155)][d(911)](J)),{seqID:this[d(1055)],logID:C,logIDNew:B}}async reconnect(n){let s=t,{url:d}=e[s(739)](n,{}),f=Array.isArray(d)?d:e[s(1880)](e[s(1009)],typeof d)?[d]:[];n&&Object[s(522)](this[s(531)],n),f&&f.length?this[s(1419)+"tManager"]=new il(f,this[s(531)][s(2078)+"es"]):this[s(1419)+"tManager"]?.[s(919)+s(880)+s(1399)](),this["_pingLos"+s(886)]?.["resetCou"+s(1272)](this[s(531)][s(1172)+s(760)]),this["_readyCl"+s(549)]=!1,this[s(1279)]&&e.zpXjt(this[s(1279)][s(1040)+"te"],this[s(832)])?this[s(1099)+s(1471)](1e3,e[s(949)],!0):(this[s(833)]=!0,this[s(711)]())}async[t(1838)](){let n=t;if(!this[n(711)+"Lock"]){let s=e.FIhLQ[n(852)]("|"),d=0;for(;;){switch(s[d++]){case"0":this["_readyCl"+n(549)]=!1;continue;case"1":this[n(1125)+n(886)]?.[n(1566)+n(1272)]();continue;case"2":this[n(1419)+n(1150)]?.[n(919)+n(880)+n(1399)]();continue;case"3":this[n(833)]=!0;continue;case"4":this[n(711)]();continue}break}}}addEventListener(n,s){let d=t;if(e[d(906)](e[d(1379)],e[d(2048)])){if(e.KHLSd(_0xe36e2c,_0x11d61c)<1)return"";let f="";for(let p=_0x517c62;p<_0x1c3878;){let w=_0x1c8b7f[p++];if(w<=127)f+=_0x407d28[d(2120)+d(2004)](w);else if(e[d(1992)](w,192)&&e[d(1357)](w,224))f+=_0x30be68["fromChar"+d(2004)](e[d(2034)](e[d(1438)](e[d(489)](31,w),6),e[d(1974)](63,_0x44a708[p++])));else if(e[d(497)](w,224)&&e[d(1835)](w,240))f+=_0x64167a["fromChar"+d(2004)](e.iNkUj(e[d(720)](e.vuEpX(15&w,12),e.igLOP(63&_0x15fde0[p++],6)),e[d(617)](63,_0x5a7fd1[p++])));else if(e[d(1726)](w,240)){let b=e[d(1144)](e[d(824)](e.fxQAe(e[d(562)](e.WANBY(7,w),18),e[d(1160)](e[d(1575)](63,_0x157822[p++]),12)),e[d(1359)](63&_0x251ea9[p++],6))|e[d(1618)](63,_0x4f7abb[p++]),65536);f+=_0x3bca60[d(2120)+"Code"](e[d(1045)](55296,e[d(1273)](b,10))),f+=_0x4cf589[d(2120)+d(2004)](e.cWCrN(56320,e[d(1151)](1023,b)))}}return f}else this.on(n,s)}["dispatch"+t(1712)](n){let s=t;if(e[s(1435)]==="IiIDL"){let{type:d}=n;this.emit(d,n)}else{let d=this._qosDB["getStora"+s(1749)](this[s(667)]);return _0x5d8e00[s(2119)](e[s(1846)](d,"{}"))[_0x39a798]}}[t(1409)+"entListe"+t(1650)](n,s){this[t(2088)](n,s)}[t(1985)](){let n=t,s={STTCc:function(d,f){return d(f)},AQKdj:n(840),Oqgee:e[n(2043)],yHpiu:e[n(937)]};return new Promise((d,f)=>{let p=n,w={xLNlK:function(C,R){return e[G(1883)](C,R)},gjloB:e[p(2042)],xDVda:e[p(2043)],qIslW:e[p(937)]};this[p(988)+p(1746)](),this[p(656)+p(1577)+"Id"]=setTimeout(this[p(926)][p(1640)](this),this._options[p(1606)+p(1378)]);let b=()=>{let C=p;s[C(912)](d,s[C(1996)]),this[C(2088)](s.Oqgee,b),this[C(2088)](s[C(1505)],g)},g=()=>{let C=p;w.xLNlK(f,w[C(1027)]),this[C(2088)](w[C(1114)],b),this[C(2088)](w[C(592)],g)};this.on(e[p(2043)],b),this.on("ping_onc"+p(1691)+"t",g),this._ping()})}}})(),Be[M(1512)+"oseEvent"]=Re[M(1512)+M(1899)],Be[M(1028)+"rorEvent"]=Re["CustomEr"+M(1193)],Be[M(1507)+"e"]=Re[M(1507)+"e"],Be[M(1712)]=Re[M(1712)],Be[M(1653)]=Re[M(1653)],Be[M(932)+M(672)+"vent"]=Re[M(932)+M(672)+"vent"],Be[M(672)+M(671)]=Re[M(672)+M(671)],Be[M(506)+"t"]=Re[M(506)+"t"],Be[M(1439)+M(658)]=Re[M(1439)+M(658)],Be["createCl"+M(1899)]=Re[M(624)+M(1899)],Be[M(1457)+"rorEvent"]=Re[M(1457)+"rorEvent"],Be[M(1856)+M(970)+"nt"]=Re.createMessageEvent,Be[M(982)+M(1674)]=Re[M(982)+M(1674)],Be["createRe"+M(1233)+M(671)]=Re[M(1421)+M(1233)+M(671)],Be[M(712)+M(1156)]=Re[M(712)+"rame"],Be[M(1171)+M(1583)]=Re["encodeFr"+M(1583)];for(jo in Re)[M(1512)+M(1899),M(1028)+M(1193),M(1507)+"e",M(1712),M(1653),M(932)+"MessageE"+M(671),M(672)+M(671),M(506)+"t","Reconnec"+M(658),M(624)+"oseEvent",M(1457)+M(1193),M(1856)+M(970)+"nt",M(982)+M(1674),M(1421)+M(1233)+M(671),"decodedF"+M(1156),"encodeFrame"][M(1950)](jo)===-1&&(Be[jo]=Re[jo]);var jo;Object[M(516)+M(2038)](Be,M(1459)+"le",{value:!0})});import{existsSync as uS,openSync as fS}from"node:fs";import{mkdir as xS}from"node:fs/promises";import{dirname as hS}from"node:path";import{fileURLToPath as pS}from"node:url";function mS(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Md(t=Q()){return uS(t.libEntry)?t.libEntry:pS(new URL("../index.ts",import.meta.url))}async function Nh(t={}){let e=t.paths??Q(),r=t.entryOverride??Md(e),i=mS(e,process.env.COZE_BRIDGE_LOG_MODE);await xS(hS(i),{recursive:!0});let o=fS(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=st(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[os]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return gS.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var gS,os,ta=et(()=>{"use strict";Vt();re();Le();gS=H("spawn-daemon"),os="COZE_BRIDGE_DAEMON"});import{spawn as l2}from"node:child_process";import{mkdir as u2,unlink as f2,writeFile as x2}from"node:fs/promises";import{dirname as h2,join as p2}from"node:path";function Jr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function g2(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Jr(r)}</key>
|
|
21
|
-
<string>${
|
|
20
|
+
`+r)}function er(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,er),t.emit("wsClientError",d,r,e)}else ts(r,i,o,c)}});var Lx=oe(ze=>{"use strict";var M=G;(function(t,e){let r=G,i=t();for(;;)try{if(-parseInt(r(871))/1+parseInt(r(1018))/2*(-parseInt(r(1058))/3)+parseInt(r(1347))/4+parseInt(r(1710))/5+-parseInt(r(1282))/6+parseInt(r(1398))/7+-parseInt(r(1810))/8===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Ko,904225);var Hv=Object[M(1717)+"operty"],jv=Object[M(1360)+M(335)+"mes"],Cx=(t,e)=>function(){return t&&(e=(0,t[jv(t)[0]])(t=0)),e},Kv=(t,e)=>{let r={qeshq:function(o,c,d,u){return o(c,d,u)}};for(var i in e)r.qeshq(Hv,t,i,{get:e[i],enumerable:!0})};function Wv(){return Sx||(Sx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function $v(){let t=M;return Ix||(Ix=[IDBCursor[t(742)+"e"][t(1819)],IDBCursor[t(742)+"e"][t(1492)],IDBCursor[t(742)+"e"][t(1492)+t(1470)+"ey"]])}function Vv(t){let e=M,r={DevXm:e(1062),cNCOa:e(1284),unKjB:function(o,c){return o!==c},jkvzf:e(1806),ZcGLw:e(309),hovAi:function(o,c){return o(c)},XawEI:function(o){return o()},trYwj:function(o,c){return o<<c},Jdqzu:function(o,c){return o&c},RzgPV:e(950),bBlcI:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let d=e,u={eVaBD:r[d(530)],xCmSS:r.cNCOa,HdjfK:function(m,v){return r[d(1106)](m,v)},ULHyp:r[d(1692)],PBCYv:r[d(1639)],AoHIF:function(m,v){return r[d(555)](m,v)},McUlq:function(m,v){return r[d(555)](m,v)},rqphQ:function(m){return r[d(1227)](m)},lPbpx:function(m,v){return r[d(1119)](m,v)},fWYOF:function(m,v){return r[d(528)](m,v)},pcpek:function(m,v){return m!==v},XhqdC:r[d(1281)],jILxB:function(m){return r[d(1227)](m)}},f=()=>{let m=d;t[m(787)+"entListener"](u[m(1131)],x),t["removeEv"+m(1796)+"ner"](u[m(1797)],g)},x=()=>{let m=d;m(1279)!==m(1279)?_0x1f3f47[m(1077)+"d"]&&(this["_navigat"+m(880)]()&&(!this[m(1823)]||u[m(1266)](this[m(1823)].readyState,this[m(406)])||u[m(1266)](this[m(1823)][m(725)+"te"],this.CONNECTING))&&this["_handleO"+m(1002)](),this[m(1808)+"er"]&&_0x4e0fdf[m(1531)+"Listener"](u[m(651)],this["_handleO"+m(1002)]),this[m(1808)+"er"]&&_0x1ec004[m(1531)+m(836)](u[m(1255)],this[m(1072)+m(373)])):(u[m(1781)](o,u[m(797)](Ut,t[m(1138)])),u[m(542)](f))},g=()=>{let m=d,v={eqWbb:function(_,S){return u.AoHIF(_,S)},FXxcu:function(_,S){return u.lPbpx(_,S)},SeqER:function(_,S){return u[G(1693)](_,S)},dMbNo:function(_,S){return u[G(797)](_,S)},KsVZK:function(_,S){return _&S},suKiN:function(_,S){return u.lPbpx(_,S)},Jklvn:function(_,S){return _&S}};u[m(1184)](m(861),u[m(1460)])?(c(t[m(1284)]),u[m(677)](f)):(_0x5b4cac=v.eqWbb(_0x6a3e64,_0x558c93),_0x2f2551|=v[m(943)](v[m(1453)](127,_0x18f610),21),128&_0x5bf27b&&(_0x529260=v[m(924)](_0x23483f,_0x10934b),_0x4d4ba8=v[m(1453)](127,_0x11175c),v[m(1325)](128,_0x56c5ca)&&(_0x484de8=v.dMbNo(_0x17051a,_0x2af4af),_0x2ed32b|=v.suKiN(v.Jklvn(127,_0x4b900e),7))))};t["addEvent"+d(836)](r[d(530)],x),t[d(1531)+d(836)](r[d(842)],g)});return i[e(644)](o=>{let c=e;r[c(735)](o,IDBCursor)&&Nd[c(1416)](o,t)})[e(1380)](()=>{}),$o[e(1416)](i,t),i}function Ko(){let t=["yxHnB3m","ANHSEuq","C2TZs0q","CKzYvuW","ywXSzwqGBxu","vLDesg8","tLvkEhi","reHcs2W","DKXpCMO","uMzLs0e","sxnjzxO","BwfUDwfSihi","tg9Nsuq","rhn3sNq","qKzTve4","t1fyBwy","y3b5vLG","tM1wtNa","wKr0r2e","v2z6y0u","AwXLx25HBwu","Dg1Rwha","DwLADMi","B25nzxnZywC","zvrdEei","x2HHBMrSzva","vK1lB2q","z2v0qwXS","AxnrB1nby2S","x29UtwvZC2e","wMnhthC","AhDsq0m","uuz5BNu","rwLxExe","DgfIyxnL","uuP2C0C","ALn1thu","CevWwxK","y3v5uxK","ugvlrNK","z0jxyKS","Cgf5Bg9Hzeu","BvHODNe","zNvUy3rPB24","sg5Tvhq","CMvKDwnL","B25VCgvU","teLzy2q","vxvbzLy","tu9dsxG","yNLL","y3vYC29Y","s1DXsxC","Aw47y2HHCNm","AMDOEei","Avfqy2K","uKjNC0m","Dw5dBfC","Aw5PDcbrB1m","CwnuAgi","rfr5wvO","uMHly0W","t0PlyxG","B0DXsu4","CMvXDwLYzwq","C2vYDMLJzq","r3jXsg0","qND0BKS","wuHfuLK","y3jLyxrLrxi","CMfiuvG","x29WDgLVBNm","B3bLBIa","y29UBMvJDgK","CMvZzxrdB3u","yw5Nzq","CvDOBMW","wwrJB3G","wfD2z08","Ae1LC3nHz2u","jMPZy2fSBgi","vKnsvfm","C0nVDw50zxi","AMT2EMy","zLDzt0y","zNjVBu51Bwi","icSG","C3vIC3rYAw4","BwLUzW","q3vZDg9Trxi","zNHAr24","ExbL","zKTIALu","wunXEwu","yM9KEq","aaaaaaaaaaa","svrlqNC","CNzHBa","EuffzMu","rhzHDge","yxPky0G","nJyYoteYnujuwxrVBW","Dg9iyxnO","AenSB3nLrxy","x3fVC0rc","zxq9DxrMltG","CM92AwrLigi","C2fNzq","zgvMAw5Luhi","rwLYCLC","B0fkCNO","ywXSq3vYC28","t3j1sMm","ywnRx2nVzgu","AKDAuNy","yxjyrM0","C2nYAxb0","EuLuzva","tu9ntey","zgv2AwnLx2K","z2v0","x3jLywr5q2W","zw5NDgG","zxmGCMvHy2G","y3jLyxrLt2i","svHovvG","AgvHzgvYCW","zg5twhK","Dgv4Dc9WBge","x3jLy29UBMu","DvHPsvq","qxvSDKi","vKn3AKC","EgPZuwG","ywnOzwq","zu5TyKe","qxHLDgq","wg5IsK4","x194x21Zz18","B3nLza","BujZq2K","r1Hgv2u","yM9L","DcbVzIbYyw4","CMvQzwn0","rxjYB3jdB2q","sgLyrMK","Dwz1veG","CgLUz1rPBwu","x2rYB3bhBg8","BMfTzq","yMfSrxzLBNq","EMjkEKu","v1P2CgC","zMvuzNO","DvP5sKe","s3PVCw0","zv90Aw1LB3u","quLrAhu","DejUAfm","zKjUzg8","C2f5A3q","x2zVCM1HDeu","l3DZl3yY","A2v5","rvvluhC","qw1nvgC","AgfTzKO","B2rXt00","CgXHyxq","tKfusvzfx0u","vfzTDxO","qw9isuy","yuPJC0y","zgrjrcWGzgu","Aw9Ul2PZB24","uhjHtgO","uLjrt1G","A1vmwwu","CgfNzwHPzgu","D3D0y3e","zgvSzxrL","q0rWzKy","Aw5Lza","vhPvvMe","qxriruS","DgLTzw91DcW","zw50tgLZDgu","EenTu1m","x3bYB3rVy28","Aw5KzxG","C1D3wMi","vNnotM4","uvjzvvG","Ehz2wvK","DhjHBNnHy3q","Dg9oDw1Izxi","B25SAw5L","tNrLu2q","x2LZqNjVD3m","AfLnqu4","otC3mZKYAfvxqMjM","t2jQzwn0","serTC2q","C3nHz2vfDMu","y3LXwMK","zKPbqxe","BMzzsey","x2n1CNnVCK4","ENj2rNi","ywr2yw5Jzq","mhWZFdr8mxW","zvzeuNu","DMTdzMq","x3DZ","v2npD2y","tLDhuLO","BMDxyKS","uNjPCMS","BvDXCvq","AxrWDMm","EwfMDgm","zNHTAuS","zv9ZDwnJzxm","vfPHALK","Egvor1m","zxL2t20","BfjsBvu","DMXHqum","Dhr3BKe","y2XLyxjtDg8","zeXpy0S","CMvHC29U","yvnHzeG","wLLuDg4","q054CvK","C25kAey","A1rKDwK","z0zzv0y","u2TPCcbWyxm","EwvfDMm","zvPYCNu","yw5Hz2vY","CfHTtxq","z2Xezwu","AgvdvKW","DwTjEge","t3zwz3y","yxnZAwDU","vxbKyxrLq28","t1vzCK8","B2zMBgLUzq","BM5Ly3q","vuvQEvm","C0TXsue","zezgAeG","CYbPBNn0yw4","AwrI","BhjVv3q","wM9SDNi","vw5vCNG","BMCGzMfPBgu","ywX3yxLZ","vMXusg8","zvnJAgS","BKvkEhi","wgHXtuy","uvP4yw0","CNf6vei","tLzZBhy","uNzbzvm","D0fWyLa","yMHMEvC","DxbNCMfKzw4","Bg9N","sMXqyMq","x2LUDgvYDMe","B3bLCNr5tMe","wKP5Awu","A0Tzwhe","zw1PDa","tgHWrhi","qxPPyKm","y05rvxq","zKfitK4","tNL1zfu","rxnrEeq","ywnRDxbfBMq","s1vMAKu","ueXdBvm","yNvMzMvY","rfbbsxm","uxvLDwu","CvPdz1u","tfDSB0O","B3bLBG","yMXVy2TLza","D01IqK8","CenjAei","x2nSzwfYvgK","CMvTB3zLq2G","vMnTDxa","CfDSD2e","u0XREhC","rxzIAM4","zMX1C2HfEha","zvnAzgy","zerNu0K","ENzZvhe","vKf2vue","u2PeCNK","Dw50","DxrMofDYAxq","C1fyDeG","Dev2zw50","zMzmAw5L","C2HVDem","CgLUz0XVC3m","B25TzxnZywC","zw1LBNq","uwrpDMe","uw9OzKG","BKrvyKe","mhWXFdn8nhW","B0HAEwi","x2jPBMfYEvq","u3rYyxrLz3K","tLzwy0i","D3nZoI8V","vM5mv28","vwz2v3i","ihzHBgLKihm","uNrywe0","CM92AwrLige","yvbKqvy","BxnN","B2HSsLC","sen2tNO","CwzqEg4","ywDLu2HVDW","AgfUz2u","q1PWBwS","CLDquvu","wM1HvKi","C1DTr20","Cgf5Bg9Hza","tevJCvy","rvHmze0","t1bftG","B3bYCgm","v0LyEuq","zw50","yxv0B21HDgK","yw1L","Cg9PBNrdB24","DuDlzuC","BwvZC2fNztO","x2TLEvbHDgG","DMvYC2LVBMm","EM51ugK","BKH3rgK","ug1SDgG","CgfNzxnOB3C","q3rvA00","y1v1ELq","t3vtww4","v0j3sxG","wwnuzwq","DeLUDgvYy2u","zvHgEwq","EfnduMO","reXfsK0","rg15Cw4","BNzrBwO","twnwB0K","lcbxzwjtB2m","CKHJCM8","t05Nr1G","CLfbAvG","AhjpANG","qwz6wge","z010Bei","CxPXt2W","vKjev0S","rNzquLK","BufWtw4","thb6DwK","lcbOB3n0BMe","zxLiyw4","CMvJzxzPzwq","wwX4B3y","uvLgwKO","EM5PuKC","A2v5CW","B25JBg9Zzq","uNfgvKu","C3rYAw5NAwy","EvbTz2e","r3r0C00","Bg93wKu","B0jVBwG","ig1LC3nHz2u","twLlyxG","CgLUz19VBMm","su5tvefova","BMCGDxjSoIa","DK1gsfG","DgHHBIbSB2m","svfRB2W","BNruCMLLC0m","q0HAAxi","qvrJs1G","C29YDa","yMrxuxq","DM9nyMi","zg9Uzq","vxrAEKq","zw5HyMXLvhi","x2rLC3rYB3K","ywnRtxnNswq","sfnXuuy","DKnezxC","AwTOz3e","tNjLCgK","y29Uy2f0","AgDYtuW","Bg9NsurozxC","rLDt","qwjVCNrfCNi","C2vUza","C2vYDMLJzs0","zMzjDNO","CezID1O","BwfW","y2DVDKS","B25tDgfYDfi","uLjpuG","wgP2sLa","EwjbtNe","DvLwAhm","C0jf","txLcEKy","thzxrgW","AxjLza","Afzjy3O","uMvJB25Uzwm","seDus2m","ywzL","vwXyDuW","vNLNsfm","Buzesfq","sM9kvw0","BxLsu0e","B25Uzwn0Aw4","DwHxwvO","ywDLsgLKzq","CNnVCL9Uyw0","yxnL","y21nC1y","whfwy2e","u0f0D3q","ChnvshK","ugfkEeS","ignVzgu6ia","x3bPBMDmB3m","qM9Lzvm","yNLcCwK","yxbWBgLJyxq","yNL0zuXLBMC","BNPztxq","sMrXENu","s3f0C2m","rgv2wg0","igzHAwWSig0","EwD4A2W","wgXyELG","D1nHB3q","zuXwEfy","yM9Aqwu","y3vYCMvUDeu","teDHENG","swvLB3G","sePlvKC","CNLKBxy","CNfWAfe","rKz6vve","CLbQwwG","DxbKyxrLq3u","EwDQwhK","qNjPzgDL","ChHPwxO","tvbRy0C","qKTcu3q","wKrfANm","D2HusNi","yNL0zu9MzNm","AwzJwMC","Ag92qwK","y29TCgXLDgu","yxbWBhK","BMnVzgLUzW","x3nLBMrby2S","y2HnyxHuCMK","pxv0zI04","x2LZtwLUAvC","EvjLy29UBMu","B0LIA1i","uwrfB3m","zgvJB2rLzey","z0PbyuS","thvryw0","DwvpC1i","zKT6ALa","u1bhA0C","Dg9Y","r2vlvg8","ENnLzxe","BK5crhm","weDXquC","zK1Ysum","C3jJ","BNvjsLK","yujAuw0","q2jfrwi","x3DZsw5ZDge","z2v0sxrLBq","v0zwB2W","y29UBMvJDca","CwLKrNO","ywXSB2nvBNm","BefdA0u","Aw5KzxHpzG","Au1fthe","tw9NBeO","y2HHCKnVzgu","t2POsNm","ywrKt25L","qxzSAwC","C3vIyxjYyxK","zvvYBa","CxrPz1u","B1bwCuC","BMDuAw1LCG","z3D6zMK","y2XVC2veqG","vfv5qKW","vwLzC2e","tevtAKC","BMnLq2XVC2u","tgflANO","r2fuB0G","q291BNq","wxvwEum","C29Tzq","AujkzKe","turhBeq","qMPmENa","qvvAvwy","txfHr2q","qLzNA3e","B0TKruS","D2fZq2XLyw4","y2fnq2y","wNniuuO","CgXLyxnLiha","DgzJuKe","txn4EwO","DMfSDwvZ","DMLLtLO","AM5dq2W","y0TAwuu","rwP3EKi","Bg9Nsurhzw4","CMvHzfvjBNq","qu1vD2i","zw5HyMXLuw8","DMTQvLa","zMLIthK","zfDVCMTLCKC","u2nfvMO","EM9tBKm","tenby24","wMjNwuS","vhHjzuq","D24GCMvHC28","sNP1s3K","DgHLBG","DhbizwfKzxi","CwLisLK","uM1YELO","v3ryruC","zM9Yy2u","reiGzMfPBgu","vuXiExa","A0HZyMS","x29Uq2XVC2u","x3bPBMDqB24","z2vtEw5J","CM5Ywwm","BKX6yLe","AevYCM9Yrxy","ywjJCe4","x2nSzwfYugK","z1r6zhq","uxnlA3y","C2vYDMvYvgK","Dg9cExrLCW","s3nAC2W","vMjgC28","uMTNBeS","A1nKC1e","BfrPBwvVDxq","C2DPza","sgXhDvq","vw5Oyw5KBgu","s21Ny0m","seniq3C","zMzMzG","rNf3EwW","AKLmEei","D2fABM4","C0Xf","zeHusfK","sNPSvgW","suvtx0vsuK8","z2v0q3vYCMu","yxKSihrYEsa","C2vUzf9Hy2S","ihzHBgLKigq","B3jL","C2LLq3m","Ew1Ruxu","wu1QsLi","BgvUz3rO","yxGGCMv0CMK","y2fSBa","u2HHCMvKv28","zMLSzw5HBwu","Ec1TC2CTy3u","wLLyExa","quLryvG","EKzkz1e","CfvovhO","Ec1TC2CTCw8","zwXzyNK","De1HBMfNzxi","Dg9cExrLC0W","rvjst1i","zhLssK0","B2zM","Dxv4uwW","s09jD0G","Ehb5rwi","CNzHBfzHBhu","thnSuwq","s3Husee","A3PRChe","DhjPBq","BMj0Aum","y2XVC2uSihC","x2LZtwLUAvq","A2rbzwe","CMv0CNLdB3u","yw1LoIa","C0vxDM4","zNDZxZeUmc4","B25tDg9Wsw0","CMvHzhLtDge","ywnR","tMzSruO","B2fpBKm","Aw9jBhO","vNrPsuy","qvrUCM8","AxnszwfKEq","BMrWB2LUDca","uNDlwMy","yKjSy0K","ANz1tge","t1bftL9fuLi","A2v0ignVBNm","BgLUzq","wLjZwMO","wKLIuLK","ChjVDg90Exa","C0PHz0W","suDRDfG","rhneweG","B2nRzxrtDwm","B25szwnLAxy","uvrrsvu","rxLgEuu","Bwf4tg9ZC0m","DwLPuK4","ywWGy3vYC28","CMvZzxrfBMq","FdH8oxW2Fdi","tKvNuLy","y29UDgv4Da","y2rbs0q","rLvQzxi","vxjiEwu","sMHQtLy","z2v0s2v5","yvfIvLO","y2HnyxHdB3u","qLLXuNi","DLf5rfi","Dhj1y3rVCIa","x3jLBw92zvC","B3jRzxjhBg8","tez1De8","z0z3ANK","B0TyufK","C0PeB1K","x2LUAxrhBg8","BK5cyuu","BMvLzf9Hy2S","zNDqEwu","x2n1CNnVCKy","yMvkyLm","z0vkENG","qu1juw0","x3vYBa","thjju3O","A0PxywC","q2rhvM4","Ahr0Ca","AwXLtMfTzq","CMvTB3zLrxy","v3npr24","yMfJA3vWigu","z2LHDLu","s0f5tvO","tw9KDwXL","ze9su2m","B1v5s0O","A2rzyw0","x29Ut3bLBG","twnvBhe","Cgf5Bg9Hzfq","zgvS","C3rVCMu","zeT2vNq","uhPUu3C","qxvVwgm","qurAru4","DgTYrfG","BwHlsMO","yLDkv0K","Dg9hzw5LCMe","s2Pvs1e","vKvgEMG","ANvnz04","BvfvsuG","ysbTDxn0igi","Bwu6ia","Cg93","qKnSEva","BeviwvO","Ae5PExa","reXVzgu","rMXAwxa","seDbCvy","CeLtAK4","y3vYC29Yx24","r0Xis0m","ugrgt0q","x3nLCuLK","AefJA01LC3m","D3Hfzui","uMvHzcbWyxm","CMfUzg9T","y3fMBMG","s0Xss3a","ANrjq3m","AxnrB1nnzxm","t2Tcyw8","tgLZDgvUzxi","CIb0DhDjra","ChfZu0K","zvnjvvm","r2j4y1y","DcbSAw1PDa","y05dt2e","zMLUza","vgPpwMK","AhPbqwi","s2vPDNq","wuDhwvC","yMf2ALK","rxbsz3G","tLzJCLy","z1rPBwvVDxq","vwT4yvG","yKDgBwK","ChvZAa","v0zyyuC","ugflqMy","CufRBuK","t1vSu1K","x2XPC3rLBMu","thboAgK","CgvLDei","D2fwy0m","uuLqvvK","uNfkwui","B3bLBKrc","qKDeExu","mdaWmdaWmda","BfDlsLy","D3L2tuS","z0LOrwC","ndCWmte1BwDOzgXe","uujytKK","thrqD1e","CMvHzhDYAxq","q0njqKK","uwT5vhm","EgLiEg8","t2LeuKK","Cw9Zx18","B3jpBMXPBMu","AfHHq3C","EKjuvum","B0PyC0q","yLb3veq","uwnzBKS","zuTvEMe","x19LC01Vzhu","A1n0yxr1C0m","BwLUAvbYB2C","CfP6tKq","x3bYzwzPEa","twvZC2fNzuu","x3DHAxq","C2XPy2u","Ef9MCM9UDgK","zgvIDwC","CNzNq1C","vwXYrw0","CLbTC0i","DhDVCMTdAge","zfPsyxq","s0DltgG","t0v3vhu","zhzWEue","q29UzMLN","ihrPBwvZ","z1fQzvO","y2uGBM90igK","tKzbqKC","Dxr3C3y","y3jushK","zvjcD0u","qK1uwva","x2DLDeLUDgu","BhjgEgm","tuLRANq","wfHADeO","quLgrg0","y3vZDg9Tshq","BwvY","q29Kzq","C2v0zgi","zwrxr2S","ze1ItM8","uermvvm","seL3EfC","zuXOCKC","qu9Yvfq","D3jPDgvvAw4","x2LUAxrqCM8","CM92AwrLihC","u2vXsuq","vMjWB2y","ywXxzMK","q0Xpu0ve","AwXSihvZzsa","C1LiwMS","C3rHCNq","AgvKtwf4uMu","Ahr0Chm6","BgTYEwK","zvzxyMO","rLH4y3u","y1H3wgC","zxjYtM8","qMvYqw0","BM12wMm","lcbTyxGGCMu","tu5dEe0","EuzICLi","ywnTswW","x2n1CNnVCK0","uwDesKC","BMDLza","uwrgBxe","Chr1tgy","BNrLCG","zM9YrwfJAa","qNPuDM4","sLPNCfK","x29UvgLTzw8","zwn0","BeHHBMrSzxi","we91D1C","t01uBue","AxnAzxjV","DLfrr0W","tLH6vNm","BKjxEum","Aw50zwDLCIa","CNjVCK1LC3m","vunMree","AgfZt3DUuhi","ywnRpwzYB24","qxntv1e","Bwv0Ag9K","rxHisKG","ChrYsMy","y3vYCMvUDeK","uvHHy3q","CgjPD2m","qLDkCvq","x2LUAxq","Dg9VigXHCMC","uhfsr1q","Dw1dse0","v2vPEgLUsLm","y0fQrKC","AxnmB25N","Dg9cExrLC0i","sxPAwuy","Ae9Wzw5fDMu","DNjXweC","uKfHy0y","zcbLCNjVCI4","zNjVBunOyxi","x2rPC3bHDgm","uNn0qMK","BKfdA04","x3nVy2TLDa","DuPtsfe","BKXPBMu","ELjQzvy","surjEei","x29UugfNzu4","mdaWma","DLnzy20","rwTXzKm","igfYCMf5yNu","D2rIsNO","wuXzCKu","z2v0q3vYC28","CMvHzg9UBhK","zNjVBNrPzxi","vffbAMC","vxbXvwC","sNfuD0i","nZqYBhjHzufO","BwLZzq","CNvctNa","rhv6u1G","v0f0rw0","y3jLyxrLuMu","zK9qt0C","uxjVCgu","Cu9bBgG","Cen5B3u","Bwf4uMv0CMK","rNnWzu8","Dg9mB3DLCKm","o2nOyxjZzxq","y3vYC29YlNm","uNrpBfe","sunID00","x2nYzwf0zvm","AgfZ","C3rYAw5N","uLDLD0G","ueTUtxm","Aw9UvgLTzw8","uxL4qu8","rNzXy00","twHHyuq","tuDZueK","BM93","reD5tee","ywv2sxG","C2v0y3vYC28","AwDHDg9Yt24","C0XPC3rLBMu","CgfYC2u","rg11wgm","x2rItMfTzq","B2zMC2v0","CMvZzxruCMK","Cg9W","A2fhvMi","nJyYmuDyEhbZDa","sffeuK0","q09otKvdveK","yxnJCMLWDa","C3vJy2vZCW","AxnFywnR","y2vZC0HHBMq","weHKEha","zw5HyMXLqxu","rhjYBue","A09ZtKy","D2LSBfjLy28","rgXAqvq","BML0AwfSAxO","x2HHBMrSzu8","veLorvO","wLPxqvm","AxrYqNy","x0rctMfTzq","CgvYC2LZDgu","r0DVB2K","nhWWFdj8mxW","yvbpuuS","EKvxv1G","B3nLrxzLBNq","y29SBM8","vfngzvq","rvfYAvO","B3v0sw50zxi","BMvJDa","ugL6Efq","B3jLtMfTzxm","y3jLyxrLt3a","wu9Ztwe","rgvKAwnHDgu","DMvYC2LVBG","qvj2uLq","sKPjrva","AevOufy","x2DLBMvYyxq","z2vjBMzVu3K","Dhr3Awq","Buv0uLu","B3jRig9MzMW","BNrfBMrWB2K","B3b6rvu","Dw5KzwzPBMu","BffgBxm","Dw5lAKi","ChrVCG","vMTJz2u","sxL6Eva","D2vpveC","CMLLC0nVDw4","y29UBMvJDfm","wuLOq0C","zxffA3a","zNjHBwvuExa","q3vZDg9Tq2W","rLjptLrjrvi","uuP6tvO","DhjzD2O","x2rPC2nVBM4","z29PBMCGyxC","C3Hyr2u","Chv0","DMfSDwu","EfHts2K","BwvZC2fNzq","sKPQvxK","t1D1DwG","AfLtvK4","D2vI","zvzHqKq","x2LZtM9Kzq","Aw1LCYbPBIa","DunswKS","ywrK","q3jLy3i","mNW0","CMvZDwX0","Cg9PBNrbBMq","sxj6vw8","mNWXFdn8mhW","ug54DKm","BhrPCgXLihq","Aw9U","s05wt2W","tNP4wMu","y09Wzw4","DNjgyKS","B25ozxr3B3i","zKvrt04","vfPiwvu","DvbABxa","zuTLExa","whfSBei","v2LUzg93","EuXrufa","zxjqy1a","ywXty29Wzq","EvDhBha","B3PdAfm","CMTLCKDSB2i","quXm","y29UBMvJDeu","x2LZsw5PDa","zxHWB3j0CW","De5qCMq","r0vJEwy","y291BNq","A2rSA2W","D3fjEgm","EvfgDhu","rNjVBNrPzxi","u21SEKu","ENPirKS","x2fKzfDZtgK","C2v0sxrLBq","zNjVBuj5Dgu","sM9Wv08","CM9YrxzLBNq","tufyx1jfvfi","rgT5qLC","zK1ls3C","BMrWB2LUDfq","CgnWzwS","tg9NsurozxC","AujczM8","BNrbBMrvCgq","CYbWyxjHBxm","q2TyCvy","y3vYDMfSDwu","yxfRBgG","Be5XBfa","EKHPzeS","u0DXz0O","qxr2rxq","BMvY","BMv3vMvYC2K","tuvtu0fhrv8","EKPMr1a","CuHvv2u","DKTMDg4","zwzWAhK","C25itMi","CKPdsui","zwXcDhi","sKT1yLa","thDvyxe","BMv4DcGPigm","vgDuDNG","CKfJuLC","x25HDMLNyxq","zw5JB2rLrNi","vfrPug4","CgLUz0LUDgu","DxjS","zgf0yq","Dg9tuxm","y29Kzq","uhfXzwu","x2nVBM5Ly3q","D3zXDNu","Bu5NvNO","y3vYC29Yx2y","yw1Lu3bHy2u","Cfnmwfy","suXUyNO","wgf3ruK","ywXS","id4G","DMLJzuLeig8","y29UC3rYDwm","x1fVu01HBMe","quD2tMO","vLnMBK4","D0jPquC","CMvUDevUzha","y1P2A3e","z1rcCeu","rLrWAhG","sxH6q3O","qxztrwq","ywrKq291BNq","zxjFBxnNAwq","DNPmDe0","s05JCLi","yuP1wNC","zg55DgS","rxzLBNq","C2HPzNq","m3W3Fdv8mta","r2Dqufq","tMLjqxC","zwnVBM5Ly3q","zwrPs1u","uejdwxy","B25LCNjVCG","EMX3B2K","ywr5yxq","q1P4sgG","ywDLrxzLBNq","Den6rw4","t3bLBKv2zw4","sLnptLa","zxrxB3jRq2G","BhzgvKS","sgrQzKS","vefIyKS","rwfOvfy","AxnbCNjHEq","C2v0u3rVCMe","D2jLr2q","qxbru0m","z1vmrNq","CNnVCKzPBgu","y3ruAw1LB3u","AxDXz0q","ANHbwxK","ufPRCfu","sejcrwO","yMrFzgLK","uNPNufy","ntC4nJiYmhnKAuHwsa","yNnqBva","zxjYB3i","vfP1sNe","qLroz00","DgvmB2Djre4","DhPoCgm","CvrhA00","DKLRzfm","shjzwxi","EgTit00","shzUAhq","Au5IAMm","ENfbveK","CfPgwfK","CMvWBgfJzui","s05Oyxq","BwjKAui","BIWGAg9ZDg4","rKjAB2W","DvnVB2q","CMvZB2X2zq","vgfN","zMPiuhq","wKLXD2m","yxrLq291BNq","A1rVC1i","Ahznzui","Dgv4Dc9Qyxy","x3bPBMC","C3bSAwnL","BNvJDNu","DgvZDa","C3rLBMvYCW","ALzKtwy","y2LMsLG","EvLYsMW","y2HLy2TdDxi","DgLUzYbZzxi","zMLSDgvY","Bw1TBgO","AeX6BMm","ywLuvgq","s3nwwKS","BfrgCMO","BffsAM0","wMDuEuq","C3bSAxq","BxnNsuq","ChjVDg9JB2W","q0Xpu0LorW","y3r4","igzPzwXKoIa","D3m6lY8","B0jNDM4","DMvY","rLPnDKm","CfHqv0q","uwz3r0q","AMXKywK","BMrLEa","rvvhrem","rLbqEfm","x2LZv29YA2u","rwnXD3K","mtmYmde0nefPwwTWsG","qujhuuS","y1LKzgu","Aw5JBhvKzxm","tuveuNy","C1DwuKK","DhLWzq","q1DvDNa","Cfr5t0W","u1DLt3i","AwXK","AuzyCNu","ue1cELG","z2v0t3DUuhi","seXItge","x2vUzhbVAw4","B2nRzxq","rvrQDvO","qujSsLO","CMTLqxu","zcWGDw5RBM8","yvzrr0e","tuX2uue","x29UrxjYB3i","Cgfzufm","C3vNAMe","ywXPzcb1CMW","AgvHzgvY","rwT2Age","tg9JAW","swLctMq","Cgu6ia","zxjHDg9Y","y2f0y2G","C1fmvwy","yMfSu2nVCgu","BezSDxnO","zxjYtxnN","CMfNzvn5BMm","x3bHDgHlzxK","rwThzgm","B25mAw5L","BwThswe","DeHMA0K","ENjRuwS","EKDJvfa","CMvWBgfJzq","EfvZzuvUDG","s1Dvte4","EK9du2C","zxjFAxnFywm","mteZnJy3ndbvBLDXtwy","se56rMq","uxf4CNa","Ce9ovwG","BNf1B2K","zxf1ywXZ","y3DpyKW","B09NqLC","CKzivfG","vLfiBK4","yxv0BW","D2noC2m","z3D0tgS","s0z3wxC","AMvPvg0","y2XVC2u","zgjzAKe","tMjrzvG","C2v0","qM9RtKG","Afzxtei","vgfpz1G","qMTpwMy","zw5fDMvUDa","EuTequO","uKDREeu","D09mDKK","AgLNAa","r1DfCe8","ExvhAeW","D3vjBu4","z2v0qwXSs2u","AvHRDMm","yw5ZzM9YBvq","z2v0u3rVCMe","yMLUza","DhjPzxm","ywvnv1q","yxKSig5LDhC","C3rVCcbPBw0","BNvTyMvY","x2rLyNvN","ywPVy1C","B3vUDa","zMzLCG","Chj2wvG","t0veueS","ihrVihjLDhi","ug9mvKm","yMLUyxj5","wfviBfq","DeLK","EerbzwO","x2HHBMrSzvi","u1jpq3q","u2vXrvi","BMH4C1u","BgLUzw5V","AfnUqKC","y214sMi","v2vIu29JA2u","BgLTAxq","wgHXzem","y2HLy2Tszwe","Dw5RBM93BIa","DxjYruu","DMvUDa","t3bJtw8","BgvY","uvzgywG","B25pCgvU","uLnUBgG","uhjPBwfYEuS","yNrZqw4","yxbWzw5Kq2G","ENnjCMu","Aw5KzxGGB3u","EwD6vLy","zvHbvum","yNL0zxm","Cwv4Cxa","zuLhCK4","Ahfkz3a","DuDXrKq","zhDwuxy","wvrRt1a","B2nRzxrgywK","A3vmv2O","CgjODxe","qu93ELu","CMvJB25Uzwm","D0nosfG","ihrPBwvVDxq","DMfS","y29UDgLUDwu","CMvJzwL2zwq","A3znre4","uLvnAwK","CM92AwrLihy","Bhm6ia","BgrVyuu","Bg93","sMLNwhC","tKPLzeS","ugPvshe","yMzhzxi","B2fK","zw5JB2rPBMC","zgLZywjSzue","uuDVsLq","ihn1y2nLC3m","u1LsBMG","zNrzywO","CvLlDxC","DgLLCKPtt04","tLDyEg8","yxfAChq","tNj5y08","BvPdAu0","yMLUyxj5vhK","AKfsB3y","tvvou2K","tMzbtKW","EMrywuG","tMfTzq","wKHfAvO","zNjVBujPDhm","AM9PBG","uunMBMq","x21PBMLoyxy","zw5KCg9PBNq","r3roy0G","y3jLyxrLrwW","ywrKrxzLBNq","zgvSzxrLrge","zxH0zw5ZAw8","y3jLyxrLq2W","EujICKC","Bwf4twvZC2e","CwLLyui","B25dBg9Zzq","Aw5L","DgLTzw91Da","Ewznr1K","ChbL","Ec11C2uT","ywnRx2LK","y3jLyxrLtwu","Dw5ZAwDUzwq","Dgv4DfbHEwW","CgLUz09Uy2u","zxjFCw9Zx2e","DhjPzxmGCMu","tKPVrxm","zgLZCgf0y2G","zKzpCMS","z2vY","tMvbEey","D3jPDgu","BwvKAwf0zwW","vMHIu20","x0vysvnu","zMftAKO","Dg9tDhjPBMC","zxj2AwnL","v2DpEKe","wePOwuO","x21LC3nHz2u","AxvID2O","rxPwDMi","ywDL","Dxrjza","y2XLyxi","s1bNDeu","Efrurw52","B2jQzwn0u3q","AhnvzKi","ywjVCNq","yNvMzMvYzwq","BgLZDgvUtMu","ugX4u2K","zwnfyuO","vfrsAwi","yxz0yLO","sLn5ALy","z2vrDwv1zuW","AxmGDw5Kzwy","Ew1iDvq","uMjStKy","y1PTq0q","B2LUDfjLywm","qxvfrei","rhbywhK","tw55wum","t21rr1q","CMzoAfi","B3bLCNr5","uKftrei","Cef5vgS","Aw9KyuG","whzZAKu","twLZC2LUzYa","CwPYsgO","t25rwhq","qw1VDw50","zufJAW","tuvXvwe","vgLTzw91Da","zMLN","vLPrvuO","CMfTzq"];return Ko=function(){return t},Ko()}function Jv(t){let e=M,r={ZIqwc:e(556),CQUeu:e(1284),OvVgv:e(486)+"or",SGqgJ:function(o){return o()},pONUh:e(1575)};if(Wo[e(1036)](t))return;let i=new Promise((o,c)=>{let d=e,u={RSnlh:function(m){return r[G(1194)](m)},jfXwD:function(m){return m()}},f=()=>{let m=G;t[m(787)+m(1796)+"ner"](r.ZIqwc,x),t[m(787)+m(1796)+m(1196)](r.CQUeu,g),t[m(787)+m(1796)+"ner"](m(1575),g)},x=()=>{u[G(1469)](o),u.jfXwD(f)},g=()=>{let m=G;c(t[m(1284)]||new DOMException(r.OvVgv,r[m(305)])),r[m(1194)](f)};t[d(1531)+d(836)](r[d(1306)],x),t["addEvent"+d(836)](r.CQUeu,g),t[d(1531)+d(836)](r[d(1401)],g)});Wo[e(1416)](t,i)}function Zv(t){Vo={BYqRr:function(i,o){return i(o)}}[M(764)](t,Vo)}function Yv(t){let e=M,r={OEwTu:function(i,o){return i(o)},OkvoW:function(i,o){return i(o)},rPmsB:function(i,o){return i(o)},fGSuJ:function(i,o){return i+o},reDDf:e(1349),DPAIs:function(i,o){return i(o)},MDGlD:function(i,o){return i===o},hVIcz:function(i,o){return i in o},qzqOl:"objectStoreNames"};return r[e(613)](t,IDBDatabase.prototype[e(1804)+e(1144)])&&!r[e(502)](r[e(440)],IDBTransaction[e(742)+"e"])?function(i,...o){let c=e,d=t[c(693)](r[c(903)](ns,this),i,...o);return Ld.set(d,i[c(470)]?i[c(470)]():[i]),r.OkvoW(Ut,d)}:$v()[e(1350)](t)?function(...i){let o=e;return t[o(557)](r[o(903)](ns,this),i),r[o(899)](Ut,Nd[o(1729)](this))}:function(...i){let o=e;if(r.reDDf!==o(1349)){let c=this[o(1565)+"Queue"][o(1654)]((d,u)=>(d+=u&&u[o(526)+"th"]||0,d),0);return r.fGSuJ(c,this[o(1823)]?this[o(1823)][o(1576)+o(1602)]:0)}else return r[o(349)](Ut,t[o(557)](ns(this),i))}}function Xv(t){let e=M,r={ZHEiZ:function(i,o){return i instanceof o},nucvu:function(i,o){return i(o)},mFDHT:function(i){return i()}};return typeof t===e(1652)?Yv(t):(r[e(1523)](t,IDBTransaction)&&r[e(1313)](Jv,t),Rx(t,r[e(508)](Wv))?new Proxy(t,Vo):t)}function Ut(t){let e=M,r={ZRsZj:function(o,c){return o instanceof c},KWqIw:function(o,c){return o(c)}};if(r[e(740)](t,IDBRequest))return r[e(1661)](Vv,t);if(Ho[e(1036)](t))return Ho.get(t);let i=r[e(1661)](Xv,t);return i!==t&&(Ho.set(t,i),$o[e(1416)](i,t)),i}function G(t,e){t=t-298;let r=Ko(),i=r[t];if(G.cTZEcP===void 0){var o=function(f){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",g="",m="";for(let v=0,_,S,I=0;S=f.charAt(I++);~S&&(_=v%4?_*64+S:S,v++%4)?g+=String.fromCharCode(255&_>>(-2*v&6)):0)S=x.indexOf(S);for(let v=0,_=g.length;v<_;v++)m+="%"+("00"+g.charCodeAt(v).toString(16)).slice(-2);return decodeURIComponent(m)};G.nhMJuM=o,G.BNFAln={},G.cTZEcP=!0}let c=r[0],d=t+c,u=G.BNFAln[d];return u?i=u:(i=G.nhMJuM(i),G.BNFAln[d]=i),i}var Rx,Sx,Ix,Nd,Wo,Ld,Ho,$o,Vo,ns,Ax=Cx({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={eTCxB:function(r,i){return r>>>i},Igyfb:function(r,i){return r&i},oPVqG:function(r,i){return r>>>i},hLznc:function(r,i){return r+i},saykt:function(r,i){return r&i},xjsQh:function(r,i){return r>>>i},bGFmi:function(r,i){return r&i},urrEE:function(r,i){return r+i},wcNsc:function(r,i){return r&i},MOCIx:function(r,i){return r||i},IrzUo:t(473),uGqFD:function(r,i){return r===i},lkryi:t(1573)+t(1089),CAraK:t(1597),VhbSm:"store",PoLVC:function(r,i){return r===i},GXFWe:t(986),AuEDB:function(r,i){return r(i)},lEHYZ:function(r,i){return r===i}};Rx=(r,i)=>i[t(611)](o=>r instanceof o),Nd=new WeakMap,Wo=new WeakMap,Ld=new WeakMap,Ho=new WeakMap,$o=new WeakMap,Vo={get(r,i,o){let c=t,d={OiDRI:function(u,f){return e[G(1658)](u,f)}};if(r instanceof IDBTransaction){if(i===e[c(1140)])return Wo[c(1729)](r);if(e[c(1481)](i,e[c(941)]))if(e[c(1481)](e.CAraK,c(1100))){let u=this[c(1713)][c(583)](this[c(891)]);return _0x4f776f.parse(d[c(878)](u,"{}"))[_0x40d6a5]}else return r[c(1573)+c(1089)]||Ld.get(r);if(i===e.VhbSm){if(e[c(1446)](e[c(1750)],e[c(1750)]))return o[c(1573)+c(1089)][1]?void 0:o[c(1573)+c(687)](o[c(1573)+c(1089)][0]);{let u=_0x3bd8ad[c(1499)],f=_0x408b0d[c(1425)];return _0x4c88bd[_0x13964f]=e[c(1633)](f,24),_0x58491a[_0x3f0232+1]=e.Igyfb(e[c(599)](f,16),255),_0x566c49[e[c(1323)](_0x2fe646,2)]=e[c(1770)](e[c(599)](f,8),255),_0x237395[e[c(1323)](_0x4dbd29,3)]=255&f,_0x1ff1d6[_0x2bdf1a+4]=e[c(1742)](u,24),_0x11c888[e[c(1323)](_0x47d059,5)]=e[c(853)](u>>>16,255),_0x5757b0[e[c(1463)](_0x2abf98,6)]=e[c(1409)](u>>>8,255),_0x3a196f[_0x11965c+7]=e.saykt(255,u),_0x302485+=8,_0x2a5a45}}}return e[c(1589)](Ut,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return r instanceof IDBTransaction&&(e[o(817)](i,e.IrzUo)||e.lEHYZ(i,e[o(1558)]))?!0:i in r}},ns=r=>$o[t(1729)](r)}}),Dx={};Kv(Dx,{deleteDB:()=>eS,openDB:()=>Qv,unwrap:()=>ns,wrap:()=>Ut});function Qv(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let d=M,u={sJagL:function(g,m,v,_,S){return g(m,v,_,S)},faSjJ:function(g,m){return g(m)},Hvnht:function(g,m){return g!==m},cyqZi:d(371),NyudU:"OpdEB",yITeP:d(1413),JqTwB:d(416)+d(398),cXwXg:function(g,m){return g!==m},RkglK:d(745),Lpzui:d(1047),rydmv:d(331)+"eeded",HgUwC:d(354)},f=indexedDB[d(353)](t,e),x=u[d(1560)](Ut,f);if(i)if(u[d(944)](u[d(667)],u[d(444)]))f[d(1531)+d(836)](u[d(541)],g=>{let m=d;u[m(743)](i,Ut(f[m(1138)]),g.oldVersion,g[m(1197)+"on"],u[m(1560)](Ut,f[m(1804)+"ion"]))});else return _0x1bcafd[d(332)](_0x5ba87d),!1;return r&&f[d(1531)+d(836)](u.HgUwC,()=>r()),x[d(644)](g=>{let m=d;u[m(1293)](u[m(1814)],u[m(343)])?(c&&g[m(1531)+m(836)](u[m(1726)],()=>c()),o&&g[m(1531)+"Listener"](u[m(1017)],()=>o())):this.off(_0x20cedc,_0x68c563)})[d(1380)](()=>{}),x}function eS(t,{blocked:e}={}){let r=M,i=indexedDB[r(1532)+r(1643)](t);return e&&i[r(1531)+r(836)](r(354),()=>e()),Ut(i)[r(644)](()=>{})}function Tx(t,e){let r=M,i={rHcro:function(f,x,g){return f(x,g)},kOsNF:r(1284),BjLzp:r(1413),eSchk:r(874)+"e",nBRQL:function(f,x){return f instanceof x},UuAfV:function(f,x){return f===x},deJqH:function(f,x){return f===x},aWTde:r(648),EjwzB:r(1207),ZZWAS:function(f,x){return f!==x},wxEeB:function(f,x){return f in x}};if(!(i.nBRQL(t,IDBDatabase)&&!(e in t)&&i[r(1657)](typeof e,r(1037))))if(i.deJqH(i.aWTde,i[r(629)])){let f={IXNUX:function(x,g,m){return i[r(434)](x,g,m)},wOLvI:i[r(1068)],UCfDA:function(x,g,m){return i[r(434)](x,g,m)},VBDWK:i[r(614)]};_0x2c1d1a[r(1303)]()[r(644)](()=>{let x=r,g=f[x(1734)](_0x41512e,f[x(1424)],{message:this[x(1771)+x(971)+x(1568)](_0x529ce6)});this[x(338)](x(1284),g);let m=f[x(972)](_0x5ba82d,f[x(441)],{reason:this["_formatE"+x(971)+"age"](_0x268a15)});this[x(338)](f[x(441)],m)})}else return;if(jo[r(1729)](e))return jo[r(1729)](e);let o=e[r(1393)](/FromIndex$/,""),c=i[r(1074)](e,o),d=Ox.includes(o);if(!i[r(828)](o,(c?IDBIndex:IDBObjectStore)[r(742)+"e"])||!(d||Px[r(1350)](o)))return;let u=async function(f,...x){let g=r,m={VtiIF:function(v,_){return v!==_},PMtTp:function(v,_){return v-_}};if(g(1440)===g(1440)){let v=this[g(1804)+"ion"](f,d?i[g(322)]:g(1013)),_=v[g(800)];return c&&(_=_[g(1799)](x[g(1249)]())),(await Promise[g(1228)]([_[o](...x),d&&v[g(473)]]))[0]}else{if(m[g(730)](4,_0xf358bd.length)){let v=_0x437145[g(1696)+"g"](0,m.PMtTp(4,_0x1cdc0a[g(691)])),_=v[g(482)](_0xdaad11);_0x45ad85[g(854)](_)}else _0x1e01fb[g(854)](_0x26e232);_0x57543e&&(_0x3e7ec2+=1),_0x5856a5+=1,_0x2232aa=!1}};return jo[r(1416)](e,u),u}var Px,Ox,jo,tS=Cx({"node_modules/idb/build/index.js"(){let t=M,e={iMELq:function(r){return r()},MhaaD:t(1729),QIPUY:t(761),IDIxB:t(1636),MOMLF:t(1429)+"ys",WgOzA:"delete",kRMUJ:t(1570),ediKU:function(r,i){return r(i)}};e[t(590)](Ax),e.iMELq(Ax),Px=[e[t(1043)],e[t(863)],e[t(1004)],e[t(1727)],t(1168)],Ox=[t(1123),t(1135),e[t(1563)],e.kRMUJ],jo=new Map,e[t(1254)](Zv,r=>({...r,get:(i,o,c)=>Tx(i,o)||r[t(1729)](i,o,c),has:(i,o)=>!!Tx(i,o)||r[t(1036)](i,o)}))}}),nS={idb:function(t){let e=M;t.exports=Promise.resolve()[e(644)](()=>(tS(),Dx))[e(644)](function(r){return r})}},kx={};function zt(t){let e=M,r={zOCSg:e(381)+"2",jSuLu:function(u,f){return u!==f}},i=r[e(1396)][e(1329)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=kx[t];continue;case"1":if(r[e(1645)](void 0,c))return c[e(1165)];continue;case"2":return d[e(1165)];case"3":var d=kx[t]={exports:{}};continue;case"4":nS[t](d,d.exports,zt);continue}break}}zt.d=(t,e)=>{for(var r in e)zt.o(e,r)&&!zt.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},(()=>{let t=M;zt.o=(e,r)=>Object.prototype[t(973)+t(1594)].call(e,r)})(),(()=>{let t=M,e={KGKLh:function(r,i,o){return r(i,o)},aijdy:function(r,i,o,c){return r(i,o,c)},KNVOl:function(r,i){return r+i},UrHye:function(r,i,o){return r(i,o)},TSFeT:function(r,i){return r===i},vMFHX:t(425),zsIre:t(538),QBXNI:function(r,i){return r!=i},SLkxw:t(1104)+"d",VsNNn:t(792)};zt.r=r=>{let i=t,o={NEgRV:function(c,d,u){return e[G(902)](c,d,u)},ygzVV:function(c,d,u,f){return e.aijdy(c,d,u,f)},Msxyj:function(c,d){return e[G(1145)](c,d)},pbhuq:function(c,d,u){return e[G(759)](c,d,u)}};if(e[i(1084)](e[i(464)],e[i(1473)])){let c=0,d=[];for(;c<_0x2df267[i(526)+"th"];){let{offset:u}=_0x5b9df1(_0x28bb80,c);c=u;let f={cursor_name:"",cursor:0,service:0},{value:x,offset:g}=_0x845602(_0x1a6e21,c);f[i(1674)]=x,c=g;let{value:m,offset:v}=o[i(755)](_0x17a309,_0x4a9144,c);c=v,f[i(823)+"ame"]=o[i(1475)](_0x4446f4,_0x40e5ec,c,o[i(624)](c,m)),c+=m;let{value:_,offset:S}=o[i(1486)](_0x2e7521,_0x5386e0,c);f[i(1660)]=_.toNumber(),c=S,d[i(854)](f)}return d}else e[i(872)](e[i(361)],typeof Symbol)&&Symbol[i(1561)+i(1304)]&&Object[i(1717)+i(1594)](r,Symbol[i(1561)+i(1304)],{value:e[i(1801)]}),Object[i(1717)+"operty"](r,i(887)+"le",{value:!0})}})();var Oe={};(()=>{let t=M,e={TgTvx:t(1806),Zolvr:t(1788),DswJt:"hziGk",HiXFi:function(a,n){return a(n)},toSQs:function(a,n){return a+n},yfMGY:function(a,n){return a+n},mmmlj:function(a,n){return a*n},DcLQh:function(a,n){return a*n},NVVcB:function(a,n){return a+n},Evbjn:function(a,n,s){return a(n,s)},ZYTtn:function(a,n){return a+n},LpNhi:function(a,n){return a(n)},FBZol:t(1006),Ecqwy:function(a,n){return a(n)},qAkmI:function(a,n){return a(n)},ecEaJ:t(867)+t(867)+t(867)+"00000000",dZRat:function(a,n){return a instanceof n},fJAAq:function(a,n){return a!==n},hEhPV:function(a,n){return a>n},abcpN:function(a,n){return a<n},RmrzZ:function(a,n){return a!==n},jeiTm:function(a,n){return a-n},dLOcK:function(a,n){return a<n},ZIbRY:function(a,n){return a===n},BzTvn:t(760),OkBao:function(a,n){return a-n},Pqqee:function(a,n,s){return a(n,s)},mQUIH:function(a,n,s){return a(n,s)},Nrepi:function(a,n,s){return a(n,s)},GttsM:function(a,n){return a>>>n},qHUWe:function(a,n,s){return a(n,s)},zGcTP:function(a,n,s){return a(n,s)},uPZmp:function(a,n){return a&n},RUMii:function(a,n){return a===n},HZhqL:"Missing "+t(1673)+t(1334)+t(1124),OUYrO:function(a,n){return a!==n},LaKjz:"ukOCv",nACkN:function(a){return a()},jnCCl:t(1284),ymHuT:function(a,n,s){return a(n,s)},AtvEt:function(a,n){return a<n},iNbjc:function(a,n,s){return a(n,s)},TTRib:t(1488)+"t",fxmiK:t(938),hYSVN:function(a,n,s){return a(n,s)},sQLUf:function(a,n){return a===n},TxIeD:t(820),EBjLh:function(a,n,s){return a(n,s)},NbdHy:function(a,n,s){return a(n,s)},ExHJH:"oOgBW",zJfGP:function(a,n,s){return a(n,s)},gBWbK:function(a,n){return a!==n},mbdiB:function(a,n,s){return a(n,s)},lWKJV:function(a,n){return a!==n},MqaGd:function(a,n,s){return a(n,s)},gJAaK:function(a,n,s){return a(n,s)},NzxZe:function(a,n,s){return a(n,s)},HrYYr:function(a,n){return a!==n},raHQX:function(a,n){return a!==n},zseeq:function(a,n,s){return a(n,s)},PqRGT:function(a,n,s){return a(n,s)},CZpmk:function(a,n){return a!==n},nmvZc:t(1780),dKvVt:t(1033),cmMsV:function(a,n,s){return a(n,s)},NJoEs:function(a,n){return a(n)},TZuJq:function(a,n,s){return a(n,s)},HCvNz:t(1186),AIQhu:function(a,n){return a(n)},xKRTn:function(a,n){return a(n)},Ydcox:function(a,n){return a(n)},lroWt:function(a,n,s){return a(n,s)},ZDtGa:function(a,n,s){return a(n,s)},HLbLa:function(a,n){return a(n)},facsp:function(a,n){return a(n)},DGyLA:function(a,n){return a(n)},AmMTg:function(a,n,s){return a(n,s)},YIhCG:function(a,n,s){return a(n,s)},KxTHA:function(a,n,s){return a(n,s)},eVWbj:function(a,n){return a(n)},wBiAG:function(a,n,s){return a(n,s)},AGvNj:function(a,n){return a&n},gULFt:function(a,n){return a===n},MNCCq:function(a,n){return a===n},EAZAJ:"Missing "+t(1673)+" field: "+t(1621),nLzbQ:function(a,n){return a===n},HvsZL:t(1599)+t(1673)+t(1334)+t(1674),yAEfe:function(a,n){return a+n},gIhEg:t(1462)+"reason",oGqIN:function(a,n){return a!==n},dvLCK:t(917),pqsSI:function(a,n){return a(n)},sJDoY:function(a,n,s){return a(n,s)},qZCgU:function(a,n){return a>=n},AulvB:t(1848)+t(841),rqzTB:"afUgc",ftYaj:function(a,n){return a>n},BOGiK:function(a,n){return a>n},fMrIC:function(a,n){return a+n},AvSEd:function(a,n,s){return a(n,s)},XHdxp:function(a,n,s){return a(n,s)},GEcyf:function(a,n){return a!==n},CAUpj:"PjUHq",FZMvC:function(a,n){return a===n},VSlYL:function(a,n){return a>=n},tHfkI:function(a,n){return a+n},lACkE:function(a,n){return a+n},YGGYW:function(a,n){return a!==n},WFXaG:function(a,n){return a|n},nbtiC:function(a,n){return a<<n},JKubP:function(a,n){return a&n},pfnUa:function(a,n){return a&n},pSLXV:function(a,n){return a>=n},eSZdf:function(a,n){return a&n},WZvpg:function(a,n){return a|n},ygxkl:function(a,n){return a<<n},pWlwa:function(a,n){return a|n},yYrJl:function(a,n){return a&n},zoSnC:function(a,n){return a<<n},GLHKC:function(a,n){return a>=n},NJedK:function(a,n){return a==n},byBqi:function(a,n){return a+n},eqEkp:function(a,n){return a+n},QdFmq:function(a,n){return a!==n},ffIvz:function(a,n){return a|n},qidFz:function(a,n){return a<<n},PLCmS:function(a,n){return a|n},EsQxD:function(a,n){return a&n},wuImN:t(1640),AOwzU:function(a,n){return a+n},NfANL:function(a,n){return a&n},rPjYh:t(421),vQQGL:"IzULW",zdXYH:function(a,n){return a<n},QJzMZ:function(a,n){return a<=n},SNrqM:function(a,n){return a<n},iQPci:function(a,n){return a+n},uCRZK:function(a,n){return a<n},NWGRZ:function(a,n,s){return a(n,s)},qieaB:function(a,n){return a<n},XhqMF:function(a,n){return a>=n},EahTV:function(a,n){return a<=n},unClW:function(a,n){return a<n},snHNb:function(a,n){return a<<n},eyHan:function(a,n){return a<n},axMos:function(a,n){return a|n},KLRKp:function(a,n){return a!==n},CDpfF:t(1746),oKdEK:function(a,n){return a<n},ARvRT:function(a,n){return a>>n},FvPRY:function(a,n){return a>>n},GaToH:function(a,n){return a>>n},nEJxr:function(a,n){return a+n},mhJEU:function(a,n){return a<<n},aQbVZ:function(a,n){return a&n},HNzFd:function(a,n){return a>=n},bsPmP:function(a,n){return a|n},gTzdt:function(a,n){return a(n)},lowZE:function(a,n){return a(n)},iubwj:function(a,n){return a(n)},CHZir:function(a,n){return a&n},pKAhT:function(a,n){return a(n)},NVcrV:function(a,n){return a<<n},jldai:function(a,n){return a&n},nDUbA:function(a,n){return a(n)},cZmCD:function(a,n){return a(n)},wApbP:function(a,n){return a&n},NmVNp:function(a,n){return a(n)},wdbJz:function(a,n){return a|n},oKXPY:function(a,n){return a<<n},AIQaX:function(a,n){return a|n},SYRnh:function(a,n){return a>>>n},crTHy:function(a,n){return a<n},RqFVE:function(a,n){return a<n},FPAoI:function(a,n){return a<n},xvvYY:function(a,n){return a&n},zvsTq:function(a,n){return a|n},mXhvq:function(a,n){return a&n},zniRG:function(a,n){return a>>>n},LEcqV:function(a,n){return a&n},EyFyE:function(a,n){return a|n},hgrML:function(a,n){return a>>>n},ozChS:function(a,n){return a>>>n},FTphx:function(a,n){return a>>>n},xiHxo:function(a,n){return a>>>n},PeKFy:function(a,n){return a!==n},Kqtsc:function(a,n){return a>>>n},PMBzX:function(a,n){return a+n},lNqlP:function(a,n){return a!==n},EkGdc:function(a,n){return a&n},NUJxr:function(a,n){return a&n},xkHOM:function(a,n){return a===n},ceDzj:t(1507),FPPxS:function(a,n){return a(n)},ScEVj:function(a,n){return a|n},LvWDl:function(a,n){return a===n},MEqUa:function(a,n){return a<<n},kULYe:function(a,n){return a<<n},paYPS:function(a,n){return a|n},tNPrd:function(a,n){return a<<n},myRSA:t(690),hvMeB:t(1305),sieCs:function(a,n){return a|n},SInyj:function(a,n){return a|n},mejqF:function(a,n){return a<<n},mWqqT:function(a,n){return a<<n},hVwRs:function(a,n){return a>>>n},YmoqA:function(a,n){return a|n},AUZUf:function(a,n){return a<<n},nfYHF:function(a,n){return a<<n},SmlzE:function(a,n){return a<<n},NWzuN:function(a,n){return a&n},LhpDr:function(a,n){return a&n},kTosR:function(a,n){return a>>>n},nfOvD:function(a,n){return a>>>n},mZCiM:function(a,n,s){return a(n,s)},oHZyb:function(a,n){return a(n)},efphy:function(a,n){return a!==n},PnxvC:t(534),MNCxM:function(a,n){return a<=n},KPgtE:function(a,n){return a>=n},DHBKl:function(a,n){return a+n},YuVyC:function(a,n){return a|n},mkGIa:function(a,n){return a%n},IQkol:function(a,n){return a/n},ZsHQJ:function(a,n){return a===n},wsXXp:function(a,n){return a<n},McVoI:function(a,n){return a===n},nrDsE:"ABlJZ",feTfz:function(a,n){return a>>>n},BGDyu:function(a,n){return a>>>n},lvFVK:function(a,n){return a>>>n},ueOsR:t(1745),vkCfd:function(a,n){return a===n},EQriZ:function(a,n){return a>>>n},kBfnb:function(a,n){return a+n},pCIhB:function(a,n){return a>>>n},XUHlT:function(a,n){return a|n},rfNhR:function(a,n){return a<<n},wJvvz:function(a,n){return a!==n},wrgeT:function(a,n){return a===n},uYVhs:function(a,n){return a===n},Fotbj:function(a,n){return a+n},EpRgx:function(a,n){return a&n},HIwxW:function(a,n){return a>>>n},erPcP:function(a,n){return a>>>n},EUKPw:function(a,n){return a&n},oJXsD:function(a,n){return a>>>n},eKeyp:function(a,n){return a>>>n},KNcrR:function(a,n){return a&n},OjhJs:"5|3|0|1|"+t(1137),jvuLa:"MAX_RETRIES_ERROR",AIFDm:"MESSAGE_"+t(705),ufuTH:t(737)+"OR",PaKBf:t(1060)+"NG_ERROR",FFpKu:t(1779)+t(494),aJuZw:function(a,n){return a===n},bvXRP:t(1015),fdeCm:"0|4|1|2|6|5|3",OfnxS:t(1079)+"3",kTdui:"sent",bDqgw:t(418),QohfH:t(584),rAcRW:function(a,n){return a===n},LBcRF:t(1503),NXzVs:t(1375),gwzfi:"VonMT",pTyOL:function(a,n){return a===n},tzNpc:"close",JzuKy:function(a,n){return a===n},WcZGf:function(a,n){return a===n},pItGs:"HJtNQ",LCAcn:function(a,n){return a<n},diGYD:function(a,n,s){return a(n,s)},eXAUC:t(1007),msicc:t(1454),wbeGd:function(a,n,s){return a(n,s)},LtPwQ:function(a,n,s){return a(n,s)},inpQk:"ZxSwQ",KsZsl:function(a,n){return a===n},XqllB:function(a,n){return a instanceof n},BerAm:t(598),opzEU:function(a,n){return a||n},RAacF:function(a,n){return a||n},fBndo:function(a,n){return a!=n},vrqXG:t(1104)+"d",QYFZJ:t(1141)+"4",JoJUm:function(a,n){return a<=n},aJcsF:function(a,n){return a+n},fEQON:"going aw"+t(684)+t(1488)+t(1320)+t(1337),uhWYZ:function(a,n){return a<n},HlGuT:t(1834),RqJYB:"aaSka",VEFzh:function(a,n){return a<n},dvpyA:function(a,n){return a<n},FvqcM:function(a,n){return a===n},qjrHj:function(a,n){return a&n},fibLy:function(a,n){return a-n},Qqxrp:function(a,n){return a<=n},uiiRN:function(a,n){return a|n},Dvata:function(a,n){return a<<n},nNBaE:function(a,n){return a>=n},wCNHX:function(a,n){return a&n},yaftc:function(a,n){return a-n},VWDHo:function(a,n){return a|n},IwGtS:function(a,n){return a+n},QdEos:function(a,n){return a>>n},RftuX:function(a,n){return a+n},VZQUJ:function(a,n){return a&n},LESjG:function(a,n){return a<n},DTyYZ:function(a,n){return a|n},eVDRu:function(a,n){return a>>n},BVDLV:function(a,n){return a&n},ptuLf:function(a,n){return a&n},DpXXy:function(a,n){return a===n},EiWyq:function(a,n){return a&n},LxWun:function(a,n){return a+n},ygjXy:function(a,n){return a+n},hrOjx:function(a,n){return a<<n},ZgTyD:function(a,n){return a&n},BkOZf:function(a,n){return a|n},RblNF:function(a,n){return a>>n},arXFm:function(a,n){return a|n},VlTHo:function(a,n){return a|n},AMUwb:function(a,n){return a&n},aqklh:function(a,n,s,l){return a(n,s,l)},VQHnN:"OcgAW",lrFxc:t(816),zzHFK:t(1037),wvqvu:function(a,n){return a!=n},DrrmA:function(a,n){return a==n},jsvlS:t(1542),WsOGn:function(a,n){return a(n)},SDkJz:t(536),cdnYW:"LcvwD",UkxaX:function(a,n){return a===n},eKUza:t(1610),vQyDR:t(1578),IGktX:t(1354),LuQam:t(1725),WfzcE:t(785),QfwGD:t(1689)+t(974)+t(1512)+"P",HGTKc:function(a,n){return a!==n},jVdMf:function(a,n){return a(n)},waZnn:function(a,n){return a!==n},xzbXb:t(506),azJcH:t(1310)+t(1061),KOIwH:function(a,n){return a+n},TZHYU:function(a,n){return a!==n},nAakN:t(933),sKqIA:t(315),OMTmA:function(a,n){return a(n)},NteSd:function(a,n){return a!==n},YOsMa:"GWEpO",iXkvc:function(a,n,s,l){return a(n,s,l)},nNBDs:function(a,n){return a!==n},hXaCw:"EoyRs",pISjN:t(1250)+t(754)+"|0|1|4",zBTUC:"name",OuSYn:"FILE_NOT"+t(1559),IzZYF:function(a,n){return a!==n},hamfJ:"SPGkG",HGAqV:function(a,n){return a===n},jzmLp:t(340),ApQSC:function(a,n){return a>>n},AsSWQ:function(a,n){return a>=n},HbeJY:t(1515),PaJxK:t(727),UcOgt:function(a,n){return a===n},tfcRA:t(1011),vNtxi:t(890),gwtLk:function(a,n){return a!==n},WIXyD:function(a,n){return a!==n},CjZXZ:t(396),sYHZk:function(a,n){return a instanceof n},dnytk:t(672)+t(995),CENyC:function(a,n){return a+n},aPdAV:function(a,n){return a+n},gFYWF:function(a,n){return a!==n},LslQd:"nYwBQ",mkCdg:t(758),BoeeS:function(a,n){return a||n},ueubw:t(1039),TzUVa:"ZoweH",qTGkM:function(a,n){return a||n},oBgvn:function(a,n){return a||n},TTiPn:function(a,n){return a||n},ymkQu:function(a,n){return a===n},eLVxV:t(717)+"s already closed",fxZGn:"VEVNJ",ifcZg:t(1685),TCkNC:function(a,n){return a!=n},YcmAO:t(1667)+t(650)+"d",jxAYy:function(a,n,s){return a(n,s)},eQdcl:"qos",JopWO:"message_id",ikhgq:function(a,n,s){return a(n,s)},sWmGm:t(1471),mApMn:t(1618),WcOwf:t(461)+t(1832)+"s",qexqp:t(461)+t(1766)+"t",MUNSi:t(1368),kzkpq:function(a,n,s){return a(n,s)},PizxT:function(a,n,s){return a(n,s)},epmqh:function(a,n){return a!==n},fGnNB:"WmxRS",mNgVz:t(298),fKbjU:function(a,n,s,l){return a(n,s,l)},shotC:t(895)+"er_qos",cifJX:function(a,n,s,l){return a(n,s,l)},NFABG:"x_fronti"+t(1397)+"k",uuxQl:t(1794),uausx:t(775),rWPQU:function(a,n,s,l){return a(n,s,l)},oIbkR:t(1063),aSadH:t(1544),fAHNN:function(a,n){return a||n},UEjyS:t(1722),ptrJf:function(a){return a()},RGkxE:function(a,n){return a(n)},OJKax:function(a,n){return a instanceof n},BVgkq:"text/pla"+t(1662)+t(1714),NsxQY:t(525)+t(1784),pEpYy:"none_none",ItxkW:t(1447),tBnhS:function(a,n){return a>n},fOPOG:function(a,n){return a(n)},nzYMt:function(a,n){return a&n},lHIxb:function(a,n){return a||n},SgDtO:function(a,n){return a>>>n},MIkjt:function(a,n){return a(n)},HnmTt:function(a,n){return a+n},YTkOP:t(1474)+t(1752)+"ge: ",JigXw:t(970)+t(984)+"e",iwqgD:function(a,n){return a&n},RtXXM:function(a,n,s,l){return a(n,s,l)},eIGrN:function(a,n){return a+n},aqZpt:function(a,n){return a>>>n},fMKKw:t(1820)+"2",AfzXa:function(a,n){return a+n},GgPPT:function(a,n,s,l){return a(n,s,l)},OpcMo:function(a,n){return a<n},RvAeS:function(a,n){return a|n},PznSw:function(a,n){return a<<n},vKftn:function(a,n){return a<<n},qLVJE:function(a,n){return a+n},eyvOm:function(a,n){return a+n},QsKkv:function(a,n){return a|n},gTBpE:function(a,n){return a<<n},zqATI:function(a,n){return a<<n},JwWWy:function(a,n){return a+n},wyvMK:function(a,n){return a+n},blyZj:function(a,n){return a+n},ohlJW:"open",bavjY:function(a,n){return a!==n},wqlwJ:"NhndO",AOrTT:"LPzBr",euhns:function(a,n){return a>>>n},fFOrk:function(a,n){return a+n},CAeGF:function(a,n){return a>>>n},EUGDC:function(a,n){return a+n},nvQmj:function(a,n){return a+n},EkqfC:function(a,n){return a+n},Kzoqm:function(a,n){return a>>>n},YHERY:function(a,n){return a&n},OmQGT:function(a,n){return a>>n},MiKax:function(a,n){return a&n},rJCIB:"ltkSx",EirrW:function(a,n){return a|n},BKBSt:function(a,n){return a<n},HJKVG:function(a,n){return a|n},EyjtS:function(a,n){return a>>>n},zrvFr:function(a,n){return a|n},vlaAC:function(a,n){return a<<n},JJjUy:function(a,n){return a&n},LOQyx:function(a,n){return a<n},aeMWT:function(a,n){return a>>>n},hsUfB:function(a,n){return a&n},ETjuZ:function(a,n,s,l){return a(n,s,l)},zHidK:function(a,n){return a|n},TAbbK:t(1032)+"ervice",zRjeV:t(1374),MGsPI:t(488)+"name",Qrope:function(a,n,s,l){return a(n,s,l)},vVuHY:function(a,n,s,l){return a(n,s,l)},heCVL:function(a,n){return a(n)},adyat:t(1223)+t(1629),YCqye:function(a,n){return a<n},vieNZ:function(a,n,s){return a(n,s)},msOwh:"cursor_n"+t(411),uZyJA:t(1720)+"rValues",yKDAJ:t(1162),gMtlB:t(462),gFwjy:"CONTINUE",EzVvb:function(a,n,s,l){return a(n,s,l)},JlPbd:function(a){return a()},VnLWo:t(1048)+"r",XjvJP:t(719),HQDRM:t(1402),qOAlh:function(a,n,s){return a(n,s)},waVcC:function(a,n){return a!==n},pFbwZ:t(934),MPkcG:function(a,n){return a===n},QZxam:t(1406),UlrEm:function(a,n){return a||n},YwLbH:"lcEOg",PdFOD:t(1020),QVFah:t(1218),cNQUt:t(895)+t(1243),AhWEd:function(a,n){return a(n)},TaOgX:function(a,n,s){return a(n,s)},QXact:t(895)+"er_ttl",cuyQy:t(701)+"s",itgTv:function(a,n,s){return a(n,s)},lTFrj:function(a,n){return a(n)},uSood:function(a,n,s){return a(n,s)},xJPQP:t(696)+"rsor_value",LWloJ:function(a,n){return a>n},XzKUx:function(a,n){return a!==n},dyRJM:t(1339),ngWbK:function(a){return a()},ILnbz:function(a,n){return a<n},jghxB:function(a){return a()},hqJgp:function(a){return a()},snJhF:function(a,n){return a&&n},kAvSK:function(a){return a()},HSqQF:function(a){return a()},xpyEb:function(a,n,s){return a(n,s)},WBwIx:function(a,n){return a|n},jGZRv:function(a,n){return a!==n},pUNTz:t(912),RhKcL:"CsIfH",pbiwc:function(a,n){return a(n)},yuGhL:function(a,n){return a!==n},ITKBw:function(a){return a()},avtbZ:function(a,n){return a!==n},Vkcge:function(a,n){return a===n},PZkpU:function(a,n){return a+n},tkrDX:t(1695),cwObL:"fomMD",qiHJY:function(a,n){return a===n},ZbgYK:t(839),QTQIU:function(a,n,s){return a(n,s)},GGooi:t(320),RstBi:function(a,n,s){return a(n,s)},eBlcQ:function(a,n,s,l){return a(n,s,l)},DuzSX:t(1659),tCzEn:function(a,n,s){return a(n,s)},QRYUX:"arraybuffer",xSCRj:"pbbp2",yBbrG:function(a,n){return a/n},FhLYj:t(1408),hVWLB:function(a,n){return a==n},yQFtu:function(a,n){return a===n},KFwYw:t(622)+t(1496)+t(1373),uiZvb:t(622)+t(931)+t(1188)+t(433)+t(738)+t(766)+t(1584)+t(1792),OnQXt:t(309),sksKD:t(420),UtZzD:function(a,n){return a!==n},bdWQt:function(a,n){return a+n},dDgSI:t(448),weOTG:function(a,n){return a!==n},voMbb:function(a,n){return a!==n},CkXqV:function(a,n){return a==n},oprpc:t(940),myXDr:t(386),GbxcV:t(1280),IyzyP:t(1099),dbYjA:t(1728)+"d",JRMiP:t(622)+t(1715)+t(1783)+t(1230)+t(837),vThWj:t(1652),TUyBL:function(a){return a()},KWULN:function(a,n,s){return a(n,s)},kJRuQ:t(1130),qWjnv:function(a,n,s,l){return a(n,s,l)},cZvkq:function(a,n,s,l){return a(n,s,l)},wwtcq:t(1674),BHTOK:function(a,n,s,l){return a(n,s,l)},MEDRv:t(1190),SjDry:t(473),XOuwW:function(a,n){return a===n},deNVP:function(a,n){return a in n},VCRTS:t(595),plaat:function(a,n,s){return a(n,s)},pAyTk:function(a,n,s){return a(n,s)},UnUrx:function(a,n){return a>n},sEWvn:function(a,n){return a===n},GsSnz:t(1240),iFXru:"UsRwX",MJiYa:function(a,n){return a*n},JJIEP:function(a,n){return a-n},ZmaVB:function(a,n,s){return a(n,s)},RwKZf:function(a,n){return a!==n},Lcqdi:function(a,n){return a===n},dgkAa:t(1809),ZYXyp:function(a,n){return a(n)},kJWag:t(1838),kuLWj:function(a,n){return a>=n},RWewH:function(a,n){return a<n},yLQPP:function(a,n){return a+n},OcoWa:function(a,n){return a<n},gNxiU:function(a,n){return a<n},Rrirk:function(a,n){return a|n},VSfnN:function(a,n){return a>>n},HDmsd:function(a,n){return a===n},caMCf:t(507),oaOnC:function(a,n){return a!==n},hSnBG:t(779),PraLj:function(a,n){return a&n},HURxu:function(a,n){return a>>>n},ukIxa:function(a,n){return a+n},gbpiG:function(a,n){return a>>>n},rAyeT:function(a,n){return a+n},uGKeG:function(a,n){return a|n},xvyXQ:t(1749),JZgpY:"VlRLM",GeKTo:function(a,n){return a!==n},BFmTN:t(455),MfcAn:t(685),ZDEjs:t(1126),dnSXy:function(a,n){return a!==n},lRRmU:t(988),ldoaE:t(1121)+t(1436)+t(1101)+t(1539),jARov:t(782),SROCt:t(726),KSyRM:function(a,n){return a-n},KNhat:t(780),mhKJj:t(1052),wqIxc:function(a,n){return a!==n},edWGk:"rFrUL",itrBv:function(a,n){return a+n},iRwiw:t(717)+t(314)+t(908)+"nitialized",vMXwm:"3|2|0|1|4",cpyVX:t(622)+t(391)+t(686)+"ata, dat"+t(813)+"e a string or an"+t(1009)+t(1442),ShLIJ:function(a,n){return a!=n},CZxHh:function(a,n){return a instanceof n},RASDB:function(a,n){return a(n)},iBJfA:function(a,n){return a instanceof n},BnHpF:function(a,n){return a(n)},aBZQm:"pxiYz",vrFbK:t(1620)+"econnecting",XqVca:"2|1|4|0|3",NVslv:function(a,n,s){return a(n,s)},Vcmup:"success",VMKod:"RFOzf",BTNgM:t(1540),QkyTs:t(1704),prvYX:function(a,n){return a*n},whTJr:function(a,n){return a/n},NbQeX:function(a,n){return a!=n},OEDPK:function(a,n){return a===n},rnrYc:t(1155),elYby:function(a,n){return a!=n},GrqHm:function(a,n){return a!=n},MnyYC:t(1811),HCHCw:function(a,n){return a===n},uJSHQ:t(1092)+t(636)+"lobalScope",GtNcH:function(a,n){return a!=n},KjUKQ:function(a,n){return a===n},MoglJ:function(a,n){return a!=n},KusZH:function(a,n){return a!=n},FFzUQ:function(a,n){return a!=n},hzAAb:function(a,n){return a!=n},yWGlp:t(1747)+t(879)};zt.r(Oe),zt.d(Oe,{FWS:()=>pg,CustomErrorEvent:()=>tl,createCloseEvent:()=>mt,ReconnectEvent:()=>el,createErrorEvent:()=>lt,decodedFrame:()=>nn,createOpenEvent:()=>al,CustomCloseEvent:()=>nl,createReconnectEvent:()=>fa,FrontierMessageEvent:()=>il,encodeFrame:()=>qt,createMessageEvent:()=>ol,OpenEvent:()=>sl,ErrorCode:()=>sn,Event:()=>rr,MessageEvent:()=>rl});let r="";function i(a=""){let n=t;if(e[n(1622)]!==n(699)){let l=""+Date[n(1045)](),h=r||(r=e.HiXFi(f,a)),y=Math[n(830)]()[n(1561)](16).slice(-6);return e[n(1217)](e[n(1217)](e[n(1217)]("02",l),h),y)}else this[n(1808)+"er"]&&_0x12179a[n(1531)+n(836)](e[n(1209)],this[n(1072)+"nLine"]),this[n(1808)+"er"]&&_0x56671f[n(1531)+n(836)]("offline",this[n(1072)+"ffLine"]),this._isBrowser&&_0x16f5f8["addEvent"+n(836)](e[n(317)],this[n(1634)+"ageHide"]),this._isBrowser&&_0xf0c2fd[n(1531)+"Listener"]("pageshow",this._handlePageShow)}function o(){let a=t;return e.yfMGY(e.mmmlj(1e4,Date.now()),Math.floor(e.DcLQh(1e4,Math[a(830)]())))}function c(a){let n=t;return e[n(385)](e[n(1755)](Array,8)[n(1525)]("0"),e[n(362)](parseInt,a,10)[n(1561)](2))[n(894)](-8)}function d(a){let n=t;return(e[n(1755)](Array,4)[n(1525)]("0")+parseInt(a,2).toString(16))[n(894)](-4)}function u(a){let n=t,s=a[n(1329)](/\./)[n(491)](y=>c(y)),l=[];return l[0]=d(e[n(1843)](s[0],s[1])),l[1]=e[n(860)](d,e[n(1843)](s[2],s[3])),[e[n(1301)],e[n(1301)],n(1006),e[n(1301)],e.FBZol,n(675),l[0],l[1]].join("")}function f(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(1314)](a),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1314)](a);return s?e[n(1346)](u,a):l?e[n(857)](x,a):e[n(1579)]}function x(a){let n=t;if(e[n(1815)](n(925),n(1511))){let s="",l=[],h=0,y=0,w=!0,b=n(1006);if(e[n(1096)](a[n(589)]("::"),-1)){let p=a[n(1329)]("::");for(let L=0;e[n(659)](L,p[n(691)]);L++){let B=p[L];if(e[n(1096)](B[n(589)](":"),0)){let q=B[n(1329)](":");w&&(h=q.length),y+=q[n(691)];for(let $=0;$<q.length;$++)if(e.fJAAq(4,q[$][n(691)])){let ge=b[n(1696)+"g"](0,4-q[$][n(691)]),Te=ge.concat(q[$]);l[n(854)](Te)}else l[n(854)](q[$]);w=!1}else{if(e.RmrzZ(4,B[n(691)])){let q=b[n(1696)+"g"](0,e.jeiTm(4,B[n(691)])),$=q[n(482)](B);l[n(854)]($)}else l[n(854)](B);w&&(h+=1),y+=1,w=!1}}let C="";for(let L=0;e.abcpN(L,e[n(1412)](8,y));L++)C=C[n(482)](b);for(let L=0;e[n(1840)](L,l.length);L++)e[n(741)](L,h)&&(s=s[n(482)](C)),s=s[n(482)](l[L]);return s}if(e.ZIbRY(n(1665),e[n(959)])){if(DtsaBF.dZRat(_0xf4eaf3,_0x1d0592))return _0x162ff7(_0x293d48);if(_0x35a725[n(1036)](_0x55021a))return _0x22f7d8[n(1729)](_0xd30463);let p=_0x306e18(_0x117ba9);return DtsaBF.fJAAq(p,_0x13639e)&&(_0x4f5614[n(1416)](_0x4a68aa,p),_0x11146f.set(p,_0x5d234f)),p}else{let p=a[n(1329)](":");for(let C=0;C<p.length;C++){let L=p[C];if(e[n(647)](4,p[C][n(691)])){let B=b[n(1696)+"g"](0,e[n(835)](4,p[C].length)),q=B[n(482)](L);s=s.concat(q)}else s=s.concat(L)}return s}}else this[n(1713)]?.[n(799)](_0x6310b5.message_id)}function g(a,n){let s=t,l=a[s(1773)];l!==void 0&&(e[s(1219)](pe,n,10),U(n,l));let h=a[s(1124)];e.RmrzZ(void 0,h)&&(e[s(812)](pe,n,18),e[s(481)](U,n,h))}function m(a){let n=t,s={};e:for(;!e[n(1346)](V,a);){let l=e[n(857)](xe,a);switch(e.GttsM(l,3)){case 0:break e;case 1:s.key=e.qHUWe(D,a,xe(a));break;case 2:s.value=e[n(1392)](D,a,xe(a));break;default:e[n(481)](k,a,e[n(1152)](7,l))}}if(e[n(741)](void 0,s[n(1773)]))throw new Error(n(1599)+n(1673)+" field: "+n(1773));if(e[n(1495)](void 0,s[n(1124)]))throw new Error(e.HZhqL);return s}function v(a){let n=t;if(e[n(308)](n(1181),e[n(607)])){let s=e[n(999)](R);return _(a,s),N(s)}else this.on(_0x985957,_0x1fbb5b)}function _(a,n){let s=t,l={NDFPI:function(he,be,we){return e[G(1294)](he,be,we)},eLhrG:e[s(1580)],ATcKX:e[s(1831)],QcYnK:e[s(627)],NYuCv:function(he,be,we){return e[s(1129)](he,be,we)}},h=a[s(932)];if(e[s(647)](void 0,h))if(e[s(1381)](s(820),e[s(641)]))e.Pqqee(pe,n,8),e.EBjLh(gt,n,h);else{let he=l.NDFPI(_0x3e0ebf,l[s(927)],{message:l[s(469)]});this[s(493)+s(1253)]&&this[s(493)+s(1253)](he)}let y=a[s(1621)];e.OUYrO(void 0,y)&&(pe(n,16),e.NbdHy(gt,n,y));let w=a[s(1674)];if(e.fJAAq(void 0,w))if(e[s(1815)](s(1405),e[s(977)])){let he={kKYXq:e[s(627)],rvgCW:function(be,we,wt){return e[s(1585)](be,we,wt)}};if(e[s(901)](_0x9b179b,_0x21b8cb)){let be=_0x26797e.buffer[s(894)](_0x383c1c.byteOffset,e[s(1217)](_0x23769c[s(526)+"th"],_0x15058c[s(553)+"et"]));this[s(1e3)]&&this[s(1e3)].send({data:be,fail:we=>{let wt=s;this[wt(338)](he[wt(337)],he[wt(897)](_0x5c29b0,he.kKYXq,{message:this[wt(1771)+"rrorMess"+wt(1568)](we)}))}})}else this[s(1e3)]&&this[s(1e3)][s(487)]({data:_0x6f50,fail:be=>{let we=s;this.emit(l[we(885)],l.NYuCv(_0x291b0a,l[we(885)],{message:this[we(1771)+we(971)+we(1568)](be)}))}})}else e[s(1199)](pe,n,24),gt(n,e.HiXFi(P,w));let b=a[s(976)];e[s(1649)](void 0,b)&&(e.mbdiB(pe,n,32),e.Nrepi(gt,n,e[s(860)](P,b)));let p=a[s(1735)];if(e[s(868)](void 0,p))for(let he of p){pe(n,42);let be=e[s(999)](R);e[s(616)](g,he,be),e[s(567)](pe,n,be[s(1459)]),e[s(1146)](K,n,be),O(be)}let C=a["payloadE"+s(558)];e[s(1291)](void 0,C)&&(e[s(362)](pe,n,50),e.iNbjc(U,n,C));let L=a[s(798)+s(1700)];e.raHQX(void 0,L)&&(pe(n,58),e.EBjLh(U,n,L));let B=a[s(403)];e.fJAAq(void 0,B)&&(e.zseeq(pe,n,66),pe(n,B[s(691)]),e[s(985)](se,n,B));let q=a[s(1185)];if(e[s(399)](void 0,q))if(e.CZpmk(e[s(947)],e[s(801)]))pe(n,74),e[s(1294)](U,n,q);else{let he=0,be={};for(let we=0;e.AtvEt(we,_0x55bfdb[s(691)]);we++)be[_0x428e04[we][s(823)+s(411)]]=e[s(1346)](_0x30557a,_0x184aa2[we][s(823)+s(411)]),he+=e[s(385)](14,be[_0x17f182[we]["cursor_n"+s(411)]]);return[he,be]}let $=a[s(663)+s(1697)];e[s(308)](void 0,$)&&(e.zJfGP(pe,n,82),e[s(1299)](U,n,$));let ge=a[s(1330)];ge!==void 0&&(pe(n,90),U(n,ge));let Te=a[s(1115)+"e"];e[s(1679)](void 0,Te)&&(pe(n,96),e[s(516)](gt,n,e[s(1551)](P,Te)))}function S(a){let n=t,s={rkeAu:function(l,h,y){return e[G(1285)](l,h,y)}};if(n(1186)!==e[n(395)])zDbidi.rkeAu(_0x4b27d3,_0x2798c3,66),zDbidi[n(1366)](_0x26a8af,_0x26ea97,_0x338681[n(691)]),zDbidi[n(1366)](_0x117cbd,_0x4d92c2,_0x3023f3);else return e[n(1767)](I,e.xKRTn(F,a))}function I(a){let n=t,s={};e:for(;!V(a);){let l=e[n(1686)](xe,a);switch(l>>>3){case 0:break e;case 1:s[n(932)]=e[n(316)](Tt,a,!0);break;case 2:s.LogID=e[n(1627)](Tt,a,!0);break;case 3:s[n(1674)]=xe(a);break;case 4:s[n(976)]=e[n(1361)](xe,a);break;case 5:{let h=A(a);(s[n(1735)]||(s.headers=[]))[n(854)](e.facsp(m,a)),a.limit=h;break}case 6:s.payloadEncoding=e.zseeq(D,a,e[n(1046)](xe,a));break;case 7:s["payloadT"+n(1700)]=e[n(1775)](D,a,e.Ecqwy(xe,a));break;case 8:s.payload=e[n(1129)](ie,a,xe(a));break;case 9:s[n(1185)]=e[n(1113)](D,a,e.Ecqwy(xe,a));break;case 10:s[n(663)+n(1697)]=e[n(713)](D,a,xe(a));break;case 11:s.msgID=e[n(574)](D,a,xe(a));break;case 12:s[n(1115)+"e"]=e[n(942)](xe,a);break;default:e[n(1235)](k,a,e[n(1233)](7,l))}}if(e[n(1273)](void 0,s[n(932)]))throw new Error(n(1599)+n(1673)+" field: "+n(932));if(e.MNCCq(void 0,s[n(1621)]))throw new Error(e.EAZAJ);if(e.nLzbQ(void 0,s[n(1674)]))throw new Error(e.HvsZL);if(e[n(1273)](void 0,s.method))throw new Error("Missing required"+n(1334)+n(976));return s}function A(a){let n=t,s=xe(a),l=a[n(1459)];return a[n(1459)]=e[n(1707)](a[n(1054)],s),l}function k(a,n){let s=t;if(e[s(1672)](s(419),e.dvLCK))switch(n){case 0:for(;e[s(1152)](128,e[s(838)](ee,a)););break;case 2:e[s(516)](J,a,xe(a));break;case 5:e[s(772)](J,a,4);break;case 1:J(a,8);break;default:throw new Error(e[s(1217)]("Unimplemented ty"+s(1378),n))}else _0x257bb0["frontier"+s(1263)]=void 0,e[s(1551)](_0x51db58,e.gIhEg)}function P(a){let n=t;return a|=0,{low:a,high:a>>31,unsigned:e[n(351)](a,0)}}let E=[];function R(){let a=t,n=E[a(1056)]();return n?(n.offset=n.limit=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){E[t(854)](a)}function F(a){return{bytes:a,offset:0,limit:a.length}}function N(a){let n=t,s=a[n(1477)],l=a.limit;return s.length===l?s:s.subarray(0,l)}function J(a,n){let s=t;if(e[s(1096)](e[s(385)](a.offset,n),a[s(1459)]))throw new Error(e[s(1740)]);a.offset+=n}function V(a){return a[t(1054)]>=a.limit}function ne(a,n){let s=t;if(e.oGqIN(s(1377),e[s(326)])){let l=a[s(1477)],h=a[s(1054)],y=a[s(1459)],w=e[s(1707)](h,n);if(e[s(1510)](w,l[s(691)])){let b=new Uint8Array(2*w);b.set(l),a.bytes=b}return a.offset=w,e[s(1096)](w,y)&&(a[s(1459)]=w),h}else return _0x709780?_0x34e4a5[s(1177)+s(679)](_0x52d1ed,_0x2a312d):_0x3c6822["fromByte"+s(498)](_0x2b6157,_0x59b3c0)}function Y(a,n){let s=t,l=a[s(1054)];if(e.BOGiK(l+n,a[s(1459)]))throw new Error(s(829)+s(841));return a[s(1054)]+=n,l}function ie(a,n){let s=t,l=Y(a,n);return a[s(1477)][s(596)](l,e[s(577)](l,n))}function se(a,n){let s=t,l=e[s(1241)](ne,a,n.length);a.bytes[s(1416)](n,l)}function D(a,n){let s=t,l=e[s(1065)](Y,a,n),h=String[s(996)+"Code"],y=a.bytes,w="\uFFFD",b="";for(let p=0;p<n;p++)if(e[s(1167)](s(1502),e.CAUpj)){if(this[s(1680)][s(1506)+"utoRecon"+s(1087)]||this[s(1730)+s(1748)])return;this[s(1451)+s(1253)]()}else{let C=y[e[s(577)](p,l)],L,B,q,$;if(e.nLzbQ(128&C,0))b+=e[s(942)](h,C);else if(e[s(1338)](224&C,192))e.VSlYL(e[s(1390)](p,1),n)?b+=w:(L=y[e[s(1843)](e.lACkE(p,l),1)],e[s(847)](e[s(1152)](192,L),128)?b+=w:($=e[s(855)](e[s(716)](e.JKubP(31,C),6),63&L),e[s(1195)]($,128)?b+=w:(b+=e[s(1767)](h,$),p++)));else if(e.pfnUa(240,C)==224)e[s(1225)](e[s(1390)](p,2),n)?b+=w:(L=y[e[s(588)](p,l)+1],B=y[e[s(1843)](e[s(1541)](p,l),2)],e.fJAAq(e[s(364)](e[s(1762)](L,e[s(532)](B,8)),49344),32896)?b+=w:($=e[s(855)](e[s(360)](e.yYrJl(15,C)<<12,e[s(638)](63&L,6)),e.JKubP(63,B)),$<2048||e[s(824)]($,55296)&&$<=57343?b+=w:(b+=e.facsp(h,$),p+=2)));else if(e[s(1501)](248&C,240))if(e[s(524)](p,3)>=n)b+=w;else if(L=y[e[s(1114)](e.yfMGY(p,l),1)],B=y[e.byBqi(e[s(524)](p,l),2)],q=y[p+l+3],e[s(955)](e[s(855)](e[s(489)](L,B<<8),e.qidFz(q,16))&12632256,8421504))b+=w;else if($=e.ffIvz(e[s(347)](e[s(638)](e[s(344)](7,C),18),e[s(1206)](63,L)<<12),e.nbtiC(e.JKubP(63,B),6))|e[s(1318)](63,q),e[s(1840)]($,65536)||$>1114111)b+=w;else if(s(1640)===e[s(1428)])$-=65536,b+=e[s(1235)](h,e[s(1487)]($>>10,55296),e[s(1520)](1023,$)+56320),p+=3;else return this._ws?this._ws[s(725)+"te"]:this._options[s(410)+s(1147)]?this[s(1060)+"NG"]:this[s(935)];else b+=w}return b}function U(a,n){let s=t;if(e[s(741)](e[s(544)],e[s(967)]))return this[s(1713)]?.isReady;{let l=n[s(691)],h=0;for(let b=0;e[s(1521)](b,l);b++){let p=n.charCodeAt(b);p>=55296&&e[s(1118)](p,56319)&&e.SNrqM(e.iQPci(b,1),l)&&(p=e[s(716)](p,10)+n.charCodeAt(++b)-56613888),h+=e[s(1134)](p,128)?1:e.abcpN(p,2048)?2:p<65536?3:4}e.Nrepi(pe,a,h);let y=e[s(1825)](ne,a,h),w=a[s(1477)];for(let b=0;e[s(1537)](b,l);b++){let p=n[s(592)+"At"](b);e[s(324)](p,55296)&&e.EahTV(p,56319)&&e[s(1666)](e[s(1664)](b,1),l)&&(p=e[s(1203)](p,10)+n[s(592)+"At"](++b)-56613888),p<128?w[y++]=p:(e.eyHan(p,2048)?w[y++]=e.axMos(e.JKubP(p>>6,31),192):e[s(832)](e[s(1791)],e[s(1791)])?(this[s(1164)]=!0,this[s(1220)]()):(e[s(618)](p,65536)?w[y++]=e[s(1094)](p,12)&15|224:(w[y++]=e[s(344)](e[s(442)](p,18),7)|240,w[y++]=e[s(360)](e[s(1233)](p>>12,63),128)),w[y++]=e[s(1206)](e[s(608)](p,6),63)|128),w[y++]=e[s(347)](63&p,128))}}}function K(a,n){let s=t,l=ne(a,n.limit),h=a[s(1477)],y=n[s(1477)];for(let w=0,b=n[s(1459)];w<b;w++)h[e.nEJxr(w,l)]=y[w]}function ee(a){let n=t;return a[n(1477)][e[n(1199)](Y,a,1)]}function nt(a,n){let s=t,l=e[s(516)](ne,a,1);a[s(1477)][l]=n}function xe(a){let n=0,s=0,l;do l=ee(a),n<32&&(s|=e.mhJEU(e.aQbVZ(127,l),n)),n+=7;while(128&l);return s}function pe(a,n){let s=t;for(n>>>=0;e[s(1399)](n,128);)e[s(481)](nt,a,e[s(1283)](e[s(1233)](127,n),128)),n>>>=7;e[s(481)](nt,a,n)}function Tt(a,n){let s=t,l=0,h=0,y=0,w;return w=e[s(661)](ee,a),l=127&w,128&w&&(w=e[s(457)](ee,a),l|=e[s(638)](127&w,7),e[s(344)](128,w)&&(w=e[s(1566)](ee,a),l|=e.snHNb(e.pfnUa(127,w),14),e[s(468)](128,w)&&(w=e.pKAhT(ee,a),l|=e[s(1203)](127&w,21),128&w&&(w=ee(a),h=127&w,e.uPZmp(128,w)&&(w=ee(a),h|=e[s(850)](e.jldai(127,w),7),128&w&&(w=e.iubwj(ee,a),h|=e[s(532)](e.eSZdf(127,w),14),128&w&&(w=e.nDUbA(ee,a),h|=e[s(468)](127,w)<<21,e[s(1341)](128,w)&&(w=e[s(1587)](ee,a),y=e.wApbP(127,w),e.eSZdf(128,w)&&(w=e.NmVNp(ee,a),y|=e[s(850)](127&w,7)))))))))),{low:e[s(1010)](l,e[s(586)](h,28)),high:e[s(360)](h>>>4,e[s(771)](y,24)),unsigned:n}}function gt(a,n){let s=t,l=e.GttsM(n[s(1499)],0),h=e[s(698)](e.SYRnh(n[s(1499)],28),n.high<<4)>>>0,y=e[s(1509)](n[s(1425)],24),w=e[s(1273)](0,y)?h===0?e[s(911)](l,16384)?l<128?1:2:e.qieaB(l,2097152)?3:4:e[s(453)](h,16384)?e.FPAoI(h,128)?5:6:h<2097152?7:8:y<128?9:10,b=e[s(713)](ne,a,w),p=a.bytes;switch(w){case 10:p[e[s(588)](b,9)]=e[s(1803)](e.GttsM(y,7),1);case 9:p[e[s(323)](b,8)]=e[s(1679)](9,w)?e[s(366)](128,y):e[s(1651)](127,y);case 8:p[e.AOwzU(b,7)]=w!==8?e.zniRG(h,21)|128:e[s(1803)](h>>>21,127);case 7:p[e.yAEfe(b,6)]=e[s(399)](7,w)?e[s(1609)](e[s(456)](h,14),128):e.LEcqV(e.GttsM(h,14),127);case 6:p[b+5]=w!==6?e[s(749)](e[s(483)](h,7),128):e[s(1341)](e[s(1160)](h,7),127);case 5:p[b+4]=e[s(1291)](5,w)?e[s(366)](128,h):127&h;case 4:p[e[s(588)](b,3)]=w!==4?e[s(1239)](l,21)|128:e[s(468)](e[s(877)](l,21),127);case 3:p[b+2]=e[s(1648)](3,w)?e[s(855)](e.Kqtsc(l,14),128):e.xvvYY(l>>>14,127);case 2:p[e[s(1359)](b,1)]=e[s(1192)](2,w)?e.FTphx(l,7)|128:e[s(1387)](l>>>7,127);case 1:p[b]=w!==1?128|l:e[s(1615)](127,l)}}function nn(a){return e[t(838)](S,a)}function qt(a){let n=t;if(e.xkHOM(e.ceDzj,"QGoJT"))return e[n(1344)](v,a);throw this["_connect"+n(1376)]=!1,_0x582da3}let rn=65536,Xr=e[t(876)],ye=e[t(1443)](rn,rn),Ce=ye*ye,nr=e[t(552)](Ce,2),Ne=String[t(742)+"e"].charCodeAt;class ue{constructor(n,s,l){let h=t;this[h(989)]=!0,this[h(1499)]=e.ScEVj(0,n),this[h(1425)]=e[h(698)](0,s),this[h(1546)]=!!l}static[t(989)](n){return n&&e[t(500)](!0,n.isLong)}static[t(1524)](n,s,l){return new ue(n,s,l)}static[t(1177)+"s"](n,s,l){let h=t;return l?ue["fromByte"+h(679)](n,s):ue[h(1177)+"sBE"](n,s)}static["fromByte"+t(679)](n,s){let l=t;return new ue(e[l(347)](n[0]|e.MEqUa(n[1],8)|e.kULYe(n[2],16),n[3]<<24),e[l(1371)](e[l(489)](e[l(637)](n[4],n[5]<<8),e[l(1166)](n[6],16)),e[l(1203)](n[7],24)),s)}static[t(1177)+t(498)](n,s){let l=t;if(e[l(1495)](e[l(510)],e[l(1309)]))this[l(777)+l(786)]=_0x561a06;else return new ue(e[l(688)](e.SInyj(e.MEqUa(n[4],24),e.mejqF(n[5],16)),n[6]<<8)|n[7],e[l(360)](e.sieCs(e[l(1283)](e[l(771)](n[0],24),n[1]<<16),e[l(1828)](n[2],8)),n[3]),s)}static fromHash(n){let s=t;return e[s(657)](n,Xr)?Qd:new ue(e.hVwRs(e[s(1283)](e[s(749)](Ne[s(693)](n,0)|e[s(1828)](Ne.call(n,1),8),e[s(638)](Ne[s(693)](n,2),16)),Ne[s(693)](n,3)<<24),0),(e.YmoqA(Ne.call(n,4)|e[s(615)](Ne[s(693)](n,5),8),e[s(1816)](Ne.call(n,6),16))|e.SmlzE(Ne[s(693)](n,7),24))>>>0,!0)}[t(1711)](){let n=t;return String["fromChar"+n(921)](e.NWzuN(255,this[n(1499)]),e[n(339)](e[n(1308)](this[n(1499)],8),255),e[n(529)](this.low,16)&255,this[n(1499)]>>>24,e.CHZir(255,this[n(1425)]),this[n(1425)]>>>8&255,e[n(529)](this[n(1425)],16)&255,e.nfOvD(this[n(1425)],24))}static[t(1694)+"er"](n,s=!0){let l=t;if(e[l(382)](isNaN,n))return s?Tp:Qd;if(s){if(e[l(1202)](e[l(1142)],e.PnxvC))e[l(1587)](_0x41962f,this[l(334)+l(669)+"Id"]),this[l(334)+"lTimeoutId"]=e[l(1516)](_0x1678e8,()=>{this["flushExp"+l(501)]()},this[l(334)+"l"]);else if(n>=Ce)return Cp}else{if(e[l(949)](n,-nr))return Rp;if(e[l(1571)](e[l(1616)](n,1),nr))return kp}return ue[l(1524)](e[l(610)](e[l(1389)](n,ye),0),e[l(366)](e[l(466)](n,ye),0),s)}toNumber(){let n=t;if(e[n(432)](e.nrDsE,n(1365)))return this[n(1546)]?e[n(1322)](e[n(1763)](this[n(1425)],0),ye)+e[n(866)](this[n(1499)],0):e[n(1322)](this[n(1425)],ye)+e[n(1265)](this[n(1499)],0);if(_0x8fc145===void 0)this[n(859)+"rs"]={};else if(e[n(621)](void 0,_0x160c28))this[n(859)+"rs"][_0x28f3a4]=null;else{let s=this[n(859)+"rs"][_0x28a2d6];if(s)for(let l=0;e.wsXXp(l,s[n(691)]);)s[l].fn===_0x509ba1?s[n(1312)](l,1):++l}return this}[t(966)](){let n=t;return e[n(569)]!==n(778)?e[n(1822)](0,this[n(1425)])&&this[n(1499)]===0:_0x28292e[n(1573)+n(1089)][1]?void 0:_0xcda4d9[n(1573)+n(687)](_0x5613ac["objectSt"+n(1089)][0])}[t(1135)](n){let s=t;ue.isLong(n)||(n=ue[s(1694)+"er"](n));let l=e.EQriZ(this[s(1425)],16),h=e[s(1152)](65535,this[s(1425)]),y=e[s(1085)](this[s(1499)],16),w=65535&this[s(1499)],b=n[s(1425)]>>>16,p=65535&n[s(1425)],C=n[s(1499)]>>>16,L=65535&n[s(1499)],B=0,q=0,$=0,ge=0;return ge+=e[s(385)](w,L),$+=ge>>>16,ge&=65535,$+=e.kBfnb(y,C),q+=e[s(356)]($,16),$&=65535,q+=h+p,B+=e[s(866)](q,16),q&=65535,B+=l+b,B&=65535,ue[s(1524)](e[s(1448)](e[s(1593)]($,16),ge),e[s(1609)](B<<16,q),this[s(1546)])}[t(1403)](n){let s=t;return ue[s(989)](n)||(n=ue.fromNumber(n)),e.wJvvz(this[s(1546)],n.unsigned)&&e.wrgeT(e[s(866)](this.high,31),1)&&e[s(497)](n[s(1425)]>>>31,1)?!1:e[s(1822)](this[s(1425)],n.high)&&e[s(1381)](this.low,n[s(1499)])}[t(594)](){let n=t;return e[n(1292)](-1,this[n(1499)])&&this[n(1425)]===-1?ue[n(1524)](0,0,this[n(1546)]):this[n(1499)]===-1?ue[n(1524)](0,e.Fotbj(this[n(1425)],1),this[n(1546)]):ue[n(1524)](e[n(1390)](this.low,1),this[n(1425)],this.unsigned)}[t(664)](n){let s=t;return n?this[s(704)+"E"]():this[s(990)+"E"]()}[t(704)+"E"](){let n=t,s=this.high,l=this.low;return[e[n(849)](255,l),e.NfANL(e[n(483)](l,8),255),e[n(329)](e[n(926)](l,16),255),e.feTfz(l,24),e.xvvYY(255,s),e.jldai(e[n(1157)](s,8),255),e[n(1651)](s>>>16,255),s>>>24]}[t(990)+"E"](){let n=t,s=this[n(1425)],l=this[n(1499)];return[e[n(1239)](s,24),e.NWzuN(s>>>16,255),e[n(1774)](s>>>8,255),e[n(1520)](255,s),e[n(883)](l,24),e[n(344)](e[n(1153)](l,16),255),e[n(1245)](l>>>8,255),255&l]}}let Qd=new ue(0,0,!1),Tp=new ue(0,0,!0),kp=ue[t(1524)](-1,2147483647,!1),Cp=ue[t(1524)](-1,-1,!0),Rp=ue[t(1524)](0,-2147483648,!1);var sn=(function(a){let n=t,s=e[n(593)].split("|"),l=0;for(;;){switch(s[l++]){case"0":a[a[e.jvuLa]=5003]=e[n(736)];continue;case"1":a[a.MESSAGE_ERROR=5004]=e[n(918)];continue;case"2":a[a[e[n(1756)]]=5005]=e.ufuTH;continue;case"3":a[a[e[n(856)]]=5002]=e[n(856)];continue;case"4":return a;case"5":a[a[e.FFpKu]=5001]=e.FFpKu;continue}break}})({});class rr{constructor(n){this.type=n,this.target=null}}class el extends rr{constructor(n,s){let l=t;if(e[l(1246)]("TQAjg",e.bvXRP))super(n),this.message=s&&s[l(1126)]||null;else try{this._qosDB?.[l(1413)](),this[l(1713)]=void 0}catch(h){_0x2ec926.log(h)}}}class tl extends rr{constructor(n,s){let l=t,h=e.fdeCm[l(1329)]("|"),y=0;for(;;){switch(h[y++]){case"0":super(n);continue;case"1":this[l(1083)]=s&&s[l(1083)]||0;continue;case"2":this[l(695)]=s&&s[l(695)]||"";continue;case"3":this[l(1218)]=s&&s[l(1218)]||5001;continue;case"4":this[l(1284)]=s&&s[l(1284)]||null;continue;case"5":this[l(1126)]=s&&s[l(1126)]||"";continue;case"6":this[l(1455)]=s&&s[l(1455)]||0;continue}break}}}class nl extends rr{constructor(n,s){let l=t,h=e.OfnxS[l(1329)]("|"),y=0;for(;;){switch(h[y++]){case"0":this[l(1218)]=s&&s.code||0;continue;case"1":this[l(619)]=s&&s[l(619)]||!1;continue;case"2":this[l(1841)]=s&&s[l(1841)]||"";continue;case"3":this[l(1069)+l(310)]=s&&s[l(1069)+l(310)]||!1;continue;case"4":super(n);continue}break}}}class rl extends rr{constructor(n,s){let l=t;super(n),this[l(1216)]=s&&s[l(1216)]||null}}class il extends rl{constructor(n,s){let l=t;super(n),this[l(1216)]=s&&s[l(1216)]||null,this[l(1126)]=s&&s[l(1126)]||null}}class sl extends rr{constructor(n,s){let l=t;super(n),this[l(1216)]=s&&s[l(1216)]||null}}function lt(a,{message:n,code:s,error:l}){let h=t;if(e[h(1648)](e.bDqgw,e[h(379)]))return new tl(a,{message:n,code:s,error:l});this[h(1823)]&&this[h(1823)][h(487)](_0x31063a),this._debug(e.kTdui,_0x26e793)}function mt(a,{code:n,reason:s,wasClean:l,willReconnect:h}){let y=t;if(e[y(1210)](e.LBcRF,e[y(968)]))for(var w in _0x4f0ccf)_0x11e9d8.o(_0x31cc68,w)&&!_0x43aaeb.o(_0x216d6a,w)&&_0xc00019["definePr"+y(1594)](_0x1ec415,w,{enumerable:!0,get:_0x214161[w]});else return new nl(a,{code:n,reason:s,wasClean:l,willReconnect:h})}function ol(a,{data:n,message:s}){return new il(a,{data:n,message:s})}function al(a,{data:n}){return new sl(a,{data:n})}function fa(a,{message:n}){return new el(a,{message:n})}class cl{constructor(n,s){let l=t;this[l(1528)+"s"]=n,this[l(1028)+"es"]=s,this.currentIndex=0,this["currentEndpointT"+l(1111)+"t"]=0}resetEndpointConfig(){let n=t;e[n(601)]===e[n(601)]?(this["currentI"+n(1342)]=0,this["currentEndpointT"+n(1111)+"t"]=0):(this.endpoints=_0x3485c6,this[n(1028)+"es"]=_0x865ccc,this[n(979)+"ndex"]=0,this[n(537)+n(1183)+n(1111)+"t"]=0)}[t(1055)+"es"](){let n=t;this["currentEndpointT"+n(1111)+"t"]=0}getCurrentEndpoint(){let n=t;return this[n(1528)+"s"][this[n(979)+n(1342)]]}["getCurre"+t(1102)+t(467)+t(1441)](){let n=t;return this[n(537)+"ndpointT"+n(1111)+"t"]}["checkRea"+t(560)+"es"](){let n=t;return!!(this[n(979)+n(1342)]>=this.endpoints[n(691)]||this.currentIndex===e[n(835)](this[n(1528)+"s"][n(691)],1)&&e[n(1355)](this[n(537)+n(1183)+n(1111)+"t"],this[n(1028)+"es"]))}[t(1319)+t(1236)+t(1588)+t(939)+"tries"](){let n=t;return this[n(979)+n(1342)]==this[n(1528)+"s"][n(691)]?!0:this[n(537)+"ndpointTriesCount"]>this[n(1028)+"es"]}[t(1297)+t(345)+t(1139)+"UpdateCo"+t(369)](){let n=t;return this[n(537)+n(1183)+"riesCount"]=1,this[n(979)+n(1342)]++,this[n(1528)+"s"][this[n(979)+"ndex"]]}[t(683)+t(1102)+t(1187)+t(1307)](){let n=t;return this["currentE"+n(1183)+n(1111)+"t"]++,this.getCurrentEndpoint()}}let ir=(e[t(1415)](t(1104)+"d",typeof globalThis)&&e[t(1444)](e[t(656)],globalThis[t(1231)+t(572)].name)||e[t(702)](e.vrqXG,typeof window)&&e[t(722)]("Window",window[t(1231)+t(572)][t(1759)]))&&t(1104)+"d"!=typeof document,Pn=e[t(1675)](e.vrqXG,typeof globalThis)&&(e.yQFtu(e[t(1591)],globalThis["construc"+t(572)].name)||e[t(674)](e[t(1001)],globalThis.constructor[t(1759)]))&&e[t(993)]!=typeof tt,Qr=(e[t(702)](t(1104)+"d",typeof globalThis)&&e[t(741)](e[t(1591)],globalThis[t(1231)+"tor"][t(1759)])||t(1104)+"d"==typeof globalThis||e[t(993)]!=typeof globalThis&&!!globalThis[t(987)+t(547)])&&e[t(993)]!=typeof wx,ei=e[t(1529)](e.vrqXG,typeof globalThis)&&(e[t(964)](e[t(1001)],globalThis[t(1231)+t(572)][t(1759)])||t(694)+t(1161)+t(1158)===globalThis[t(1231)+t(572)][t(1759)]||e[t(809)]("ServiceW"+t(768)+t(1382),globalThis["construc"+t(572)].name))&&e[t(591)](e[t(993)],typeof self),Dp=e[t(1675)](e[t(993)],typeof globalThis)&&e[t(1210)](e[t(1591)],globalThis[t(1231)+t(572)][t(1759)])&&e.KusZH(e[t(993)],typeof global)&&e[t(1495)](e[t(1591)],global[t(1231)+"tor"][t(1759)])&&e[t(543)](e.vrqXG,typeof process)&&!!process[t(1093)];class ha{constructor(){let n=t;this[n(859)+"rs"]={}}emit(n,...s){let l=t,h=this[l(859)+"rs"][n];if(h)h.slice().forEach(y=>y.fn[l(557)](y[l(1333)],s));else if(e[l(1273)]("error",n)&&!this[l(1256)]){let y=s[l(691)]&&s[0];if(y instanceof Error)throw y;let w=new Error(l(672)+l(995)+(y?" ("+y[l(1126)]+")":""));throw w.context=y,y}return this}[t(707)](n,s){let l=t;if(e[l(643)](void 0,n))this[l(859)+"rs"]={};else if(e.WcZGf(void 0,s))this[l(859)+"rs"][n]=null;else if(e.pItGs!==e.pItGs){let h=this[l(1362)+l(703)]?.[l(683)+"ntEndpoint"](),y=this[l(1680)][l(1488)+l(426)+l(1107)](_0xa9dcd.code,_0x3f38cd[l(1841)]);this[l(997)+l(1712)+l(409)](e[l(574)](_0x588bb0,e[l(1288)],{code:1006,reason:_0x33d00d[l(1841)]||l(1682)+"ng faile"+l(1367)+l(642)+l(1300)+l(721)+h,willReconnect:y})),y&&this[l(1220)]();return}else{let h=this[l(859)+"rs"][n];if(h)for(let y=0;e[l(639)](y,h[l(691)]);)e[l(741)](h[y].fn,s)?h[l(1312)](y,1):++y}return this}on(n,s,l){let h=t;return(this[h(859)+"rs"][n]||(this[h(859)+"rs"][n]=[]))[h(854)]({fn:s,ctx:l||this}),this}}class Pp extends ha{["_formatE"+t(971)+t(1568)](n){let s=t;return n[s(1384)]||n.errNo?(s(414)+" "+(n.errMsg||"")+" code: "+(n[s(945)]||""))[s(715)]():JSON[s(454)+"y"](n)}constructor(n,s,l){let h=t;super(),this._socket=null,Qr&&wx[h(1112)+h(1363)]&&(this._socket=wx[h(1112)+"ocket"]({url:n,protocols:s,header:l,fail:this[h(1035)+h(1484)+h(963)][h(1433)](this),success:this[h(1035)+h(746)+h(1064)+h(1466)][h(1433)](this)})),Pn&&tt[h(1112)+h(1363)]&&(this[h(1e3)]=tt[h(1112)+h(1363)]({url:n,protocols:s,header:l,fail:this[h(1035)+"ocketFailHandler"][h(1433)](this),success:this[h(1035)+h(746)+"cessHand"+h(1466)].bind(this)}))}["_createS"+t(746)+t(1064)+t(1466)](){let n=t;Promise.resolve()[n(644)](()=>{let s=n;this[s(1175)+s(1315)]()})}["_createS"+t(1484)+t(963)](n){let s=t,l={hNiyp:function(h,y,w){return e.diGYD(h,y,w)},dFFhH:e[s(627)],eZrru:e[s(1288)]};Promise[s(1303)]().then(()=>{let h=s,y=l[h(818)](lt,l[h(313)],{message:this[h(1771)+h(971)+h(1568)](n)});this[h(338)]("error",y);let w=mt(l[h(299)],{reason:this[h(1771)+h(971)+h(1568)](n)});this.emit(l[h(299)],w)})}[t(1175)+t(1315)](){let n=t,s={NWXxo:function(l,h,y){return e[G(873)](l,h,y)},vkjVP:n(1413),bWJWI:n(1126),KUfjE:e[n(627)]};this[n(1e3)][n(1468)](l=>{let h=n;if(e[h(1476)]===e.msicc)return!!this[h(1713)];this[h(338)](h(353),e[h(1271)](al,h(353),{...l,data:l.errMsg||""}))}),this[n(1e3)][n(1538)](l=>{let h=n;this[h(338)](h(1413),s.NWXxo(mt,s[h(634)],{...l}))}),this[n(1e3)][n(1632)+"e"](l=>{let h=n;this[h(338)](s[h(807)],ol(s.bWJWI,{...l}))}),this._socket.onError(l=>{let h=n;this[h(338)](h(1284),s[h(1513)](lt,s[h(346)],{...l,message:l[h(1384)]||""}))})}[t(487)](n){let s=t,l={sWwZb:function(h,y){return e[G(665)](h,y)},NeAxF:function(h,y){return e.XqllB(h,y)},ZJyie:function(h,y){return h+y},WAtEm:e[s(627)],aPOQK:function(h,y,w){return e[s(1585)](h,y,w)}};if(n instanceof Uint8Array){let h=n.buffer[s(894)](n[s(553)+"et"],n.byteLength+n[s(553)+"et"]);this[s(1e3)]&&this[s(1e3)][s(487)]({data:h,fail:y=>{let w=s;if(w(790)===e.inpQk){let b=this._listeners[_0x541ec5];if(b)b.slice()[w(958)](p=>p.fn[w(557)](p[w(1333)],_0x21c869));else if(blnkiI[w(1800)]("error",_0x56b38b)&&!this[w(1256)]){let p=_0x1fff5e[w(691)]&&_0x1aaeab[0];if(blnkiI[w(1555)](p,_0x14f954))throw p;let C=new _0x1930b5(w(672)+"d error."+(p?blnkiI[w(336)](" ("+p.message,")"):""));throw C[w(756)]=p,p}return this}else this[w(338)](w(1284),e[w(812)](lt,e[w(627)],{message:this["_formatErrorMess"+w(1568)](y)}))}})}else this._socket&&this[s(1e3)].send({data:n,fail:h=>{let y=s;this.emit(l[y(1022)],l[y(1080)](lt,l[y(1022)],{message:this._formatErrorMessage(h)}))}})}close(n,s){let l=t;this[l(1e3)]&&this[l(1e3)][l(1413)]({code:n,reason:s})}[t(1531)+"Listener"](n,s){this.on(n,s)}[t(787)+t(1796)+t(1196)](n,s){this[t(707)](n,s)}get[t(725)+"te"](){let n=t;return this._socket[n(725)+"te"]}get binaryType(){let n=t;return this._socket[n(1517)+"pe"]}set[t(1517)+"pe"](n){}get url(){let n=t;return this[n(1e3)][n(1215)]}get[t(1331)](){let n=t;return this[n(1e3)][n(1331)]}get[t(1533)+"ns"](){let n=t;if(e[n(946)]!==n(1668))return this._socket[n(1533)+"ns"];_0x419e0b=_0xaf3f55[n(482)](_0x22d935),_0x2f692b=_0xd8d826[n(482)](_0x23b27b[_0x9ff3ec])}get["buffered"+t(1602)](){return 0}}function Op(a,n){let s=t;if(n)return new n(a[s(1215)],a.protocol);if(e.opzEU(Qr,Pn))return new Pp(a[s(1215)],a[s(1331)],a[s(1735)]);if(e[s(994)](ir,ei)&&e[s(1769)](e[s(993)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(1215)],a[s(1331)+"s"])}function Lp(a){let n=t,s=e[n(449)][n(1329)]("|"),l=0;for(;;){switch(s[l++]){case"0":if((ir||ei)&&e[n(1769)](e[n(993)],typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(Qr&&wx.connectSocket)return!0;continue;case"2":if(a)return!0;continue;case"3":if(Pn&&tt[n(1112)+n(1363)])return!0;continue;case"4":return!1}break}}function dl(a,n,s){let l=-1;async function h(y){let w=G;return e[w(509)](y,l)?Promise[w(1753)](new Error(w(1208)+w(1613)+w(1143)+w(1133)+"process")):(l=y,e[w(432)](y,s[w(691)])?Promise[w(1303)]():s[y].bind(a)(n,h[w(1433)](null,e[w(1782)](y,1))))}h(0)}function ll(a){let n=t,s={MyBzF:e[n(1150)]},l=0,h=0;for(let y=0;e[n(512)](y,a[n(691)]);++y)if(e.MNCCq(e[n(671)],e[n(864)])){if(!this[n(1211)+n(880)]()||this[n(1730)+"osed"])return;this[n(1362)+"tManager"]?.[n(753)+n(412)+n(1606)](),this[n(522)+n(1691)]?.[n(1683)+n(957)](),this[n(1823)]?this[n(1120)+n(962)](1001,s[n(499)],!0):this._connect()}else h=a[n(592)+"At"](y),e[n(810)](h,128)?l+=1:e[n(904)](h,2048)?l+=2:e[n(1042)](e.EsQxD(64512,h),55296)&&e[n(1338)](e[n(1600)](64512,a.charCodeAt(e[n(1707)](y,1))),56320)?(++y,l+=4):l+=3;return l}function ul(a,n,s){let l=t;if(e[l(1537)](e[l(635)](s,n),1))return"";let h="";for(let y=n;e[l(1521)](y,s);){let w=a[y++];if(e[l(1400)](w,127))h+=String["fromChar"+l(921)](w);else if(w>=192&&e[l(512)](w,224))h+=String[l(996)+l(921)](e[l(751)](e[l(1708)](31&w,6),63&a[y++]));else if(e[l(774)](w,224)&&e[l(1134)](w,240))h+=String[l(996)+l(921)](e[l(360)](e[l(1593)](e[l(329)](15,w),12)|e[l(1489)](63,a[y++])<<6,e[l(364)](63,a[y++])));else if(e.qZCgU(w,240)){let b=e[l(1830)](e[l(637)](e[l(1614)](e[l(1828)](e[l(1520)](7,w),18),e.JKubP(63,a[y++])<<12),e[l(1173)](63&a[y++],6))|63&a[y++],65536);h+=String.fromCharCode(e.IwGtS(55296,e[l(565)](b,10))),h+=String.fromCharCode(e.RftuX(56320,e[l(1607)](1023,b)))}}return h}function xa(a,n,s){let l=t,h=s,y,w;for(let b=0;e[l(639)](b,a[l(691)]);++b)y=a[l(592)+"At"](b),y<128?n[s++]=y:e.LESjG(y,2048)?(n[s++]=e[l(1669)](e[l(1821)](y,6),192),n[s++]=e[l(347)](e.BVDLV(63,y),128)):e[l(956)](64512,y)===55296&&e[l(1590)](e[l(1642)](64512,w=a.charCodeAt(e.LxWun(b,1))),56320)?(y=e[l(1541)](e[l(546)](65536,e[l(437)](e[l(1328)](1023,y),10)),1023&w),++b,n[s++]=e[l(1420)](e[l(1586)](y,18),240),n[s++]=e[l(698)](e[l(339)](e[l(442)](y,12),63),128),n[s++]=e[l(1724)](e[l(762)](e[l(442)](y,6),63),128),n[s++]=e[l(321)](63&y,128)):(n[s++]=e.sieCs(y>>12,224),n[s++]=e[l(751)](y>>6&63,128),n[s++]=e[l(632)](63,y)|128);return e[l(835)](s,h)}async function fl(a){let n=t;if(n(1037)==typeof a){let s=new Uint8Array(ll(a));return e[n(1191)](xa,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a[n(348)],a.byteOffset,a[n(526)+"th"])}function Np(a){let n=t;try{return e[n(647)](e[n(1407)],e[n(915)])?e[n(1174)]!=typeof a&&(e[n(901)](a,ArrayBuffer)||a.buffer&&e[n(1154)](a[n(348)],ArrayBuffer))||e[n(1221)](e.zzHFK,typeof a)?"":(JSON[n(1051)](a),"applicat"+n(1784)):(_0x203fb9[_0x193847]=_0x4383d5,!0)}catch{return e[n(1067)](e.zzHFK,typeof a)?n(1737)+n(1662)+"et=utf-8":""}}let Mp=(a,n)=>{let s=t;switch(a){case s(1751):case e.jsvlS:return{[s(1543)+a]:1,"x-tt-env":n};default:return{}}};class Bp{constructor(n){let s=t,l={pXmMt:function(h,y){return e[G(788)](h,y)}};e.SDkJz!==e.cdnYW?(this[s(750)+s(1441)]=n,this[s(1168)]=0):(_0x687b0b[s(1703)][s(358)+s(1357)](_0x404b8e),_0x4c374d["frontier"+s(1263)]=void 0,l[s(301)](_0x2c1d95,_0x413c3b&&_0x187ad5[s(393)]||"unknown reason"))}[t(1242)](){let n=t;this[n(1168)]++}[t(1461)+t(763)+"nt"](){let n=t;return this[n(1168)]>=this[n(750)+"ount"]}["resetCou"+t(957)](n=0){let s=t;this[s(750)+s(1441)]=n,this[s(1168)]=0}}async function Fp(a){let n={fwPye:function(s,l){return e.waZnn(s,l)},URTrq:e.xzbXb,OruJc:"AyLEf",AgOQs:function(s,l){return e[G(1626)](s,l)}};return new Promise(s=>{let l=G,h={cUuzT:function(y,w){return y==w},CdGVn:function(y,w){return e[G(1510)](y,w)}};if(e[l(852)](e[l(886)],e[l(765)]))return oSfFNI[l(422)](this[l(979)+l(1342)],this.endpoints[l(691)])?!0:oSfFNI[l(784)](this[l(537)+l(1183)+"riesCount"],this.maxRetries);if(!ir)return e.Ecqwy(s,"unknown "+l(1841));try{if(e[l(744)]===l(844))this[l(1076)]=_0x701e5b,this[l(1386)]=_0x39c2f9,this[l(1713)]=_0x5a251f?_0x250e4f:_0xb8e89c?_0x2a2aa6:null;else{let y=document["createEl"+l(377)](e[l(568)]);window[l(1014)+l(1263)]=w=>{let b=l;if(n[b(776)](n.URTrq,n[b(1721)]))document.body[b(358)+b(1357)](y),window[b(1014)+b(1263)]=void 0,n.AgOQs(s,w&&w.msg||b(1462)+b(1841));else{let p=this[b(1362)+"tManager"]?.[b(683)+"ntEndpoint"]();this["_dispatc"+b(1712)+b(409)](_0x52accc(b(1413),{code:_0xc1ed3[b(1218)],reason:"connecti"+b(319)+b(1367)+"wn reaso"+b(1300)+b(721)+p})),this[b(1362)+"tManager"]?.[b(753)+"pointCon"+b(1606)](),this[b(522)+b(1691)]?.["resetCou"+b(957)]();return}},y[l(1353)]=l(1310)+l(1061),y[l(578)]=a[l(1393)](/^ws/,e[l(1628)])+e[l(1340)];try{document[l(1703)][l(1472)+l(1357)](y)}catch{if(e[l(504)](l(1417),"BokNH"))return null;document.body[l(358)+l(1357)](y)}}}catch{window[l(1014)+l(1263)]=void 0,e[l(1316)](s,e[l(870)])}})}function on(a,n,s){let l=t,h={UHTbE:l(1462)+l(1841),cmxJb:l(1725),Fqwyl:e[l(1709)],JzlTl:function(y,w){return e[l(709)](y,w)}};if(e[l(1151)](e.nAakN,e.nAakN)){let y={Awtpe:AVcaro.UHTbE},w=_0x5e8bc1[l(1530)+l(377)](AVcaro[l(1457)]);_0x4caf9c[l(1014)+l(1263)]=b=>{let p=l;_0x3936ac[p(1703)]["removeCh"+p(1357)](w),_0x3f7875[p(1014)+"JSONP"]=void 0,_0x1220e6(b&&b.msg||y.Awtpe)},w.type=AVcaro[l(676)],w.src=AVcaro[l(681)](_0x5734bd.replace(/^ws/,l(785)),l(1689)+l(974)+l(1512)+"P");try{_0x3ac34b[l(1703)][l(1472)+l(1357)](w)}catch{_0x5c23a2[l(1703)].removeChild(w)}}else return!!a?.[l(843)](y=>y[l(1773)]===n&&y.value===s)}function sr(a,n){let s=t;return a?.[s(843)](l=>l.key===n)?.[s(1124)]}let pa=null;async function zp(){let a=t;return pa||(pa=Promise[a(1303)]().then(zt[a(1433)](zt,e[a(312)]))),pa}class Up extends ha{constructor(n,s){let l=t,h={XlXzX:function(y,w){return e[G(965)](y,w)}};if(e[l(1807)](e[l(1091)],l(1426)))return hlGvzX[l(533)](_0x5af012,_0xa426e9);super(),this._dbName=n,this[l(415)]=s,this[l(1713)]=void 0,this[l(930)+"mise"]=null}async[t(865)](){await this[t(983)]()}async _init(){let n=t,s={uisOm:function(l,h,y,w){return e[G(1430)](l,h,y,w)}};if(e[n(575)](e[n(881)],e[n(881)]))_0x506232[n(332)](_0x2d4ecd);else{if(this[n(1713)])return;if(this[n(930)+"mise"])return this[n(930)+n(1019)];try{let l=this[n(1053)],h=this[n(415)];this[n(930)+n(1019)]=(async()=>{let y=n,{openDB:w}=await zp();this._qosDB=await s.uisOm(w,y(1014)+"_"+l,1,{upgrade(b){b[y(1733)+"jectStore"](l,{keyPath:h})}})})(),await this[n(930)+n(1019)]}catch(l){console[n(332)](l)}finally{this[n(930)+n(1019)]=null}}}async[t(1729)](n){let s=t;try{return await this[s(983)](),this[s(1713)]?.[s(1729)](this[s(1053)],n)}catch(l){console.log(l)}}async[t(1416)](n,s){let l=t;return await this[l(983)](),this[l(1713)]?.[l(1123)](this[l(1053)],n)}async[t(799)](n){let s=t;try{return await this._init(),this[s(1713)]?.[s(1790)](this[s(1053)],n)}catch(l){console[s(332)](l)}}async[t(1570)](){let n=t,s={sugja:e[n(822)],DLEJM:e[n(882)],NiIAw:function(l,h,y,w){return l(h,y,w)},juMgN:n(1032)+"ervice",kSdsQ:function(l,h){return e[n(857)](l,h)},pZTEY:n(1223)+"ile_name",jtICs:e[n(423)]};if(e[n(991)](n(571),e[n(1776)])){let l={BWJqT:s[n(1372)],OUlSY:s[n(429)],gQjeZ:function(p,C,L,B){return s[n(1252)](p,C,L,B)},SZeAu:s[n(811)],utwsv:"curvalue",XGqAG:n(1374),bhfyW:function(p,C,L,B){return s[n(1252)](p,C,L,B)}},[h,y]=s[n(668)](_0x2f4a3a,_0x14f753),w=s[n(668)](_0x1af678,h),b=0;return _0x22a8bf[n(958)](p=>{let C=n,L=l[C(982)].split("|"),B=0;for(;;){switch(L[B++]){case"0":_0x11b2be.log(l[C(858)],b);continue;case"1":b=l[C(907)](_0x48039d,_0x5c18cd[C(1694)+"er"](p[C(1660)]||_0x135e8c),w,b);continue;case"2":b=l[C(907)](_0x327fb3,p[C(823)+C(411)],w,b);continue;case"3":_0x41c372[C(332)](l.SZeAu,p,p.service);continue;case"4":_0x533794[C(332)](l[C(910)],b);continue;case"5":_0x186a51[C(332)](l[C(576)],b);continue;case"6":_0x24eff8[C(332)](C(488)+"name",b);continue;case"7":b=l[C(907)](_0x33b291,0,w,b);continue;case"8":_0x3cb071[C(332)](C(1674),b);continue;case"9":b=l[C(330)](_0x59455c,y[p[C(823)+C(411)]],w,b);continue;case"10":b=_0x5beffa(w,b,p[C(1674)]||0);continue}break}}),{frameType:_0x4ff6a6,headers:[{key:n(1223)+"ile_name",value:_0x38ebd3}],payload:w}}else try{return e.HGAqV("AzibC",e.jzmLp)?(await this[n(983)](),this[n(1713)]?.[n(1570)](this._dbName)):{frameType:_0x49dc53,headers:[{key:s.pZTEY,value:s[n(833)]}],payload:void 0}}catch(l){console[n(332)](l)}}async[t(451)](){let n=t;return e.HbeJY!==e[n(520)]?(await this[n(983)](),this._qosDB?.[n(1429)+"ys"](this[n(1053)])):(_0x534b3e|=0,{low:_0x5006cf,high:e[n(1272)](_0x5fc48b,31),unsigned:e[n(975)](_0x16b369,0)})}async[t(1636)](){let n=t;return await this[n(983)](),this[n(1713)]?.[n(1636)](this[n(1053)])}async closeDB(){let n=t;if(e.UcOgt(e[n(623)],e[n(623)]))try{this[n(1713)]?.close(),this[n(1713)]=void 0}catch(s){console[n(332)](s)}else return _0x445caf[n(332)]("setdb",_0x3280ef,_0x39e186,_0x36a738),this[n(1713)][n(1416)]({cursor_name:_0x559a89,cursor:_0x53ef76,service:_0x3f74a1})}get[t(732)](){let n=t;try{if(e.HGTKc(e.vNtxi,e.vNtxi))this[n(718)+"T"]?_0x5f2a5a[n(1149)+n(888)+n(398)](({isConnected:s})=>{let l=n;this[l(1527)+l(1049)+l(739)]=s,s?this[l(1072)+"nLine"]():this[l(1072)+"ffLine"]()}):this[n(562)+"X"]&&_0x4701d6["onNetworkStatusC"+n(398)](({isConnected:s})=>{let l=n;this[l(1527)+l(1049)+l(739)]=s,s?this[l(1072)+l(1002)]():this[l(1072)+l(373)]()});else return!!this._qosDB}catch(s){return console.log(s),!1}}}class qp{constructor(n,s){let l=t;this[l(1076)]=n,this[l(1386)]=s,this[l(1713)]=localStorage}async[t(865)](){}get[t(891)](){let n=t,s={RRQOX:function(l,h){return e[G(657)](l,h)},ydTCZ:function(l,h,y){return e[G(1200)](l,h,y)},UpqUg:function(l,h){return e[G(1410)](l,h)}};if(e[n(408)](e.CjZXZ,e.CjZXZ)){if(this[n(1823)]&&s[n(1786)](this[n(1823)][n(725)+"te"],this[n(1060)+"NG"])){this[n(660)+n(600)](),this[n(654)+n(851)+"Id"]=s.ydTCZ(_0x5897e6,this[n(1311)][n(1433)](this),this[n(1680)]["pingInte"+n(1706)]);return}if(!this[n(1823)]||s[n(1016)](this[n(1823)].readyState,this.OPEN))return void this["_handleR"+n(1253)]();this._ws&&this[n(1823)][n(487)]("hi"),this[n(1738)+n(1275)+n(1449)]=_0x1587eb(this._handleReconnectTimeout[n(1433)](this),this[n(1680)][n(1757)+n(1086)+n(1491)])}else return n(1014)+"_"+this[n(1076)]}async[t(1729)](n){let s=t;if(e[s(1847)](e[s(712)],e.mkCdg)){let l=this._qosDB[s(583)](this[s(891)]);return JSON.parse(e[s(523)](l,"{}"))[n]}else{let l=_0x2e06c4[s(691)]&&_0x572a48[0];if(e[s(937)](l,_0x4f32f0))throw l;let h=new _0x29a59e(e[s(1247)]+(l?e.CENyC(e[s(392)](" (",l[s(1126)]),")"):""));throw h.context=l,l}}async[t(1416)](n,s){let l=t,h=this[l(1713)].getItem(this[l(891)]),y=JSON.parse(h||"{}");return y[s||n[this._pathKey]]=n,this._qosDB[l(1176)](this[l(891)],JSON[l(454)+"y"](y)),s||n[this[l(1386)]]}async[t(799)](n){let s=t;if(e.ueubw!==e[s(1793)]){let l=this[s(1713)][s(583)](this[s(891)]),h=JSON[s(1051)](e[s(1289)](l,"{}"));return h[n]=void 0,this[s(1713)][s(1176)](this[s(891)],JSON[s(454)+"y"](h))}else this[s(338)](e.jnCCl,e.mZCiM(_0x211c17,e[s(627)],{..._0x214767,message:_0x7e770b.errMsg||""}))}async[t(1570)](){let n=t;return this[n(1713)][n(1570)]()}async[t(451)](){let n=t,s=this[n(1713)][n(583)](this[n(891)]),l=JSON[n(1051)](e[n(1336)](s,"{}"));return Object[n(451)](l)}async[t(1636)](){let n=t,s=this[n(1713)].getItem(this[n(891)]),l=JSON.parse(e[n(1103)](s,"{}"));return Object[n(625)](l)}closeDB(){return Promise[t(1303)]()}get isReady(){return!!this[t(1713)]}}class Gp{constructor(n,s){let l=t;this._DBName=n,this[l(1386)]=s,this._qosDB=Pn?tt:Qr?wx:null}async[t(865)](){}get[t(891)](){return t(1014)+"_"+this._DBName}async[t(1729)](n){let s=t,l=this[s(1713)][s(1432)+s(655)](this[s(891)]);return JSON[s(1051)](e[s(1213)](l,"{}"))[n]}async[t(1416)](n,s){let l=t,h=this[l(1713)][l(1432)+"geSync"](this[l(891)]),y=JSON[l(1051)](e[l(1103)](h,"{}"));return y[s||n[this[l(1386)]]]=n,this[l(1713)].setStorageSync(this[l(891)],JSON[l(454)+"y"](y)),s||n[this[l(1386)]]}async del(n){let s=t,l=this._qosDB.getStorageSync(this[s(891)]),h=JSON.parse(e.qTGkM(l,"{}"));return h[n]=void 0,this[s(1713)][s(1270)+s(655)](this[s(891)],JSON[s(454)+"y"](h))}async[t(1570)](){let n=t;return this._qosDB[n(1839)+n(1385)]()}async keys(){let n=t,s=this._qosDB[n(1432)+n(1098)+"nc"](this[n(891)]),l=JSON.parse(e[n(1289)](s,"{}"));return Object[n(451)](l)}async[t(1636)](){let n=t;if(n(1073)===e[n(1699)]){if(this["_readyCl"+n(1748)]=!0,this[n(357)+n(920)](),this[n(660)+n(600)](),this[n(1758)+n(1760)+"Listener"](),this[n(1232)+n(1554)]?.[n(602)](),!this[n(1823)])return void this[n(1439)]("close, ws instan"+n(908)+n(1071)+"ed");if(e[n(689)](this[n(1823)].readyState,this[n(935)])||this[n(1823)][n(725)+"te"]===this[n(1332)])return void this[n(1439)](e[n(535)]);this[n(476)+n(1458)+"t"](_0xe2c280,_0x194349)}else{let s=this[n(1713)][n(1432)+"geInfoSync"](this[n(891)]),l=JSON[n(1051)](e[n(1289)](s,"{}"));return Object.values(l)}}closeDB(){return Promise[t(1303)]()}get[t(732)](){return!!this._qosDB}}function hl(a,n){let s=t;if(e[s(678)](e[s(554)],e.ifcZg))return _0x330bbb[s(1384)]||_0x1b906c[s(945)]?(s(414)+" "+(_0x2a5776[s(1384)]||"")+s(521)+(_0x452e70.errNo||"")).trim():_0x4859a5[s(454)+"y"](_0x38a6cd);if(e[s(523)](Pn,Pn))return new Gp(a,n);if((ir||ei)&&e.fBndo(e[s(993)],typeof indexedDB))return new Up(a,n);if(e[s(1336)](ir,ei)&&e.TCkNC(e[s(993)],typeof localStorage))return new qp(a,n);throw new Error(e.YcmAO)}class Hp{constructor(){let n=t;this[n(334)+n(669)+"Id"]=null,this[n(334)+"l"]=36e5,this[n(1713)]=e[n(1277)](hl,e.eQdcl,e[n(1178)])}async[t(334)+t(1383)](){let n=t;e[n(1566)](clearInterval,this[n(334)+n(669)+"Id"]),this[n(334)+n(669)+"Id"]=e[n(480)](setInterval,()=>{this[n(363)+"ired"]()},this[n(334)+"l"])}async[t(865)](){let n=t,s={ExwCD:function(l,h){return e[G(1821)](l,h)},cqfnh:e[n(402)]};if(e[n(443)]!==e.mApMn){let l=_0x4ad681[n(1477)],h=_0x55c0ce.limit;return l.length===h?l:l.subarray(0,h)}else await this[n(1713)][n(865)]()[n(644)](()=>{let l=n;s[l(831)]!=="btsAn"?(_0x2ae1c6[_0x9fb46f++]=wBFoeU.ExwCD(_0x5b7c58,6)|192,_0x5832bc[_0x3c8ee2++]=63&_0x1184cb|128):this[l(334)+l(1383)]()})}async[t(363)+"ired"](){let n=t;(await this[n(1713)]?.getAll()||[])[n(1321)](({timestamp:h})=>h<Date.now())[n(958)](h=>{this._qosDB?.del(h.message_id)})}async[t(799)](n){let s=t;return this[s(1713)]?.[s(799)](n)}async[t(1416)](n,s){let l=t,h={lQFms:function(y,w){return y(w)},nuIJY:e[l(1824)],pCyou:e[l(1478)],YkZQM:function(y,w){return y(w)}};if(e[l(1519)]!==l(628))return this._qosDB?.[l(1416)]({message_id:n,timestamp:s});{let y={yMfnj:function(w,b){return h.YkZQM(w,b)}};return new _0x1a360e((w,b)=>{let p=l,C={acmIl:function(q,$){return h[G(1105)](q,$)},AuoXc:"success",cdAKD:h[p(579)],kvMDN:p(461)+"e_timeout"};this._clearPingTimer(),this[p(654)+p(851)+"Id"]=_0xe56fdd(this[p(1311)][p(1433)](this),this[p(1680)][p(1214)+p(1706)]);let L=()=>{let q=p;C[q(951)](w,C[q(803)]),this.off(C[q(757)],L),this[q(707)](C[q(1494)],B)},B=()=>{let q=p;y.yMfnj(b,q(1540)),this[q(707)]("ping_onc"+q(1832)+"s",L),this[q(707)](q(461)+q(1766)+"t",B)};this.on(p(461)+p(1832)+"s",L),this.on(h[p(1027)],B),this[p(1311)]()})}}async get(n){let s=t;return this._qosDB?.[s(1729)](n)}async[t(602)](){let n=t;e[n(1344)](clearInterval,this[n(334)+"lTimeoutId"]),await this[n(1713)]?.[n(602)]()}get[t(732)](){let n=t;if(e.epmqh(e.fGnNB,e[n(1222)]))return this._qosDB?.isReady;{e[n(714)](_0x4c705e,_0x466527,42);let s=_0x464164();e[n(1088)](_0x3c002c,_0x136704,s),_0x3abc59(_0x2e6e24,s[n(1459)]),_0xc2e459(_0x420708,s),e.cZmCD(_0xaf534b,s)}}}function ga(a){let n=t,s=!!this._options[n(633)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e[n(1701)](on,a[n(1126)][n(1735)],e[n(374)],"2"),h=l&&e[n(1191)](on,a[n(1126)].headers,n(895)+n(1549)+"ck","1"),y=l&&e[n(1317)](on,a[n(1126)][n(1735)],e[n(909)],"1"),w=y?e.qHUWe(sr,a[n(1126)][n(1735)],n(895)+"er_ack_m"+n(670))?.[n(1329)](",")[n(1321)](Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:y,ackMsgIds:w}}async function xl(){let a=t;return this[a(1232)+a(1554)]||(this[a(1232)+a(1554)]=new Hp),this["_QoSMana"+a(1554)][a(732)]||await this[a(1232)+a(1554)].openDB(),this[a(1232)+a(1554)]}async function jp(a,n){let s=t;if(e[s(1192)](e[s(708)],"AtHEK"))return _0x39074a;{let{enableAutoAck:l}=this[s(1680)],h=on(a[s(1126)].headers,e.uausx,"1"),y=e[s(400)](on,a[s(1126)][s(1735)],e[s(564)],"1"),w=ga[s(693)](this,a);if(l&&h){let{SeqID:b,LogID:p,service:C,LogIDNew:L,method:B}=a[s(1126)];this[s(559)]({SeqID:b,LogID:p,LogIDNew:L,service:C,method:B,headers:[{key:e[s(564)],value:"1"},{key:e[s(1842)],value:e[s(342)](L,"")},{key:e[s(311)],value:"0"}]})}y&&!w[s(1637)]&&this[s(997)+s(827)+s(1260)](a),e.ptrJf(n)}}async function Kp(a,n){let s=t;this._debug(s(1493),a[s(1126)]),e[s(978)](n)}async function Wp(a,n){let s=t,l=e[s(1423)](nn,await e[s(1686)](fl,a[s(1216)]));try{if(l[s(403)]instanceof Uint8Array){let h=e.sYHZk(this[s(1680)][s(1650)+s(558)],Object)?{force:!!this._options["payloadE"+s(558)].force,encoding:this[s(1680)][s(1650)+s(558)][s(1505)]?this._options[s(1650)+s(558)][s(1505)][s(1393)](/\s/g,"")["toLowerC"+s(515)]():""}:{force:!1,encoding:this[s(1680)][s(1650)+s(558)]?this._options[s(1650)+s(558)][s(1393)](/\s/g,"")[s(1030)+"ase"]():""},y=l[s(1650)+"ncoding"]?l[s(1650)+s(558)][s(1393)](/\s/g,"")[s(1030)+s(515)]():"",w=e.OJKax(this._options[s(798)+s(1700)],Object)?{force:!!this[s(1680)]["payloadT"+s(1700)][s(649)],type:this[s(1680)][s(798)+s(1700)][s(1353)]?this[s(1680)][s(798)+s(1700)][s(1353)][s(1393)](/\s/g,"")[s(1030)+s(515)]():""}:{force:!1,type:this._options[s(798)+s(1700)]?this[s(1680)][s(798)+s(1700)][s(1393)](/\s/g,"").toLowerCase():""},b=l.payloadType?l[s(798)+s(1700)].replace(/\s/g,"")[s(1030)+"ase"]():"",p=w.force?w[s(1353)]:b||w[s(1353)],C=h[s(649)]?h[s(1505)]:y||h[s(1505)],L=[e[s(617)],e.NsxQY,s(525)+s(1784)+s(1031)+s(561),e.zzHFK],B=[e[s(1646)],e.ItxkW];this._options[s(475)+s(1431)+"extPayload"]&&L.includes(p)&&(!C||B[s(1350)](C))?l[s(1547)+s(1504)]=e[s(1430)](ul,l[s(403)],0,l.payload[s(526)+"th"]):l[s(1547)+s(1504)]=""}else l["textPayl"+s(1504)]=""}catch(h){l[s(1547)+"oad"]="",console[s(332)](h)}a[s(1126)]=l,e[s(978)](n)}function $p(a,n,s){let l={xXSKi:function(p,C){return e.LCAcn(p,C)},UfvWr:function(p,C){return e[G(1768)](p,C)},psUHy:function(p,C){return e[G(1024)](p,C)},nBWyC:function(p,C){return p+C},uXiIT:function(p,C){return e.pKAhT(p,C)},CbEEb:function(p,C){return e[G(527)](p,C)}},h=e.lHIxb(s,8192),y=e.SgDtO(h,1),w=null,b=h;return function(p){let C=G;if(l[C(1125)](p,1)||l[C(388)](p,y))return l[C(519)](a,p);l[C(969)](b,p)>h&&(w=l[C(1739)](a,h),b=0);let L=n[C(693)](w,b,b+=p);return l[C(581)](7,b)&&(b=l[C(969)](7|b,1)),L}}let Vp=4294967295;function Jp(a,n,s){let l=t;return e[l(916)](RangeError,e.Fotbj(e[l(1653)](e.aPdAV(e.eqEkp(e[l(1483)],a),l(1695))+e[l(1103)](n,1)," > "),s))}function Zp(a,n,s){let l=t;if(s>Vp)throw new Error(e[l(1500)]);let h=3;for(;e.HNzFd(h,0);){let y=e.iwqgD(255,s);e[l(390)](wa,y,a,e[l(1479)](n,h)),s>>>=8,h--}return n+4}function Yp(a,n){let s=t,l=0,h=n,y=n+4;for(;e[s(605)](h,y);){let{value:w,offset:b}=ma(a,h);h=b,l=e[s(1514)](l<<8,0),l+=w}return{value:l,offset:y}}function Xp(a,n,s){let l=t,h=e[l(1182)][l(1329)]("|"),y=0;for(;;){switch(h[y++]){case"0":if(!a)return s;continue;case"1":if(n[l(1556)])return e[l(588)](n[l(1556)](a,s),s);continue;case"2":return e[l(438)](e[l(1251)](xa,a,n,s),s);case"3":if(e[l(1465)](a.length,40))return e.tHfkI(e[l(390)](xa,a,n,s),s);continue;case"4":if(n.utf8Write)return e[l(1843)](n[l(370)+"e"](a,s),s);continue}break}}function Qp(a,n){let s=t,l=new ue(e[s(749)](e.WZvpg(e[s(328)](e[s(802)](a[e[s(1843)](n,4)],24),e[s(1201)](a[e.qLVJE(n,5)],16)),e[s(638)](a[e[s(1114)](n,6)],8)),a[e[s(1835)](n,7)]),e[s(662)](e.VWDHo(e.YmoqA(e[s(1238)](a[n+0],24),e[s(1295)](a[e.JwWWy(n,1)],16)),a[e[s(869)](n,2)]<<8),a[e[s(546)](n,3)]),!0);return n+=8,{value:l,offset:e.blyZj(n,8)}}function eg(a,n,s){let l=t,h={zEWWX:e[l(394)],zrkQk:e[l(1288)],bXwbT:"message",ATnro:e[l(627)]};if(e[l(848)](e.wqlwJ,e[l(928)])){let y=a[l(1499)],w=a[l(1425)];return n[s]=e.euhns(w,24),n[e[l(1553)](s,1)]=e.LEcqV(e.CAeGF(w,16),255),n[s+2]=e[l(344)](e[l(1308)](w,8),255),n[e[l(1343)](s,3)]=e[l(1152)](255,w),n[s+4]=e.xiHxo(y,24),n[e[l(431)](s,5)]=e[l(450)](y,16)&255,n[e[l(1008)](s,6)]=e.EkGdc(e[l(1765)](y,8),255),n[e[l(1664)](s,7)]=e[l(1677)](255,y),s+=8,s}else{if(!this[l(1823)])return;this[l(1823)][l(1531)+l(836)](h[l(1081)],this[l(796)]),this._ws[l(1531)+l(836)](h[l(1391)],this[l(653)]),this._ws.addEventListener(h.bXwbT,this[l(1638)+"ge"]),this[l(1823)][l(1531)+l(836)](h[l(731)],this._onError)}}function ma(a,n){let s=t;return a[s(631)+"8"]?{value:a.readUInt8(n),offset:e[s(1653)](n,1)}:{value:255&a[n],offset:e[s(709)](n,1)}}function wa(a,n,s){let l=t,h={JSyjV:function(y,w){return y|w},QdOva:function(y,w){return e[G(1592)](y,w)},ioIlz:function(y,w){return y|w},KAalS:function(y,w){return e[G(460)](y,w)}};if(e[l(643)](e[l(1204)],e[l(1204)]))return n[l(929)+"t8"]?n.writeUint8(a,s):n[s]=e.iwqgD(255,a),e.aPdAV(s,1);_0x42fc47[_0x42b76d++]=fVpQbf[l(1582)](fVpQbf[l(378)](_0x27f80b,12),224),_0xd2709e[_0x32c6cc++]=fVpQbf.JSyjV(fVpQbf[l(378)](_0x5dfd5c,6)&63,128),_0x4892e0[_0x20c1b0++]=fVpQbf[l(729)](fVpQbf.KAalS(63,_0xeedea0),128)}let tg=function(a){return new Uint8Array(a)},ng=e[t(845)](e[t(993)],typeof Buffer)?Buffer[t(587)+t(505)]:e.tCzEn($p,tg,Uint8Array[t(742)+"e"].subarray),rg=16,_a=32;function ig(a){let n=t,s=0,l={};for(let h=0;e[n(904)](h,a[n(691)]);h++)l[a[h][n(823)+n(411)]]=e.DGyLA(ll,a[h]["cursor_n"+n(411)]),s+=e[n(1835)](14,l[a[h][n(823)+n(411)]]);return[s,l]}function pl(a,n,s){let l=t,[h,y]=ig(a),w=e[l(303)](ng,h),b=0;return a[l(958)](p=>{let C=l;console[C(332)](e[C(1267)],p,p.service),b=e[C(1251)](wa,0,w,b),console[C(332)](e[C(1003)],b),b=Zp(w,b,p[C(1674)]||0),console[C(332)]("service",b),b=e[C(1317)](wa,y[p["cursor_n"+C(411)]],w,b),console[C(332)](e[C(1044)],b),b=e[C(1025)](Xp,p[C(823)+C(411)],w,b),console[C(332)](e[C(882)],b),b=e.vVuHY(eg,ue[C(1694)+"er"](p[C(1660)]||n),w,b),console[C(332)]("curvalue",b)}),{frameType:_a,headers:[{key:e[l(1258)],value:s}],payload:w}}function sg(a){let n=t,s=0,l=[];for(;e[n(1702)](s,a[n(526)+"th"]);){let{offset:h}=e[n(985)](ma,a,s);s=h;let y={cursor_name:"",cursor:0,service:0},{value:w,offset:b}=Yp(a,s);y[n(1674)]=w,s=b;let{value:p,offset:C}=ma(a,s);s=C,y.cursor_name=e[n(1364)](ul,a,s,e.fFOrk(s,p)),s+=p;let{value:L,offset:B}=e[n(626)](Qp,a,s);y[n(1660)]=L[n(1805)](),s=B,l[n(854)](y)}return l}function og(){let a=t;return{frameType:_a,headers:[{key:e[a(1258)],value:e[a(423)]}],payload:void 0}}class ag{constructor(n,s,l){let h=t;this[h(1817)+h(1224)]=n,this[h(777)+h(786)]=s,this[h(1565)+h(384)]=l,this[h(1713)]=e[h(1199)](hl,this[h(1817)+h(1224)],e.msOwh)}async openDB(){let n=t;await this[n(1713)][n(865)]()}async[t(1012)+"rs"](){let n=t;if(!this[n(1713)][n(732)])return;let s=this[n(1565)+n(384)],l=await this[n(1713)][n(1636)]();switch(console[n(332)](e[n(1764)],l),s){case e[n(1422)]:return l&&l.length?e.fKbjU(pl,l,0,this[n(777)+n(786)]):void 0;case e[n(439)]:return;case e[n(770)]:return l&&l[n(691)]?e[n(1567)](pl,l,0,this._cursorFileName):e[n(333)](og)}}async[t(1416)](n,s,l){let h=t;return console[h(332)](h(922),n,s,l),this[h(1713)].set({cursor_name:n,cursor:s,service:l})}async setCursors(n){let s=t,l=e[s(1551)](sg,n);for(let h of l)console[s(332)](e[s(387)],l),await this[s(1713)].set(h)}async[t(1729)](n){let s=t;return(await this._qosDB[s(1729)](n))?.[s(1660)]}async closeDB(){let n=t;e[n(495)]!==e[n(1059)]?await this[n(1713)][n(602)]():(this["_message"+n(350)][n(1249)](),this[n(1565)+n(350)][n(854)](_0x55eab2))}[t(545)+t(1274)+"Name"](n){let s=t,l={dHTHY:function(h,y,w){return e[G(1026)](h,y,w)},FCFEf:function(h,y,w){return e[G(481)](h,y,w)}};e[s(862)](e[s(490)],"AGqvn")?this[s(777)+s(786)]=n:(aLxUkI[s(680)](_0x332819,_0x4e24f7,74),aLxUkI.FCFEf(_0x526b5c,_0x29a314,_0x5e4f41))}get[t(732)](){let n=t,s={kdYam:e[n(394)]};if(e[n(549)](e[n(325)],e[n(325)]))return this[n(1713)][n(732)];this[n(338)](n(353),_0x3457ad(RZeiLM[n(795)],{..._0x430f3f,data:_0x37ed28[n(1384)]||""}))}}let cg=e[t(1159)];async function gl(a){let n=t;if(!this[n(1680)][n(633)+"S"])return null;let{aID:s,fpID:l,messageStrategy:h}=this[n(1680)],y=e[n(898)](a,cg);try{return this[n(952)+"anager"]?a&&this[n(952)+"anager"]["updateCu"+n(1274)+n(1522)](a):this[n(952)+n(300)]=new ag(l+"_"+s+"_"+y,y,h),this._cursorManager[n(732)]||await this[n(952)+"anager"].openDB(),this[n(952)+n(300)]}catch{return null}}async function dg(a,n){let s=t;if(e[s(1273)](e.YwLbH,e[s(825)]))return _0x22ca6d+=_0x484c6a&&_0x2b2a0b[s(526)+"th"]||0,_0x463ecd;{let l=on(a[s(1126)][s(1735)],e[s(1467)],"-1"),h=e.aqklh(on,a.message.headers,e.oIbkR,"1"),y=e[s(1775)](sr,a[s(1126)][s(1735)],e[s(341)]),w=e.AhWEd(Number,e[s(1419)](sr,a[s(1126)][s(1735)],e[s(980)]))||0,b=ga[s(693)](this,a),p=e[s(1317)](on,a.message[s(1735)],e[s(1647)],"2"),C=e.itgTv(sr,a[s(1126)][s(1735)],"x-msg-cu"+s(514)+"e"),L=e[s(1326)](Number,e[s(1302)](sr,a.message[s(1735)],e.xJPQP));if(b[s(1637)])return n();let B=b[s(834)+s(1716)]?await xl.call(this):null;if(e.tBnhS(a[s(1126)][s(1674)],0)&&h&&!l||e[s(352)](a[s(1126)][s(1674)],0))if(e.XzKUx("LJaxU",e[s(706)])){if(y&&b[s(834)+s(1716)]&&B)return!!!await B.get(y)&&(this[s(997)+s(1688)+s(1248)](a),await B[s(1416)](y,e[s(1653)](Date[s(1045)](),w))),e[s(1826)](n);if(p){let q=await gl.call(this);if(!q)return this[s(997)+s(1688)+"Event"](a),e[s(999)](n);let $=await q[s(1729)](C)??-1;if(e[s(1226)]($,L))this[s(997)+"hMessage"+s(1248)](a),q[s(1416)](C,L,a[s(1126)][s(1674)]);else throw new Error(s(447)+s(459)+" cursor "+L+(" larger "+s(465)+s(752)+"r ")+$);return e[s(1663)](n)}return this[s(997)+s(1688)+s(1248)](a),e[s(1480)](n)}else{let q=_0x129b52[s(1056)]();return q?(q[s(1054)]=q[s(1459)]=0,q):{bytes:new _0x3ecfbe(64),offset:0,limit:0}}}}async function lg(a,n){let s=t,l=ga.call(this,a);if(!l[s(834)+s(1716)])return e[s(978)](n);let h=await xl.call(this);if(l["isAckCleanupMess"+s(1568)]&&l[s(477)+"s"][s(691)])for(let y of l[s(477)+"s"])await h[s(799)](y);e.hqJgp(n)}async function ug(a,n){let s=t,l=e[s(1381)](a[s(1126)].frameType,rg),h=a[s(1126)][s(1115)+"e"]===_a;if(e[s(1845)](!l,!h))return e[s(978)](n);let y=sr(a[s(1126)].headers,e[s(1258)]);if(!y)return e.kAvSK(n);let w=await gl[s(693)](this,y);if(!w)return e[s(478)](n);if(l){let b=await w[s(1012)+"rs"](),p={frameType:b?.[s(1115)+"e"],SeqID:ue.fromNumber(this._seqId++),LogID:ue[s(1694)+"er"](this[s(1680)][s(630)+s(1379)]()),service:9e3,method:5,headers:b?.[s(1735)],payload:b?.[s(403)]},C=v(p);this[s(1823)]&&this[s(1823)][s(725)+"te"]&&this[s(1823)][s(487)](C)}if(h){let b=a.message[s(403)];b&&w.setCursors(b)}}let fg=async function(a,n){let s=t;e[s(1723)](e[s(700)],e[s(1670)])?(this[s(1164)]=!1,e[s(981)](clearTimeout,this["_connect"+s(1040)+s(1569)]),e[s(978)](n)):(e[s(710)](_0x2f0ad3,_0x7a754d,e[s(424)](e[s(1774)](127,_0x5f5934),128)),_0x5719c1>>>=7)},hg=async function(a,n){let s=t;if(!this[s(1823)]||e[s(1427)](this[s(1823)][s(725)+"te"],this.OPEN))return e[s(1705)](n);let{pingInterval:l}=this[s(1680)];this[s(1362)+s(703)]?.["resetEnd"+s(412)+"fig"]();for(let y=0;y<this[s(1565)+s(350)][s(691)];y++){let w=this._messageQueue[y];if(e[s(1042)](this[s(1823)].readyState,this[s(406)])&&e[s(1581)](null,w))this._ws&&this[s(1823)][s(487)](w),this[s(1565)+s(350)][y]=null;else break}this._messageQueue=this["_message"+s(350)].filter(y=>!!y),this["_pingPon"+s(851)+"Id"]=e.sJDoY(setTimeout,()=>this._ping(),l),this["_dispatc"+s(992)+"nt"](a),this._isBrowser&&this[s(1823)]&&(this._ws[s(1517)+"pe"]=this[s(383)+"ype"]);let h=this[s(1362)+s(703)]?.[s(683)+s(1102)+"nt"]();this[s(1439)](s(1681)+h+s(1508)),e[s(1663)](n)},xg=async function(a,n){let s=t,l=this[s(1362)+s(703)]?.[s(683)+s(1102)+"nt"]();this._debug(s(1681)+l),n()};class pg extends ha{constructor(n){let s=t,l={zFTSv:function(b,p){return e[G(1217)](b,p)},ybANq:function(b,p){return e[G(1278)](b,p)},Keivt:e[s(805)],QFynu:function(b,p){return b||p},oBomh:s(1229),vLOrj:function(b,p,C){return b(p,C)},XJhYJ:function(b,p){return e[s(308)](b,p)},kHsbk:e[s(1404)],CNxqY:function(b,p){return e[s(646)](b,p)},FspeO:s(492),zlwoi:e[s(640)],wMbBO:function(b,p,C){return e[s(748)](b,p,C)},LFutO:e[s(627)],QJvsG:function(b,p){return e[s(1273)](b,p)},OQXmf:e[s(1078)],TZajY:e[s(1824)],hTHHC:function(b,p,C){return e[s(998)](b,p,C)},KAyMZ:function(b,p){return b===p},DLode:function(b,p,C,L){return e.eBlcQ(b,p,C,L)},pZFXY:e.aSadH,VGysL:e[s(311)],vIkdS:e[s(1288)],VCwjG:function(b,p){return e[s(1167)](b,p)},dwVQv:e[s(1021)],vCDew:function(b,p){return e[s(1427)](b,p)},sxXGe:function(b,p,C){return e[s(1261)](b,p,C)}};super(),this[s(1527)+"igatorOn"+s(739)]=!0,this._isBrowser=ir,this[s(1132)]=Dp,this._isMiniTT=Pn,this[s(562)+"X"]=Qr,this[s(1345)+"r"]=ei,this[s(1565)+"Queue"]=[],this[s(1362)+s(703)]=null,this[s(1730)+s(1748)]=!1,this[s(383)+s(1700)]=e[s(1802)],this[s(1220)+s(1376)]=!1,this[s(1220)+s(1040)+"utId"]=null,this[s(1738)+s(1275)+"tId"]=null,this[s(654)+"gTimeoutId"]=null,this[s(826)]=0,this[s(1164)]=!1,this._url="",this[s(1232)+s(1554)]=null,this[s(952)+s(300)]=null,this[s(522)+s(1691)]=null,this[s(1798)+"ls"]=e[s(428)],this.CLOSED=3,this[s(1060)+"NG"]=0,this[s(406)]=1,this.CLOSING=2,this[s(796)]=b=>{let p=s;if(l[p(1564)](p(1369),l[p(652)]))try{if(l[p(1844)](l[p(1029)],l[p(1257)]))return _0x202e1d(RKpjwl.zFTSv(RKpjwl[p(496)](p(1474)+p(1752)+"ge: "+_0x4752a3+RKpjwl[p(846)]+RKpjwl[p(1641)](_0x44856e,1),RKpjwl[p(458)]),_0x1e963b));dl(this,b,[fg,hg,xg])}catch(C){let L=l[p(355)](lt,l[p(769)],{message:C.message,code:sn[p(737)+"OR"],error:C});this["_dispatc"+p(658)+p(409)](L)}else l[p(1617)](_0x2daa5a,_0x420ba6,this[p(914)+"rvalValue"](_0xef7875))},this._onMessage=async b=>{let p=s,{pingInterval:C,pingFrequency:L}=this._options;if((l[p(1844)]("hi",b.data)&&l[p(1644)](l[p(1624)],L)||p(1408)===L)&&(this[p(660)+p(600)](),this[p(338)](l[p(1833)],p(1062)),this[p(654)+"gTimeoutId"]=l.hTHHC(setTimeout,this[p(1311)][p(1433)](this),C)),!l[p(791)]("hi",b[p(1216)]))try{l[p(819)](dl,this,b,[Wp,jp,lg,ug,dg,Kp])}catch(B){let q=l.vLOrj(lt,l[p(769)],{message:B[p(1126)],code:sn[p(1198)+p(705)],error:B});this[p(997)+p(658)+"ent"](q)}},this._onError=b=>{let p=s,C=this[p(1362)+p(703)]?.[p(1461)+p(560)+"es"](),L=this._endpointManager?.["getCurre"+p(1102)+"nt"]();if(C&&!b[p(1126)]){let B="connect "+L+(p(531)+p(692)+p(1732)+"ed");this[p(997)+p(658)+p(409)](e[p(1088)](lt,e[p(627)],{message:B,code:sn[p(1180)+p(682)+"R"],error:b}));return}this[p(1823)]&&e[p(1108)](this[p(1823)][p(725)+"te"],this.OPEN)&&this[p(1120)+p(962)](),this[p(997)+"hErrorEvent"](lt(e[p(627)],{message:b.message,code:sn["NATIVE_E"+p(494)],error:b}))},this[s(653)]=async b=>{let p=s;if(l[p(1844)](p(666),p(1352))){let{SeqID:C,LogID:L,service:B,LogIDNew:q,method:$}=_0x381f30.message;this[p(559)]({SeqID:C,LogID:L,LogIDNew:q,service:B,method:$,headers:[{key:"is_ack",value:"1"},{key:RKpjwl[p(1296)],value:RKpjwl.QFynu(q,"")},{key:RKpjwl.VGysL,value:"0"}]})}else{this["_clearTi"+p(920)](),this[p(660)+p(600)](),this[p(767)+p(1050)+"rs"](),this[p(1823)]=null,this[p(1220)+"Lock"]=!1;let C=this[p(1362)+p(703)]?.checkReachMaxTries();if(!C&&this["_navigat"+p(880)]()&&!this._readyClosed){let L=this._endpointManager?.[p(683)+"ntEndpoint"](),B=this._options[p(1488)+"tInterceptor"](b[p(1218)],b[p(1841)]);this["_dispatc"+p(1712)+p(409)](l[p(1617)](mt,l[p(1290)],{code:1006,reason:b[p(1841)]||p(1682)+p(319)+p(1367)+p(642)+"n, hostn"+p(721)+L,willReconnect:B})),B&&this[p(1220)]();return}if(l[p(1741)](1e3,b.code)&&this["_readyCl"+p(1748)]){this[p(997)+p(1712)+p(409)](mt(l[p(1290)],{code:1e3,reason:l[p(1482)]})),this[p(1362)+p(703)]?.["resetEnd"+p(412)+p(1606)](),this["_pingLos"+p(1691)]?.[p(1683)+p(957)]();return}if(l[p(1741)](1e3,b[p(1218)])&&C){let L=this[p(1362)+p(703)]?.[p(683)+p(1102)+"nt"](),B=b[p(1841)];B||(B=await Fp(this[p(781)])),B="connecti"+p(319)+"d, "+B+(p(445)+p(814))+L+(p(948)+p(1550)+p(1743)),this[p(997)+p(1712)+p(409)](l[p(1617)](mt,l[p(1290)],{code:b[p(1218)],reason:B}));let q=p(585)+L+(p(531)+p(692)+p(1732)+"ed");this[p(997)+p(658)+p(409)](l.wMbBO(lt,l[p(769)],{message:q,code:sn[p(1180)+p(682)+"R"]})),this[p(1362)+p(703)]?.[p(753)+"pointCon"+p(1606)](),this["_pingLos"+p(1691)]?.["resetCou"+p(957)]();return}if(l[p(479)](1e3,b[p(1218)])&&!b[p(1841)]){let L=this[p(1362)+"tManager"]?.[p(683)+"ntEndpoint"]();this[p(997)+p(1712)+p(409)](l[p(1122)](mt,l[p(1290)],{code:b[p(1218)],reason:p(1682)+"ng faile"+p(1367)+p(642)+p(1300)+"ame: "+L})),this[p(1362)+p(703)]?.[p(753)+p(412)+p(1606)](),this[p(522)+p(1691)]?.[p(1683)+p(957)]();return}this[p(997)+"hCloseEv"+p(409)](b),this[p(1362)+p(703)]?.[p(753)+p(412)+p(1606)](),this[p(522)+p(1691)]?.resetCounter()}},this[s(452)]=null,this[s(1256)]=null,this[s(376)+"e"]=null,this[s(1655)]=null,this.onStartReconnect=null,this[s(747)+s(1603)]=null,this[s(724)+"mediatel"+s(563)+"ct"]=null,this["_handleO"+s(1002)]=this[s(1072)+s(1002)][s(1433)](this),this[s(1072)+s(373)]=this._handleOffLine.bind(this),this[s(1634)+s(513)]=this[s(1634)+s(513)].bind(this),this[s(1634)+s(397)]=this._handlePageShow[s(1433)](this),this[s(1680)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1535)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e.FhLYj,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(770)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:h,ws:y}=n,w=Array[s(1269)](h)?h:e[s(1418)](e.zzHFK,typeof h)?[h]:[];if(!w||e[s(1171)](0,w.length))throw new Error(e[s(1411)]);if(!Lp(y))throw new Error(e[s(1631)]);Object.assign(this._options,n),this["_endpoin"+s(703)]=new cl(w,this[s(1680)][s(1028)+"es"]),this[s(522)+s(1691)]=new Bp(this[s(1680)][s(375)+s(609)]),this[s(1680)][s(410)+s(1147)]&&(this[s(1164)]=!0,this._connect()),this[s(1680)][s(1577)+s(900)+s(954)]&&(this[s(718)+"T"]||this[s(562)+"X"]?this["_onPageN"+s(1264)+s(1684)]():this._isBrowser&&this["_initGlo"+s(1760)+s(836)]())}["_handleO"+t(1002)](){let n=t;if(e[n(1355)]("BsiJL","BsiJL")){if(this._options[n(1506)+"utoReconnect"]||this._readyClosed)return;this[n(1451)+n(1253)]()}else return _0x459868&&(_0xb9d4dd=(0,_0x498a42[_0x7d6df3(_0x47c9f2)[0]])(_0x3d049c=0)),_0x1abd15}["_handleO"+t(373)](){let n=t;this[n(476)+"WebSocket"]();let s=e.PizxT(fa,e[n(1580)],{message:n(1437)+"ediately reconnect"});this[n(724)+n(1557)+n(563)+"ct"]&&this[n(724)+"mediatelyReconnect"](s)}[t(773)+t(1760)+t(836)](){let n=t;this[n(1808)+"er"]&&window[n(1531)+n(836)](e[n(1209)],this[n(1072)+"nLine"]),this[n(1808)+"er"]&&window[n(1531)+n(836)](e[n(1601)],this[n(1072)+"ffLine"]),this[n(1808)+"er"]&&window["addEvent"+n(836)](e[n(317)],this[n(1634)+n(513)]),this[n(1808)+"er"]&&window["addEvent"+n(836)](n(420),this[n(1634)+n(397)])}[t(1758)+"balEvent"+t(836)](){let n=t;this[n(1808)+"er"]&&window[n(787)+"entListener"](n(1806),this[n(1072)+n(1002)]),this[n(1808)+"er"]&&window[n(787)+"entListe"+n(1196)](e[n(1601)],this[n(1072)+n(373)]),this._isBrowser&&window[n(787)+n(1796)+n(1196)](e[n(317)],this[n(1634)+n(513)]),this._isBrowser&&window[n(787)+n(1796)+n(1196)](e[n(1611)],this._handlePageShow)}[t(1634)+t(513)](n){let s=t;e[s(474)](s(427),s(793))?(!n[s(1077)+"d"]&&(this._isBrowser&&window[s(787)+s(1796)+s(1196)](e.Zolvr,this[s(1634)+s(513)]),this[s(1808)+"er"]&&window[s(787)+"entListe"+s(1196)](e[s(1611)],this[s(1634)+s(397)]),this[s(1413)]()),this[s(1808)+"er"]&&window[s(787)+"entListe"+s(1196)](s(1806),this[s(1072)+s(1002)]),this[s(1808)+"er"]&&window[s(787)+"entListe"+s(1196)](e.OnQXt,this[s(1072)+s(373)])):(this[s(750)+s(1441)]=_0x51b276,this[s(1168)]=0)}[t(1634)+"ageShow"](n){let s=t,l={EXLdM:function(h,y){return e[G(431)](h,y)},LUZfu:function(h,y){return e[G(1322)](h,y)},znuPi:function(h,y){return e[G(471)](h,y)},lrNsp:function(h,y){return h>>>y}};if(n[s(1077)+"d"]){if(e[s(365)]===s(518))return this[s(1546)]?jxMfom[s(405)](jxMfom.LUZfu(this.high>>>0,_0x102659),this[s(1499)]>>>0):jxMfom[s(417)](this[s(1425)]*_0xf4c8a3,jxMfom.lrNsp(this[s(1499)],0));this[s(1211)+s(880)]()&&(!this._ws||e[s(1110)](this[s(1823)][s(725)+"te"],this[s(406)])||e[s(472)](this[s(1823)][s(725)+"te"],this[s(1060)+"NG"]))&&this["_handleO"+s(1002)](),this[s(1808)+"er"]&&window[s(1531)+s(836)](e.TgTvx,this[s(1072)+"nLine"]),this[s(1808)+"er"]&&window[s(1531)+"Listener"](e[s(1601)],this[s(1072)+s(373)])}}async[t(1097)+t(597)](n){let s=t,{fpID:l,deviceID:h,bddID:y,ttwID:w,accessKey:b,aID:p,customParams:C={},enableAutoAck:L,enableQoS:B,QoSLevel:q,env:$}=this[s(1680)],ge,Te,he;this._isBrowser||this[s(562)+"X"]||this[s(718)+"T"]?(ge=location&&e[s(1189)](e[s(407)],location[s(1331)])?"wss://":s(1335),Te=n[s(1393)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),he=/^wss(.*:\/\/)/[s(1314)](n)?n:""+ge+Te):(ge=e.myXDr,Te=n.replace(/(^http)((?:[s]*:\/\/))/,""),he=/(^ws)((?:[s]*:\/\/))/[s(1314)](Te)?Te:""+ge+Te);let be=y?e[s(840)]:w?e[s(1109)]:e[s(1414)],we=y||w||h;if(!we||!be)throw new Error(e.JRMiP);let wt=e.vThWj==typeof C?await e[s(603)](C):C,ml=$?e[s(1395)](Mp,$[s(1394)],$[s(1572)]):{},ya=Object.assign({device_platform:e.kJRuQ,version_code:s(723)+"0",access_key:b,fpid:l,aid:p,[be]:we,xsack:L?1:0,xaack:L?1:0,xsqos:B?1:0,qos_level:B?q:void 0,qos_sdk_version:2,...ml},wt),gg=Object.keys(ya)[s(1654)]((ba,Ea)=>ya[Ea]!==void 0?""+ba+(ba?"&":"?")+Ea+"="+ya[Ea]:ba,"");return he+s(1772)+gg}async[t(1220)](){let n=t,s={SWeOr:function(l,h){return e[G(901)](l,h)},KZzrO:e[n(368)],xDAej:function(l,h){return e[n(964)](l,h)},itpvc:"store",glDee:function(l,h){return e.deNVP(l,h)}};if(!(this[n(1220)+n(1376)]||this[n(1730)+n(1748)])){this[n(1220)+n(1376)]=!0;try{let l=this[n(1362)+n(703)]?.[n(1319)+"rentEndp"+n(1588)+n(939)+n(1434)](),{timeoutInterval:h}=this[n(1680)];if(l)if(e[n(1273)](e[n(1690)],e[n(1690)])){let w=this[n(1362)+"tManager"]?.[n(683)+"ntEndpoint"](),b=this["_endpoin"+n(703)]?.[n(1297)+n(345)+"pointAnd"+n(307)+n(369)](),p=this["_endpoin"+n(703)]?.[n(683)+n(1102)+n(467)+n(1441)]();if(b){let C="connect "+w+(n(1490)+n(948)+n(1550)+"ached, w"+n(936)+n(789)+n(733))+b+(n(1445)+"y"),L=e[n(1778)](lt,e.jnCCl,{message:C,code:sn[n(1180)+"IES_ERROR"]});this[n(1439)](C),this[n(997)+n(658)+n(409)](L),this[n(781)]=await this[n(1097)+n(597)](b),this._debug(n(585)+b+" "+p+" times"),this[n(767)+n(1050)+"rs"]()}else{let C=n(585)+w+(n(1490)+n(948)+n(1550)+n(1743));this[n(1439)](C),this[n(997)+"hErrorEv"+n(409)](e[n(1596)](lt,e[n(627)],{message:C,code:sn[n(1180)+n(682)+"R"]}));return}}else return oqjvOF[n(1356)](_0x26ceb4,_0x37798a)&&(_0x40689c===oqjvOF.KZzrO||oqjvOF[n(1450)](_0x252187,oqjvOF[n(1829)]))?!0:oqjvOF[n(302)](_0x395e51,_0x267e70);else{let w=this[n(1362)+n(703)]?.[n(683)+"ntEndpoi"+n(1187)+n(1307)](),b=this[n(1362)+n(703)]?.[n(683)+n(1102)+n(467)+n(1441)]();this._url=await this["_generat"+n(597)](e.RAacF(w,"")),this[n(1439)](n(585)+w+" "+b+n(906)),this[n(767)+n(1050)+"rs"]()}if(this[n(1164)])this[n(1164)]=!1;else{let w=fa(e[n(1580)],{message:e[n(1831)]});this[n(493)+"econnect"]&&this["onStartR"+n(1253)](w)}let y=this[n(1362)+n(703)]?.[n(683)+n(1102)+n(467)+"ount"]()||0;e[n(318)](y,1)&&await this[n(893)](e[n(1830)](y,1)),this[n(1439)](n(1682)+n(463)+this[n(781)]+(" protoco"+n(1497))+this[n(1798)+"ls"]),this[n(1823)]=e.wbeGd(Op,{url:this[n(781)],protocols:[this[n(1798)+"ls"]],headers:this[n(1680)][n(889)+"ramParams"][n(919)+n(645)]},this[n(1680)].ws),(this[n(1808)+"er"]||this[n(1345)+"r"])&&this[n(1823)]&&(this[n(1823)].binaryType=this[n(383)+n(1700)]),this[n(1175)+n(1315)](),this[n(1220)+"ionTimeo"+n(1569)]=e[n(1778)](setTimeout,this[n(961)+"ut"][n(1433)](this),h)}catch(l){if(e[n(722)](e.GsSnz,n(1240)))throw this[n(1220)+n(1376)]=!1,l;_0x41b7ae[n(332)](n(1032)+n(1562),_0x2cd78b,_0x3b5148[n(1674)]),_0x60a5c3=e.qWjnv(_0x9e26a9,0,_0xba3b9d,_0x414e24),_0x54318a[n(332)](e[n(1003)],_0x2fe0b7),_0x52fa1d=e[n(1237)](_0x18eae1,_0x136cf9,_0x117a44,_0x2ae52e[n(1674)]||0),_0x14312c.log(e[n(1789)],_0x5da8db),_0x50c316=e.BHTOK(_0x5b1f7c,_0x116a42[_0x169c6d[n(823)+"ame"]],_0x2e9e87,_0x429394),_0x5262a2[n(332)](e[n(1044)],_0x5c06fd),_0x3057cc=e.cZvkq(_0x3a67bb,_0x1545bd[n(823)+"ame"],_0x2714f3,_0x2f54cb),_0x6ddf2d[n(332)](e[n(882)],_0x516d9b),_0x10b377=_0x1b3ff9(_0x1690b9[n(1694)+"er"](_0x3c482c[n(1660)]||_0x1c0fea),_0x3c0614,_0x38176f),_0x3dfe32[n(332)](e[n(1351)],_0x3547dc)}}}[t(357)+t(920)](){let n=t;e[n(303)](clearTimeout,this[n(1220)+n(1040)+"utId"]),this[n(1220)+n(1040)+"utId"]=null}[t(660)+t(600)](){let n=t;clearTimeout(this[n(654)+n(851)+"Id"]),e[n(857)](clearTimeout,this[n(1738)+n(1275)+n(1449)]),this["_pingPon"+n(851)+"Id"]=null,this[n(1738)+n(1275)+n(1449)]=null}[t(1439)](...n){let s=t;if(e[s(1358)]!==e.iFXru){let l=_0x7a02c9(e[s(627)],{message:_0x560d06.message,code:_0x56f785[s(737)+"OR"],error:_0x45498b});this[s(997)+s(658)+s(409)](l)}else this[s(1680)][s(896)]&&console[s(332)][s(557)](console,[s(1117)+">",...n])}[t(914)+t(711)+"e"](n){let s=t,{initReconnectInterval:l,maxReconnectInterval:h,reconnectIntervalGrowFactor:y}=this._options,w=e.MJiYa(l,Math[s(815)](y,e[s(1095)](n,1)));return w>h?h:w}[t(1311)](){let n=t;if(this[n(1823)]&&this[n(1823)][n(725)+"te"]===this[n(1060)+"NG"]){this[n(660)+"ngTimer"](),this[n(654)+n(851)+"Id"]=e[n(401)](setTimeout,this[n(1311)].bind(this),this[n(1680)][n(1214)+n(1706)]);return}if(!this._ws||e[n(734)](this[n(1823)].readyState,this.OPEN))return void this[n(1451)+n(1253)]();this._ws&&this._ws.send("hi"),this["_reconnectTimeou"+n(1449)]=setTimeout(this["_handleR"+n(1253)+n(1605)][n(1433)](this),this[n(1680)][n(1757)+n(1086)+"val"])}[t(1451)+t(1253)+t(1605)](){let n=t;this[n(522)+n(1691)]?.addCount(),this[n(338)](e.qexqp,n(1540)),this["_pingLos"+n(1691)]?.[n(1461)+n(763)+"nt"]()?this[n(1451)+"econnect"]():this[n(1311)]()}[t(1211)+t(880)](){let n=t,s={rQAiX:function(l,h){return e[G(380)](l,h)},Crecr:function(l){return l()}};if(e.Lcqdi(n(1809),e.dgkAa))return this[n(718)+"T"]||this._isMiniWX?this[n(1527)+n(1049)+"line"]:(this[n(1808)+"er"]||this[n(1345)+"r"])&&this._options[n(1577)+n(900)+"nged"]?navigator[n(1388)]:!0;lkBmoZ[n(436)](_0x4b4bd0,lkBmoZ[n(436)](_0x5f5897,_0x25b291[n(1138)])),lkBmoZ[n(1136)](_0x51c46f)}["_handleR"+t(1253)](){let n=t;!this[n(1211)+n(880)]()||this[n(1730)+n(1748)]||(this[n(1362)+n(703)]?.[n(753)+n(412)+"fig"](),this["_pingLos"+n(1691)]?.["resetCou"+n(957)](),this[n(1823)]?this[n(1120)+n(962)](1001,e[n(1150)],!0):this[n(1220)]())}[t(1005)+"etWorkChange"](){let n=t,s={QCfnd:function(l,h){return e[G(697)](l,h)},odqOM:function(l,h){return e[G(1787)](l,h)},OWuuh:function(l,h){return e.nzYMt(l,h)},Ieeox:e[n(783)],kfXUs:n(1327)};this[n(718)+"T"]?tt[n(1149)+n(888)+n(398)](({isConnected:l})=>{let h=n;this[h(1527)+h(1049)+h(739)]=l,l?this[h(1072)+"nLine"]():this["_handleO"+h(373)]()}):this[n(562)+"X"]&&wx.onNetworkStatusChange(({isConnected:l})=>{let h=n;s[h(539)]!==s.kfXUs?(this._miniNavigatorOnline=l,l?this._handleOnLine():this[h(1072)+"ffLine"]()):(_0x1d42d6=hyALPG[h(1526)](_0x46e833,_0x3e4215),_0x326007|=hyALPG[h(1777)](hyALPG[h(1128)](127,_0x3839c1),7))})}[t(893)](n){let s=t;if(e[s(728)]("QcJuR",e[s(1456)]))return new Promise(l=>{let h=s,y={NwQzT:function(w,b){return e[G(1485)](w,b)},cCTLo:function(w,b){return e[G(1268)](w,b)},JSlKH:function(w,b){return e[G(1038)](w,b)},QyxAO:function(w,b){return e.HnmTt(w,b)},mUEat:function(w,b){return w-b},oAJrz:function(w,b){return e[G(1156)](w,b)},eNmbA:function(w,b){return e.OcoWa(w,b)},bPwTD:function(w,b){return e.gNxiU(w,b)},BwtnK:function(w,b){return e[G(328)](w,b)},XWvgO:function(w,b){return e[G(1152)](w,b)},aiTTd:function(w,b){return e[G(404)](w,b)},tmkXp:function(w,b){return e[G(1586)](w,b)},DjtgC:function(w,b){return e[G(347)](w,b)},vzLtM:function(w,b){return w|b},QgDJG:function(w,b){return e[G(1827)](w,b)},KmgcC:function(w,b){return e[G(1234)](w,b)},ABGQK:function(w,b){return e[G(749)](w,b)}};if(e[h(1812)](h(507),e[h(620)]))e.PizxT(setTimeout,l,this[h(914)+"rvalValue"](n));else{let w=_0x4aeae7[h(592)+"At"](_0x42bfe8);kfcmoY.NwQzT(w,55296)&&kfcmoY.cCTLo(w,56319)&&kfcmoY.JSlKH(kfcmoY[h(1041)](_0x53e3a0,1),_0x1b6a19)&&(w=kfcmoY.mUEat(kfcmoY[h(1719)](w<<10,_0x5ea570[h(592)+"At"](++_0x3bbdeb)),56613888)),kfcmoY[h(1744)](w,128)?_0xda5a6c[_0x3304a7++]=w:(kfcmoY[h(884)](w,2048)?_0x3314d9[_0xd6a586++]=kfcmoY[h(1676)](kfcmoY[h(1687)](w>>6,31),192):(w<65536?_0x4fdbba[_0x2bbf40++]=kfcmoY[h(1676)](kfcmoY[h(1324)](kfcmoY[h(1630)](w,12),15),224):(_0x1c30d4[_0x16696d++]=kfcmoY.DjtgC(kfcmoY.aiTTd(w>>18,7),240),_0x57da8e[_0x125c79++]=kfcmoY[h(1244)](kfcmoY[h(1630)](w,12)&63,128)),_0x310bec[_0x311be7++]=kfcmoY[h(953)](kfcmoY[h(1324)](kfcmoY[h(673)](w,6),63),128)),_0x3161bb[_0x55ea61++]=kfcmoY[h(1348)](kfcmoY[h(1324)](63,w),128))}});this._binaryType=_0x9fe9da,this._ws&&(this[s(1823)][s(1517)+"pe"]=_0x2d6e95)}_disconnect(n=1e3,s="",l=!1){let h=t;if(e.xvyXQ!==e[h(960)]){if(!this[h(1823)])return;this[h(476)+h(1458)+"t"](n,s,l)}else{_0x59a448[h(989)](_0x33f94f)||(_0x1a52f7=_0x3817c9[h(1694)+"er"](_0x1af32e));let y=this.high>>>16,w=e[h(1774)](65535,this[h(1425)]),b=e[h(1153)](this[h(1499)],16),p=e[h(1785)](65535,this[h(1499)]),C=e[h(926)](_0x51bb33[h(1425)],16),L=e[h(1206)](65535,_0x310779[h(1425)]),B=e.HURxu(_0x3da12b[h(1499)],16),q=e[h(1152)](65535,_0x379fa7[h(1499)]),$=0,ge=0,Te=0,he=0;return he+=e.eqEkp(p,q),Te+=e.hgrML(he,16),he&=65535,Te+=e[h(304)](b,B),ge+=e[h(1157)](Te,16),Te&=65535,ge+=e[h(438)](w,L),$+=e.gbpiG(ge,16),ge&=65535,$+=e.rAyeT(y,C),$&=65535,_0x5e9ba0[h(1524)](e[h(413)](Te<<16,he),e[h(360)](e[h(1787)]($,16),ge),this[h(1546)])}}[t(961)+"ut"](){let n=t,s=this[n(1362)+"tManager"]?.getCurrentEndpoint();this._debug(n(585)+s+n(1490)),this[n(1120)+n(962)](1001,n(1795)+" try rec"+n(511)+"g",!0)}[t(559)](n){let s=t,l=qt(n);if(this[s(1823)]&&this[s(1823)][s(725)+"te"]===this[s(406)])if(e[s(573)](e[s(1623)],e[s(1623)])){let h="connect "+_0x23d1db+(" timeout"+s(948)+s(1550)+s(1743));this[s(1439)](h),this[s(997)+s(658)+"ent"](_0x3fe2c8(s(1284),{message:h,code:_0x2b9316["MAX_RETR"+s(682)+"R"]}));return}else this._ws&&this[s(1823)][s(487)](l),this._debug(e.MfcAn,n)}[t(767)+t(1050)+"rs"](){let n=t;this._ws&&(this[n(1823)][n(787)+n(1796)+n(1196)](e[n(394)],this[n(796)]),this[n(1823)][n(787)+"entListener"](n(1413),this[n(653)]),this[n(1823)][n(787)+"entListe"+n(1196)](e[n(551)],this._onMessage),this[n(1823)][n(787)+n(1796)+"ner"](e.jnCCl,this[n(1370)]))}[t(1175)+t(1315)](){let n=t;this[n(1823)]&&(this[n(1823)][n(1531)+"Listener"]("open",this[n(796)]),this[n(1823)][n(1531)+n(836)](e[n(1288)],this[n(653)]),this[n(1823)]["addEvent"+n(836)](n(1126),this[n(1638)+"ge"]),this[n(1823)][n(1531)+n(836)](n(1284),this[n(1370)]))}["_wsInsta"+t(606)](n=1e3,s=""){let l=t;try{this[l(1823)]&&this[l(1823)][l(1413)](n,s)}catch{}}[t(476)+t(1458)+"t"](n=1e3,s="",l=!1){let h=t,y={oUyKJ:function(w,b){return w===b}};if(this._clearPingTimer(),this[h(357)+h(920)](),this[h(767)+"sListeners"](),this[h(582)+"nceClose"](1e3,s),this[h(1220)+"Lock"]=!1,l&&this[h(1211)+h(880)]()&&!this[h(1730)+"osed"]){if(this[h(1362)+"tManager"]?.[h(1461)+h(560)+"es"]()){let b=this["_endpoin"+h(703)]?.[h(683)+h(1102)+"nt"]();this[h(997)+h(1712)+h(409)](mt(e.tzNpc,{code:1006,reason:h(585)+b+(h(1490)+", max re"+h(1550)+h(1743)),wasClean:!0}))}else{if(e[h(1736)](e[h(1836)],e[h(1836)]))return _0x30a546&&DpNCba[h(794)](!0,_0x3f9206[h(989)]);{let b=this[h(1680)]["reconnectInterce"+h(1107)](n,s);this["_dispatc"+h(1712)+h(409)](e[h(1129)](mt,e[h(1288)],{code:n,reason:s,wasClean:!0,willReconnect:b})),b&&this[h(1220)]()}}return}this[h(1211)+"orOnline"]()||this["_readyCl"+h(1748)]?this[h(997)+h(1712)+h(409)](mt("close",{code:n,reason:"bye"})):this[h(997)+h(1712)+h(409)](e.NbdHy(mt,h(1413),{code:1006,reason:e[h(1498)]})),this[h(1823)]=null,this[h(1362)+h(703)]?.["resetEnd"+h(412)+h(1606)](),this[h(522)+h(1691)]?.[h(1683)+h(957)]()}[t(997)+t(992)+"nt"](n){let s=t,l={elBtr:e[s(312)]};if(e[s(549)](e[s(1518)],e[s(1518)]))this[s(338)]("open",n),this[s(1655)]&&this.onopen(n);else return _0x526e9b||(_0x2021d7=_0x2fc26d.resolve()[s(644)](_0x47b843.bind(_0x21be64,mpxqVT[s(1205)]))),_0x2a7f59}["_dispatc"+t(1688)+t(1248)](n){let s=t;this.emit(e[s(551)],n),this[s(376)+"e"]&&this[s(376)+"e"](n)}["_dispatc"+t(827)+t(1260)](n){let s=t;this[s(338)](e[s(1452)],n),this[s(747)+s(1603)]&&this[s(747)+s(1603)](n)}[t(997)+t(658)+"ent"](n){let s=t;this.emit(e.jnCCl,n),this[s(1256)]&&this[s(1256)](n)}[t(997)+t(1712)+t(409)](n){let s=t;this.emit(e[s(1288)],n),this[s(452)]&&this[s(452)](n)}get[t(1517)+"pe"](){let n=t;if(e.KNhat!==e[n(1298)]){let{initReconnectInterval:s,maxReconnectInterval:l,reconnectIntervalGrowFactor:h}=this._options,y=s*_0x45d0e2[n(815)](h,e.KSyRM(_0x8ceec4,1));return e[n(352)](y,l)?l:y}else return this[n(1823)]?this[n(1823)].binaryType:this._binaryType}set[t(1517)+"pe"](n){let s=t;e[s(806)]!==e[s(806)]?this.on(_0x50fd38,_0x3d69a2):(this[s(383)+s(1700)]=n,this[s(1823)]&&(this._ws.binaryType=n))}get[t(720)+"nt"](){let n=t;if(e.XzKUx(e[n(923)],n(1612)))this[n(1211)+"orOnline"]()&&(!this[n(1823)]||e[n(474)](this[n(1823)][n(725)+"te"],this.OPEN)||e[n(1170)](this[n(1823)][n(725)+"te"],this[n(1060)+"NG"]))&&this[n(1072)+n(1002)](),this[n(1808)+"er"]&&_0x1cf867[n(1531)+n(836)](e[n(1209)],this[n(1072)+n(1002)]),this._isBrowser&&_0x44280b["addEvent"+n(836)](e[n(1601)],this[n(1072)+n(373)]);else return this[n(1362)+"tManager"]?.[n(683)+n(1102)+n(467)+n(1441)]()||0}get[t(1576)+t(1602)](){let n=t,s=this[n(1565)+n(350)].reduce((l,h)=>(l+=h&&h.byteLength||0,l),0);return e[n(1075)](s,this[n(1823)]?this[n(1823)][n(1576)+n(1602)]:0)}get[t(1533)+"ns"](){let n=t;return this[n(1823)]?this[n(1823)][n(1533)+"ns"]:""}get[t(1331)](){let n=t;return this[n(1823)]?this[n(1823)][n(1331)]:""}get readyState(){let n=t;if(!e[n(575)](n(1656),"LIYcd"))return this[n(1823)]?this._ws[n(725)+"te"]:this[n(1680)][n(410)+n(1147)]?this.CONNECTING:this[n(935)]}get url(){let n=t;if(e.PeKFy(n(1169),n(1169)))this[n(1713)]?.[n(1413)](),this[n(1713)]=void 0;else return this._ws?this._ws[n(1215)]:this._url}close(n=1e3,s){let l=t;if(this[l(1730)+l(1748)]=!0,this[l(357)+l(920)](),this[l(660)+"ngTimer"](),this._dropGlobalEventListener(),this[l(1232)+l(1554)]?.[l(602)](),!this._ws)return void this[l(1439)](e.iRwiw);if(e[l(821)](this[l(1823)][l(725)+"te"],this.CLOSED)||e[l(1171)](this[l(1823)][l(725)+"te"],this[l(1332)]))return void this._debug(e[l(535)]);this[l(476)+"WebSocket"](n,s)}async[t(487)](n,s){let l=t;if(n==null)throw new Error(e[l(1625)]);e[l(1501)](l(1438),typeof n)&&(n=JSON[l(454)+"y"](n)),e.ShLIJ(l(1037),typeof n)&&!e[l(1259)](n,ArrayBuffer)&&!(n[l(348)]&&e[l(1671)](n.buffer,ArrayBuffer))&&(n=JSON[l(454)+"y"](n));let h=await fl(n),y=e[l(1595)](Np,n),{method:w=0,service:b=this._options[l(1674)],logID:p=this[l(1680)][l(630)+l(1379)](),headers:C=this._options[l(1735)],payloadEncoding:L=this[l(1680)][l(1650)+l(558)],payloadType:B=this[l(1680)][l(798)+l(1700)],logIDNew:q=this[l(1680)][l(484)+"Config"][l(1066)+l(808)+l(1287)+"ew"]?e[l(1551)](i,this[l(1680)][l(484)+l(905)].userIp):""}=s||{};if(!b)throw new Error(l(622)+l(391)+l(389)+l(1562));let $={SeqID:ue[l(1694)+"er"](this._seqId++),LogID:ue.fromNumber(p),service:b,method:w,headers:C,payloadEncoding:e[l(1154)](L,Object)?L.encoding?L[l(1505)]:"":L,payloadType:e[l(612)](B,Object)?B[l(1353)]?B[l(1353)]:y:B||y,payload:h,LogIDNew:q},ge=e.BnHpF(qt,$);if(this[l(1823)]&&e[l(852)](this._ws[l(725)+"te"],this[l(406)]))this[l(1823)]&&this[l(1823)][l(487)](ge),this[l(1439)](e[l(1846)],$);else if(e[l(1702)](this[l(1565)+"Queue"].length,this[l(1680)][l(1536)+l(1583)+l(1731)]))if(e[l(964)](e[l(580)],l(548)))this[l(1565)+l(350)][l(854)](ge),this[l(1439)]("enqueue",$);else{let be=e.vMXwm.split("|"),we=0;for(;;){switch(be[we++]){case"0":var Te=_0x20bec8[_0x391b0d]={exports:{}};continue;case"1":_0x24b2e3[_0x484f5b](Te,Te[l(1165)],_0x3e3320);continue;case"2":if(DtsaBF[l(862)](void 0,he))return he[l(1165)];continue;case"3":var he=_0x403431[_0x227c56];continue;case"4":return Te.exports}break}}else this[l(1565)+l(350)][l(1249)](),this[l(1565)+"Queue"][l(854)](ge);return{seqID:this._seqId,logID:p,logIDNew:q}}async reconnect(n){let s=t,{url:l}=e[s(523)](n,{}),h=Array[s(1269)](l)?l:e.CkXqV(e[s(1174)],typeof l)?[l]:[];n&&Object[s(306)](this[s(1680)],n),h&&h[s(691)]?this["_endpoin"+s(703)]=new cl(h,this[s(1680)][s(1028)+"es"]):this["_endpoin"+s(703)]?.[s(753)+s(412)+s(1606)](),this["_pingLos"+s(1691)]?.[s(1683)+s(957)](this[s(1680)][s(375)+s(609)]),this._readyClosed=!1,this[s(1823)]&&this._ws.readyState!==this[s(935)]?this[s(1120)+s(962)](1e3,e[s(1148)],!0):(this[s(1164)]=!0,this[s(1220)]())}async connect(){let n=t;if(!this["_connect"+n(1376)]){let s=e[n(517)][n(1329)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(1164)]=!0;continue;case"1":this["_pingLos"+n(1691)]?.[n(1683)+n(957)]();continue;case"2":this[n(1362)+n(703)]?.["resetEnd"+n(412)+n(1606)]();continue;case"3":this[n(1220)]();continue;case"4":this["_readyCl"+n(1748)]=!1;continue}break}}}[t(1531)+"Listener"](n,s){this.on(n,s)}[t(1552)+"Event"](n){let{type:s}=n;this.emit(s,n)}[t(787)+t(1796)+t(1196)](n,s){this[t(707)](n,s)}[t(1548)](){let n=t,s={XvsjE:function(l,h){return l(h)},iCgEI:e[n(359)],CCIBI:e[n(1824)],BNEZd:function(l,h){return e[n(1338)](l,h)},UiYsa:function(l,h){return e[n(1265)](l,h)},ICbwM:function(l,h){return e[n(751)](l,h)},fKzjP:function(l,h){return e[n(1787)](l,h)},kaGVb:function(l,h){return l===h},vbbXU:n(1619),jjdpI:e[n(1635)],zbJzE:e[n(1286)]};return new Promise((l,h)=>{let y=n;this[y(660)+y(600)](),this[y(654)+"gTimeoutId"]=e[y(327)](setTimeout,this[y(1311)].bind(this),this._options.pingInterval);let w=()=>{let p=y;s[p(1598)](l,s.iCgEI),this[p(707)](s[p(875)],w),this[p(707)](p(461)+p(1766)+"t",b)},b=()=>{let p=y,C={VAvUA:function(L,B){return s.BNEZd(L,B)},BMTYP:function(L,B){return s[G(604)](L,B)},DlZAT:function(L,B){return L|B},ADZEN:function(L,B){return s[G(1034)](L,B)},Dmyqn:function(L,B){return L<<B},WFzVm:function(L,B){return s[G(570)](L,B)},ONgGX:function(L,B){return s.fKzjP(L,B)}};if(s[p(1057)](s.vbbXU,s.jjdpI))return LZSKlI[p(367)](_0x46560c,_0x2b1bd2)?_0x3eedd0:new _0x50e826(LZSKlI[p(913)](LZSKlI.DlZAT(LZSKlI[p(804)](_0x54a72f[p(693)](_0x19ace1,0),_0x34e45[p(693)](_0x41c0ce,1)<<8),_0x11c99d.call(_0x337f5a,2)<<16)|_0x348887[p(693)](_0x564718,3)<<24,0),LZSKlI[p(1070)](LZSKlI[p(804)](LZSKlI[p(804)](_0x501bff[p(693)](_0x684d9f,4),LZSKlI[p(430)](_0x76e731[p(693)](_0xc8bf7c,5),8)),LZSKlI.WFzVm(_0x43e0e0[p(693)](_0x7f443d,6),16)),LZSKlI[p(435)](_0x44e364[p(693)](_0x33a093,7),24))>>>0,!0);h(s[p(1761)]),this.off(p(461)+p(1832)+"s",w),this[p(707)](p(461)+p(1766)+"t",b)};this.on(e[y(1824)],w),this.on(e[y(1478)],b),this[y(1311)]()})}}})(),ze[M(1116)+M(1082)]=Oe["CustomCl"+M(1082)],ze["CustomEr"+M(1179)]=Oe[M(1698)+M(1179)],ze[M(1754)+"e"]=Oe[M(1754)+"e"],ze[M(1248)]=Oe[M(1248)],ze[M(485)]=Oe[M(485)],ze["Frontier"+M(892)+M(1464)]=Oe[M(1172)+M(892)+M(1464)],ze[M(892)+M(1464)]=Oe[M(892)+M(1464)],ze[M(1262)+"t"]=Oe[M(1262)+"t"],ze[M(503)+"tEvent"]=Oe[M(503)+M(372)],ze[M(1534)+"oseEvent"]=Oe.createCloseEvent,ze[M(1678)+"rorEvent"]=Oe[M(1678)+"rorEvent"],ze[M(1545)+"ssageEvent"]=Oe["createMe"+M(1813)+"nt"],ze[M(1090)+M(1421)]=Oe[M(1090)+M(1421)],ze[M(1023)+M(1163)+M(1464)]=Oe["createRe"+M(1163)+"vent"],ze["decodedF"+M(1608)]=Oe[M(566)+"rame"],ze[M(1212)+"ame"]=Oe["encodeFr"+M(411)];for(Go in Oe)[M(1116)+M(1082),M(1698)+M(1179),M(1754)+"e",M(1248),M(485),M(1172)+M(892)+"vent",M(892)+"vent",M(1262)+"t","Reconnec"+M(372),"createCloseEvent",M(1678)+M(1179),M(1545)+"ssageEvent",M(1090)+M(1421),"createRe"+M(1163)+M(1464),M(566)+"rame",M(1212)+M(411)][M(589)](Go)===-1&&(ze[Go]=Oe[Go]);var Go;Object[M(1717)+M(1594)](ze,M(887)+"le",{value:!0})});import{existsSync as vS,openSync as SS}from"node:fs";import{mkdir as IS}from"node:fs/promises";import{dirname as AS}from"node:path";import{fileURLToPath as TS}from"node:url";function CS(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ud(t=Q()){return vS(t.libEntry)?t.libEntry:TS(new URL("../index.ts",import.meta.url))}async function Wx(t={}){let e=t.paths??Q(),r=t.entryOverride??Ud(e),i=CS(e,process.env.COZE_BRIDGE_LOG_MODE);await IS(AS(i),{recursive:!0});let o=SS(i,"a"),d=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=st(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[ss]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return kS.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var kS,ss,Qo=rt(()=>{"use strict";Jt();te();Me();kS=H("spawn-daemon"),ss="COZE_BRIDGE_DAEMON"});import{spawn as v1}from"node:child_process";import{mkdir as S1,unlink as I1,writeFile as A1}from"node:fs/promises";import{dirname as T1,join as k1}from"node:path";function Zr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function C1(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Zr(r)}</key>
|
|
21
|
+
<string>${Zr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function R1(t,e){return new Promise((r,i)=>{let o=v1(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Jr,as,oa,Jd,fp=rt(()=>{"use strict";te();Jr=H("supervisor.launchd"),as="ai.coze.bridge",oa=R1,Jd={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>${as}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Zr(t.nodeBin)}</string>
|
|
35
|
+
<string>${Zr(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>${Zr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Zr(t.logFile)}</string>${C1(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return k1(t.homeDir,"Library","LaunchAgents",`${as}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await S1(T1(i),{recursive:!0}),await A1(i,this.renderConfig(t),"utf8"),Jr.info("plist written",{plistPath:i,activate:r}),!r)return;await oa("launchctl",["unload","-w",i]).catch(c=>Jr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await oa("launchctl",["load","-w",i]),Jr.info("launchd job loaded",{label:as});let o=process.getuid?.()??0;await oa("launchctl",["kickstart","-k",`gui/${o}/${as}`]),Jr.info("launchd job kickstarted",{label:as,uid:o})},async uninstall(t){let e=this.configPath(t);await oa("launchctl",["unload","-w",e]).catch(r=>Jr.warn("launchctl unload failed (ignored)",{err:String(r)})),await I1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Jr.info("launchd job removed",{plistPath:e})}}});import{spawn as D1}from"node:child_process";import{mkdir as P1,unlink as O1,writeFile as L1}from"node:fs/promises";import{dirname as N1,join as hp}from"node:path";function ca(t,e){return t.isRoot?e:["--user",...e]}function B1(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function da(t,e){return new Promise((r,i)=>{let o=D1(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var aa,Yr,M1,Zd,xp=rt(()=>{"use strict";te();aa=H("supervisor.systemd"),Yr="coze-bridge.service",M1="/etc/systemd/system";Zd={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
|
+
${B1(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?hp(M1,Yr):hp(t.homeDir,".config","systemd","user",Yr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await P1(N1(i),{recursive:!0}),await L1(i,this.renderConfig(t),"utf8"),aa.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await da("systemctl",ca(t,["daemon-reload"])),await da("systemctl",ca(t,r?["enable","--now",Yr]:["enable",Yr])),aa.info("systemd unit enabled",{unitName:Yr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await da("systemctl",ca(t,["disable","--now",Yr])).catch(r=>aa.warn("systemctl disable failed (ignored)",{err:String(r)})),await O1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await da("systemctl",ca(t,["daemon-reload"])).catch(()=>{}),aa.info("systemd unit removed",{unitPath:e})}}});import{spawn as F1}from"node:child_process";import{join as z1}from"node:path";function pp(t,e){return new Promise((r,i)=>{let o=F1(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Yd,la,Xd,gp=rt(()=>{"use strict";te();Yd=H("supervisor.taskscheduler"),la="CozeBridge",Xd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,48 +86,50 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return I2(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 ip("schtasks",["/Create","/SC","ONLOGON","/TN",fa,"/TR",r,"/RU",t.userName,"/F"]),$d.info("task scheduler entry created",{task:fa,logFile:t.logFile})},async uninstall(t){await ip("schtasks",["/Delete","/TN",fa,"/F"]).catch(e=>$d.warn("schtasks /Delete failed (ignored)",{err:String(e)})),$d.info("task scheduler entry removed",{task:fa})}}});var op={};va(op,{buildContext:()=>P2,getSupervisor:()=>R2,launchdSupervisor:()=>Wd,systemdSupervisor:()=>Kd,taskSchedulerSupervisor:()=>Vd});import{homedir as C2,userInfo as T2}from"node:os";function R2(t=process.platform){switch(t){case"darwin":return Wd;case"linux":return Kd;case"win32":return Vd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function k2(){let t={};for(let e of D2){let r=process.env[e];r&&(t[e]=r)}return t}function P2(){let t=Q();return{nodeBin:process.execPath,entry:Md(t),logFile:t.logFile,homeDir:C2(),userName:T2().username,isRoot:process.getuid?.()===0,env:k2()}}var D2,ap=et(()=>{"use strict";Le();ta();tp();rp();sp();D2=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});re();an();var Sl=H("acp-installer-warmup"),kg=["claude-code","codex"];async function Al(t={}){let e=t.ensure??dr,i=(await Promise.allSettled(kg.map(async o=>{let c=await e(o);Sl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&Sl.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))})}ln();re();import{readdir as $g}from"node:fs/promises";import{mkdir as Rl,readFile as Wg,writeFile as Dl}from"node:fs/promises";import{join as Da}from"node:path";var Kg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function fr(t,e,r){await Rl(t,{recursive:!0});let i=Kg[e],o=Da(t,i);return await Dl(o,r??"","utf8"),o}async function ka(t,e,r){let i=Da(t,".claude");await Rl(i,{recursive:!0});let o=Da(i,"settings.local.json"),c={};try{let u=await Wg(o,"utf8"),x=JSON.parse(u);typeof x=="object"&&x!==null&&!Array.isArray(x)&&(c=x)}catch{}let l=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")l.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");l.defaultMode===void 0&&(l.defaultMode=r)}return c.permissions=l,await Dl(o,JSON.stringify(c,null,2),"utf8"),o}var Xe=H("agent-detail-sync"),Vg=6e4,Zg=5*6e4,ys=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await $g(r)}catch(o){Xe.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Xe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Fe(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Xe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Xe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Xe.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){Xe.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Xe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Fe(e,this.opts.paths);if(!i){Xe.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(x){Xe.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let h=this.retryQueue.get(e),m=h?Math.min(h.currentDelay*2,Zg):Vg;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(o.agentId&&o.agentId!==e){Xe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Xe.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Xe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Xe.debug("detail sync: no diff",{agentId:e});return}await rt(i,this.opts.paths),Xe.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Xe.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):l&&(await fr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Zf=qt(du(),1);import{lstat as Wc,mkdir as Kc,readFile as Wf,readdir as D_,rm as k_,stat as P_,writeFile as $c}from"node:fs/promises";import{dirname as O_,join as Lt,normalize as L_,relative as Jc,resolve as Vc,sep as Kf}from"node:path";import{Readable as $f}from"node:stream";import{pipeline as Vf}from"node:stream/promises";import mm from"events";import it from"fs";import{EventEmitter as Dc}from"node:events";import ju from"node:stream";import{StringDecoder as wm}from"node:string_decoder";import $u from"node:path";import Sr from"node:fs";import{dirname as km,parse as Pm}from"path";import{EventEmitter as Um}from"events";import uc from"assert";import{Buffer as Wn}from"buffer";import*as hu from"zlib";import qm from"zlib";import{posix as mr}from"node:path";import{basename as hw}from"node:path";import Ys from"fs";import kt from"fs";import bu from"path";import{win32 as Iw}from"node:path";import Tu from"path";import df from"node:fs";import Hw from"node:assert";import{randomBytes as lf}from"node:crypto";import ie from"node:fs";import Me from"node:path";import uf from"fs";import ao from"node:fs";import Ci from"node:path";import ct from"node:fs";import Jw from"node:fs/promises";import to from"node:path";import{join as Ef}from"node:path";import at from"node:fs";import Af from"node:path";var pm=Object.defineProperty,gm=(t,e)=>{for(var r in e)pm(t,r,{get:e[r],enumerable:!0})},lu=typeof process=="object"&&process?process:{stdout:null,stderr:null},_m=t=>!!t&&typeof t=="object"&&(t instanceof Vn||t instanceof ju||ym(t)||bm(t)),ym=t=>!!t&&typeof t=="object"&&t instanceof Dc&&typeof t.pipe=="function"&&t.pipe!==ju.Writable.prototype.pipe,bm=t=>!!t&&typeof t=="object"&&t instanceof Dc&&typeof t.write=="function"&&typeof t.end=="function",Gt=Symbol("EOF"),Ht=Symbol("maybeEmitEnd"),fn=Symbol("emittedEnd"),As=Symbol("emittingEnd"),li=Symbol("emittedError"),Is=Symbol("closed"),uu=Symbol("read"),Cs=Symbol("flush"),fu=Symbol("flushChunk"),mt=Symbol("encoding"),gr=Symbol("decoder"),Ue=Symbol("flowing"),ui=Symbol("paused"),br=Symbol("resume"),qe=Symbol("buffer"),Ye=Symbol("pipes"),Ge=Symbol("bufferLength"),Ba=Symbol("bufferPush"),Ts=Symbol("bufferShift"),Je=Symbol("objectMode"),Se=Symbol("destroyed"),za=Symbol("error"),Fa=Symbol("emitData"),xu=Symbol("emitEnd"),Ua=Symbol("emitEnd2"),Tt=Symbol("async"),qa=Symbol("abort"),Rs=Symbol("aborted"),fi=Symbol("signal"),Mn=Symbol("dataListeners"),ot=Symbol("discarded"),xi=t=>Promise.resolve().then(t),Em=t=>t(),vm=t=>t==="end"||t==="finish"||t==="prefinish",Sm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Am=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Wu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[br](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Im=class extends Wu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Cm=t=>!!t.objectMode,Tm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Vn=class extends Dc{[Ue]=!1;[ui]=!1;[Ye]=[];[qe]=[];[Je];[mt];[Tt];[gr];[Gt]=!1;[fn]=!1;[As]=!1;[Is]=!1;[li]=null;[Ge]=0;[Se]=!1;[fi];[Rs]=!1;[Mn]=0;[ot]=!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");Cm(e)?(this[Je]=!0,this[mt]=null):Tm(e)?(this[mt]=e.encoding,this[Je]=!1):(this[Je]=!1,this[mt]=null),this[Tt]=!!e.async,this[gr]=this[mt]?new wm(this[mt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[qe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ye]});let{signal:r}=e;r&&(this[fi]=r,r.aborted?this[qa]():r.addEventListener("abort",()=>this[qa]()))}get bufferLength(){return this[Ge]}get encoding(){return this[mt]}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[Je]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Tt]}set async(t){this[Tt]=this[Tt]||!!t}[qa](){this[Rs]=!0,this.emit("abort",this[fi]?.reason),this.destroy(this[fi]?.reason)}get aborted(){return this[Rs]}set aborted(t){}write(t,e,r){if(this[Rs])return!1;if(this[Gt])throw new Error("write after end");if(this[Se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[Tt]?xi:Em;if(!this[Je]&&!Buffer.isBuffer(t)){if(Am(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Sm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Je]?(this[Ue]&&this[Ge]!==0&&this[Cs](!0),this[Ue]?this.emit("data",t):this[Ba](t),this[Ge]!==0&&this.emit("readable"),r&&i(r),this[Ue]):t.length?(typeof t=="string"&&!(e===this[mt]&&!this[gr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[mt]&&(t=this[gr].write(t)),this[Ue]&&this[Ge]!==0&&this[Cs](!0),this[Ue]?this.emit("data",t):this[Ba](t),this[Ge]!==0&&this.emit("readable"),r&&i(r),this[Ue]):(this[Ge]!==0&&this.emit("readable"),r&&i(r),this[Ue])}read(t){if(this[Se])return null;if(this[ot]=!1,this[Ge]===0||t===0||t&&t>this[Ge])return this[Ht](),null;this[Je]&&(t=null),this[qe].length>1&&!this[Je]&&(this[qe]=[this[mt]?this[qe].join(""):Buffer.concat(this[qe],this[Ge])]);let e=this[uu](t||null,this[qe][0]);return this[Ht](),e}[uu](t,e){if(this[Je])this[Ts]();else{let r=e;t===r.length||t===null?this[Ts]():typeof r=="string"?(this[qe][0]=r.slice(t),e=r.slice(0,t),this[Ge]-=t):(this[qe][0]=r.subarray(t),e=r.subarray(0,t),this[Ge]-=t)}return this.emit("data",e),!this[qe].length&&!this[Gt]&&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[Gt]=!0,this.writable=!1,(this[Ue]||!this[ui])&&this[Ht](),this}[br](){this[Se]||(!this[Mn]&&!this[Ye].length&&(this[ot]=!0),this[ui]=!1,this[Ue]=!0,this.emit("resume"),this[qe].length?this[Cs]():this[Gt]?this[Ht]():this.emit("drain"))}resume(){return this[br]()}pause(){this[Ue]=!1,this[ui]=!0,this[ot]=!1}get destroyed(){return this[Se]}get flowing(){return this[Ue]}get paused(){return this[ui]}[Ba](t){this[Je]?this[Ge]+=1:this[Ge]+=t.length,this[qe].push(t)}[Ts](){return this[Je]?this[Ge]-=1:this[Ge]-=this[qe][0].length,this[qe].shift()}[Cs](t=!1){do;while(this[fu](this[Ts]())&&this[qe].length);!t&&!this[qe].length&&!this[Gt]&&this.emit("drain")}[fu](t){return this.emit("data",t),this[Ue]}pipe(t,e){if(this[Se])return t;this[ot]=!1;let r=this[fn];return e=e||{},t===lu.stdout||t===lu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ye].push(e.proxyErrors?new Im(this,t,e):new Wu(this,t,e)),this[Tt]?xi(()=>this[br]()):this[br]()),t}unpipe(t){let e=this[Ye].find(r=>r.dest===t);e&&(this[Ye].length===1?(this[Ue]&&this[Mn]===0&&(this[Ue]=!1),this[Ye]=[]):this[Ye].splice(this[Ye].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[ot]=!1,this[Mn]++,!this[Ye].length&&!this[Ue]&&this[br]();else if(t==="readable"&&this[Ge]!==0)super.emit("readable");else if(vm(t)&&this[fn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[li]){let i=e;this[Tt]?xi(()=>i.call(this,this[li])):i.call(this,this[li])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Mn]=this.listeners("data").length,this[Mn]===0&&!this[ot]&&!this[Ye].length&&(this[Ue]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Mn]=0,!this[ot]&&!this[Ye].length&&(this[Ue]=!1)),e}get emittedEnd(){return this[fn]}[Ht](){!this[As]&&!this[fn]&&!this[Se]&&this[qe].length===0&&this[Gt]&&(this[As]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Is]&&this.emit("close"),this[As]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Se&&this[Se])return!1;if(t==="data")return!this[Je]&&!r?!1:this[Tt]?(xi(()=>this[Fa](r)),!0):this[Fa](r);if(t==="end")return this[xu]();if(t==="close"){if(this[Is]=!0,!this[fn]&&!this[Se])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[li]=r,super.emit(za,r);let o=!this[fi]||this.listeners("error").length?super.emit("error",r):!1;return this[Ht](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ht](),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[Ht](),i}[Fa](t){for(let r of this[Ye])r.dest.write(t)===!1&&this.pause();let e=this[ot]?!1:super.emit("data",t);return this[Ht](),e}[xu](){return this[fn]?!1:(this[fn]=!0,this.readable=!1,this[Tt]?(xi(()=>this[Ua]()),!0):this[Ua]())}[Ua](){if(this[gr]){let e=this[gr].end();if(e){for(let r of this[Ye])r.dest.write(e);this[ot]||super.emit("data",e)}}for(let e of this[Ye])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Je]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Je]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Je])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[mt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Se,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[ot]=!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[Gt])return e();let i,o,c=h=>{this.off("data",l),this.off("end",u),this.off(Se,x),e(),o(h)},l=h=>{this.off("error",c),this.off("end",u),this.off(Se,x),this.pause(),i({value:h,done:!!this[Gt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Se,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{o=m,i=h,this.once(Se,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[ot]=!1;let t=!1,e=()=>(this.pause(),this.off(za,e),this.off(Se,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(za,e),this.once(Se,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Se])return t?this.emit("error",t):this.emit(Se),this;this[Se]=!0,this[ot]=!0,this[qe].length=0,this[Ge]=0;let e=this;return typeof e.close=="function"&&!this[Is]&&e.close(),t?this.emit("error",t):this.emit(Se),this}static get isStream(){return _m}},Rm=it.writev,En=Symbol("_autoClose"),bt=Symbol("_close"),hi=Symbol("_ended"),le=Symbol("_fd"),Ga=Symbol("_finished"),$t=Symbol("_flags"),Ha=Symbol("_flush"),dc=Symbol("_handleChunk"),lc=Symbol("_makeBuf"),Ai=Symbol("_mode"),Ds=Symbol("_needDrain"),Ir=Symbol("_onerror"),Cr=Symbol("_onopen"),ja=Symbol("_onread"),Er=Symbol("_onwrite"),vn=Symbol("_open"),yt=Symbol("_path"),mn=Symbol("_pos"),Rt=Symbol("_queue"),vr=Symbol("_read"),Wa=Symbol("_readSize"),Kt=Symbol("_reading"),pi=Symbol("_remain"),Ka=Symbol("_size"),Us=Symbol("_write"),Bn=Symbol("_writing"),qs=Symbol("_defaultFlag"),jn=Symbol("_errored"),kc=class extends Vn{[jn]=!1;[le];[yt];[Wa];[Kt]=!1;[Ka];[pi];[En];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[jn]=!1,this[le]=typeof e.fd=="number"?e.fd:void 0,this[yt]=t,this[Wa]=e.readSize||16*1024*1024,this[Kt]=!1,this[Ka]=typeof e.size=="number"?e.size:1/0,this[pi]=this[Ka],this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[le]=="number"?this[vr]():this[vn]()}get fd(){return this[le]}get path(){return this[yt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[vn](){it.open(this[yt],"r",(t,e)=>this[Cr](t,e))}[Cr](t,e){t?this[Ir](t):(this[le]=e,this.emit("open",e),this[vr]())}[lc](){return Buffer.allocUnsafe(Math.min(this[Wa],this[pi]))}[vr](){if(!this[Kt]){this[Kt]=!0;let t=this[lc]();if(t.length===0)return process.nextTick(()=>this[ja](null,0,t));it.read(this[le],t,0,t.length,null,(e,r,i)=>this[ja](e,r,i))}}[ja](t,e,r){this[Kt]=!1,t?this[Ir](t):this[dc](e,r)&&this[vr]()}[bt](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Ir](t){this[Kt]=!0,this[bt](),this.emit("error",t)}[dc](t,e){let r=!1;return this[pi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[pi]<=0)&&(r=!1,this[bt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[le]=="number"&&this[vr](),!1;case"error":return this[jn]?!1:(this[jn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Dm=class extends kc{[vn](){let t=!0;try{this[Cr](null,it.openSync(this[yt],"r")),t=!1}finally{t&&this[bt]()}}[vr](){let t=!0;try{if(!this[Kt]){this[Kt]=!0;do{let e=this[lc](),r=e.length===0?0:it.readSync(this[le],e,0,e.length,null);if(!this[dc](r,e))break}while(!0);this[Kt]=!1}t=!1}finally{t&&this[bt]()}}[bt](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.closeSync(t),this.emit("close")}}},no=class extends mm{readable=!1;writable=!0;[jn]=!1;[Bn]=!1;[hi]=!1;[Rt]=[];[Ds]=!1;[yt];[Ai];[En];[le];[qs];[$t];[Ga]=!1;[mn];constructor(t,e){e=e||{},super(e),this[yt]=t,this[le]=typeof e.fd=="number"?e.fd:void 0,this[Ai]=e.mode===void 0?438:e.mode,this[mn]=typeof e.start=="number"?e.start:void 0,this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[mn]!==void 0?"r+":"w";this[qs]=e.flags===void 0,this[$t]=e.flags===void 0?r:e.flags,this[le]===void 0&&this[vn]()}emit(t,...e){if(t==="error"){if(this[jn])return!1;this[jn]=!0}return super.emit(t,...e)}get fd(){return this[le]}get path(){return this[yt]}[Ir](t){this[bt](),this[Bn]=!0,this.emit("error",t)}[vn](){it.open(this[yt],this[$t],this[Ai],(t,e)=>this[Cr](t,e))}[Cr](t,e){this[qs]&&this[$t]==="r+"&&t&&t.code==="ENOENT"?(this[$t]="w",this[vn]()):t?this[Ir](t):(this[le]=e,this.emit("open",e),this[Bn]||this[Ha]())}end(t,e){return t&&this.write(t,e),this[hi]=!0,!this[Bn]&&!this[Rt].length&&typeof this[le]=="number"&&this[Er](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[hi]?(this.emit("error",new Error("write() after end()")),!1):this[le]===void 0||this[Bn]||this[Rt].length?(this[Rt].push(t),this[Ds]=!0,!1):(this[Bn]=!0,this[Us](t),!0)}[Us](t){it.write(this[le],t,0,t.length,this[mn],(e,r)=>this[Er](e,r))}[Er](t,e){t?this[Ir](t):(this[mn]!==void 0&&typeof e=="number"&&(this[mn]+=e),this[Rt].length?this[Ha]():(this[Bn]=!1,this[hi]&&!this[Ga]?(this[Ga]=!0,this[bt](),this.emit("finish")):this[Ds]&&(this[Ds]=!1,this.emit("drain"))))}[Ha](){if(this[Rt].length===0)this[hi]&&this[Er](null,0);else if(this[Rt].length===1)this[Us](this[Rt].pop());else{let t=this[Rt];this[Rt]=[],Rm(this[le],t,this[mn],(e,r)=>this[Er](e,r))}}[bt](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Ku=class extends no{[vn](){let t;if(this[qs]&&this[$t]==="r+")try{t=it.openSync(this[yt],this[$t],this[Ai])}catch(e){if(e?.code==="ENOENT")return this[$t]="w",this[vn]();throw e}else t=it.openSync(this[yt],this[$t],this[Ai]);this[Cr](null,t)}[bt](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.closeSync(t),this.emit("close")}}[Us](t){let e=!0;try{this[Er](null,it.writeSync(this[le],t,0,t.length,this[mn])),e=!1}finally{if(e)try{this[bt]()}catch{}}}},Om=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"]]),Lm=t=>!!t.sync&&!!t.file,Nm=t=>!t.sync&&!!t.file,Mm=t=>!!t.sync&&!t.file,Bm=t=>!t.sync&&!t.file,zm=t=>!!t.file,Fm=t=>Om.get(t)||t,Pc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Fm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Li=(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=Pc(c);if(o?.(x,l),Lm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(Nm(x)){let h=e(x,l);return u?h.then(()=>u(),u):h}else if(Mm(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(Bm(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}),Gm=qm.constants||{ZLIB_VERNUM:4736},Ot=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},Gm)),Hm=Wn.concat,pu=Object.getOwnPropertyDescriptor(Wn,"concat"),jm=t=>t,$a=pu?.writable===!0||pu?.set!==void 0?t=>{Wn.concat=t?jm:Hm}:t=>{},Kn=Symbol("_superWrite"),ks=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"}},Va=Symbol("flushFlag"),Oc=class extends Vn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof hu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new hu[e](t)}catch(r){throw new ks(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 ks(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return uc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Wn.alloc(0),{[Va]: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}[Kn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Wn.from(t,e)),this.#e)return;uc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},$a(!0);let l;try{let x=typeof t[Va]=="number"?t[Va]:this.#r;l=this.#t._processChunk(t,x),$a(!1)}catch(x){$a(!1),this.#o(new ks(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 ks(x,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];u=this[Kn](Wn.from(x));for(let h=1;h<l.length;h++)u=this[Kn](l[h])}else u=this[Kn](Wn.from(l));return r&&r(),u}},Vu=class extends Oc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Ot.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ot.Z_FINISH,t.fullFlushFlag=Ot.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(Ot.Z_SYNC_FLUSH),uc(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)}}}},Wm=class extends Vu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Kn](t){return this.#e?(this.#e=!1,t[9]=255,super[Kn](t)):super[Kn](t)}},Km=class extends Vu{constructor(t){super(t,"Unzip")}},Zu=class extends Oc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ot.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ot.BROTLI_OPERATION_FLUSH,super(t,e)}},$m=class extends Zu{constructor(t){super(t,"BrotliCompress")}},Vm=class extends Zu{constructor(t){super(t,"BrotliDecompress")}},Ju=class extends Oc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ot.ZSTD_e_end,t.fullFlushFlag=Ot.ZSTD_e_flush,super(t,e)}},Zm=class extends Ju{constructor(t){super(t,"ZstdCompress")}},Jm=class extends Ju{constructor(t){super(t,"ZstdDecompress")}},Xm=(t,e)=>{if(Number.isSafeInteger(t))t<0?Qm(t,e):Ym(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ym=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Qm=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Xu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Yu(o))}},ew=t=>{let e=t[0],r=e===128?nw(t.subarray(1,t.length)):e===255?tw(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},tw=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Xu(c):c===0?l=c:(i=!0,l=Yu(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},nw=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Xu=t=>(255^t)&255,Yu=t=>(255^t)+1&255,rw={};gm(rw,{code:()=>Lc,isCode:()=>Gs,isName:()=>iw,name:()=>ro,normalFsTypes:()=>Qu});var Gs=t=>ro.has(t),iw=t=>Lc.has(t),Qu=new Set(["0","","1","2","3","4","5","6","7","D"]),ro=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"]]),Lc=new Map(Array.from(ro).map(t=>[t[1],t[0]])),$n=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");let o=zn(t,e+156,1),c=Qu.has(o),l=c?r:void 0,u=c?i:void 0;if(this.path=l?.path??zn(t,e,100),this.mode=l?.mode??u?.mode??wn(t,e+100,8),this.uid=l?.uid??u?.uid??wn(t,e+108,8),this.gid=l?.gid??u?.gid??wn(t,e+116,8),this.size=l?.size??u?.size??wn(t,e+124,12),this.mtime=l?.mtime??u?.mtime??Za(t,e+136,12),this.cksum=wn(t,e+148,12),u&&this.#n(u,!0),l&&this.#n(l),Gs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=zn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=l?.uname??u?.uname??zn(t,e+265,32),this.gname=l?.gname??u?.gname??zn(t,e+297,32),this.devmaj=l?.devmaj??u?.devmaj??wn(t,e+329,8)??0,this.devmin=l?.devmin??u?.devmin??wn(t,e+337,8)??0,t[e+475]!==0){let h=zn(t,e+345,155);this.path=h+"/"+this.path}else{let h=zn(t,e+345,130);h&&(this.path=h+"/"+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 x=256;for(let h=e;h<e+148;h++)x+=t[h];for(let h=e+156;h<e+512;h++)x+=t[h];this.cksumValid=x===this.cksum,this.cksum===void 0&&x===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=sw(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Fn(t,e,100,o)||this.needPax,this.needPax=_n(t,e+100,8,this.mode)||this.needPax,this.needPax=_n(t,e+108,8,this.uid)||this.needPax,this.needPax=_n(t,e+116,8,this.gid)||this.needPax,this.needPax=_n(t,e+124,12,this.size)||this.needPax,this.needPax=Ja(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Fn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Fn(t,e+265,32,this.uname)||this.needPax,this.needPax=Fn(t,e+297,32,this.gname)||this.needPax,this.needPax=_n(t,e+329,8,this.devmaj)||this.needPax,this.needPax=_n(t,e+337,8,this.devmin)||this.needPax,this.needPax=Fn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Fn(t,e+345,155,c)||this.needPax:(this.needPax=Fn(t,e+345,130,c)||this.needPax,this.needPax=Ja(t,e+476,12,this.atime)||this.needPax,this.needPax=Ja(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,_n(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:ro.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Lc.get(t));if(Gs(e)||e==="Unsupported")this.#e=e;else if(Gs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},sw=(t,e)=>{let r=t,i="",o,c=mr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=mr.dirname(r),r=mr.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=mr.join(mr.basename(i),r),i=mr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},zn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Za=(t,e,r)=>ow(wn(t,e,r)),ow=t=>t===void 0?void 0:new Date(t*1e3),wn=(t,e,r)=>Number(t[e])&128?ew(t.subarray(e,e+r)):cw(t,e,r),aw=t=>isNaN(t)?void 0:t,cw=(t,e,r)=>aw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),dw={12:8589934591,8:2097151},_n=(t,e,r,i)=>i===void 0?!1:i>dw[r]||i<0?(Xm(i,t.subarray(e,e+r)),!0):(lw(t,e,r,i),!1),lw=(t,e,r,i)=>t.write(uw(i,r),e,r,"ascii"),uw=(t,e)=>fw(Math.floor(t).toString(8),e),fw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ja=(t,e,r,i)=>i===void 0?!1:_n(t,e,r,i.getTime()/1e3),xw=new Array(156).join("\0"),Fn=(t,e,r,i)=>i===void 0?!1:(t.write(i+xw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Xs=class ef{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new $n({path:("PaxHeader/"+hw(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),
|
|
91
|
-
`).reduce(mw,Object.create(null)),mw=(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},ww=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=ww!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),_w=class extends Vn{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))))}},io=(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))},yw=1024*1024,fc=Buffer.from([31,139]),xc=Buffer.from([40,181,47,253]),bw=Math.max(fc.length,xc.length),ut=Symbol("state"),Un=Symbol("writeEntry"),jt=Symbol("readEntry"),Xa=Symbol("nextEntry"),gu=Symbol("processEntry"),Dt=Symbol("extendedHeader"),gi=Symbol("globalExtendedHeader"),xn=Symbol("meta"),mu=Symbol("emitMeta"),ge=Symbol("buffer"),Wt=Symbol("queue"),hn=Symbol("ended"),Ya=Symbol("emittedEnd"),qn=Symbol("emit"),Te=Symbol("unzip"),Ps=Symbol("consumeChunk"),Os=Symbol("consumeChunkSub"),Qa=Symbol("consumeBody"),wu=Symbol("consumeMeta"),_u=Symbol("consumeHeader"),mi=Symbol("consuming"),ec=Symbol("bufferConcat"),Ls=Symbol("maybeEnd"),wr=Symbol("writing"),pn=Symbol("aborted"),Ns=Symbol("onDone"),Gn=Symbol("sawValidEntry"),Ms=Symbol("sawNullBlock"),Bs=Symbol("sawEOF"),yu=Symbol("closeStream"),Ew=()=>!0,Oi=class extends Um{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[ge];[jt];[Un];[ut]="begin";[xn]="";[Dt];[gi];[hn]=!1;[Te];[pn]=!1;[Gn];[Ms]=!1;[Bs]=!1;[wr]=!1;[mi]=!1;[Ya]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ns,()=>{(this[ut]==="begin"||this[Gn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Ns,t.ondone):this.on(Ns,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||yw,this.filter=typeof t.filter=="function"?t.filter:Ew;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[yu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){io(this,t,e,r)}[_u](t,e){this[Gn]===void 0&&(this[Gn]=!1);let r;try{r=new $n(t,e,this[Dt],this[gi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ms]?(this[Bs]=!0,this[ut]==="begin"&&(this[ut]="header"),this[qn]("eof")):(this[Ms]=!0,this[qn]("nullBlock"));else if(this[Ms]=!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[Un]=new _w(r,this[Dt],this[gi]);if(!this[Gn])if(o.remain){let c=()=>{o.invalid||(this[Gn]=!0)};o.on("end",c)}else this[Gn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[qn]("ignoredEntry",o),this[ut]="ignore",o.resume()):o.size>0&&(this[xn]="",o.on("data",c=>this[xn]+=c),this[ut]="meta"):(this[Dt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[qn]("ignoredEntry",o),this[ut]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ut]="body":(this[ut]="header",o.end()),this[jt]?this[Wt].push(o):(this[Wt].push(o),this[Xa]())))}}}[yu](){queueMicrotask(()=>this.emit("close"))}[gu](t){let e=!0;if(!t)this[jt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[jt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Xa]()),e=!1);return e}[Xa](){do;while(this[gu](this[Wt].shift()));if(this[Wt].length===0){let t=this[jt];!t||t.flowing||t.size===t.remain?this[wr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Qa](t,e){let r=this[Un];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[ut]="header",this[Un]=void 0,r.end()),o.length}[wu](t,e){let r=this[Un],i=this[Qa](t,e);return!this[Un]&&r&&this[mu](r),i}[qn](t,e,r){this[Wt].length===0&&!this[jt]?this.emit(t,e,r):this[Wt].push([t,e,r])}[mu](t){switch(this[qn]("meta",this[xn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Dt]=Xs.parse(this[xn],this[Dt],!1);break;case"GlobalExtendedHeader":this[gi]=Xs.parse(this[xn],this[gi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Dt]??Object.create(null);this[Dt]=e,e.path=this[xn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Dt]||Object.create(null);this[Dt]=e,e.linkpath=this[xn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[pn]=!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[pn])return r?.(),!1;if((this[Te]===void 0||this.brotli===void 0&&this[Te]===!1)&&t){if(this[ge]&&(t=Buffer.concat([this[ge],t]),this[ge]=void 0),t.length<bw)return this[ge]=t,r?.(),!0;for(let l=0;this[Te]===void 0&&l<fc.length;l++)t[l]!==fc[l]&&(this[Te]=!1);let o=!1;if(this[Te]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<xc.length;l++)if(t[l]!==xc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Te]===!1&&c)if(t.length<512)if(this[hn])this.brotli=!0;else return this[ge]=t,r?.(),!0;else try{new $n(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Te]===void 0||this[Te]===!1&&(this.brotli||o)){let l=this[hn];this[hn]=!1,this[Te]=this[Te]===void 0?new Km({}):o?new Jm({}):new Vm({}),this[Te].on("data",x=>this[Ps](x)),this[Te].on("error",x=>this.abort(x)),this[Te].on("end",()=>{this[hn]=!0,this[Ps]()}),this[wr]=!0;let u=!!this[Te][l?"end":"write"](t);return this[wr]=!1,r?.(),u}}this[wr]=!0,this[Te]?this[Te].write(t):this[Ps](t),this[wr]=!1;let i=this[Wt].length>0?!1:this[jt]?this[jt].flowing:!0;return!i&&this[Wt].length===0&&this[jt]?.once("drain",()=>this.emit("drain")),r?.(),i}[ec](t){t&&!this[pn]&&(this[ge]=this[ge]?Buffer.concat([this[ge],t]):t)}[Ls](){if(this[hn]&&!this[Ya]&&!this[pn]&&!this[mi]){this[Ya]=!0;let t=this[Un];if(t&&t.blockRemain){let e=this[ge]?this[ge].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ge]&&t.write(this[ge]),t.end()}this[qn](Ns)}}[Ps](t){if(this[mi]&&t)this[ec](t);else if(!t&&!this[ge])this[Ls]();else if(t){if(this[mi]=!0,this[ge]){this[ec](t);let e=this[ge];this[ge]=void 0,this[Os](e)}else this[Os](t);for(;this[ge]&&this[ge]?.length>=512&&!this[pn]&&!this[Bs];){let e=this[ge];this[ge]=void 0,this[Os](e)}this[mi]=!1}(!this[ge]||this[hn])&&this[Ls]()}[Os](t){let e=0,r=t.length;for(;e+512<=r&&!this[pn]&&!this[Bs];)switch(this[ut]){case"begin":case"header":this[_u](t,e),e+=512;break;case"ignore":case"body":e+=this[Qa](t,e);break;case"meta":e+=this[wu](t,e);break;default:throw new Error("invalid state: "+this[ut])}e<r&&(this[ge]=this[ge]?Buffer.concat([t.subarray(e),this[ge]]):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[pn]||(this[Te]?(t&&this[Te].write(t),this[Te].end()):(this[hn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ls]())),this}},Ii=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)},vw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},tf=(t,e)=>{let r=new Map(e.map(c=>[Ii(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Pm(c).root||".",x;if(c===u)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(km(c),u)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(Ii(c)):c=>o(Ii(c))},Sw=t=>{let e=new Oi(t),r=t.file,i;try{i=Sr.openSync(r,"r");let o=Sr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=Sr.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=Sr.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{Sr.closeSync(i)}catch{}}},Aw=(t,e)=>{let r=new Oi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),Sr.stat(o,(u,x)=>{if(u)l(u);else{let h=new kc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},Tr=Li(Sw,Aw,t=>new Oi(t),t=>new Oi(t),(t,e)=>{e?.length&&tf(t,e),t.noResume||vw(t)}),nf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:Cw,parse:Eu}=Iw,Nc=t=>{let e="",r=Eu(t);for(;Cw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Eu(t)}return[e,t]},so=["|","<",">","?",":"],Mc=so.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Tw=new Map(so.map((t,e)=>[t,Mc[e]])),Rw=new Map(Mc.map((t,e)=>[t,so[e]])),vu=t=>so.reduce((e,r)=>e.split(r).join(Tw.get(r)),t),Dw=t=>Mc.reduce((e,r)=>e.split(r).join(Rw.get(r)),t),rf=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),Ii(e)+"/"+t):Y(t),kw=16*1024*1024,Su=Symbol("process"),Au=Symbol("file"),Iu=Symbol("directory"),hc=Symbol("symlink"),Cu=Symbol("hardlink"),wi=Symbol("header"),Hs=Symbol("read"),pc=Symbol("lstat"),js=Symbol("onlstat"),gc=Symbol("onread"),mc=Symbol("onreadlink"),wc=Symbol("openfile"),_c=Symbol("onopenfile"),yn=Symbol("close"),Qs=Symbol("mode"),yc=Symbol("awaitDrain"),tc=Symbol("ondrain"),Pt=Symbol("prefix"),sf=class extends Vn{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=Pc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||kw,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]=Nc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Dw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||bu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[js](o):this[pc]()}warn(t,e,r={}){return io(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[pc](){kt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[js](e)})}[js](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Lw(t),this.emit("stat",t),this[Su]()}[Su](){switch(this.type){case"File":return this[Au]();case"Directory":return this[Iu]();case"SymbolicLink":return this[hc]();default:return this.end()}}[Qs](t){return nf(t,this.type==="Directory",this.portable)}[Pt](t){return rf(t,this.prefix)}[wi](){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 $n({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,mode:this[Qs](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Xs({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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Iu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[wi](),this.end()}[hc](){kt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[mc](e)})}[mc](t){this.linkpath=Y(t),this[wi](),this.end()}[Cu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(bu.relative(this.cwd,t)),this.stat.size=0,this[wi](),this.end()}[Au](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Cu](e);this.linkCache.set(t,this.absolute)}if(this[wi](),this.stat.size===0)return this.end();this[wc]()}[wc](){kt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[_c](e)})}[_c](t){if(this.fd=t,this.#e)return this[yn]();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[Hs]()}[Hs](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");kt.read(t,e,r,i,o,(c,l)=>{if(c)return this[yn](()=>this.emit("error",c));this[gc](l)})}[yn](t=()=>{}){this.fd!==void 0&&kt.close(this.fd,t)}[gc](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[yn](()=>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[yn](()=>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[tc]():this[yc](()=>this[tc]())}[yc](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)}[tc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[yn](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[Hs]()}},Pw=class extends sf{sync=!0;[pc](){this[js](kt.lstatSync(this.absolute))}[hc](){this[mc](kt.readlinkSync(this.absolute))}[wc](){this[_c](kt.openSync(this.absolute,"r"))}[Hs](){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=kt.readSync(e,r,i,o,c);this[gc](l),t=!1}finally{if(t)try{this[yn](()=>{})}catch{}}}[yc](t){t()}[yn](t=()=>{}){this.fd!==void 0&&kt.closeSync(this.fd),t()}},Ow=class extends Vn{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 io(this,t,e,r)}constructor(t,e={}){let r=Pc(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[Qs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Nc(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 $n({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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 Xs({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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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)}[Pt](t){return rf(t,this.prefix)}[Qs](t){return nf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},Lw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Nw=class Ar{tail;head;length=0;static create(e=[]){return new Ar(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)Bw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)zw(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 Ar;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 Ar;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 Ar;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 Ar;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=Mw(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 Mw(t,e,r){let i=e,o=e?e.next:t.head,c=new Bc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Bw(t,e){t.tail=new Bc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function zw(t,e){t.head=new Bc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Bc=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}},Ru=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Du=Buffer.alloc(1024),Ws=Symbol("onStat"),_i=Symbol("ended"),wt=Symbol("queue"),yi=Symbol("pendingLinks"),gn=Symbol("current"),Hn=Symbol("process"),bi=Symbol("processing"),zs=Symbol("processJob"),_t=Symbol("jobs"),nc=Symbol("jobDone"),Ks=Symbol("addFSEntry"),ku=Symbol("addTarEntry"),bc=Symbol("stat"),Ec=Symbol("readdir"),$s=Symbol("onreaddir"),Vs=Symbol("pipe"),Pu=Symbol("entry"),rc=Symbol("entryOpt"),Zs=Symbol("writeEntryClass"),of=Symbol("write"),ic=Symbol("ondrain"),oo=class extends Vn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Zs];onWriteEntry;[wt];[yi]=new Map;[_t]=0;[bi]=!1;[_i]=!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[Zs]=sf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Wm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new $m(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Zm(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[ic]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ic]);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[wt]=new Nw,this[_t]=0,this.jobs=Number(t.jobs)||4,this[bi]=!1,this[_i]=!1}[of](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[_i]=!0,this[Hn](),r&&r(),this}write(t){if(this[_i])throw new Error("write after end");return typeof t=="string"?this[Ks](t):this[ku](t),this.flowing}[ku](t){let e=Y(Tu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Ru(t.path,e);r.entry=new Ow(t,this[rc](r)),r.entry.on("end",()=>this[nc](r)),this[_t]+=1,this[wt].push(r)}this[Hn]()}[Ks](t){let e=Y(Tu.resolve(this.cwd,t));this[wt].push(new Ru(t,e)),this[Hn]()}[bc](t){t.pending=!0,this[_t]+=1;let e=this.follow?"stat":"lstat";Ys[e](t.absolute,(r,i)=>{t.pending=!1,this[_t]-=1,r?this.emit("error",r):this[Ws](t,i)})}[Ws](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[gn])this[zs](t);else{let r=`${e.dev}:${e.ino}`,i=this[yi].get(r);i?i.push(t):this[yi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Hn]()}[Ec](t){t.pending=!0,this[_t]+=1,Ys.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[_t]-=1,e)return this.emit("error",e);this[$s](t,r)})}[$s](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Hn]()}[Hn](){if(!this[bi]){this[bi]=!0;for(let t=this[wt].head;t&&this[_t]<this.jobs;t=t.next)if(this[zs](t.value),t.value.ignore){let e=t.next;this[wt].removeNode(t),t.next=e}this[bi]=!1,this[_i]&&this[wt].length===0&&this[_t]===0&&(this.zip?this.zip.end(Du):(super.write(Du),super.end()))}}get[gn](){return this[wt]&&this[wt].head&&this[wt].head.value}[nc](t){this[wt].shift(),this[_t]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[yi].get(r);if(i){this[yi].delete(r);for(let o of i)o.pending=!1,this[zs](o)}}this[Hn]()}[zs](t){if(t.pending&&t.pendingLink&&t===this[gn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[gn]&&!t.piped&&this[Vs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ws](t,e):this[bc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[$s](t,e):this[Ec](t),!t.readdir)return}if(t.entry=this[Pu](t),!t.entry){t.ignore=!0;return}t===this[gn]&&!t.piped&&this[Vs](t)}}}[rc](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Pu](t){this[_t]+=1;try{return new this[Zs](t.path,this[rc](t)).on("end",()=>this[nc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ic](){this[gn]&&this[gn].entry&&this[gn].entry.resume()}[Vs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ks](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={}){io(this,t,e,r)}},zc=class extends oo{sync=!0;constructor(t){super(t),this[Zs]=Pw}pause(){}resume(){}[bc](t){let e=this.follow?"statSync":"lstatSync";this[Ws](t,Ys[e](t.absolute))}[Ec](t){this[$s](t,Ys.readdirSync(t.absolute))}[Vs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ks](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[of](i)})}},Fw=(t,e)=>{let r=new zc(t),i=new Ku(t.file,{mode:t.mode||438});r.pipe(i),af(r,e)},Uw=(t,e)=>{let r=new oo(t),i=new no(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return cf(r,e).catch(c=>r.emit("error",c)),o},af=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Tr({file:$u.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},cf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Tr({file:$u.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},qw=(t,e)=>{let r=new zc(t);return af(r,e),r},Gw=(t,e)=>{let r=new oo(t);return cf(r,e).catch(i=>r.emit("error",i)),r},pA=Li(Fw,Uw,qw,Gw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),jw=process.env.__FAKE_PLATFORM__||process.platform,ff=jw==="win32",{O_CREAT:xf,O_NOFOLLOW:Ou,O_TRUNC:hf,O_WRONLY:pf}=uf.constants,gf=Number(process.env.__FAKE_FS_O_FILENAME__)||uf.constants.UV_FS_O_FILEMAP||0,Ww=ff&&!!gf,Kw=512*1024,$w=gf|hf|xf|pf,Lu=!ff&&typeof Ou=="number"?Ou|hf|xf|pf:null,mf=Lu!==null?()=>Lu:Ww?t=>t<Kw?$w:"w":()=>"w",vc=(t,e,r)=>{try{return ao.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},eo=(t,e,r,i)=>{ao.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Vw=(t,e,r,i,o)=>{if(e.isDirectory())wf(Ci.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=Ci.resolve(t,e.name);eo(l,r,i,o)});else{let c=Ci.resolve(t,e.name);eo(c,r,i,o)}},wf=(t,e,r,i)=>{ao.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 eo(t,e,r,i);let l=c.length,u=null,x=h=>{if(!u){if(h)return i(u=h);if(--l===0)return eo(t,e,r,i)}};for(let h of c)Vw(t,h,e,r,x)})},Zw=(t,e,r,i)=>{e.isDirectory()&&_f(Ci.resolve(t,e.name),r,i),vc(Ci.resolve(t,e.name),r,i)},_f=(t,e,r)=>{let i;try{i=ao.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return vc(t,e,r);throw c}for(let o of i)Zw(t,o,e,r);return vc(t,e,r)},yf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},co=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"}},Xw=(t,e)=>{ct.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new yf(t,r?.code||"ENOTDIR")),e(r)})},Yw=(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),h=e.preserve,m=e.unlink,E=Y(e.cwd),S=(v,A)=>{v?r(v):A&&x?wf(A,l,u,I=>S(I)):c?ct.chmod(t,o,r):r()};if(t===E)return Xw(t,S);if(h)return Jw.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let _=Y(to.relative(E,t)).split("/");Sc(E,_,o,m,E,void 0,S)},Sc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),x=Y(to.resolve(t+"/"+u));ct.mkdir(x,r,bf(x,e,r,i,o,c,l))},bf=(t,e,r,i,o,c,l)=>u=>{u?ct.lstat(t,(x,h)=>{if(x)x.path=x.path&&Y(x.path),l(x);else if(h.isDirectory())Sc(t,e,r,i,o,c,l);else if(i)ct.unlink(t,m=>{if(m)return l(m);ct.mkdir(t,r,bf(t,e,r,i,o,c,l))});else{if(h.isSymbolicLink())return l(new co(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,Sc(t,e,r,i,o,c,l))},Qw=t=>{let e=!1,r;try{e=ct.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new yf(t,r??"ENOTDIR")}},e_=(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,h=e.unlink,m=Y(e.cwd),E=v=>{v&&u&&_f(v,c,l),o&&ct.chmodSync(t,i)};if(t===m)return Qw(m),E();if(x)return E(ct.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Y(to.relative(m,t)).split("/"),_;for(let v=S.shift(),A=m;v&&(A+="/"+v);v=S.shift()){A=Y(to.resolve(A));try{ct.mkdirSync(A,i),_=_||A}catch{let I=ct.lstatSync(A);if(I.isDirectory())continue;if(h){ct.unlinkSync(A),ct.mkdirSync(A,i),_=_||A;continue}else if(I.isSymbolicLink())return new co(A,A+"/"+S.join("/"))}}return E(_)},sc=Object.create(null),Nu=1e4,_r=new Set,t_=t=>{_r.has(t)?_r.delete(t):sc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),_r.add(t);let e=sc[t],r=_r.size-Nu;if(r>Nu/10){for(let i of _r)if(_r.delete(i),delete sc[i],--r<=0)break}return e},n_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,r_=n_==="win32",i_=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Ef(i,r)),e.push(r||"/"),e},[]),s_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=r_?["win32 parallelization disabled"]:t.map(i=>Ii(Ef(t_(i))));let r=new Set(t.map(i=>i_(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}},o_=()=>process.umask(),Mu=Symbol("onEntry"),Ac=Symbol("checkFs"),Bu=Symbol("checkFs2"),Ic=Symbol("isReusable"),ft=Symbol("makeFs"),Cc=Symbol("file"),Tc=Symbol("directory"),Js=Symbol("link"),zu=Symbol("symlink"),Fu=Symbol("hardlink"),Si=Symbol("ensureNoSymlink"),Uu=Symbol("unsupported"),qu=Symbol("checkPath"),oc=Symbol("stripAbsolutePath"),bn=Symbol("mkdir"),He=Symbol("onError"),Fs=Symbol("pending"),Gu=Symbol("pend"),yr=Symbol("unpend"),ac=Symbol("ended"),cc=Symbol("maybeClose"),Rc=Symbol("skip"),Ti=Symbol("doChown"),Ri=Symbol("uid"),Di=Symbol("gid"),ki=Symbol("checkedCwd"),a_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pi=a_==="win32",c_=1024,d_=(t,e)=>{if(!Pi)return ie.unlink(t,e);let r=t+".DELETE."+lf(16).toString("hex");ie.rename(t,r,i=>{if(i)return e(i);ie.unlink(r,e)})},l_=t=>{if(!Pi)return ie.unlinkSync(t);let e=t+".DELETE."+lf(16).toString("hex");ie.renameSync(t,e),ie.unlinkSync(e)},Hu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Fc=class extends Oi{[ac]=!1;[ki]=!1;[Fs]=0;reservations=new s_;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[ac]=!0,this[cc]()},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:c_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Pi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:o_():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Mu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[cc](){this[ac]&&this[Fs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[oc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Nc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Pi&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Me.posix.dirname(t.path),x=Me.posix.normalize(Me.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}[qu](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[oc](t,"path")||!this[oc](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Y(Me.resolve(t.path)):Y(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Y(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+vu(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+vu(t.path.slice(o.length))}return!0}[Mu](t){if(!this[qu](t))return t.resume();switch(Hw.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[Ac](t);default:return this[Uu](t)}}[He](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[yr](),e.resume())}[bn](t,e,r){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},r)}[Ti](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}[Ri](t){return Hu(this.uid,t.uid,this.processUid)}[Di](t){return Hu(this.gid,t.gid,this.processGid)}[Cc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new no(String(t.absolute),{flags:mf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ie.close(i.fd,()=>{}),i.write=()=>!0,this[He](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ie.close(i.fd,()=>{}),this[He](u,t),e();return}--o===0&&i.fd!==void 0&&ie.close(i.fd,x=>{x?this[He](x,t):this[yr](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let h=t.atime||new Date,m=t.mtime;ie.futimes(x,h,m,E=>E?ie.utimes(u,h,m,S=>c(S&&E)):c())}if(typeof x=="number"&&this[Ti](t)){o++;let h=this[Ri](t),m=this[Di](t);typeof h=="number"&&typeof m=="number"&&ie.fchown(x,h,m,E=>E?ie.chown(u,h,m,S=>c(S&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[He](u,t),e()}),t.pipe(l)),l.pipe(i)}[Tc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[bn](String(t.absolute),r,i=>{if(i){this[He](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[yr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ie.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Ti](t)&&(o++,ie.chown(String(t.absolute),Number(this[Ri](t)),Number(this[Di](t)),c)),c()})}[Uu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[zu](t,e){let r=Y(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Si](t,this.cwd,r,()=>this[Js](t,String(t.linkpath),"symlink",e),i=>{this[He](i,t),e()})}[Fu](t,e){let r=Y(Me.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[Si](t,this.cwd,i,()=>this[Js](t,r,"link",e),o=>{this[He](o,t),e()})}[Si](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);ie.lstat(l,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new co(l,Me.resolve(l,r.join("/"))));this[Si](t,l,r,i,o)})}[Gu](){this[Fs]++}[yr](){this[Fs]--,this[cc]()}[Rc](t){this[yr](),t.resume()}[Ic](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Pi}[Ac](t){this[Gu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Bu](t,r))}[Bu](t,e){let r=l=>{e(l)},i=()=>{this[bn](this.cwd,this.dmode,l=>{if(l){this[He](l,t),r();return}this[ki]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[bn](l,this.dmode,u=>{if(u){this[He](u,t),r();return}c()})}c()},c=()=>{ie.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Rc](t),r();return}if(l||this[Ic](t,u))return this[ft](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,h=m=>this[ft](m??null,t,r);return x?ie.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return ie.rmdir(String(t.absolute),x=>this[ft](x??null,t,r))}if(t.absolute===this.cwd)return this[ft](null,t,r);d_(String(t.absolute),x=>this[ft](x??null,t,r))})};this[ki]?o():i()}[ft](t,e,r){if(t){this[He](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Cc](e,r);case"Link":return this[Fu](e,r);case"SymbolicLink":return this[zu](e,r);case"Directory":case"GNUDumpDir":return this[Tc](e,r)}}[Js](t,e,r,i){ie[r](e,String(t.absolute),o=>{o?this[He](o,t):(this[yr](),t.resume()),i()})}},Ei=t=>{try{return[null,t()]}catch(e){return[e,null]}},vf=class extends Fc{sync=!0;[ft](t,e){return super[ft](t,e,()=>{})}[Ac](t){if(!this[ki]){let o=this[bn](this.cwd,this.dmode);if(o)return this[He](o,t);this[ki]=!0}if(t.absolute!==this.cwd){let o=Y(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[bn](o,this.dmode);if(c)return this[He](c,t)}}let[e,r]=Ei(()=>ie.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Rc](t);if(e||this[Ic](t,r))return this[ft](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?Ei(()=>{ie.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ft](l,t)}let[o]=Ei(()=>ie.rmdirSync(String(t.absolute)));this[ft](o,t)}let[i]=t.absolute===this.cwd?[]:Ei(()=>l_(String(t.absolute)));this[ft](i,t)}[Cc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ie.closeSync(o)}catch(x){u=x}(l||u)&&this[He](l||u,t),e()},o;try{o=ie.openSync(String(t.absolute),mf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[He](l,t)),t.pipe(c)),c.on("data",l=>{try{ie.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{ie.futimesSync(o,u,x)}catch(h){try{ie.utimesSync(String(t.absolute),u,x)}catch{l=h}}}if(this[Ti](t)){let u=this[Ri](t),x=this[Di](t);try{ie.fchownSync(o,Number(u),Number(x))}catch(h){try{ie.chownSync(String(t.absolute),Number(u),Number(x))}catch{l=l||h}}}i(l)})}[Tc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[bn](String(t.absolute),r);if(i){this[He](i,t),e();return}if(t.mtime&&!this.noMtime)try{ie.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Ti](t))try{ie.chownSync(String(t.absolute),Number(this[Ri](t)),Number(this[Di](t)))}catch{}e(),t.resume()}[bn](t,e){try{return e_(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}}[Si](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Me.resolve(c,l);let[u,x]=Ei(()=>ie.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new co(c,Me.resolve(e,r.join("/"))))}i()}[Js](t,e,r,i){let o=`${r}Sync`;try{ie[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[He](c,t)}}},u_=t=>{let e=new vf(t),r=t.file,i=df.statSync(r),o=t.maxReadSize||16*1024*1024;new Dm(r,{readSize:o,size:i.size}).pipe(e)},f_=(t,e)=>{let r=new Fc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),df.stat(o,(u,x)=>{if(u)l(u);else{let h=new kc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},Sf=Li(u_,f_,t=>new vf(t),t=>new Fc(t),(t,e)=>{e?.length&&tf(t,e)}),x_=(t,e)=>{let r=new zc(t),i=!0,o,c;try{try{o=at.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=at.openSync(t.file,"w+");else throw x}let l=at.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=at.readSync(o,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new $n(u);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>l.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,h_(t,r,c,o,e)}finally{if(i)try{at.closeSync(o)}catch{}}},h_=(t,e,r,i,o)=>{let c=new Ku(t.file,{fd:i,start:r});e.pipe(c),g_(e,o)},p_=(t,e)=>{e=Array.from(e);let r=new oo(t),i=(o,c,l)=>{let u=(S,_)=>{S?at.close(o,v=>l(S)):l(null,_)},x=0;if(c===0)return u(null,0);let h=0,m=Buffer.alloc(512),E=(S,_)=>{if(S||_===void 0)return u(S);if(h+=_,h<512&&_)return at.read(o,m,h,m.length-h,x+h,E);if(x===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(h<512)return u(null,x);let v=new $n(m);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),h=0,at.read(o,m,0,512,x,E)};at.read(o,m,0,512,x,E)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(x,h)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",at.open(t.file,l,u);if(x||!h)return c(x);at.fstat(h,(m,E)=>{if(m)return at.close(h,()=>c(m));i(h,E.size,(S,_)=>{if(S)return c(S);let v=new no(t.file,{fd:h,start:_});r.pipe(v),v.on("error",c),v.on("close",o),m_(r,e)})})};at.open(t.file,l,u)})},g_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Tr({file:Af.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},m_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Tr({file:Af.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},vi=Li(x_,p_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!zm(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")}),DA=Li(vi.syncFile,vi.asyncFile,vi.syncNoFile,vi.asyncNoFile,(t,e=[])=>{vi.validate?.(t,e),w_(t)}),w_=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))};ln();var Et={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete"};function lo(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function If(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function uo(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Cf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Tf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Rr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Vt();Ze();re();Le();Ze();function Sn(t,e){if(lo(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ni(t){return t.startsWith("http://")||t.startsWith("https://")}function fo(t){return t.endsWith("/")?t.slice(0,-1):t}Ze();re();var xo="1008033",Pf="1289";var Of="pbbp2",Lf="https://www.coze.cn",Nf="/api/coze_claw/resource/get_frontier_key",I_="https://www.coze.cn",C_="wss://frontier.coze.cn";function ho(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??I_}function Mf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??C_}function Dr(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 Bi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Mi=H("handshake");async function Uc(t){let e=ho(t.endpoint),r=t.timeoutMs??1e4,i=`${fo(e)}${Nf}?aid=${encodeURIComponent(xo)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Dr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Mi.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",h=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let E=m.data??{},S=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!S||!_){let v=JSON.stringify(m).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Mi.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:S,deviceId:_}}catch(u){if(u instanceof T)throw Mi.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Mi.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw Mi.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 qc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto",Bf=15e4;function zf(t){return{model:Gc(t.model)??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function T_(t){return!t||t===vt}var R_=new Set(["auto","\u81EA\u52A8"]);function Gc(t){let e=t?.trim();if(e)return R_.has(e.toLowerCase())?vt:e}function Ff(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=qc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||vt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else T_(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Uf(t,e,r){return t.modelToken?{baseUrl:`${qc}/v1`,providerName:"coze",headers:{Authorization:`Bearer ${t.modelToken}`,...Hc(e,r)}}:null}function qf(t){if(!t.modelToken)return{};let e={model:t.model||vt,model_context_window:t.modelInfo?.contextWindow??Bf};return{CODEX_CONFIG:JSON.stringify(e)}}function Hc(t,e){let{ttEnv:r,usePpe:i}=Bi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Gf(t,e,r){if(!t.modelToken)return{};let i=Hc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
-
`)}}function jc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Hf(t,e,r){if(!t.modelToken)return null;let i=t.model||vt,o=Hc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${qc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Bf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}var Ae=H("agent-handlers"),jf=5*1024*1024,N_=1,M_=6,B_=new Set(["node_modules",".git",".coze","dist","build",".next"]),z_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,F_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,U_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function q_(t){let e=t?.trim();return e?U_.test(e)||F_.test(e)?e:(Ae.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function G_(t){return new Promise((e,r)=>{let i=st("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=l=>{o||(o=!0,l?r(l):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",l=>c(l))})}var po=class{constructor(e){this.opts=e}opts;async listSkills(e){Sn(e._meta,"_agent/listSkills");let r=Rr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??nt(r).workspace,c=i?.skills??[],l=[];for(let u of c){let x=Lt(o,u.relPath,"SKILL.md");await P_(x).then(m=>m.isFile()).catch(()=>!1)&&l.push($_(u))}return{skills:l}}async addSkills(e){let r=Rr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,h)=>[x.skillId,h])),u=[];for(let x of o){let h=await Xc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Yc(c,l,h),u.push(x)}return await ws(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Sn(e._meta,"_agent/removeSkills");let r=Rr(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=Lt(i.workspace,u.relPath);await k_(x,{recursive:!0,force:!0}),Ae.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ws(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ae.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Ae.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(h=>Ae.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Fe(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await fr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await rt(i),Ae.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Fe(r))throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Ni(e.registry)&&o.push(`--registry=${e.registry}`);let c=q_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let l=e._meta?.cozeEnv;l&&z_.test(l)&&o.push("--env",l);let u=await G_(o);return Ae.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Fe(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await rt(i),Ae.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Sn(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Gc(e.model)??vt,i=await Fe(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 rt(i),Ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ae.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Ae.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Ae.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Sn(e._meta,Et.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${Et.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,Et.RESET),await this.runDetailSync(e.agentId,Et.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ae.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ci(e,o)}async clearPersistedAcpSessionIds(e){let r=await Fe(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 rt(r)}async repairAgent(e){if(Sn(e._meta,Et.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${Et.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${Et.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,Et.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ae.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ae.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Sn(e._meta,"_agent/getFileTree");let r=e._meta,i=Rr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Wc(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 ai(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=iy(e.depth);return u.isDirectory()?{tree:await ry(o,l,c,x)}:{tree:[{name:sy(c),path:Xf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Sn(e._meta,"_agent/getFileContent");let r=Rr(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 Wc(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 ai(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>jf)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${jf})`);let l=await Wf(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 Fe(e).catch(()=>null))?.workspace??nt(e).workspace}safeJoin(e,r){let i=Vc(e,r||"."),o=Jc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Kf}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Fe(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 H_(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 j_(t){return t==="claude-code"?Lt(".claude","skills"):Lt(".agents","skills")}var W_=3e4,K_=50*1024*1024,kr=3e4;async function Xc(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=H_(o.skillName),x=j_(i),h=Lt(x,u),m=Lt(r,h);if(await Kc(m,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");zi(S.length),await $c(Lt(m,"SKILL.md"),S,"utf8")}else{let S=await V_(o.downloadUrl);J_(S)?await ey(S,m):X_(S)?await Y_(S,m):await $c(Lt(m,"SKILL.md"),S.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:h,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Ae.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function Yc(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){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function V_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);zi(e);let r=Z_(t);return zi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Wf(e);return zi(r.length),r}if(Ni(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),W_);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 zi(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 zi(t){if(t>K_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Z_(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 J_(t){return t.length>=2&&t[0]===31&&t[1]===139}function X_(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 Zc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Y_(t,e){let r,i;try{r=new Zf.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||Zc(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(h=>h===".."))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=Q_(i),c=Vc(e);for(let l of i){if(Zc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Vc(e,u),h=Jc(c,x);if(h.startsWith("..")||h==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Kc(x,{recursive:!0});continue}await Kc(O_(x),{recursive:!0});let m;try{m=l.getData()}catch(E){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await $c(x,m)}}function Q_(t){let e;for(let r of t){let i=r.entryName;if(!i||Zc(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 ey(t,e){await ty(t);let r=Sf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${kr}ms)`))},kr);try{await Vf($f.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${kr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function ty(t){let e=[],r=Tr({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(h=>h==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${kr}ms)`))},kr);try{await Vf($f.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${kr}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 ny=5e3;async function ry(t,e,r,i){return Jf(t,e,r,i,{count:0})}async function Jf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await D_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(B_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=ny){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Lt(e,u.name),h=L_(Lt(r,u.name)),m=null;try{m=await Wc(x)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let E={name:u.name,path:Xf(Jc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(E.children=await Jf(t,x,h,i-1,o)),l.push(E)}return l.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),l}function iy(t){return!t||t<=0?N_:Math.min(t,M_)}function sy(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Xf(t){return t.split(Kf).join("/")}re();import{readFileSync as WI}from"node:fs";import{dirname as $I,join as VI}from"node:path";import{fileURLToPath as JI}from"node:url";var Pr="0.1.104-alpha.21";var An=H("agent-health-reporter"),oy=1e4,Fi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??oy}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()}),An.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),An.info("heartbeat stopped"))}async tick(){if(this.inFlight){An.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){An.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=ay(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:Pr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){An.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(An.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){An.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){An.warn("onTickEnd hook failed",{err:String(r)})}}};function ay(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}ln();import{mkdir as id,rm as tb,stat as nb}from"node:fs/promises";import{homedir as rb}from"node:os";import{join as od}from"node:path";an();import{existsSync as yy}from"node:fs";import{release as by}from"node:os";import{basename as Ey,isAbsolute as vy}from"node:path";function Ui(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Or(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Lr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function In(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ze();var go=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,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32022};function Yf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Qf(t){return"method"in t&&!("id"in t)}function mo(t){return!("method"in t)&&"id"in t}var cy={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,METHOD_NOT_FOUND:ee.METHOD_NOT_FOUND,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,OPERATION_NOT_ALLOWED_FOR_CLOUD:ee.OPERATION_NOT_ALLOWED_FOR_CLOUD,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 dy(t){if(t!=null)return t instanceof Error?{name:t.name,message:qi(t.message)}:typeof t=="string"?qi(t):typeof t=="object"?uy(t):t}var ly=[[/\/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 qi(t){let e=t;for(let[r,i]of ly)e=e.replace(r,i);return e}function uy(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=qi(i):e[r]=i;return e}function Gi(t){if(t instanceof T){let e=dy(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:cy[t.code]??ee.INTERNAL_ERROR,message:qi(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:qi(t instanceof Error?t.message:String(t))}}function e0(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 n0(t){return`${JSON.stringify(t)}
|
|
93
|
-
|
|
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 i0={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission","session/set_mode":"session.setMode",initialize:"initialize"},aC=Object.fromEntries(Object.entries(i0).map(([t,e])=>[e,t])),fy={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"session.setMode":["agentId","sessionId"],"agent.pair":[],initialize:[]},Nr=class{seq=0;next(e,r){this.seq+=1;let i=i0[e]??xy(e),o=fy[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>r0(r?.[x]??"")),u=hy(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>r0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function xy(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function r0(t){return t.replace(/[:_\s]+/g,"-")}function hy(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}dn();import{readFileSync as py}from"node:fs";var gy=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 ur(t.agentEnvFile,r,{mode:gy})}function ed(t){try{let e=JSON.parse(py(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function s0(t,e,r={},i=o=>o){return{...i({...t,...ed(e)}),...r}}Vt();or();Ze();re();Le();import{execFileSync as my,spawnSync as wy}from"node:child_process";function Hi(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function ji(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),wy("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var td=new Set;function o0(t){typeof t=="number"&&t>0&&td.add(t)}function a0(t){typeof t=="number"&&td.delete(t)}function c0(){for(let t of td)ji(t,"SIGKILL")}var Mr="coze-bridge-daemon";function d0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return my("pgrep",["-U",String(o),"-f",Mr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
|
|
95
|
-
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function l0(t,e){if(t.length===0)return;let r=e?.killFn??ji,i=e?.isAliveFn??Hi,o=e?.sleepFn??(u=>new Promise(x=>setTimeout(x,u))),c=e?.graceMs??3e3,l=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(x=>i(x));u+=l)await o(Math.min(l,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var _y=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @(zed-industries|agentclientprotocol)\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function u0(t,e){if(!e)return null;for(let r of _y)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function f0(t,e){return u0(t,e)}function x0(t,e){return u0(t,e)}function Br(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function h0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let h=t.suspendedMs+o,m=r-t.startedAt-h;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Br(m,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Br(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Br(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Br(c,!1,e)}}var p0=Ve("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Sy=200,Ay=40,Iy=Ve("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Cy=Ve("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),Ty=Ve("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),Ry=Ve("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),Dy=Ve("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),ky=Ve("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),g0=500;function Py(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=g0?t:`${e.slice(0,g0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Oy(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function m0(t){try{return yy(t)}catch{return}}function Ly(t,e){return{platform:process.platform,osRelease:by(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:vy(e.command)?m0(e.command):void 0,cwd:e.cwd,cwdExists:m0(e.cwd),envKeys:e.envKeys}}function Ny(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${Ey(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Nt=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new wo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Nr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;spawnEnv={};sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=s0(process.env,this.opts.agentEnvFile??Q().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o));this.spawnEnv=r;let i=st(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,o0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Sy&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,a0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=Ly(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",Ny(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()));ji(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||ji(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:Dy,phase2GateMs:Iy,livenessWindowMs:Cy,absoluteMaxMs:Ty,approvalMaxMs:ky,suspendThresholdMs:Ry,...r};return this.call("session/prompt",e,p0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Or("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",e)}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Lr(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(In(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=p0,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Ui(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,h)=>{let m={resolve:x,reject:h,timer:null,method:e,promptTimeout:null};if(o){let E=this.now(),S={cfg:o,startedAt:E,lastActivityAt:E,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:E,expectedIntervalMs:Br(0,!1,o),sessionId:u};m.promptTimeout=S;let _=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},A=this.now(),I=h0(v,S.cfg,A),D=O=>{S.armedAt=A,S.expectedIntervalMs=O,m.timer=setTimeout(_,O)};if(I.action==="suspend"){S.suspendedMs+=I.suspendedDeltaMs,S.lastActivityAt=A,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:I.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),D(I.rearmMs);return}if(I.action==="continue"){D(I.rearmMs);return}this.pending.delete(c),I.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:I.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),h(I.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),h(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};m.timer=setTimeout(_,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(m.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),h(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,m);try{this.writeFrame(l)}catch(E){m.timer&&clearTimeout(m.timer),this.pending.delete(c),h(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(n0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(mo(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Py(e.result)}),r.resolve(e.result));return}if(Qf(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Yf(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(In(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(In(e.id,Gi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=e0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=x0(this.framework,Oy(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(Ay).join(`
|
|
96
|
-
`),o=f0(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function My(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 _o=class extends Nt{framework="claude-code";constructor(e){let{command:r,args:i}=oi("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 My(e)}};an();import{mkdtempSync as Uy,rmSync as qy}from"node:fs";import{tmpdir as Gy}from"node:os";import{join as Hy}from"node:path";import{readFileSync as _0}from"node:fs";import{homedir as By}from"node:os";import{join as w0}from"node:path";function y0(t){let e=t.CODEX_HOME?.trim()||w0(t.HOME?.trim()||By(),".codex");return w0(e,"config.toml")}function zy(t){let e=null;for(let r=0;r<t.length;r++){let i=t[r];if(e)i===e&&(e=null);else if(i==='"'||i==="'")e=i;else if(i==="#")return t.slice(0,r)}return t}function Fy(t){let e=t.trim();if(e.length>=2){let r=e[0];if((r==='"'||r==="'")&&e[e.length-1]===r)return e.slice(1,-1)}return e}function b0(t){let e={},r={},i=e;for(let o of t.split(/\r?\n/)){let c=zy(o).trim();if(!c)continue;let l=/^\[([^\]]+)\]$/.exec(c);if(l){let h=(l[1]??"").trim(),m=r[h]??{};r[h]=m,i=m;continue}let u=c.indexOf("=");if(u<=0)continue;let x=c.slice(0,u).trim();x&&(i[x]=Fy(c.slice(u+1)))}return{root:e,tables:r}}function E0(t){let e=t.root.model_provider;if(!e||e==="openai")return null;let r=t.tables[`model_providers.${e}`];return r?{providerId:e,baseUrl:r.base_url,envKey:r.env_key,bearerToken:r.experimental_bearer_token}:null}function v0(t){let e;try{e=_0(y0(t),"utf8")}catch{return null}return E0(b0(e))?.providerId??null}function S0(t){let e;try{e=_0(y0(t),"utf8")}catch{return null}let r=E0(b0(e));if(!r?.baseUrl)return null;let i=r.bearerToken||(r.envKey?t[r.envKey]?.trim():void 0);return i?{baseUrl:r.baseUrl,providerName:r.providerId,headers:{Authorization:`Bearer ${i}`}}:null}var yo=class t extends Nt{framework="codex";authRequest;resolveLocalGatewayAuth;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=oi("codex",e.command,i),l=e.isolateCodexHome?Uy(Hy(Gy(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authRequest=e.authRequest,this.resolveLocalGatewayAuth=e.resolveLocalGatewayAuth??!1,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e),i=this.authRequest??this.localGatewayAuthRequest();return i&&await this.call("authenticate",i),r}localGatewayAuthRequest(){if(!this.resolveLocalGatewayAuth)return null;let e=S0(this.spawnEnv);return e?(this.log.info("codex local: \u7528 config.toml custom provider \u8D70 gateway \u8BA4\u8BC1",{providerName:e.providerName,baseUrl:e.baseUrl}),{methodId:"gateway",_meta:{gateway:e}}):null}static MODE_ID_MAP={"read-only":"read-only",auto:"agent","full-access":"agent-full-access"};setSessionMode(e){let r=t.MODE_ID_MAP[e.modeId]??e.modeId;return super.setSessionMode({...e,modeId:r})}async stop(e){if(await super.stop(e),this.codexHomeDir)try{qy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};Ze();var jy=3e4,zr=class extends Nt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},jy))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var A0=["default","acceptEdits","plan","auto","bypassPermissions"],I0=["read-only","auto","full-access"];function Cn(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return A0.includes(e);case"codex":return I0.includes(e);case"openclaw":return!1}}function nd(t){switch(t){case"claude-code":return A0.join("/");case"codex":return I0.join("/");case"openclaw":return""}}dn();Ze();re();Le();function rd(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}an();var Tn=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 bo=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 Tn,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)Wi(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 Wi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Zt(t){return t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Vt();re();import{constants as C0}from"node:fs";import{access as Wy}from"node:fs/promises";import{delimiter as Ky,join as $y}from"node:path";var St=H("framework-detector"),T0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Vy=[".exe",".cmd",".bat",".ps1"],Zn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??st,access:e.access??Wy}}async detect(e){let r=T0[e],i=await this.which(r);if(!i)return St.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(T0).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(Ky).filter(Boolean),i=this.env.platform==="win32"?["",...Vy]:[""];for(let o of r)for(let c of i){let l=$y(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?C0.F_OK:C0.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 St.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return St.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 St.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 St.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?(St.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}:(St.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return St.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 St.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||St.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){St.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&&(Jy(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",h=>{o+=h.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",h=>u({code:h,stdout:o}))}catch{u(null)}})}},Zy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Jy(t){return t.replace(Zy,"")}import{homedir as Xy}from"node:os";import{join as Yy}from"node:path";dn();Vt();or();Ze();re();async function k0(){let t=Yy(Xy(),".openclaw/openclaw.json");return(await lr(t))?.gateway?.auth?.token??""}var R0=H("openclaw.config"),Qy=[0,5e3,5e3],eb=Ve("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),D0="models.providers.",Eo="agents.defaults.models",vo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new Tn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Qy,this.cliTimeoutMs=e.cliTimeoutMs??eb}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,R0.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=st(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=h=>{l||(l=!0,clearTimeout(x),h())};o.stderr?.on("data",h=>{c+=h.toString("utf8")});let x=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",h=>u(()=>i(h))),o.on("close",h=>u(()=>{h===0?r():i(new Error(`exit ${h}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){R0.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",`${D0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${D0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Eo}[${e}]`,()=>this.runCli(["config","set",Eo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Eo}[${e}]`,`${Eo}.${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 ue=H("agent-manager"),ad="bypassPermissions",L0="full-access",N0="full-access";function ib(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}var sb=(t,e,r,i,o,c,l,u,x,h)=>{switch(t){case"claude-code":{let m={...o?{...Ff(o),...Gf(o,l,u)}:{},...x??{},IS_SANDBOX:"1"};return new _o({cwd:r,env:m,agentId:i})}case"codex":{let m=L0;h!==void 0&&(Cn("codex",h)?m=h:ue.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:h}));let E=o?null:v0(process.env),S={...o?qf(o):{},INITIAL_AGENT_MODE:ib(m),...process.env.COZE_BRIDGE_CODEX_APP_SERVER_LOGS==="1"?{APP_SERVER_LOGS:od(r,"..","logs","codex-app-server")}:{},...E?{MODEL_PROVIDER:E}:{},...x??{}},_=o?Uf(o,l,u):null,v=_?{methodId:"gateway",_meta:{gateway:_}}:void 0,A=!!o,I=!A&&process.env.COZE_BRIDGE_CODEX_LOCAL_GATEWAY_AUTH==="1";return new yo({cwd:r,agentId:i,...Object.keys(S).length>0?{env:S}:{},...v?{authRequest:v}:{},...A?{isolateCodexHome:!0}:{},...I?{resolveLocalGatewayAuth:!0}:{}})}case"openclaw":return new zr({command:e,cwd:r,agentId:i,...c?{sessionName:rd(c)}:{}})}};function sd(t){return t==="claude-code"||t==="codex"}function ob(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(ab(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return z1(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 pp("schtasks",["/Create","/SC","ONLOGON","/TN",la,"/TR",r,"/RU",t.userName,"/F"]),Yd.info("task scheduler entry created",{task:la,logFile:t.logFile})},async uninstall(t){await pp("schtasks",["/Delete","/TN",la,"/F"]).catch(e=>Yd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Yd.info("task scheduler entry removed",{task:la})}}});var mp={};Sa(mp,{buildContext:()=>K1,getSupervisor:()=>G1,launchdSupervisor:()=>Jd,systemdSupervisor:()=>Zd,taskSchedulerSupervisor:()=>Xd});import{homedir as U1,userInfo as q1}from"node:os";function G1(t=process.platform){switch(t){case"darwin":return Jd;case"linux":return Zd;case"win32":return Xd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function j1(){let t={};for(let e of H1){let r=process.env[e];r&&(t[e]=r)}return t}function K1(){let t=Q();return{nodeBin:process.execPath,entry:Ud(t),logFile:t.logFile,homeDir:U1(),userName:q1().username,isRoot:process.getuid?.()===0,env:j1()}}var H1,wp=rt(()=>{"use strict";Me();Qo();fp();xp();gp();H1=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();an();var Cl=H("acp-installer-warmup"),Hg=["claude-code","codex"];async function Rl(t={}){let e=t.ensure??dr,i=(await Promise.allSettled(Hg.map(async o=>{let c=await e(o);Cl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&Cl.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))})}ln();te();import{readdir as sm}from"node:fs/promises";import{mkdir as Ll,readFile as rm,writeFile as Nl}from"node:fs/promises";import{join as Da}from"node:path";var im={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function fr(t,e,r){await Ll(t,{recursive:!0});let i=im[e],o=Da(t,i);return await Nl(o,r??"","utf8"),o}async function Pa(t,e,r){let i=Da(t,".claude");await Ll(i,{recursive:!0});let o=Da(i,"settings.local.json"),c={};try{let u=await rm(o,"utf8"),f=JSON.parse(u);typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}catch{}let d=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")d.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");d.defaultMode===void 0&&(d.defaultMode=r)}return c.permissions=d,await Nl(o,JSON.stringify(c,null,2),"utf8"),o}var Qe=H("agent-detail-sync"),om=6e4,am=5*6e4,ms=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await sm(r)}catch(o){Qe.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Qe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await De(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Qe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){Qe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),Qe.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){Qe.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Qe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await De(e,this.opts.paths);if(!i){Qe.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Qe.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),g=x?Math.min(x.currentDelay*2,am):om;this.retryQueue.set(e,{dueAt:Date.now()+g,currentDelay:g});return}if(o.agentId&&o.agentId!==e){Qe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!1;o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,d=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Qe.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Qe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Qe.debug("detail sync: no diff",{agentId:e});return}await Ue(i,this.opts.paths),Qe.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Qe.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):d&&(await fr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Qc=Gt(xu(),1);import{createHash as G_}from"node:crypto";import{lstat as Wc,mkdir as $c,readFile as lo,readdir as Xf,rm as Vc,stat as Jf,writeFile as Jc}from"node:fs/promises";import{dirname as H_,join as Je,normalize as j_,relative as Xc,resolve as Zc,sep as Qf}from"node:path";import{Readable as e0}from"node:stream";import{pipeline as t0}from"node:stream/promises";import Cm from"events";import it from"fs";import{EventEmitter as Dc}from"node:events";import Ju from"node:stream";import{StringDecoder as Rm}from"node:string_decoder";import Xu from"node:path";import Sr from"node:fs";import{dirname as Hm,parse as jm}from"path";import{EventEmitter as Xm}from"events";import fc from"assert";import{Buffer as jn}from"buffer";import*as _u from"zlib";import Qm from"zlib";import{posix as mr}from"node:path";import{basename as Aw}from"node:path";import Js from"fs";import Pt from"fs";import Au from"path";import{win32 as Fw}from"node:path";import Ou from"path";import xf from"node:fs";import t_ from"node:assert";import{randomBytes as pf}from"node:crypto";import re from"node:fs";import Fe from"node:path";import gf from"fs";import io from"node:fs";import Ai from"node:path";import ct from"node:fs";import c_ from"node:fs/promises";import Xs from"node:path";import{join as Tf}from"node:path";import at from"node:fs";import Rf from"node:path";var Tm=Object.defineProperty,km=(t,e)=>{for(var r in e)Tm(t,r,{get:e[r],enumerable:!0})},pu=typeof process=="object"&&process?process:{stdout:null,stderr:null},Dm=t=>!!t&&typeof t=="object"&&(t instanceof $n||t instanceof Ju||Pm(t)||Om(t)),Pm=t=>!!t&&typeof t=="object"&&t instanceof Dc&&typeof t.pipe=="function"&&t.pipe!==Ju.Writable.prototype.pipe,Om=t=>!!t&&typeof t=="object"&&t instanceof Dc&&typeof t.write=="function"&&typeof t.end=="function",Ht=Symbol("EOF"),jt=Symbol("maybeEmitEnd"),fn=Symbol("emittedEnd"),Es=Symbol("emittingEnd"),di=Symbol("emittedError"),vs=Symbol("closed"),gu=Symbol("read"),Ss=Symbol("flush"),mu=Symbol("flushChunk"),_t=Symbol("encoding"),gr=Symbol("decoder"),qe=Symbol("flowing"),li=Symbol("paused"),br=Symbol("resume"),Ge=Symbol("buffer"),et=Symbol("pipes"),He=Symbol("bufferLength"),Fa=Symbol("bufferPush"),Is=Symbol("bufferShift"),Xe=Symbol("objectMode"),ke=Symbol("destroyed"),za=Symbol("error"),Ua=Symbol("emitData"),wu=Symbol("emitEnd"),qa=Symbol("emitEnd2"),Ct=Symbol("async"),Ga=Symbol("abort"),As=Symbol("aborted"),ui=Symbol("signal"),Nn=Symbol("dataListeners"),ot=Symbol("discarded"),fi=t=>Promise.resolve().then(t),Lm=t=>t(),Nm=t=>t==="end"||t==="finish"||t==="prefinish",Mm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Bm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Zu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[br](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Fm=class extends Zu{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)}},zm=t=>!!t.objectMode,Um=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",$n=class extends Dc{[qe]=!1;[li]=!1;[et]=[];[Ge]=[];[Xe];[_t];[Ct];[gr];[Ht]=!1;[fn]=!1;[Es]=!1;[vs]=!1;[di]=null;[He]=0;[ke]=!1;[ui];[As]=!1;[Nn]=0;[ot]=!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");zm(e)?(this[Xe]=!0,this[_t]=null):Um(e)?(this[_t]=e.encoding,this[Xe]=!1):(this[Xe]=!1,this[_t]=null),this[Ct]=!!e.async,this[gr]=this[_t]?new Rm(this[_t]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ge]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[et]});let{signal:r}=e;r&&(this[ui]=r,r.aborted?this[Ga]():r.addEventListener("abort",()=>this[Ga]()))}get bufferLength(){return this[He]}get encoding(){return this[_t]}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[Xe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ct]}set async(t){this[Ct]=this[Ct]||!!t}[Ga](){this[As]=!0,this.emit("abort",this[ui]?.reason),this.destroy(this[ui]?.reason)}get aborted(){return this[As]}set aborted(t){}write(t,e,r){if(this[As])return!1;if(this[Ht])throw new Error("write after end");if(this[ke])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[Ct]?fi:Lm;if(!this[Xe]&&!Buffer.isBuffer(t)){if(Bm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Mm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Xe]?(this[qe]&&this[He]!==0&&this[Ss](!0),this[qe]?this.emit("data",t):this[Fa](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[qe]):t.length?(typeof t=="string"&&!(e===this[_t]&&!this[gr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[_t]&&(t=this[gr].write(t)),this[qe]&&this[He]!==0&&this[Ss](!0),this[qe]?this.emit("data",t):this[Fa](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[qe]):(this[He]!==0&&this.emit("readable"),r&&i(r),this[qe])}read(t){if(this[ke])return null;if(this[ot]=!1,this[He]===0||t===0||t&&t>this[He])return this[jt](),null;this[Xe]&&(t=null),this[Ge].length>1&&!this[Xe]&&(this[Ge]=[this[_t]?this[Ge].join(""):Buffer.concat(this[Ge],this[He])]);let e=this[gu](t||null,this[Ge][0]);return this[jt](),e}[gu](t,e){if(this[Xe])this[Is]();else{let r=e;t===r.length||t===null?this[Is]():typeof r=="string"?(this[Ge][0]=r.slice(t),e=r.slice(0,t),this[He]-=t):(this[Ge][0]=r.subarray(t),e=r.subarray(0,t),this[He]-=t)}return this.emit("data",e),!this[Ge].length&&!this[Ht]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ht]=!0,this.writable=!1,(this[qe]||!this[li])&&this[jt](),this}[br](){this[ke]||(!this[Nn]&&!this[et].length&&(this[ot]=!0),this[li]=!1,this[qe]=!0,this.emit("resume"),this[Ge].length?this[Ss]():this[Ht]?this[jt]():this.emit("drain"))}resume(){return this[br]()}pause(){this[qe]=!1,this[li]=!0,this[ot]=!1}get destroyed(){return this[ke]}get flowing(){return this[qe]}get paused(){return this[li]}[Fa](t){this[Xe]?this[He]+=1:this[He]+=t.length,this[Ge].push(t)}[Is](){return this[Xe]?this[He]-=1:this[He]-=this[Ge][0].length,this[Ge].shift()}[Ss](t=!1){do;while(this[mu](this[Is]())&&this[Ge].length);!t&&!this[Ge].length&&!this[Ht]&&this.emit("drain")}[mu](t){return this.emit("data",t),this[qe]}pipe(t,e){if(this[ke])return t;this[ot]=!1;let r=this[fn];return e=e||{},t===pu.stdout||t===pu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[et].push(e.proxyErrors?new Fm(this,t,e):new Zu(this,t,e)),this[Ct]?fi(()=>this[br]()):this[br]()),t}unpipe(t){let e=this[et].find(r=>r.dest===t);e&&(this[et].length===1?(this[qe]&&this[Nn]===0&&(this[qe]=!1),this[et]=[]):this[et].splice(this[et].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[ot]=!1,this[Nn]++,!this[et].length&&!this[qe]&&this[br]();else if(t==="readable"&&this[He]!==0)super.emit("readable");else if(Nm(t)&&this[fn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[di]){let i=e;this[Ct]?fi(()=>i.call(this,this[di])):i.call(this,this[di])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Nn]=this.listeners("data").length,this[Nn]===0&&!this[ot]&&!this[et].length&&(this[qe]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Nn]=0,!this[ot]&&!this[et].length&&(this[qe]=!1)),e}get emittedEnd(){return this[fn]}[jt](){!this[Es]&&!this[fn]&&!this[ke]&&this[Ge].length===0&&this[Ht]&&(this[Es]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[vs]&&this.emit("close"),this[Es]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ke&&this[ke])return!1;if(t==="data")return!this[Xe]&&!r?!1:this[Ct]?(fi(()=>this[Ua](r)),!0):this[Ua](r);if(t==="end")return this[wu]();if(t==="close"){if(this[vs]=!0,!this[fn]&&!this[ke])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[di]=r,super.emit(za,r);let o=!this[ui]||this.listeners("error").length?super.emit("error",r):!1;return this[jt](),o}else if(t==="resume"){let o=super.emit("resume");return this[jt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[jt](),i}[Ua](t){for(let r of this[et])r.dest.write(t)===!1&&this.pause();let e=this[ot]?!1:super.emit("data",t);return this[jt](),e}[wu](){return this[fn]?!1:(this[fn]=!0,this.readable=!1,this[Ct]?(fi(()=>this[qa]()),!0):this[qa]())}[qa](){if(this[gr]){let e=this[gr].end();if(e){for(let r of this[et])r.dest.write(e);this[ot]||super.emit("data",e)}}for(let e of this[et])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Xe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Xe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Xe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[_t]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ke,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[ot]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ht])return e();let i,o,c=x=>{this.off("data",d),this.off("end",u),this.off(ke,f),e(),o(x)},d=x=>{this.off("error",c),this.off("end",u),this.off(ke,f),this.pause(),i({value:x,done:!!this[Ht]})},u=()=>{this.off("error",c),this.off("data",d),this.off(ke,f),e(),i({done:!0,value:void 0})},f=()=>c(new Error("stream destroyed"));return new Promise((x,g)=>{o=g,i=x,this.once(ke,f),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ot]=!1;let t=!1,e=()=>(this.pause(),this.off(za,e),this.off(ke,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(za,e),this.once(ke,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ke])return t?this.emit("error",t):this.emit(ke),this;this[ke]=!0,this[ot]=!0,this[Ge].length=0,this[He]=0;let e=this;return typeof e.close=="function"&&!this[vs]&&e.close(),t?this.emit("error",t):this.emit(ke),this}static get isStream(){return Dm}},qm=it.writev,En=Symbol("_autoClose"),vt=Symbol("_close"),hi=Symbol("_ended"),ce=Symbol("_fd"),Ha=Symbol("_finished"),Vt=Symbol("_flags"),ja=Symbol("_flush"),lc=Symbol("_handleChunk"),uc=Symbol("_makeBuf"),Si=Symbol("_mode"),Ts=Symbol("_needDrain"),Ar=Symbol("_onerror"),Tr=Symbol("_onopen"),Ka=Symbol("_onread"),Er=Symbol("_onwrite"),vn=Symbol("_open"),Et=Symbol("_path"),mn=Symbol("_pos"),Rt=Symbol("_queue"),vr=Symbol("_read"),Wa=Symbol("_readSize"),$t=Symbol("_reading"),xi=Symbol("_remain"),$a=Symbol("_size"),Bs=Symbol("_write"),Mn=Symbol("_writing"),Fs=Symbol("_defaultFlag"),Hn=Symbol("_errored"),Pc=class extends $n{[Hn]=!1;[ce];[Et];[Wa];[$t]=!1;[$a];[xi];[En];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[Hn]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[Et]=t,this[Wa]=e.readSize||16*1024*1024,this[$t]=!1,this[$a]=typeof e.size=="number"?e.size:1/0,this[xi]=this[$a],this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[vr]():this[vn]()}get fd(){return this[ce]}get path(){return this[Et]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[vn](){it.open(this[Et],"r",(t,e)=>this[Tr](t,e))}[Tr](t,e){t?this[Ar](t):(this[ce]=e,this.emit("open",e),this[vr]())}[uc](){return Buffer.allocUnsafe(Math.min(this[Wa],this[xi]))}[vr](){if(!this[$t]){this[$t]=!0;let t=this[uc]();if(t.length===0)return process.nextTick(()=>this[Ka](null,0,t));it.read(this[ce],t,0,t.length,null,(e,r,i)=>this[Ka](e,r,i))}}[Ka](t,e,r){this[$t]=!1,t?this[Ar](t):this[lc](e,r)&&this[vr]()}[vt](){if(this[En]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Ar](t){this[$t]=!0,this[vt](),this.emit("error",t)}[lc](t,e){let r=!1;return this[xi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[xi]<=0)&&(r=!1,this[vt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[vr](),!1;case"error":return this[Hn]?!1:(this[Hn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Gm=class extends Pc{[vn](){let t=!0;try{this[Tr](null,it.openSync(this[Et],"r")),t=!1}finally{t&&this[vt]()}}[vr](){let t=!0;try{if(!this[$t]){this[$t]=!0;do{let e=this[uc](),r=e.length===0?0:it.readSync(this[ce],e,0,e.length,null);if(!this[lc](r,e))break}while(!0);this[$t]=!1}t=!1}finally{t&&this[vt]()}}[vt](){if(this[En]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,it.closeSync(t),this.emit("close")}}},Qs=class extends Cm{readable=!1;writable=!0;[Hn]=!1;[Mn]=!1;[hi]=!1;[Rt]=[];[Ts]=!1;[Et];[Si];[En];[ce];[Fs];[Vt];[Ha]=!1;[mn];constructor(t,e){e=e||{},super(e),this[Et]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[Si]=e.mode===void 0?438:e.mode,this[mn]=typeof e.start=="number"?e.start:void 0,this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[mn]!==void 0?"r+":"w";this[Fs]=e.flags===void 0,this[Vt]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[vn]()}emit(t,...e){if(t==="error"){if(this[Hn])return!1;this[Hn]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[Et]}[Ar](t){this[vt](),this[Mn]=!0,this.emit("error",t)}[vn](){it.open(this[Et],this[Vt],this[Si],(t,e)=>this[Tr](t,e))}[Tr](t,e){this[Fs]&&this[Vt]==="r+"&&t&&t.code==="ENOENT"?(this[Vt]="w",this[vn]()):t?this[Ar](t):(this[ce]=e,this.emit("open",e),this[Mn]||this[ja]())}end(t,e){return t&&this.write(t,e),this[hi]=!0,!this[Mn]&&!this[Rt].length&&typeof this[ce]=="number"&&this[Er](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[hi]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[Mn]||this[Rt].length?(this[Rt].push(t),this[Ts]=!0,!1):(this[Mn]=!0,this[Bs](t),!0)}[Bs](t){it.write(this[ce],t,0,t.length,this[mn],(e,r)=>this[Er](e,r))}[Er](t,e){t?this[Ar](t):(this[mn]!==void 0&&typeof e=="number"&&(this[mn]+=e),this[Rt].length?this[ja]():(this[Mn]=!1,this[hi]&&!this[Ha]?(this[Ha]=!0,this[vt](),this.emit("finish")):this[Ts]&&(this[Ts]=!1,this.emit("drain"))))}[ja](){if(this[Rt].length===0)this[hi]&&this[Er](null,0);else if(this[Rt].length===1)this[Bs](this[Rt].pop());else{let t=this[Rt];this[Rt]=[],qm(this[ce],t,this[mn],(e,r)=>this[Er](e,r))}}[vt](){if(this[En]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Yu=class extends Qs{[vn](){let t;if(this[Fs]&&this[Vt]==="r+")try{t=it.openSync(this[Et],this[Vt],this[Si])}catch(e){if(e?.code==="ENOENT")return this[Vt]="w",this[vn]();throw e}else t=it.openSync(this[Et],this[Vt],this[Si]);this[Tr](null,t)}[vt](){if(this[En]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,it.closeSync(t),this.emit("close")}}[Bs](t){let e=!0;try{this[Er](null,it.writeSync(this[ce],t,0,t.length,this[mn])),e=!1}finally{if(e)try{this[vt]()}catch{}}}},Km=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"]]),Wm=t=>!!t.sync&&!!t.file,$m=t=>!t.sync&&!!t.file,Vm=t=>!!t.sync&&!t.file,Jm=t=>!t.sync&&!t.file,Zm=t=>!!t.file,Ym=t=>Km.get(t)||t,Oc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=Ym(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Oi=(t,e,r,i,o)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let f=Oc(c);if(o?.(f,d),Wm(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(f,d)}else if($m(f)){let x=e(f,d);return u?x.then(()=>u(),u):x}else if(Vm(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(f,d)}else if(Jm(f)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(f,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),ew=Qm.constants||{ZLIB_VERNUM:4736},Lt=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},ew)),tw=jn.concat,yu=Object.getOwnPropertyDescriptor(jn,"concat"),nw=t=>t,Va=yu?.writable===!0||yu?.set!==void 0?t=>{jn.concat=t?nw:tw}:t=>{},Kn=Symbol("_superWrite"),ks=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Ja=Symbol("flushFlag"),Lc=class extends $n{#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 _u[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new _u[e](t)}catch(r){throw new ks(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 ks(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return fc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(jn.alloc(0),{[Ja]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Kn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=jn.from(t,e)),this.#e)return;fc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Va(!0);let d;try{let f=typeof t[Ja]=="number"?t[Ja]:this.#r;d=this.#t._processChunk(t,f),Va(!1)}catch(f){Va(!1),this.#o(new ks(f,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",f=>this.#o(new ks(f,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let f=d[0];u=this[Kn](jn.from(f));for(let x=1;x<d.length;x++)u=this[Kn](d[x])}else u=this[Kn](jn.from(d));return r&&r(),u}},Qu=class extends Lc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Lt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Lt.Z_FINISH,t.fullFlushFlag=Lt.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(Lt.Z_SYNC_FLUSH),fc(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)}}}},rw=class extends Qu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Kn](t){return this.#e?(this.#e=!1,t[9]=255,super[Kn](t)):super[Kn](t)}},iw=class extends Qu{constructor(t){super(t,"Unzip")}},ef=class extends Lc{constructor(t,e){t=t||{},t.flush=t.flush||Lt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Lt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Lt.BROTLI_OPERATION_FLUSH,super(t,e)}},sw=class extends ef{constructor(t){super(t,"BrotliCompress")}},ow=class extends ef{constructor(t){super(t,"BrotliDecompress")}},tf=class extends Lc{constructor(t,e){t=t||{},t.flush=t.flush||Lt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Lt.ZSTD_e_end,t.fullFlushFlag=Lt.ZSTD_e_flush,super(t,e)}},aw=class extends tf{constructor(t){super(t,"ZstdCompress")}},cw=class extends tf{constructor(t){super(t,"ZstdDecompress")}},dw=(t,e)=>{if(Number.isSafeInteger(t))t<0?uw(t,e):lw(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},lw=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},uw=(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]=nf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=rf(o))}},fw=t=>{let e=t[0],r=e===128?xw(t.subarray(1,t.length)):e===255?hw(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},hw=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=nf(c):c===0?d=c:(i=!0,d=rf(c)),d!==0&&(r-=d*Math.pow(256,e-o-1))}return r},xw=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},nf=t=>(255^t)&255,rf=t=>(255^t)+1&255,pw={};km(pw,{code:()=>Nc,isCode:()=>zs,isName:()=>gw,name:()=>eo,normalFsTypes:()=>sf});var zs=t=>eo.has(t),gw=t=>Nc.has(t),sf=new Set(["0","","1","2","3","4","5","6","7","D"]),eo=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"]]),Nc=new Map(Array.from(eo).map(t=>[t[1],t[0]])),Wn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");let o=Bn(t,e+156,1),c=sf.has(o),d=c?r:void 0,u=c?i:void 0;if(this.path=d?.path??Bn(t,e,100),this.mode=d?.mode??u?.mode??wn(t,e+100,8),this.uid=d?.uid??u?.uid??wn(t,e+108,8),this.gid=d?.gid??u?.gid??wn(t,e+116,8),this.size=d?.size??u?.size??wn(t,e+124,12),this.mtime=d?.mtime??u?.mtime??Za(t,e+136,12),this.cksum=wn(t,e+148,12),u&&this.#n(u,!0),d&&this.#n(d),zs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Bn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=d?.uname??u?.uname??Bn(t,e+265,32),this.gname=d?.gname??u?.gname??Bn(t,e+297,32),this.devmaj=d?.devmaj??u?.devmaj??wn(t,e+329,8)??0,this.devmin=d?.devmin??u?.devmin??wn(t,e+337,8)??0,t[e+475]!==0){let x=Bn(t,e+345,155);this.path=x+"/"+this.path}else{let x=Bn(t,e+345,130);x&&(this.path=x+"/"+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 f=256;for(let x=e;x<e+148;x++)f+=t[x];for(let x=e+156;x<e+512;x++)f+=t[x];this.cksumValid=f===this.cksum,this.cksum===void 0&&f===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=mw(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Fn(t,e,100,o)||this.needPax,this.needPax=_n(t,e+100,8,this.mode)||this.needPax,this.needPax=_n(t,e+108,8,this.uid)||this.needPax,this.needPax=_n(t,e+116,8,this.gid)||this.needPax,this.needPax=_n(t,e+124,12,this.size)||this.needPax,this.needPax=Ya(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Fn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Fn(t,e+265,32,this.uname)||this.needPax,this.needPax=Fn(t,e+297,32,this.gname)||this.needPax,this.needPax=_n(t,e+329,8,this.devmaj)||this.needPax,this.needPax=_n(t,e+337,8,this.devmin)||this.needPax,this.needPax=Fn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Fn(t,e+345,155,c)||this.needPax:(this.needPax=Fn(t,e+345,130,c)||this.needPax,this.needPax=Ya(t,e+476,12,this.atime)||this.needPax,this.needPax=Ya(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,_n(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:eo.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Nc.get(t));if(zs(e)||e==="Unsupported")this.#e=e;else if(zs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},mw=(t,e)=>{let r=t,i="",o,c=mr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=mr.dirname(r),r=mr.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=mr.join(mr.basename(i),r),i=mr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Bn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Za=(t,e,r)=>ww(wn(t,e,r)),ww=t=>t===void 0?void 0:new Date(t*1e3),wn=(t,e,r)=>Number(t[e])&128?fw(t.subarray(e,e+r)):yw(t,e,r),_w=t=>isNaN(t)?void 0:t,yw=(t,e,r)=>_w(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),bw={12:8589934591,8:2097151},_n=(t,e,r,i)=>i===void 0?!1:i>bw[r]||i<0?(dw(i,t.subarray(e,e+r)),!0):(Ew(t,e,r,i),!1),Ew=(t,e,r,i)=>t.write(vw(i,r),e,r,"ascii"),vw=(t,e)=>Sw(Math.floor(t).toString(8),e),Sw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ya=(t,e,r,i)=>i===void 0?!1:_n(t,e,r,i.getTime()/1e3),Iw=new Array(156).join("\0"),Fn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Iw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Vs=class of{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 Wn({path:("PaxHeader/"+Aw(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+o}static parse(e,r,i=!1){return new of(Tw(kw(e),r),i)}},Tw=(t,e)=>e?Object.assign({},e,t):t,kw=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(Cw,Object.create(null)),Cw=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),d=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},Rw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,X=Rw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Dw=class extends $n{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=X(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?X(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=X(t.path)),t.linkpath&&(t.linkpath=X(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},to=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Pw=1024*1024,hc=Buffer.from([31,139]),xc=Buffer.from([40,181,47,253]),Ow=Math.max(hc.length,xc.length),ut=Symbol("state"),zn=Symbol("writeEntry"),Kt=Symbol("readEntry"),Xa=Symbol("nextEntry"),bu=Symbol("processEntry"),Dt=Symbol("extendedHeader"),pi=Symbol("globalExtendedHeader"),hn=Symbol("meta"),Eu=Symbol("emitMeta"),me=Symbol("buffer"),Wt=Symbol("queue"),xn=Symbol("ended"),Qa=Symbol("emittedEnd"),Un=Symbol("emit"),Pe=Symbol("unzip"),Cs=Symbol("consumeChunk"),Rs=Symbol("consumeChunkSub"),ec=Symbol("consumeBody"),vu=Symbol("consumeMeta"),Su=Symbol("consumeHeader"),gi=Symbol("consuming"),tc=Symbol("bufferConcat"),Ds=Symbol("maybeEnd"),wr=Symbol("writing"),pn=Symbol("aborted"),Ps=Symbol("onDone"),qn=Symbol("sawValidEntry"),Os=Symbol("sawNullBlock"),Ls=Symbol("sawEOF"),Iu=Symbol("closeStream"),Lw=()=>!0,Pi=class extends Xm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[me];[Kt];[zn];[ut]="begin";[hn]="";[Dt];[pi];[xn]=!1;[Pe];[pn]=!1;[qn];[Os]=!1;[Ls]=!1;[wr]=!1;[gi]=!1;[Qa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ps,()=>{(this[ut]==="begin"||this[qn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Ps,t.ondone):this.on(Ps,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Pw,this.filter=typeof t.filter=="function"?t.filter:Lw;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[Iu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){to(this,t,e,r)}[Su](t,e){this[qn]===void 0&&(this[qn]=!1);let r;try{r=new Wn(t,e,this[Dt],this[pi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Os]?(this[Ls]=!0,this[ut]==="begin"&&(this[ut]="header"),this[Un]("eof")):(this[Os]=!0,this[Un]("nullBlock"));else if(this[Os]=!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[zn]=new Dw(r,this[Dt],this[pi]);if(!this[qn])if(o.remain){let c=()=>{o.invalid||(this[qn]=!0)};o.on("end",c)}else this[qn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Un]("ignoredEntry",o),this[ut]="ignore",o.resume()):o.size>0&&(this[hn]="",o.on("data",c=>this[hn]+=c),this[ut]="meta"):(this[Dt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Un]("ignoredEntry",o),this[ut]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ut]="body":(this[ut]="header",o.end()),this[Kt]?this[Wt].push(o):(this[Wt].push(o),this[Xa]())))}}}[Iu](){queueMicrotask(()=>this.emit("close"))}[bu](t){let e=!0;if(!t)this[Kt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Kt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Xa]()),e=!1);return e}[Xa](){do;while(this[bu](this[Wt].shift()));if(this[Wt].length===0){let t=this[Kt];!t||t.flowing||t.size===t.remain?this[wr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ec](t,e){let r=this[zn];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[ut]="header",this[zn]=void 0,r.end()),o.length}[vu](t,e){let r=this[zn],i=this[ec](t,e);return!this[zn]&&r&&this[Eu](r),i}[Un](t,e,r){this[Wt].length===0&&!this[Kt]?this.emit(t,e,r):this[Wt].push([t,e,r])}[Eu](t){switch(this[Un]("meta",this[hn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Dt]=Vs.parse(this[hn],this[Dt],!1);break;case"GlobalExtendedHeader":this[pi]=Vs.parse(this[hn],this[pi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Dt]??Object.create(null);this[Dt]=e,e.path=this[hn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Dt]||Object.create(null);this[Dt]=e,e.linkpath=this[hn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[pn]=!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[pn])return r?.(),!1;if((this[Pe]===void 0||this.brotli===void 0&&this[Pe]===!1)&&t){if(this[me]&&(t=Buffer.concat([this[me],t]),this[me]=void 0),t.length<Ow)return this[me]=t,r?.(),!0;for(let d=0;this[Pe]===void 0&&d<hc.length;d++)t[d]!==hc[d]&&(this[Pe]=!1);let o=!1;if(this[Pe]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<xc.length;d++)if(t[d]!==xc[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Pe]===!1&&c)if(t.length<512)if(this[xn])this.brotli=!0;else return this[me]=t,r?.(),!0;else try{new Wn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Pe]===void 0||this[Pe]===!1&&(this.brotli||o)){let d=this[xn];this[xn]=!1,this[Pe]=this[Pe]===void 0?new iw({}):o?new cw({}):new ow({}),this[Pe].on("data",f=>this[Cs](f)),this[Pe].on("error",f=>this.abort(f)),this[Pe].on("end",()=>{this[xn]=!0,this[Cs]()}),this[wr]=!0;let u=!!this[Pe][d?"end":"write"](t);return this[wr]=!1,r?.(),u}}this[wr]=!0,this[Pe]?this[Pe].write(t):this[Cs](t),this[wr]=!1;let i=this[Wt].length>0?!1:this[Kt]?this[Kt].flowing:!0;return!i&&this[Wt].length===0&&this[Kt]?.once("drain",()=>this.emit("drain")),r?.(),i}[tc](t){t&&!this[pn]&&(this[me]=this[me]?Buffer.concat([this[me],t]):t)}[Ds](){if(this[xn]&&!this[Qa]&&!this[pn]&&!this[gi]){this[Qa]=!0;let t=this[zn];if(t&&t.blockRemain){let e=this[me]?this[me].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[me]&&t.write(this[me]),t.end()}this[Un](Ps)}}[Cs](t){if(this[gi]&&t)this[tc](t);else if(!t&&!this[me])this[Ds]();else if(t){if(this[gi]=!0,this[me]){this[tc](t);let e=this[me];this[me]=void 0,this[Rs](e)}else this[Rs](t);for(;this[me]&&this[me]?.length>=512&&!this[pn]&&!this[Ls];){let e=this[me];this[me]=void 0,this[Rs](e)}this[gi]=!1}(!this[me]||this[xn])&&this[Ds]()}[Rs](t){let e=0,r=t.length;for(;e+512<=r&&!this[pn]&&!this[Ls];)switch(this[ut]){case"begin":case"header":this[Su](t,e),e+=512;break;case"ignore":case"body":e+=this[ec](t,e);break;case"meta":e+=this[vu](t,e);break;default:throw new Error("invalid state: "+this[ut])}e<r&&(this[me]=this[me]?Buffer.concat([t.subarray(e),this[me]]):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[pn]||(this[Pe]?(t&&this[Pe].write(t),this[Pe].end()):(this[xn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ds]())),this}},Ii=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)},Nw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},af=(t,e)=>{let r=new Map(e.map(c=>[Ii(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||jm(c).root||".",f;if(c===u)f=!1;else{let x=r.get(c);f=x!==void 0?x:o(Hm(c),u)}return r.set(c,f),f};t.filter=i?(c,d)=>i(c,d)&&o(Ii(c)):c=>o(Ii(c))},Mw=t=>{let e=new Pi(t),r=t.file,i;try{i=Sr.openSync(r,"r");let o=Sr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let d=Buffer.allocUnsafe(o.size),u=Sr.readSync(i,d,0,o.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<o.size;){let f=Sr.readSync(i,u,0,c,d);if(f===0)break;d+=f,e.write(u.subarray(0,f))}e.end()}}finally{if(typeof i=="number")try{Sr.closeSync(i)}catch{}}},Bw=(t,e)=>{let r=new Pi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),Sr.stat(o,(u,f)=>{if(u)d(u);else{let x=new Pc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(r)}})})},kr=Oi(Mw,Bw,t=>new Pi(t),t=>new Pi(t),(t,e)=>{e?.length&&af(t,e),t.noResume||Nw(t)}),cf=(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:zw,parse:Tu}=Fw,Mc=t=>{let e="",r=Tu(t);for(;zw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Tu(t)}return[e,t]},no=["|","<",">","?",":"],Bc=no.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Uw=new Map(no.map((t,e)=>[t,Bc[e]])),qw=new Map(Bc.map((t,e)=>[t,no[e]])),ku=t=>no.reduce((e,r)=>e.split(r).join(Uw.get(r)),t),Gw=t=>Bc.reduce((e,r)=>e.split(r).join(qw.get(r)),t),df=(t,e)=>e?(t=X(t).replace(/^\.(\/|$)/,""),Ii(e)+"/"+t):X(t),Hw=16*1024*1024,Cu=Symbol("process"),Ru=Symbol("file"),Du=Symbol("directory"),pc=Symbol("symlink"),Pu=Symbol("hardlink"),mi=Symbol("header"),Us=Symbol("read"),gc=Symbol("lstat"),qs=Symbol("onlstat"),mc=Symbol("onread"),wc=Symbol("onreadlink"),_c=Symbol("openfile"),yc=Symbol("onopenfile"),yn=Symbol("close"),Zs=Symbol("mode"),bc=Symbol("awaitDrain"),nc=Symbol("ondrain"),Ot=Symbol("prefix"),lf=class extends $n{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=Oc(e);super(),this.path=X(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Hw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=X(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?X(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,d]=Mc(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Gw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=X(r.absolute||Au.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[qs](o):this[gc]()}warn(t,e,r={}){return to(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[gc](){Pt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[qs](e)})}[qs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Ww(t),this.emit("stat",t),this[Cu]()}[Cu](){switch(this.type){case"File":return this[Ru]();case"Directory":return this[Du]();case"SymbolicLink":return this[pc]();default:return this.end()}}[Zs](t){return cf(t,this.type==="Directory",this.portable)}[Ot](t){return df(t,this.prefix)}[mi](){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 Wn({path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](this.linkpath):this.linkpath,mode:this[Zs](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 Vs({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[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](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)}[Du](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[mi](),this.end()}[pc](){Pt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[wc](e)})}[wc](t){this.linkpath=X(t),this[mi](),this.end()}[Pu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=X(Au.relative(this.cwd,t)),this.stat.size=0,this[mi](),this.end()}[Ru](){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[mi](),this.stat.size===0)return this.end();this[_c]()}[_c](){Pt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[yc](e)})}[yc](t){if(this.fd=t,this.#e)return this[yn]();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[Us]()}[Us](){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");Pt.read(t,e,r,i,o,(c,d)=>{if(c)return this[yn](()=>this.emit("error",c));this[mc](d)})}[yn](t=()=>{}){this.fd!==void 0&&Pt.close(this.fd,t)}[mc](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[yn](()=>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[yn](()=>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[nc]():this[bc](()=>this[nc]())}[bc](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)}[nc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[yn](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[Us]()}},jw=class extends lf{sync=!0;[gc](){this[qs](Pt.lstatSync(this.absolute))}[pc](){this[wc](Pt.readlinkSync(this.absolute))}[_c](){this[yc](Pt.openSync(this.absolute,"r"))}[Us](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let d=Pt.readSync(e,r,i,o,c);this[mc](d),t=!1}finally{if(t)try{this[yn](()=>{})}catch{}}}[bc](t){t()}[yn](t=()=>{}){this.fd!==void 0&&Pt.closeSync(this.fd),t()}},Kw=class extends $n{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 to(this,t,e,r)}constructor(t,e={}){let r=Oc(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=X(t.path),this.mode=t.mode!==void 0?this[Zs](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?X(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[d,u]=Mc(this.path);d&&typeof u=="string"&&(this.path=u,o=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Wn({path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](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 Vs({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[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](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)}[Ot](t){return df(t,this.prefix)}[Zs](t){return cf(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}},Ww=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",$w=class Ir{tail;head;length=0;static create(e=[]){return new Ir(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++)Jw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)Zw(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 Ir;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 Ir;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 Ir;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 Ir;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let d=0;o&&d<e;d++)o=o.next;let c=[];for(let d=0;o&&d<r;d++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let d of i)o=Vw(this,o,d);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function Vw(t,e,r){let i=e,o=e?e.next:t.head,c=new Fc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Jw(t,e){t.tail=new Fc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Zw(t,e){t.head=new Fc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Fc=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}},Lu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Nu=Buffer.alloc(1024),Gs=Symbol("onStat"),wi=Symbol("ended"),yt=Symbol("queue"),_i=Symbol("pendingLinks"),gn=Symbol("current"),Gn=Symbol("process"),yi=Symbol("processing"),Ns=Symbol("processJob"),bt=Symbol("jobs"),rc=Symbol("jobDone"),Hs=Symbol("addFSEntry"),Mu=Symbol("addTarEntry"),Ec=Symbol("stat"),vc=Symbol("readdir"),js=Symbol("onreaddir"),Ks=Symbol("pipe"),Bu=Symbol("entry"),ic=Symbol("entryOpt"),Ws=Symbol("writeEntryClass"),uf=Symbol("write"),sc=Symbol("ondrain"),ro=class extends $n{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ws];onWriteEntry;[yt];[_i]=new Map;[bt]=0;[yi]=!1;[wi]=!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=X(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[Ws]=lf,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 rw(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new sw(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new aw(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[sc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[sc]);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[yt]=new $w,this[bt]=0,this.jobs=Number(t.jobs)||4,this[yi]=!1,this[wi]=!1}[uf](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[wi]=!0,this[Gn](),r&&r(),this}write(t){if(this[wi])throw new Error("write after end");return typeof t=="string"?this[Hs](t):this[Mu](t),this.flowing}[Mu](t){let e=X(Ou.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Lu(t.path,e);r.entry=new Kw(t,this[ic](r)),r.entry.on("end",()=>this[rc](r)),this[bt]+=1,this[yt].push(r)}this[Gn]()}[Hs](t){let e=X(Ou.resolve(this.cwd,t));this[yt].push(new Lu(t,e)),this[Gn]()}[Ec](t){t.pending=!0,this[bt]+=1;let e=this.follow?"stat":"lstat";Js[e](t.absolute,(r,i)=>{t.pending=!1,this[bt]-=1,r?this.emit("error",r):this[Gs](t,i)})}[Gs](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[gn])this[Ns](t);else{let r=`${e.dev}:${e.ino}`,i=this[_i].get(r);i?i.push(t):this[_i].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Gn]()}[vc](t){t.pending=!0,this[bt]+=1,Js.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[bt]-=1,e)return this.emit("error",e);this[js](t,r)})}[js](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Gn]()}[Gn](){if(!this[yi]){this[yi]=!0;for(let t=this[yt].head;t&&this[bt]<this.jobs;t=t.next)if(this[Ns](t.value),t.value.ignore){let e=t.next;this[yt].removeNode(t),t.next=e}this[yi]=!1,this[wi]&&this[yt].length===0&&this[bt]===0&&(this.zip?this.zip.end(Nu):(super.write(Nu),super.end()))}}get[gn](){return this[yt]&&this[yt].head&&this[yt].head.value}[rc](t){this[yt].shift(),this[bt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[_i].get(r);if(i){this[_i].delete(r);for(let o of i)o.pending=!1,this[Ns](o)}}this[Gn]()}[Ns](t){if(t.pending&&t.pendingLink&&t===this[gn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[gn]&&!t.piped&&this[Ks](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Gs](t,e):this[Ec](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[js](t,e):this[vc](t),!t.readdir)return}if(t.entry=this[Bu](t),!t.entry){t.ignore=!0;return}t===this[gn]&&!t.piped&&this[Ks](t)}}}[ic](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}}[Bu](t){this[bt]+=1;try{return new this[Ws](t.path,this[ic](t)).on("end",()=>this[rc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[sc](){this[gn]&&this[gn].entry&&this[gn].entry.resume()}[Ks](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Hs](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={}){to(this,t,e,r)}},zc=class extends ro{sync=!0;constructor(t){super(t),this[Ws]=jw}pause(){}resume(){}[Ec](t){let e=this.follow?"statSync":"lstatSync";this[Gs](t,Js[e](t.absolute))}[vc](t){this[js](t,Js.readdirSync(t.absolute))}[Ks](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Hs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[uf](i)})}},Yw=(t,e)=>{let r=new zc(t),i=new Yu(t.file,{mode:t.mode||438});r.pipe(i),ff(r,e)},Xw=(t,e)=>{let r=new ro(t),i=new Qs(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,d)=>{i.on("error",d),i.on("close",c),r.on("error",d)});return hf(r,e).catch(c=>r.emit("error",c)),o},ff=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?kr({file:Xu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},hf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await kr({file:Xu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},Qw=(t,e)=>{let r=new zc(t);return ff(r,e),r},e_=(t,e)=>{let r=new ro(t);return hf(r,e).catch(i=>r.emit("error",i)),r},TA=Oi(Yw,Xw,Qw,e_,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),n_=process.env.__FAKE_PLATFORM__||process.platform,mf=n_==="win32",{O_CREAT:wf,O_NOFOLLOW:Fu,O_TRUNC:_f,O_WRONLY:yf}=gf.constants,bf=Number(process.env.__FAKE_FS_O_FILENAME__)||gf.constants.UV_FS_O_FILEMAP||0,r_=mf&&!!bf,i_=512*1024,s_=bf|_f|wf|yf,zu=!mf&&typeof Fu=="number"?Fu|_f|wf|yf:null,Ef=zu!==null?()=>zu:r_?t=>t<i_?s_:"w":()=>"w",Sc=(t,e,r)=>{try{return io.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Ys=(t,e,r,i)=>{io.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},o_=(t,e,r,i,o)=>{if(e.isDirectory())vf(Ai.resolve(t,e.name),r,i,c=>{if(c)return o(c);let d=Ai.resolve(t,e.name);Ys(d,r,i,o)});else{let c=Ai.resolve(t,e.name);Ys(c,r,i,o)}},vf=(t,e,r,i)=>{io.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 Ys(t,e,r,i);let d=c.length,u=null,f=x=>{if(!u){if(x)return i(u=x);if(--d===0)return Ys(t,e,r,i)}};for(let x of c)o_(t,x,e,r,f)})},a_=(t,e,r,i)=>{e.isDirectory()&&Sf(Ai.resolve(t,e.name),r,i),Sc(Ai.resolve(t,e.name),r,i)},Sf=(t,e,r)=>{let i;try{i=io.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Sc(t,e,r);throw c}for(let o of i)a_(t,o,e,r);return Sc(t,e,r)},If=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"}},so=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"}},d_=(t,e)=>{ct.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new If(t,r?.code||"ENOTDIR")),e(r)})},l_=(t,e,r)=>{t=X(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,d=e.uid,u=e.gid,f=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),x=e.preserve,g=e.unlink,m=X(e.cwd),v=(S,I)=>{S?r(S):I&&f?vf(I,d,u,A=>v(A)):c?ct.chmod(t,o,r):r()};if(t===m)return d_(t,v);if(x)return c_.mkdir(t,{mode:o,recursive:!0}).then(S=>v(null,S??void 0),v);let _=X(Xs.relative(m,t)).split("/");Ic(m,_,o,g,m,void 0,v)},Ic=(t,e,r,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),f=X(Xs.resolve(t+"/"+u));ct.mkdir(f,r,Af(f,e,r,i,o,c,d))},Af=(t,e,r,i,o,c,d)=>u=>{u?ct.lstat(t,(f,x)=>{if(f)f.path=f.path&&X(f.path),d(f);else if(x.isDirectory())Ic(t,e,r,i,o,c,d);else if(i)ct.unlink(t,g=>{if(g)return d(g);ct.mkdir(t,r,Af(t,e,r,i,o,c,d))});else{if(x.isSymbolicLink())return d(new so(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,Ic(t,e,r,i,o,c,d))},u_=t=>{let e=!1,r;try{e=ct.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new If(t,r??"ENOTDIR")}},f_=(t,e)=>{t=X(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),f=e.preserve,x=e.unlink,g=X(e.cwd),m=S=>{S&&u&&Sf(S,c,d),o&&ct.chmodSync(t,i)};if(t===g)return u_(g),m();if(f)return m(ct.mkdirSync(t,{mode:i,recursive:!0})??void 0);let v=X(Xs.relative(g,t)).split("/"),_;for(let S=v.shift(),I=g;S&&(I+="/"+S);S=v.shift()){I=X(Xs.resolve(I));try{ct.mkdirSync(I,i),_=_||I}catch{let A=ct.lstatSync(I);if(A.isDirectory())continue;if(x){ct.unlinkSync(I),ct.mkdirSync(I,i),_=_||I;continue}else if(A.isSymbolicLink())return new so(I,I+"/"+v.join("/"))}}return m(_)},oc=Object.create(null),Uu=1e4,_r=new Set,h_=t=>{_r.has(t)?_r.delete(t):oc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),_r.add(t);let e=oc[t],r=_r.size-Uu;if(r>Uu/10){for(let i of _r)if(_r.delete(i),delete oc[i],--r<=0)break}return e},x_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,p_=x_==="win32",g_=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Tf(i,r)),e.push(r||"/"),e},[]),m_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=p_?["win32 parallelization disabled"]:t.map(i=>Ii(Tf(h_(i))));let r=new Set(t.map(i=>g_(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")o.add(u);else for(let f of u)o.add(f)}for(let c of i){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let f=d[0];typeof f=="function"&&o.add(f)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},w_=()=>process.umask(),qu=Symbol("onEntry"),Ac=Symbol("checkFs"),Gu=Symbol("checkFs2"),Tc=Symbol("isReusable"),ft=Symbol("makeFs"),kc=Symbol("file"),Cc=Symbol("directory"),$s=Symbol("link"),Hu=Symbol("symlink"),ju=Symbol("hardlink"),vi=Symbol("ensureNoSymlink"),Ku=Symbol("unsupported"),Wu=Symbol("checkPath"),ac=Symbol("stripAbsolutePath"),bn=Symbol("mkdir"),je=Symbol("onError"),Ms=Symbol("pending"),$u=Symbol("pend"),yr=Symbol("unpend"),cc=Symbol("ended"),dc=Symbol("maybeClose"),Rc=Symbol("skip"),Ti=Symbol("doChown"),ki=Symbol("uid"),Ci=Symbol("gid"),Ri=Symbol("checkedCwd"),__=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Di=__==="win32",y_=1024,b_=(t,e)=>{if(!Di)return re.unlink(t,e);let r=t+".DELETE."+pf(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},E_=t=>{if(!Di)return re.unlinkSync(t);let e=t+".DELETE."+pf(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},Vu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Uc=class extends Pi{[cc]=!1;[Ri]=!1;[Ms]=0;reservations=new m_;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[cc]=!0,this[dc]()},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:y_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Di,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=X(Fe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:w_():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[qu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[dc](){this[cc]&&this[Ms]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ac](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Mc(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||Di&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Fe.posix.dirname(t.path),f=Fe.posix.normalize(Fe.posix.join(u,d.join("/")));if(f.startsWith("../")||f==="..")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}[Wu](t){let e=X(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=X(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[ac](t,"path")||!this[ac](t,"linkpath"))return!1;if(t.absolute=Fe.isAbsolute(t.path)?X(Fe.resolve(t.path)):X(Fe.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:X(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}=Fe.win32.parse(String(t.absolute));t.absolute=i+ku(String(t.absolute).slice(i.length));let{root:o}=Fe.win32.parse(t.path);t.path=o+ku(t.path.slice(o.length))}return!0}[qu](t){if(!this[Wu](t))return t.resume();switch(t_.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[Ac](t);default:return this[Ku](t)}}[je](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[yr](),e.resume())}[bn](t,e,r){l_(X(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)}[Ti](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}[ki](t){return Vu(this.uid,t.uid,this.processUid)}[Ci](t){return Vu(this.gid,t.gid,this.processGid)}[kc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Qs(String(t.absolute),{flags:Ef(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[je](u,t),e()});let o=1,c=u=>{if(u){i.fd&&re.close(i.fd,()=>{}),this[je](u,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,f=>{f?this[je](f,t):this[yr](),e()})};i.on("finish",()=>{let u=String(t.absolute),f=i.fd;if(typeof f=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,g=t.mtime;re.futimes(f,x,g,m=>m?re.utimes(u,x,g,v=>c(v&&m)):c())}if(typeof f=="number"&&this[Ti](t)){o++;let x=this[ki](t),g=this[Ci](t);typeof x=="number"&&typeof g=="number"&&re.fchown(f,x,g,m=>m?re.chown(u,x,g,v=>c(v&&m)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[je](u,t),e()}),t.pipe(d)),d.pipe(i)}[Cc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[bn](String(t.absolute),r,i=>{if(i){this[je](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[yr](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Ti](t)&&(o++,re.chown(String(t.absolute),Number(this[ki](t)),Number(this[Ci](t)),c)),c()})}[Ku](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Hu](t,e){let r=X(Fe.relative(this.cwd,Fe.resolve(Fe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[vi](t,this.cwd,r,()=>this[$s](t,String(t.linkpath),"symlink",e),i=>{this[je](i,t),e()})}[ju](t,e){let r=X(Fe.resolve(this.cwd,String(t.linkpath))),i=X(String(t.linkpath)).split("/");this[vi](t,this.cwd,i,()=>this[$s](t,r,"link",e),o=>{this[je](o,t),e()})}[vi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let d=Fe.resolve(e,c);re.lstat(d,(u,f)=>{if(u)return i();if(f?.isSymbolicLink())return o(new so(d,Fe.resolve(d,r.join("/"))));this[vi](t,d,r,i,o)})}[$u](){this[Ms]++}[yr](){this[Ms]--,this[dc]()}[Rc](t){this[yr](),t.resume()}[Tc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Di}[Ac](t){this[$u]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Gu](t,r))}[Gu](t,e){let r=d=>{e(d)},i=()=>{this[bn](this.cwd,this.dmode,d=>{if(d){this[je](d,t),r();return}this[Ri]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=X(Fe.dirname(String(t.absolute)));if(d!==this.cwd)return this[bn](d,this.dmode,u=>{if(u){this[je](u,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Rc](t),r();return}if(d||this[Tc](t,u))return this[ft](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let f=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=g=>this[ft](g??null,t,r);return f?re.chmod(String(t.absolute),Number(t.mode),x):x()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),f=>this[ft](f??null,t,r))}if(t.absolute===this.cwd)return this[ft](null,t,r);b_(String(t.absolute),f=>this[ft](f??null,t,r))})};this[Ri]?o():i()}[ft](t,e,r){if(t){this[je](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[kc](e,r);case"Link":return this[ju](e,r);case"SymbolicLink":return this[Hu](e,r);case"Directory":case"GNUDumpDir":return this[Cc](e,r)}}[$s](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[je](o,t):(this[yr](),t.resume()),i()})}},bi=t=>{try{return[null,t()]}catch(e){return[e,null]}},kf=class extends Uc{sync=!0;[ft](t,e){return super[ft](t,e,()=>{})}[Ac](t){if(!this[Ri]){let o=this[bn](this.cwd,this.dmode);if(o)return this[je](o,t);this[Ri]=!0}if(t.absolute!==this.cwd){let o=X(Fe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[bn](o,this.dmode);if(c)return this[je](c,t)}}let[e,r]=bi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Rc](t);if(e||this[Tc](t,r))return this[ft](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?bi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ft](d,t)}let[o]=bi(()=>re.rmdirSync(String(t.absolute)));this[ft](o,t)}let[i]=t.absolute===this.cwd?[]:bi(()=>E_(String(t.absolute)));this[ft](i,t)}[kc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{re.closeSync(o)}catch(f){u=f}(d||u)&&this[je](d||u,t),e()},o;try{o=re.openSync(String(t.absolute),Ef(t.size),r)}catch(d){return i(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[je](d,t)),t.pipe(c)),c.on("data",d=>{try{re.writeSync(o,d,0,d.length)}catch(u){i(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,f=t.mtime;try{re.futimesSync(o,u,f)}catch(x){try{re.utimesSync(String(t.absolute),u,f)}catch{d=x}}}if(this[Ti](t)){let u=this[ki](t),f=this[Ci](t);try{re.fchownSync(o,Number(u),Number(f))}catch(x){try{re.chownSync(String(t.absolute),Number(u),Number(f))}catch{d=d||x}}}i(d)})}[Cc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[bn](String(t.absolute),r);if(i){this[je](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Ti](t))try{re.chownSync(String(t.absolute),Number(this[ki](t)),Number(this[Ci](t)))}catch{}e(),t.resume()}[bn](t,e){try{return f_(X(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}}[vi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let d of r){c=Fe.resolve(c,d);let[u,f]=bi(()=>re.lstatSync(c));if(u)return i();if(f.isSymbolicLink())return o(new so(c,Fe.resolve(e,r.join("/"))))}i()}[$s](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[je](c,t)}}},v_=t=>{let e=new kf(t),r=t.file,i=xf.statSync(r),o=t.maxReadSize||16*1024*1024;new Gm(r,{readSize:o,size:i.size}).pipe(e)},S_=(t,e)=>{let r=new Uc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),xf.stat(o,(u,f)=>{if(u)d(u);else{let x=new Pc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(r)}})})},Cf=Oi(v_,S_,t=>new kf(t),t=>new Uc(t),(t,e)=>{e?.length&&af(t,e)}),I_=(t,e)=>{let r=new zc(t),i=!0,o,c;try{try{o=at.openSync(t.file,"r+")}catch(f){if(f?.code==="ENOENT")o=at.openSync(t.file,"w+");else throw f}let d=at.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let g=0,m=0;g<512;g+=m){if(m=at.readSync(o,u,g,u.length-g,c+g),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!m)break e}let f=new Wn(u);if(!f.cksumValid)break;let x=512*Math.ceil((f.size||0)/512);if(c+x+512>d.size)break;c+=x,t.mtimeCache&&f.mtime&&t.mtimeCache.set(String(f.path),f.mtime)}i=!1,A_(t,r,c,o,e)}finally{if(i)try{at.closeSync(o)}catch{}}},A_=(t,e,r,i,o)=>{let c=new Yu(t.file,{fd:i,start:r});e.pipe(c),k_(e,o)},T_=(t,e)=>{e=Array.from(e);let r=new ro(t),i=(o,c,d)=>{let u=(v,_)=>{v?at.close(o,S=>d(v)):d(null,_)},f=0;if(c===0)return u(null,0);let x=0,g=Buffer.alloc(512),m=(v,_)=>{if(v||_===void 0)return u(v);if(x+=_,x<512&&_)return at.read(o,g,x,g.length-x,f+x,m);if(f===0&&g[0]===31&&g[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,f);let S=new Wn(g);if(!S.cksumValid)return u(null,f);let I=512*Math.ceil((S.size??0)/512);if(f+I+512>c||(f+=I+512,f>=c))return u(null,f);t.mtimeCache&&S.mtime&&t.mtimeCache.set(String(S.path),S.mtime),x=0,at.read(o,g,0,512,f,m)};at.read(o,g,0,512,f,m)};return new Promise((o,c)=>{r.on("error",c);let d="r+",u=(f,x)=>{if(f&&f.code==="ENOENT"&&d==="r+")return d="w+",at.open(t.file,d,u);if(f||!x)return c(f);at.fstat(x,(g,m)=>{if(g)return at.close(x,()=>c(g));i(x,m.size,(v,_)=>{if(v)return c(v);let S=new Qs(t.file,{fd:x,start:_});r.pipe(S),S.on("error",c),S.on("close",o),C_(r,e)})})};at.open(t.file,d,u)})},k_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?kr({file:Rf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},C_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await kr({file:Rf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},Ei=Oi(I_,T_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Zm(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")}),GA=Oi(Ei.syncFile,Ei.asyncFile,Ei.syncNoFile,Ei.asyncNoFile,(t,e=[])=>{Ei.validate?.(t,e),R_(t)}),R_=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};ln();var ht={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete",PUBLISH_SKILL:"_agent/publishSkill"};function oo(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Df(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function ao(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Pf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Of(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Vn(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Jt();$e();te();Me();$e();function Cr(t,e){if(oo(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Li(t){return t.startsWith("http://")||t.startsWith("https://")}function Rr(t){return t.endsWith("/")?t.slice(0,-1):t}import{readFileSync as O2}from"node:fs";import{dirname as N2,join as M2}from"node:path";import{fileURLToPath as F2}from"node:url";var Nt="0.1.104-alpha.22";$e();te();var co="1008033",Bf="1289";var Ff="pbbp2",zf="https://www.coze.cn",Uf="/api/coze_claw/resource/get_frontier_key",F_="https://www.coze.cn",z_="wss://frontier.coze.cn";function Dr(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??F_}function qf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??z_}function Sn(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 Mi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ni=H("handshake");async function qc(t){let e=Dr(t.endpoint),r=t.timeoutMs??1e4,i=`${Rr(e)}${Uf}?aid=${encodeURIComponent(co)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Sn(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),r);Ni.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),f=u.headers.get("x-tt-logid")??"",x=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let S=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${f}: ${S.slice(0,200)}`)}let g=await u.json();if(g.code!==void 0&&g.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${g.code} msg=${g.msg??"-"} logid=${f}`);let m=g.data??{},v=typeof m.access_key=="string"&&m.access_key||typeof m.accessKey=="string"&&m.accessKey||void 0,_=typeof m.device_id=="string"&&m.device_id||typeof m.deviceId=="string"&&m.deviceId||void 0;if(!v||!_){let S=JSON.stringify(g).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${f}: ${S}`)}return Ni.info("handshake ok",{remoteDeviceId:_,logid:f,traceId:x}),{accessKey:v,deviceId:_}}catch(u){if(u instanceof T)throw Ni.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ni.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let f=u.cause;throw Ni.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:f?.code,syscall:f?.syscall,cause:String(u).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var Gc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",St="auto",Gf=15e4;function Hf(t){return{model:Hc(t.model)??St,...t.modelToken?{modelToken:t.modelToken}:{}}}function U_(t){return!t||t===St}var q_=new Set(["auto","\u81EA\u52A8"]);function Hc(t){let e=t?.trim();if(e)return q_.has(e.toLowerCase())?St:e}function jf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Gc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||St;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else U_(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Kf(t,e,r){return t.modelToken?{baseUrl:`${Gc}/v1`,providerName:"coze",headers:{Authorization:`Bearer ${t.modelToken}`,...jc(e,r)}}:null}function Wf(t){if(!t.modelToken)return{};let e={model:t.model||St,model_context_window:t.modelInfo?.contextWindow??Gf};return{CODEX_CONFIG:JSON.stringify(e)}}function jc(t,e){let{ttEnv:r,usePpe:i}=Mi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function $f(t,e,r){if(!t.modelToken)return{};let i=jc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,d])=>`${c}:${d}`).join(`
|
|
92
|
+
`)}}function Kc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Vf(t,e,r){if(!t.modelToken)return null;let i=t.model||St,o=jc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${Gc}/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??Gf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}var fe=H("agent-handlers"),Zf=5*1024*1024,K_=1,W_=6,$_=new Set(["node_modules",".git",".coze","dist","build",".next"]),V_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,J_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,Z_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Y_(t){let e=t?.trim();return e?Z_.test(e)||J_.test(e)?e:(fe.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function X_(t){return new Promise((e,r)=>{let i=st("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=d=>{o||(o=!0,d?r(d):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",d=>c(d))})}var uo=class{constructor(e){this.opts=e}opts;async listSkills(e){e._meta;let r=Vn(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ye(r).workspace,c=i?.skills??[],d=[],u=new Set;for(let f of c){let x=Je(o,f.relPath,"SKILL.md");await Jf(x).then(m=>m.isFile()).catch(()=>!1)&&(d.push(ny(f)),u.add(f.relPath))}if(e.scanLocal){let f=i?.framework??"claude-code",x=await Q_(r,o,f);for(let g of x)u.has(g.relPath)||(u.add(g.relPath),d.push(g.skill))}return{skills:d}}async addSkills(e){e._meta;let r=Vn(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],d=new Map(c.map((f,x)=>[f.skillId,x])),u=[];for(let f of o){let x=await fo({agentId:r,workspace:i.workspace,framework:i.framework,skill:f});ho(c,d,x),u.push(f)}return await ai(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){e._meta;let r=Vn(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],d=[];for(let u of c){if(!o.has(u.skillId)){d.push(u);continue}let f=Je(i.workspace,u.relPath);await Vc(f,{recursive:!0,force:!0}),fe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ai(r,d),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}async publishSkill(e){e._meta;let r=Vn(e._meta);if(!e.skillName)throw new T("IPC_BAD_REQUEST","_agent/publishSkill: missing skillName");fe.info("_agent/publishSkill start",{agentId:r,skillId:e.skillId??"",skillName:e.skillName,userId:e.userId??"",accountId:e.accountId??""});let i=await this.loadAgentCfg(r),o=i?.workspace??Ye(r).workspace,c=i?.framework??"claude-code",d=n0(e.skillName),u=Je(ed(c),d),f=Je(o,u),x=Je(f,"SKILL.md");if(!await Jf(x).then(k=>k.isFile()).catch(()=>!1))throw new T("SKILL_NOT_FOUND",`skill not found locally: ${e.skillName} (${u})`);let m=new Qc.default;m.addLocalFolder(f,d);let v=m.toBuffer();if(v.length>Yf)throw new T("SKILL_ZIP_TOO_LARGE",`skill zip ${v.length} bytes exceeds limit ${Yf}`);let _=await lo(x,{encoding:"utf8"}).then(k=>i0(k).description).catch(()=>{}),S={};this.opts.publishSkillToMarketplace?S=await this.opts.publishSkillToMarketplace({zip:v,...e.skillId?{skillId:e.skillId}:{},skillName:e.skillName,..._?{description:_}:{},agentId:r,...e.userId?{userId:e.userId}:{},...e.accountId?{accountId:e.accountId}:{}}):fe.warn("_agent/publishSkill: publishSkillToMarketplace not injected, skip upload",{agentId:r,skillName:e.skillName});let I=S.version??"v1.0",A=S.skillId??e.skillId??r0(r,u);if(i){let k=i.skills??[],P=k.find(E=>E.relPath===u);P?(P.version=I,P.skillId=A):k.push({skillId:A,skillName:e.skillName,relPath:u,version:I,installedAt:Date.now(),..._?{description:_}:{}}),await ai(r,k)}return fe.info("skill published",{agentId:r,skillName:e.skillName,relPath:u,zipBytes:v.length,skillId:A,version:I}),{ok:!0,skillId:A,version:I}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let d=c.acpSessionId;if(d&&i.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,fe.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d});continue}let f=c.downstream;c.downstream=void 0,fe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d}),f.stop(r).catch(x=>fe.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 fe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await De(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return fe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await fr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw fe.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 Ue(i),fe.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await De(r))throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Li(e.registry)&&o.push(`--registry=${e.registry}`);let c=Y_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let d=e._meta?.cozeEnv;d&&V_.test(d)&&o.push("--env",d);let u=await X_(o);return fe.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await De(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ue(i),fe.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}):(fe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async deleteAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST",`${ht.DELETE}: missing agentId`);let i=await De(r),o=e._meta?.cozeDeployType==="cloud"||e._meta?.cozeDeployType==="local"?e._meta.cozeDeployType:void 0,c=e.deployType??o??i?.deployType??"local";this.opts.disposeForDelete&&await this.opts.disposeForDelete(r,e.reason??"delete");let d=Ye(r);return c==="cloud"?await Vc(d.root,{recursive:!0,force:!0}):i&&(i.deletedAt=Date.now(),i.deleteReason=e.reason??"deleted",await Ue(i)),fe.info("agent deleted",{agentId:r,reason:e.reason??"",deployType:c,configFound:!!i}),{ok:!0}}async switchModel(e){if(Cr(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Hc(e.model)??St,i=await De(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 Ue(i),fe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return fe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(d=>fe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let f=o.sessions.get(d);f?.downstream&&(await f.downstream.stop(`switchModel: ${r}`).catch(()=>{}),f.downstream=void 0)}));return await Promise.all(c),fe.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(Cr(e._meta,ht.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${ht.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,ht.RESET),await this.runDetailSync(e.agentId,ht.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),fe.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,d]of i.sessions)o.set(c,{modelToken:d.modelToken,tokenGeneratedAt:d.tokenGeneratedAt});await oi(e,o)}async clearPersistedAcpSessionIds(e){let r=await De(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 Ue(r)}async repairAgent(e){if(Cr(e._meta,ht.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${ht.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${ht.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){fe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,ht.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){fe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){fe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Cr(e._meta,"_agent/getFileTree");let r=e._meta,i=Vn(r),o=await this.resolveWorkspace(i),c=e.filePath??"",d=this.safeJoin(o,c),u=await Wc(d).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 si(d,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let f=xy(e.depth);return u.isDirectory()?{tree:await hy(o,d,c,f)}:{tree:[{name:py(c),path:a0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Cr(e._meta,"_agent/getFileContent");let r=Vn(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 Wc(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 si(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Zf)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Zf})`);let d=await lo(o);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await De(e).catch(()=>null))?.workspace??Ye(e).workspace}safeJoin(e,r){let i=Zc(e,r||"."),o=Xc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Qf}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return De(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 n0(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 ed(t){return t==="claude-code"?Je(".claude","skills"):Je(".agents","skills")}function r0(t,e){return(G_("sha256").update(`${t}\0${e}`).digest().readBigUInt64BE(0)&0x7fffffffffffffffn).toString()}function i0(t){if(!t.startsWith("---"))return{};let e=t.indexOf(`
|
|
93
|
+
---`,3);if(e<0)return{};let r=t.slice(3,e),i={};for(let o of r.split(`
|
|
94
|
+
`)){let c=/^\s*(name|description)\s*:\s*(.+?)\s*$/.exec(o);if(!c||!c[2])continue;let d=c[1],u=c[2].trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),u&&(i[d]=u)}return i}async function Q_(t,e,r){let i=ed(r),o=Je(e,i),c=await Xf(o,{withFileTypes:!0}).catch(()=>null);if(!c)return[];let d=[];for(let u of c){if(!u.isDirectory())continue;let f=u.name,x=Je(i,f),g=Je(o,f,"SKILL.md"),m=await lo(g,{encoding:"utf8"}).catch(()=>null);if(m===null)continue;let v=i0(m);d.push({relPath:x,skill:{skillId:r0(t,x),skillName:v.name||f,...v.description?{description:v.description}:{}}})}return d}var ey=3e4,ty=50*1024*1024,Yf=10*1024*1024,Pr=3e4;async function fo(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,d=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!d)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=n0(o.skillName),f=ed(i),x=Je(f,u),g=Je(r,x);if(await $c(g,{recursive:!0}),c){let v=Buffer.from(o.content,"utf8");Bi(v.length),await Jc(Je(g,"SKILL.md"),v,"utf8")}else{let v=await iy(o.downloadUrl);oy(v)?await ly(v,g):ay(v)?await cy(v,g):await Jc(Je(g,"SKILL.md"),v.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 fe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:x,source:c?"content":"downloadUrl"}),m}function ho(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 ny(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}:{}}}function ry(t){return{skillId:t.skillId,skillName:t.skillName,...t.downloadUrl?{downloadUrl:t.downloadUrl}:{},...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 s0(t,e){let r=await De(t,e);if(!r)return{status:"skipped",count:0};if(r.disconnectedAt)return{status:"skipped",count:0};let i=Nt,o=r.skillsRefreshedForVersion;if(o===i)return{status:"noop",count:0};if(!o)return r.skillsRefreshedForVersion=i,await Ue(r,e),{status:"seeded",count:0};let c=[...r.skills??[]],d=new Map(c.map((g,m)=>[g.skillId,m])),u=c.filter(g=>g.builtin===!0&&!!g.downloadUrl);if(u.length===0)return r.skillsRefreshedForVersion=i,await Ue(r,e),{status:"noop",count:0};let f=0,x=0;for(let g of u)try{await Vc(Je(r.workspace,g.relPath),{recursive:!0,force:!0});let m=await fo({agentId:t,workspace:r.workspace,framework:r.framework,skill:ry(g)});ho(c,d,m),f+=1}catch(m){x+=1,fe.warn("refresh builtin skill failed (skipping)",{agentId:t,skillId:g.skillId,skillName:g.skillName,err:String(m)})}return r.skills=c,x===0&&(r.skillsRefreshedForVersion=i),await Ue(r,e),fe.info("builtin skills refreshed after bridge upgrade",{agentId:t,from:o,to:i,ok:f,failed:x}),{status:"refreshed",count:f}}async function iy(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Bi(e);let r=sy(t);return Bi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await lo(e);return Bi(r.length),r}if(Li(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),ey);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 Bi(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 Bi(t){if(t>ty)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function sy(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 oy(t){return t.length>=2&&t[0]===31&&t[1]===139}function ay(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 Yc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function cy(t,e){let r,i;try{r=new Qc.default(t),i=r.getEntries()}catch(d){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of i){let u=d.entryName;if(!u||Yc(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 f=d.header.attr>>>16&61440;if(f!==0&&f!==32768&&f!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${f.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=dy(i),c=Zc(e);for(let d of i){if(Yc(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let f=Zc(e,u),x=Xc(c,f);if(x.startsWith("..")||x==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await $c(f,{recursive:!0});continue}await $c(H_(f),{recursive:!0});let g;try{g=d.getData()}catch(m){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${m.message}`,{cause:m})}await Jc(f,g)}}function dy(t){let e;for(let r of t){let i=r.entryName;if(!i||Yc(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 ly(t,e){await uy(t);let r=Cf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`))},Pr);try{await t0(e0.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function uy(t){let e=[],r=kr({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Pr}ms)`))},Pr);try{await t0(e0.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Pr}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 fy=5e3;async function hy(t,e,r,i){return o0(t,e,r,i,{count:0})}async function o0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Xf(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if($_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=fy){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let f=Je(e,u.name),x=j_(Je(r,u.name)),g=null;try{g=await Wc(f)}catch{continue}if(g.isSymbolicLink())continue;o.count++;let m={name:u.name,path:a0(Xc(t,f)),isDir:g.isDirectory(),size:g.size,modifiedAt:Math.floor(g.mtimeMs)};g.isDirectory()&&i>1&&(m.children=await o0(t,f,x,i-1,o)),d.push(m)}return d.sort((u,f)=>u.isDir!==f.isDir?u.isDir?-1:1:u.name.localeCompare(f.name)),d}function xy(t){return!t||t<=0?K_:Math.min(t,W_)}function py(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function a0(t){return t.split(Qf).join("/")}te();var In=H("agent-health-reporter"),gy=1e4,my=3,Fi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??gy,this.livenessFailureThreshold=e.livenessFailureThreshold??my}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;livenessFailureThreshold;consecutiveFailures=0;isLivenessLost(){return this.consecutiveFailures>=this.livenessFailureThreshold}start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),In.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),In.info("heartbeat stopped"))}async tick(){if(this.inFlight){In.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){this.consecutiveFailures=0,In.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let d of this.opts.core.agents.values()){let u=wy(d);if(!u)continue;let f={agentId:d.agentId,status:u};d.patToken&&(f.patToken=d.patToken),d.accountId&&(f.accountId=d.accountId),r.push(f)}if(r.length===0){this.consecutiveFailures=0;return}let i={agents:r,bridgeVersion:Nt,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3),this.consecutiveFailures=0}catch(d){this.consecutiveFailures+=1,In.warn("heartbeat batch send failed",{count:r.length,consecutiveFailures:this.consecutiveFailures,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(In.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){In.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){In.warn("onTickEnd hook failed",{err:String(r)})}}};function wy(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}ln();import{mkdir as od,rm as fb,stat as hb}from"node:fs/promises";import{homedir as xb}from"node:os";import{join as cd}from"node:path";an();import{existsSync as Dy}from"node:fs";import{release as Py}from"node:os";import{basename as Oy,isAbsolute as Ly}from"node:path";function zi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Or(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Lr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function An(t,e){return{jsonrpc:"2.0",id:t,error:e}}$e();var xo=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)}},Z={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,SKILL_NOT_FOUND:-32022,SKILL_ZIP_TOO_LARGE:-32023,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32024};function c0(t){return"method"in t&&"id"in t&&t.id!==void 0}function d0(t){return"method"in t&&!("id"in t)}function po(t){return!("method"in t)&&"id"in t}var _y={AGENT_NOT_FOUND:Z.AGENT_NOT_FOUND,AGENT_BUSY:Z.AGENT_BUSY,AGENT_DISCONNECTED:Z.AGENT_DISCONNECTED,AGENT_TIMEOUT:Z.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Z.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Z.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Z.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Z.INTERNAL_ERROR,BRIDGE_INTERNAL:Z.INTERNAL_ERROR,IPC_AUTH_FAILED:Z.INTERNAL_ERROR,IPC_BAD_REQUEST:Z.INVALID_REQUEST,METHOD_NOT_FOUND:Z.METHOD_NOT_FOUND,MODEL_TOKEN_GEN_FAILED:Z.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Z.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Z.OPERATION_NOT_ALLOWED_FOR_LOCAL,OPERATION_NOT_ALLOWED_FOR_CLOUD:Z.OPERATION_NOT_ALLOWED_FOR_CLOUD,UPSTREAM_DISCONNECTED:Z.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Z.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Z.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Z.FILE_TOO_LARGE,UNSUPPORTED_MIME:Z.UNSUPPORTED_MIME,UPLOAD_FAILED:Z.UPLOAD_FAILED,UPSTREAM_NOT_READY:Z.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Z.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Z.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Z.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Z.AGENT_ENV_NOT_READY,SKILL_NOT_FOUND:Z.SKILL_NOT_FOUND,SKILL_ZIP_TOO_LARGE:Z.SKILL_ZIP_TOO_LARGE};function yy(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ui(t.message)}:typeof t=="string"?Ui(t):typeof t=="object"?Ey(t):t}var by=[[/\/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 Ui(t){let e=t;for(let[r,i]of by)e=e.replace(r,i);return e}function Ey(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ui(i):e[r]=i;return e}function qi(t){if(t instanceof T){let e=yy(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:_y[t.code]??Z.INTERNAL_ERROR,message:Ui(t.message),data:r}}return{code:Z.INTERNAL_ERROR,message:Ui(t instanceof Error?t.message:String(t))}}function l0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:d,...u}=e;c=u}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function f0(t){return`${JSON.stringify(t)}
|
|
95
|
+
`}var u0=10*1024*1024,go=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>u0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${u0} bytes`)}),[]}let r=this.buffer.split(`
|
|
96
|
+
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(d){this.onError?.({line:c,error:d})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var x0={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission","session/set_mode":"session.setMode",initialize:"initialize"},ET=Object.fromEntries(Object.entries(x0).map(([t,e])=>[e,t])),vy={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"session.setMode":["agentId","sessionId"],"agent.pair":[],initialize:[]},Nr=class{seq=0;next(e,r){this.seq+=1;let i=x0[e]??Sy(e),o=vy[i]??[],c=[i,String(this.seq)];if(o.length>0){let d=o.map(f=>h0(r?.[f]??"")),u=Iy(d).join(":");u&&c.push(u)}else r&&Object.values(r).some(d=>d)&&c.push(Object.values(r).filter(Boolean).map(d=>h0(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function Sy(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function h0(t){return t.replace(/[:_\s]+/g,"-")}function Iy(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}dn();import{readFileSync as Ay}from"node:fs";var Ty=384;async function td(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await ur(t.agentEnvFile,r,{mode:Ty})}function nd(t){try{let e=JSON.parse(Ay(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function p0(t,e,r={},i=o=>o){return{...i({...t,...nd(e)}),...r}}Jt();or();$e();te();Me();import{execFileSync as ky,spawnSync as Cy}from"node:child_process";function Gi(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Hi(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Cy("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var rd=new Set;function g0(t){typeof t=="number"&&t>0&&rd.add(t)}function m0(t){typeof t=="number"&&rd.delete(t)}function w0(){for(let t of rd)Hi(t,"SIGKILL")}var Mr="coze-bridge-daemon";function _0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return ky("pgrep",["-U",String(o),"-f",Mr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
|
|
97
|
+
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function y0(t,e){if(t.length===0)return;let r=e?.killFn??Hi,i=e?.isAliveFn??Gi,o=e?.sleepFn??(u=>new Promise(f=>setTimeout(f,u))),c=e?.graceMs??3e3,d=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(f=>i(f));u+=d)await o(Math.min(d,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var Ry=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @(zed-industries|agentclientprotocol)\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find module[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|zed-industries[\\/]codex-acp)/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function b0(t,e){if(!e)return null;for(let r of Ry)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function E0(t,e){return b0(t,e)}function v0(t,e){return b0(t,e)}function Br(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function S0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,g=r-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Br(g,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,d=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=d?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Br(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Br(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Br(c,!1,e)}}var I0=Ze("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ny=200,My=40,By=Ze("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Fy=Ze("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),zy=Ze("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),Uy=Ze("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),qy=Ze("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),Gy=Ze("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),A0=500;function Hy(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=A0?t:`${e.slice(0,A0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function jy(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function T0(t){try{return Dy(t)}catch{return}}function Ky(t,e){return{platform:process.platform,osRelease:Py(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:Ly(e.command)?T0(e.command):void 0,cwd:e.cwd,cwdExists:T0(e.cwd),envKeys:e.envKeys}}function Wy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${Oy(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Mt=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new go({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Nr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;spawnEnv={};sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=p0(process.env,this.opts.agentEnvFile??Q().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o));this.spawnEnv=r;let i=st(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,g0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Ny&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,m0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,d=Ky(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:d}),this.failAllPending(new T("AGENT_SPAWN_FAILED",Wy(c,d),{cause:d}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Hi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Hi(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:qy,phase2GateMs:By,livenessWindowMs:Fy,absoluteMaxMs:zy,approvalMaxMs:Gy,suspendThresholdMs:Uy,...r};return this.call("session/prompt",e,I0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Or("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",e)}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Lr(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(An(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=I0,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=zi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let f=r.sessionId;return typeof f=="string"?f:void 0})();return new Promise((f,x)=>{let g={resolve:f,reject:x,timer:null,method:e,promptTimeout:null};if(o){let m=this.now(),v={cfg:o,startedAt:m,lastActivityAt:m,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:m,expectedIntervalMs:Br(0,!1,o),sessionId:u};g.promptTimeout=v;let _=()=>{let S={startedAt:v.startedAt,lastActivityAt:v.lastActivityAt,firstFrameSeen:v.firstFrameSeen,hasActiveTool:v.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:v.suspendedMs,armedAt:v.armedAt,expectedIntervalMs:v.expectedIntervalMs},I=this.now(),A=S0(S,v.cfg,I),k=P=>{v.armedAt=I,v.expectedIntervalMs=P,g.timer=setTimeout(_,P)};if(A.action==="suspend"){v.suspendedMs+=A.suspendedDeltaMs,v.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:v.suspendedMs,...v.sessionId?{sessionId:v.sessionId}:{}}),k(A.rearmMs);return}if(A.action==="continue"){k(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...v.sessionId?{sessionId:v.sessionId}:{}}),x(A.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${v.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${v.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...v.sessionId?{sessionId:v.sessionId}:{}}),x(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${v.cfg.livenessWindowMs}ms`)))};g.timer=setTimeout(_,v.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(g.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,g);try{this.writeFrame(d)}catch(m){g.timer&&clearTimeout(g.timer),this.pending.delete(c),x(m)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(f0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(po(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Hy(e.result)}),r.resolve(e.result));return}if(d0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(c0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let d=typeof i.status=="string"?i.status:void 0,u=d==="completed"||d==="failed"||d==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(An(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(An(e.id,qi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=l0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=v0(this.framework,jy(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(My).join(`
|
|
98
|
+
`),o=E0(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function $y(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 mo=class extends Mt{framework="claude-code";constructor(e){let{command:r,args:i}=ii("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 $y(e)}};an();import{mkdtempSync as Yy,rmSync as Xy}from"node:fs";import{tmpdir as Qy}from"node:os";import{join as eb}from"node:path";import{readFileSync as C0}from"node:fs";import{homedir as Vy}from"node:os";import{join as k0}from"node:path";function R0(t){let e=t.CODEX_HOME?.trim()||k0(t.HOME?.trim()||Vy(),".codex");return k0(e,"config.toml")}function Jy(t){let e=null;for(let r=0;r<t.length;r++){let i=t[r];if(e)i===e&&(e=null);else if(i==='"'||i==="'")e=i;else if(i==="#")return t.slice(0,r)}return t}function Zy(t){let e=t.trim();if(e.length>=2){let r=e[0];if((r==='"'||r==="'")&&e[e.length-1]===r)return e.slice(1,-1)}return e}function D0(t){let e={},r={},i=e;for(let o of t.split(/\r?\n/)){let c=Jy(o).trim();if(!c)continue;let d=/^\[([^\]]+)\]$/.exec(c);if(d){let x=(d[1]??"").trim(),g=r[x]??{};r[x]=g,i=g;continue}let u=c.indexOf("=");if(u<=0)continue;let f=c.slice(0,u).trim();f&&(i[f]=Zy(c.slice(u+1)))}return{root:e,tables:r}}function P0(t){let e=t.root.model_provider;if(!e||e==="openai")return null;let r=t.tables[`model_providers.${e}`];return r?{providerId:e,baseUrl:r.base_url,envKey:r.env_key,bearerToken:r.experimental_bearer_token}:null}function O0(t){let e;try{e=C0(R0(t),"utf8")}catch{return null}return P0(D0(e))?.providerId??null}function L0(t){let e;try{e=C0(R0(t),"utf8")}catch{return null}let r=P0(D0(e));if(!r?.baseUrl)return null;let i=r.bearerToken||(r.envKey?t[r.envKey]?.trim():void 0);return i?{baseUrl:r.baseUrl,providerName:r.providerId,headers:{Authorization:`Bearer ${i}`}}:null}var wo=class t extends Mt{framework="codex";authRequest;resolveLocalGatewayAuth;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ii("codex",e.command,i),d=e.isolateCodexHome?Yy(eb(Qy(),"coze-bridge-codex-home-")):void 0,u=d?{...e.env??{},CODEX_HOME:d}:e.env,f={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(f),this.authRequest=e.authRequest,this.resolveLocalGatewayAuth=e.resolveLocalGatewayAuth??!1,this.codexHomeDir=d}async initialize(e){let r=await super.initialize(e),i=this.authRequest??this.localGatewayAuthRequest();return i&&await this.call("authenticate",i),r}localGatewayAuthRequest(){if(!this.resolveLocalGatewayAuth)return null;let e=L0(this.spawnEnv);return e?(this.log.info("codex local: \u7528 config.toml custom provider \u8D70 gateway \u8BA4\u8BC1",{providerName:e.providerName,baseUrl:e.baseUrl}),{methodId:"gateway",_meta:{gateway:e}}):null}static MODE_ID_MAP={"read-only":"read-only",auto:"agent","full-access":"agent-full-access"};setSessionMode(e){let r=t.MODE_ID_MAP[e.modeId]??e.modeId;return super.setSessionMode({...e,modeId:r})}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Xy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};$e();var tb=3e4,Fr=class extends Mt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},tb))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var N0=["default","acceptEdits","plan","auto","bypassPermissions"],M0=["read-only","auto","full-access"];function Tn(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return N0.includes(e);case"codex":return M0.includes(e);case"openclaw":return!1}}function id(t){switch(t){case"claude-code":return N0.join("/");case"codex":return M0.join("/");case"openclaw":return""}}dn();$e();te();Me();function sd(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}an();var kn=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 _o=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 kn,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)ji(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 ji(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Zt(t){return t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Jt();te();import{constants as B0}from"node:fs";import{access as nb}from"node:fs/promises";import{delimiter as rb,join as ib}from"node:path";var It=H("framework-detector"),F0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},sb=[".exe",".cmd",".bat",".ps1"],Jn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??st,access:e.access??nb}}async detect(e){let r=F0[e],i=await this.which(r);if(!i)return It.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(F0).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(rb).filter(Boolean),i=this.env.platform==="win32"?["",...sb]:[""];for(let o of r)for(let c of i){let d=ib(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?B0.F_OK:B0.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return It.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return It.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 It.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 It.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(It.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}:(It.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return It.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 It.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||It.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let d=JSON.parse(c[0]);typeof d.gateway?.port=="number"&&(o.port=d.gateway.port),typeof d.service?.runtime?.status=="string"&&(o.runtime=d.service.runtime.status),!i&&typeof d.rpc?.error=="string"&&(o.detail=d.rpc.error)}catch(d){It.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(d)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(ab(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,d,u=f=>{c||(c=!0,d&&clearTimeout(d),i(f))};try{let f=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{f.kill("SIGKILL"),u(null)},15e3),f.stdout?.on("data",x=>{o+=x.toString("utf8")}),f.on("error",()=>u(null)),f.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},ob=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ab(t){return t.replace(ob,"")}import{homedir as cb}from"node:os";import{join as db}from"node:path";dn();Jt();or();$e();te();async function q0(){let t=db(cb(),".openclaw/openclaw.json");return(await lr(t))?.gateway?.auth?.token??""}var z0=H("openclaw.config"),lb=[0,5e3,5e3],ub=Ze("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),U0="models.providers.",yo="agents.defaults.models",bo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new kn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??lb,this.cliTimeoutMs=e.cliTimeoutMs??ub}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(d=>setTimeout(d,c));try{return await r()}catch(d){i=d,z0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(d)})}}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=st(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",d=!1,u=x=>{d||(d=!0,clearTimeout(f),x())};o.stderr?.on("data",x=>{c+=x.toString("utf8")});let f=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);f.unref(),o.on("error",x=>u(()=>i(x))),o.on("close",x=>u(()=>{x===0?r():i(new Error(`exit ${x}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){z0.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",`${U0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${U0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${yo}[${e}]`,()=>this.runCli(["config","set",yo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${yo}[${e}]`,`${yo}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var de=H("agent-manager"),dd="bypassPermissions",j0="full-access",K0="full-access";function pb(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}var gb=(t,e,r,i,o,c,d,u,f,x)=>{switch(t){case"claude-code":{let g={...o?{...jf(o),...$f(o,d,u)}:{},...f??{},IS_SANDBOX:"1"};return new mo({cwd:r,env:g,agentId:i})}case"codex":{let g=j0;x!==void 0&&(Tn("codex",x)?g=x:de.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:x}));let m=o?null:O0(process.env),v={...o?Wf(o):{},INITIAL_AGENT_MODE:pb(g),...process.env.COZE_BRIDGE_CODEX_APP_SERVER_LOGS==="1"?{APP_SERVER_LOGS:cd(r,"..","logs","codex-app-server")}:{},...m?{MODEL_PROVIDER:m}:{},...f??{}},_=o?Kf(o,d,u):null,S=_?{methodId:"gateway",_meta:{gateway:_}}:void 0,I=!!o,A=!I&&process.env.COZE_BRIDGE_CODEX_LOCAL_GATEWAY_AUTH==="1";return new wo({cwd:r,agentId:i,...Object.keys(v).length>0?{env:v}:{},...S?{authRequest:S}:{},...I?{isolateCodexHome:!0}:{},...A?{resolveLocalGatewayAuth:!0}:{}})}case"openclaw":return new Fr({command:e,cwd:r,agentId:i,...c?{sessionName:sd(c)}:{}})}};function ad(t){return t==="claude-code"||t==="codex"}function mb(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(wb(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
97
99
|
`)}
|
|
98
|
-
`}function
|
|
99
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var cb={path:"",version:"cloud-deployed"},P0="openclaw_gateway_unavailable",db="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 lb={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},ub=6e4,So=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??sb,this.createTimeoutMs=e.createTimeoutMs??ub,this.detectorFactory=e.detectorFactory??(()=>new Zn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new vo({command:r})),this.openclawConfigDir=e.openclawConfigDir??od(rb(),".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=>{ue.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=od(e,".env");if(await nb(r).then(c=>c.isFile()).catch(()=>!1)){ue.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=ob({...process.env,...ed(this.paths.agentEnvFile)});await cn(r,o,{mode:384}),ue.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),ue.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=await Fe(e.agentId,this.paths).catch(()=>null),o=lo(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")ue.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(D=>ue.warn("dispose stale agent failed (ignored)",{err:String(D)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")ue.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(D=>ue.warn("dispose drifted agent failed (ignored)",{err:String(D)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){ue.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let D=await Fe(e.agentId,this.paths).catch(()=>null);D&&(D.patToken=e.patToken,await rt(D,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){ue.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let D=await Fe(e.agentId,this.paths).catch(()=>null);D&&(D.modelInfo=e.modelInfo,await rt(D,this.paths))}return ue.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=nt(e.agentId,this.paths),x=o?"cloud":"local",h=e.framework==="openclaw"&&x==="local",m;h&&!r?.revive&&(m=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let E=m??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??E??u.workspace,_=new AbortController,v=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,I=!1;try{o&&sd(e.framework)&&await dr(e.framework,_.signal);let D=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await id(u.root,{recursive:!0}),await id(S,{recursive:!0}),await id(u.logs,{recursive:!0}),D(),h||await fr(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(x==="cloud"?await ka(S,"cloud"):await ka(S,"local",ad)),D();let O=i,y=zf({model:e.model??O?.model}),k=If(e._meta)??O?.accountId,L=e.patToken??O?.patToken,U=x==="cloud"?e.modelInfo??O?.modelInfo:void 0;if(A=new bo({agentId:e.agentId,framework:e.framework,workspace:S,model:y.model??vt,deployType:x,...k?{accountId:k}:{},...L?{patToken:L}:{},...U?{modelInfo:U}:{}}),A.status="ok",O?.sessions){let V=x==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[X,se]of Object.entries(O.sessions)){let ae={acpSessionId:se.acpSessionId,modelToken:se.modelToken,tokenGeneratedAt:se.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};V?se.permissionMode===void 0?(ae.permissionMode=e.framework==="claude-code"?"bypassPermissions":"full-access",ue.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:X,framework:e.framework,fallback:ae.permissionMode})):Cn(e.framework,se.permissionMode)?ae.permissionMode=se.permissionMode:ue.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:X,framework:e.framework,value:se.permissionMode}):se.permissionMode!==void 0&&ue.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:X,framework:e.framework,deployType:x}),se.cozeGroupId&&(ae.cozeGroupId=se.cozeGroupId),A.sessions.set(X,ae)}let ne=Object.keys(O.sessions).length;ne>0&&ue.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ne})}this.registry.register(A),I=!0;let z={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:O?.createdAt??Date.now(),sessions:O?.sessions??{},model:y.model};x==="cloud"&&(z.deployType="cloud"),k&&(z.accountId=k),L&&(z.patToken=L),U&&(z.modelInfo=U),O?.skills&&(z.skills=O.skills),O?.agentName&&(z.agentName=O.agentName),O?.description&&(z.description=O.description),e.framework==="openclaw"&&x==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):ue.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let Z=e.initialSkills??[];if(Z.length>0){let V=[...z.skills??[]],ne=new Map(V.map((ae,N)=>[ae.skillId,N])),X=await Promise.allSettled(Z.map(ae=>Xc({agentId:e.agentId,workspace:S,framework:e.framework,skill:ae}))),se=0;for(let[ae,N]of X.entries()){let j=Z[ae];j&&(N.status==="fulfilled"?(Yc(V,ne,N.value),se++):ue.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:j.skillId,skillName:j.skillName,err:String(N.reason)}))}se>0&&(z.skills=V,ue.info("initialSkills installed",{agentId:e.agentId,installed:se,requested:Z.length}))}return await rt(z,this.paths),ue.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:x}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(D){throw ue.error("agent create failed, rolling back",{agentId:e.agentId,err:String(D)}),I&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await tb(u.root,{recursive:!0,force:!0}).catch(O=>ue.warn("rm agent dir failed (ignored)",{err:String(O)})),D instanceof T?D:new T("AGENT_SPAWN_FAILED",String(D),{cause:D})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&sd(e.framework))u=cb;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);sd(e.framework)&&!ps(e.framework)&&(ue.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await dr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;if(e.framework==="openclaw")h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else{let m=e.sessions.get(i),E=Zt(e)?m?.permissionMode??L0:"full-access";h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),E)}try{return await h.start(),await h.initialize(lb),h}catch(m){let E=h instanceof Nt?h.getStderrTail():[];throw E.length>0&&ue.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof T?m.code:"unknown",recentStderr:E}),await h.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,m)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",O0(o),{cause:{reason:P0}})}catch(o){ue.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?i:new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};ue.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 ue.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:db}})}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:P0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,x=rd(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new zr({command:u,cwd:S.workspace,agentId:S.id,sessionName:x})}let h=await k0(),m=i?Hf(i,c,l):null,E;if(m){let S=jc(o),v=m.models[0]?.id??vt,A=`${S}/${v}`;if(!this.ensuredProviders.has(A)){let I=this.getOpenclawConfig();await I.ensureProvider(S,m),await I.addModelToAllowlist(A),this.ensuredProviders.add(A)}E=A}return new zr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=jc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,ue.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,ue.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 _b}from"node:fs";import{basename as q0}from"node:path";Ze();re();import{promises as xb}from"node:fs";import{basename as hb}from"node:path";var M0=H("file-upload"),pb="/api/coze_claw/file/agent_upload",gb=6e4;async function B0(t,e={}){let i=`${fo(ho(e.handshakeBase))}${pb}`,o=e.timeoutMs??gb,c=await xb.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",...Dr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);M0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:u,body:l,signal:x.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let v=await m.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${v.slice(0,200)}`)}let S=await m.json();if(S.code!==void 0&&S.code!==0)throw new T("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${E}`);let _=S.data?.file?.file_url;if(!_)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(S).slice(0,200)}`);return M0.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof T?m:m.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${hb(t.path)}`):new T("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}Ze();re();import{extname as mb}from"node:path";var wb={".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 z0(t){let e=mb(t).toLowerCase();return wb[e]??"application/octet-stream"}Le();var Ao=H("agent-send"),F0=50*1024*1024;function G0(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 H0(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(h){u=h,x<2&&(Ao.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function j0(t,e){let{session:r,runtime:i}=G0(e.core,t.agentId,t.sessionId);if(!await ai(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await _b.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>F0)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${F0}`);let c=await z0(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??q0(t.path),u;try{u=await B0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw Ao.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:h instanceof T?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId: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 H0(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Ao.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 W0(t,e){let{session:r,runtime:i}=G0(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??q0(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 H0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Ao.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 K0(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}an();Vt();re();var Mt=H("coze-cli-installer"),$0="@coze/cli@latest",yb="coze",V0="0.1.8",bb=5e3,Eb=5e3,vb=9e4,Z0=1e4,Ki=null,Io=!1;async function cd(t,e={}){if(Io)return;if(Ki)return Ki;let r=e.exec??kf;return Ki=(async()=>{try{let i=await Sb(yb,r),o=!1;if(i){let l=await Ab(r);if(l===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(K0(l,V0))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:V0}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),Io=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:$0,mode:c});try{await r("npm",["i","-g","--prefer-online",$0],{timeout:vb,maxBuffer:10*1024*1024}),Mt.info("coze-cli install ok")}catch(l){Mt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){Io=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Z0}),Mt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Mt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Z0}),Mt.info("coze auth login ok")}catch(l){Mt.warn("coze auth login failed",{err:String(l)});return}Io=!0}finally{Ki=null}})(),Ki}async function Sb(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:bb});return Ra(i)}catch{return}}async function Ab(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Eb});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}dn();Le();var Ib=10*6e4;function J0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ib:e}function Co(t){return lr(t??Q().configFile)}function $i(t,e){return ur(e??Q().configFile,t)}import{randomBytes as Kb}from"node:crypto";or();Ze();re();import{createReadStream as Cb}from"node:fs";import{mkdir as Tb,readFile as Rb,realpath as Db,stat as kb,writeFile as Pb}from"node:fs/promises";import{basename as Ob,dirname as dd,isAbsolute as Lb,join as Nb,relative as Mb,resolve as X0,sep as Bb}from"node:path";import{createInterface as zb}from"node:readline";var Q0=H("fs-rpc"),Vi=Ve("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function ex(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Vi)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Vi} bytes`);let i=await nx(t.path,e);return await Tb(dd(i),{recursive:!0}),await Pb(i,t.content,"utf8"),Q0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function tx(t,e){let r=await nx(t.path,e),i=await kb(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Vi&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Vi} bytes`);let c;if(o&&i.size>Vi)c=await Fb(r,t.line??1,t.limit);else{let l=await Rb(r,"utf8");if(o){let u=l.split(`
|
|
100
|
-
`),
|
|
101
|
-
`)}else c=
|
|
102
|
-
`)}async function nx(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([Y0(X0(e)),Y0(X0(t))]),o=Mb(r,i);if(Ub(o,Bb,Lb(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function Ub(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Y0(t){let e=[],r=t;for(;r!==dd(r);)try{let i=await Db(r);return e.length?Nb(i,...e.reverse()):i}catch{e.push(Ob(r)),r=dd(r)}return t}re();var rx=H("prompt-multimodal"),ix=10*1024*1024,qb=15e3,Gb=6;async function sx(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 Hb(l))}}let o=Array.from({length:Math.min(Gb,t.length)},()=>i());return await Promise.all(o),e}function ox(t){return t.some(e=>e.type==="image")}async function Hb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ni(e.uri))return t;try{let{buf:r,contentType:i}=await Wb(e.uri),o=e.mimeType||jb(i)||"application/octet-stream";return rx.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 rx.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function jb(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Wb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),qb);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>ix)throw new Error(`image too large: ${o.byteLength} bytes (max ${ix})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}ln();Ze();re();var K=H("core"),$b=3e4,Vb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Zb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Jb="\u5BA1\u6279\u5DF2\u8D85\u65F6",Xb=3e4,To=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Nr;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=J0(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}),Wi(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(In(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(mo(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&&Vb.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(Lr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Lr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Lr(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(In(r,Gi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let h=r._meta?.cozeTriggerMsgId,m=uo(r._meta);return K.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,Zb,h,m)}}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}=Tf(i);switch(r){case"session/new":{let c=Yb();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=Zt(e)?Cf(i._meta):void 0;if(u!==void 0&&!Cn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${nd(e.framework)}`);let x=await this.ensureRuntime(e,l);if(u!==void 0&&x.permissionMode===void 0&&(x.permissionMode=u,await this.persistSessionMapping(e)),x.replySeq=0,await this.ensureDownstream(e,l,x),!x.downstream||!x.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&x.permissionMode!==void 0&&x.permissionMode!==u){let S=x.permissionMode;x.permissionMode=u,await this.persistSessionMapping(e);try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(_){throw x.permissionMode=S,await this.persistSessionMapping(e).catch(()=>{}),_}}let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(x.acpSessionId,h):e.activeTriggers.delete(x.acpSessionId);let m=uo(i._meta);if(m?e.activeGroupIds.set(x.acpSessionId,m):e.activeGroupIds.delete(x.acpSessionId),m&&x.cozeGroupId!==m&&(x.cozeGroupId=m,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&ox(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let E=await sx(c.prompt);try{let S=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:E});return x.lastActiveAt=Date.now(),S}catch(S){if(S instanceof T&&S.code==="AGENT_APPROVAL_TIMEOUT"){let _=x.pendingPermission;_&&(_.downstream.respondAgentRequest(_.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(_.upstreamId),x.pendingPermission=void 0);let v=x.acpSessionId,A=v?e.activeTriggers.get(v):void 0,I=v?e.activeGroupIds.get(v):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,x,l,Jb,A,I)}throw S}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.pendingPermission=void 0,x.reloadAfterTurn){x.reloadAfterTurn=!1;let S=x.downstream;S&&(x.downstream=void 0,K.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:x.acpSessionId}),S.stop("reload-after-turn").catch(_=>K.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(_)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,l,x)}}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}}case"session/set_mode":{let c=o,l=c.sessionId,u=c.modeId,x=uo(i._meta);if(!l)throw new T("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Zt(e))throw e.framework==="openclaw"?new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new T("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Cn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${nd(e.framework)}`);if(x)return await this.handleGroupSetMode(e,x,u);let h=e.sessions.get(l)??await this.ensureRuntime(e,l);if(h.permissionMode===u)return{};let m=h.permissionMode;if(h.permissionMode=u,await this.persistSessionMapping(e),h.downstream?.isAlive()&&h.acpSessionId)try{await h.downstream.setSessionMode({sessionId:h.acpSessionId,modeId:u})}catch(E){throw h.permissionMode=m,await this.persistSessionMapping(e).catch(()=>{}),E}else K.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:l,modeId:u});return{}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[l,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:l,runtime:u,oldMode:u.permissionMode});if(o.length===0)return K.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};K.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let l of o)l.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let l of o){let u=l.runtime.downstream,x=l.runtime.acpSessionId;u?.isAlive()&&x&&c.push({downstream:u,acpSessionId:x,oldMode:l.oldMode,runtime:l.runtime})}for(let l of c)try{await l.downstream.setSessionMode({sessionId:l.acpSessionId,modeId:i})}catch(u){for(let x of o)x.runtime.permissionMode=x.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return Zt(e)&&(c.permissionMode=e.framework==="claude-code"?ad:N0),e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(Et.GEN_MODEL_TOKEN,i,Xb);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(Wi(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(h){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),h}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),K.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){K.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}}catch(h){throw K.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,h}if(x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId),Zt(e)&&i.acpSessionId&&i.permissionMode)try{await x.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(h){K.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(h)})}}armIdleTimer(e,r,i){if(Wi(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(Or("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(Or("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(tE(r)){K.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l=r.update;if(l&&typeof l=="object"&&l.sessionUpdate==="current_mode_update"&&Zt(e)){let m=l.currentModeId;Cn(e.framework,m)&&c.permissionMode!==m?(c.permissionMode=m,this.persistSessionMapping(e).catch(E=>K.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(E)}))):typeof m=="string"&&!Cn(e.framework,m)&&K.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:m})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(i);x&&(u.cozeTriggerMsgId=x);let h=e.activeGroupIds.get(i);h&&(u.cozeGroupId=h),this.upstream.send(Or("session/update",{...r,sessionId:o,_meta:u})).catch(m=>K.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}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 ex(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await tx(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,Gi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=u?e.activeGroupIds.get(u):void 0;m&&(h.cozeGroupId=m);let E=u?this.reverseSessionId(e,u):void 0,S=E?e.sessions.get(E):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),K.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ui(o,"session/request_permission",_)).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"&&Qb(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 go(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=$b){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Ui(o,e,r)).catch(x=>{let h=this.pendingBridge.get(o);h&&(clearTimeout(h.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Zt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await ci(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(In(e,{code:r,message:i,data:{bridgeVersion:Pr}}))}};function Yb(){return Kb(16).toString("hex")}function Qb(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 eE=["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 tE(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 eE.some(c=>o.startsWith(c))}dn();re();Le();import{randomBytes as nE}from"node:crypto";import{createServer as rE}from"node:http";var iE=1e6,ax=H("ipc"),Ro=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??Q()}async start(){this.token=nE(32).toString("hex");let e=rE((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(),ax.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 cn(this.paths.portFile,String(this.port)),await cn(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Zi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Zi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await sE(e)}catch(u){Zi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Zi(r,200,u??{ok:!0})}catch(u){ax.error("IPC handler failed",{key:o,err:String(u)}),Zi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Zi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function sE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>iE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var Iv=qt(rh(),1),Cv=qt(zo(),1),Tv=qt(qr(),1),Rv=qt(yd(),1),Dv=qt(vd(),1),kv=qt(Rd(),1),fh=qt(Go(),1),Pv=qt(uh(),1);var xh=fh.default;Ze();re();var{FWS:Vv}=Sh(),De=H("upstream.frontier"),Ih="application/json",Ch="none",Zv=15e3;function Jv(t){class e extends xh{constructor(i){super(i,Of,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>De.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(ml("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");De.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){De.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var is=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){De.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Lf,...Dr(this.opts.ppeOverride)},r=Jv(e),i=Mf(this.opts.urlOverride),o={url:i,ws:r,fpID:Pf,aID:xo,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Ih,force:!0},payloadEncoding:{encoding:Ch,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Vv(o),l=!1,u=null,x,h,m=new Promise((_,v)=>{x=_,h=v}),E=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?h(_):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;De.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:_})).catch(A=>De.warn("onConnect handler threw (ignored)",{err:String(A)}))},c.onclose=_=>{this.opened=!1,De.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{De.warn("frontier error",{code:_.code,msg:_.message}),E(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let S=this.opts.openTimeoutMs??Zv;u=setTimeout(()=>{E(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(v){De.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){De.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw De.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?(De.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;Th(c)||De.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Ih,payloadEncoding:Ch})}catch(u){throw De.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){De.debug("drop non-adapter frontier frame",{service:r});return}let i=Qv(e);if(!i){De.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){De.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){De.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Th(c)||De.info("frontier frame in",{logid:Yv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Xv(i)}),Promise.resolve(this.handler(o)).catch(l=>De.warn("frontier frame handler threw",{err:String(l)}))}};function Th(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Rh=2e3;function Xv(t){return t.length<=Rh?t:`${t.slice(0,Rh)}...<truncated, total ${t.length} chars>`}function Yv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Qv(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}}re();var Od=H("upstream.switchable"),Xo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Od.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 Od.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Od.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()}};re();var Ld=H("upstream"),$r=class{handler=null;async start(){Ld.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ld.info("NoopUpstream stopped",{reason:e})}async send(e){Ld.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)}};Ze();re();dn();re();Le();import{promises as eS}from"node:fs";var Dh=H("pat-token-store");async function Yo(t=Q()){try{let r=(await eS.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(Dh.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):r}catch(e){let r=e?.code;return r!=="ENOENT"&&Dh.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function ss(t,e=Q()){if(!t)throw new Error("writePatToken: empty patToken");await cn(e.patTokenFile,t,{mode:384})}Le();Le();import{promises as Qo}from"node:fs";import{join as tS}from"node:path";function nS(t,e){return`#!/bin/sh
|
|
100
|
+
`}function wb(t){if(t.includes(`
|
|
101
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var _b={path:"",version:"cloud-deployed"},G0="openclaw_gateway_unavailable",yb="openclaw_default_agent_missing";function H0(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 bb={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Eb=6e4,Eo=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??gb,this.createTimeoutMs=e.createTimeoutMs??Eb,this.detectorFactory=e.detectorFactory??(()=>new Jn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new bo({command:r})),this.openclawConfigDir=e.openclawConfigDir??cd(xb(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{de.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=cd(e,".env");if(await hb(r).then(c=>c.isFile()).catch(()=>!1)){de.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=mb({...process.env,...nd(this.paths.agentEnvFile)});await cn(r,o,{mode:384}),de.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),de.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=await De(e.agentId,this.paths).catch(()=>null),o=oo(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")de.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(k=>de.warn("dispose stale agent failed (ignored)",{err:String(k)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")de.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(k=>de.warn("dispose drifted agent failed (ignored)",{err:String(k)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){de.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let k=await De(e.agentId,this.paths).catch(()=>null);k&&(k.patToken=e.patToken,await Ue(k,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){de.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let k=await De(e.agentId,this.paths).catch(()=>null);k&&(k.modelInfo=e.modelInfo,await Ue(k,this.paths))}return de.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=Ye(e.agentId,this.paths),f=o?"cloud":"local",x=e.framework==="openclaw"&&f==="local",g;x&&!r?.revive&&(g=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let m=g??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),v=e.workspace??m??u.workspace,_=new AbortController,S=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&ad(e.framework)&&await dr(e.framework,_.signal);let k=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await od(u.root,{recursive:!0}),await od(v,{recursive:!0}),await od(u.logs,{recursive:!0}),k(),x||await fr(v,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(f==="cloud"?await Pa(v,"cloud"):await Pa(v,"local",dd)),k();let P=i,E=Hf({model:e.model??P?.model}),R=Df(e._meta)??P?.accountId,O=e.patToken??P?.patToken,F=f==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(I=new _o({agentId:e.agentId,framework:e.framework,workspace:v,model:E.model??St,deployType:f,...R?{accountId:R}:{},...O?{patToken:O}:{},...F?{modelInfo:F}:{}}),I.status="ok",P?.sessions){let V=f==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Y,ie]of Object.entries(P.sessions)){let se={acpSessionId:ie.acpSessionId,modelToken:ie.modelToken,tokenGeneratedAt:ie.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};V?ie.permissionMode===void 0?(se.permissionMode=e.framework==="claude-code"?"bypassPermissions":"full-access",de.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Y,framework:e.framework,fallback:se.permissionMode})):Tn(e.framework,ie.permissionMode)?se.permissionMode=ie.permissionMode:de.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Y,framework:e.framework,value:ie.permissionMode}):ie.permissionMode!==void 0&&de.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Y,framework:e.framework,deployType:f}),ie.cozeGroupId&&(se.cozeGroupId=ie.cozeGroupId),I.sessions.set(Y,se)}let ne=Object.keys(P.sessions).length;ne>0&&de.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ne})}this.registry.register(I),A=!0;let N={agentId:e.agentId,framework:e.framework,workspace:v,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:E.model};f==="cloud"&&(N.deployType="cloud"),R&&(N.accountId=R),O&&(N.patToken=O),F&&(N.modelInfo=F),P?.skills&&(N.skills=P.skills),P?.agentName&&(N.agentName=P.agentName),P?.description&&(N.description=P.description),N.skillsRefreshedForVersion=P?.skillsRefreshedForVersion??Nt,e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,v)):de.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let J=e.initialSkills??[];if(J.length>0){let V=[...N.skills??[]],ne=new Map(V.map((se,D)=>[se.skillId,D])),Y=await Promise.allSettled(J.map(se=>fo({agentId:e.agentId,workspace:v,framework:e.framework,skill:se}))),ie=0;for(let[se,D]of Y.entries()){let U=J[se];U&&(D.status==="fulfilled"?(ho(V,ne,D.value),ie++):de.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:U.skillId,skillName:U.skillName,err:String(D.reason)}))}ie>0&&(N.skills=V,de.info("initialSkills installed",{agentId:e.agentId,installed:ie,requested:J.length}))}return await Ue(N,this.paths),de.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:v,framework:e.framework}}catch(k){throw de.error("agent create failed, rolling back",{agentId:e.agentId,err:String(k)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await fb(u.root,{recursive:!0,force:!0}).catch(P=>de.warn("rm agent dir failed (ignored)",{err:String(P)})),k instanceof T?k:new T("AGENT_SPAWN_FAILED",String(k),{cause:k})}finally{clearTimeout(S)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&ad(e.framework))u=_b;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);ad(e.framework)&&!hs(e.framework)&&(de.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await dr(e.framework));let f=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;if(e.framework==="openclaw")x=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else{let g=e.sessions.get(i),m=Zt(e)?g?.permissionMode??j0:"full-access";x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,this.buildBinShimPathEnv(),m)}try{return await x.start(),await x.initialize(bb),x}catch(g){let m=x instanceof Mt?x.getStderrTail():[];throw m.length>0&&de.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:g instanceof T?g.code:"unknown",recentStderr:m}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,g)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",H0(o),{cause:{reason:G0}})}catch(o){de.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?i:new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};de.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return de.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:yb}})}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",H0(r),{cause:{reason:G0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,f=sd(o);if(r.deployType==="local"){let v=await this.ensureOpenclawDefaultAgent();return new Fr({command:u,cwd:v.workspace,agentId:v.id,sessionName:f})}let x=await q0(),g=i?Vf(i,c,d):null,m;if(g){let v=Kc(o),S=g.models[0]?.id??St,I=`${v}/${S}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(v,g),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}m=I}return new Fr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:f,...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=Kc(i),c=`${o}/${e.model}`,d=!0;try{await r.removeProvider(o)}catch(u){d=!1,de.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){d=!1,de.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as Z0}from"node:crypto";import{promises as Cb}from"node:fs";import{basename as Y0}from"node:path";$e();te();import{promises as vb}from"node:fs";import{basename as Sb}from"node:path";var W0=H("file-upload"),Ib="/api/coze_claw/file/agent_upload",Ab=6e4;async function $0(t,e={}){let i=`${Rr(Dr(e.handshakeBase))}${Ib}`,o=e.timeoutMs??Ab,c=await vb.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Sn(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},f=new AbortController,x=setTimeout(()=>f.abort(),o);W0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let g=await fetch(i,{method:"POST",headers:u,body:d,signal:f.signal}),m=g.headers.get("x-tt-logid")??"";if(!g.ok){let S=await g.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${g.status} logid=${m}: ${S.slice(0,200)}`)}let v=await g.json();if(v.code!==void 0&&v.code!==0)throw new T("UPLOAD_FAILED",`upload code=${v.code} msg=${v.msg??"-"} logid=${m}`);let _=v.data?.file?.file_url;if(!_)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${m}: ${JSON.stringify(v).slice(0,200)}`);return W0.info("file upload ok",{uri:_,logid:m}),{uri:_}}catch(g){throw g instanceof T?g:g.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Sb(t.path)}`):new T("UPLOAD_FAILED",String(g),{cause:g})}finally{clearTimeout(x)}}$e();te();import{extname as Tb}from"node:path";var kb={".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 V0(t){let e=Tb(t).toLowerCase();return kb[e]??"application/octet-stream"}Me();var vo=H("agent-send"),J0=50*1024*1024;function X0(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 Q0(t,e,r,i,o,c){let u;for(let f=0;f<=2;f++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){u=x,f<2&&(vo.warn("sendAgentFileUpdate failed, retrying",{attempt:f+1,err:String(x)}),await new Promise(g=>setTimeout(g,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function eh(t,e){let{session:r,runtime:i}=X0(e.core,t.agentId,t.sessionId);if(!await si(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Cb.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>J0)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${J0}`);let c=await V0(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 d=t.name??Y0(t.path),u;try{u=await $0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw vo.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 f={sessionUpdate:"agent_file",messageId:Z0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Q0(e,r,i,t.sessionId,f,"agent file uploaded to cloud but sendAgentFileUpdate failed"),vo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function th(t,e){let{session:r,runtime:i}=X0(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??Y0(t.path),c={sessionUpdate:"group_file",messageId:Z0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Q0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),vo.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 nh(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let d=r[c]??0,u=i[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}an();Jt();te();var Bt=H("coze-cli-installer"),rh="@coze/cli@latest",Rb="coze",ih="0.1.8",Db=5e3,Pb=5e3,Ob=9e4,sh=1e4,Ki=null,So=!1;async function ud(t,e={}){if(So)return;if(Ki)return Ki;let r=e.exec??Mf;return Ki=(async()=>{try{let i=await Lb(Rb,r),o=!1;if(i){let d=await Nb(r);if(d===void 0)Bt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(nh(d,ih))Bt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:ih}),o=!0;else{Bt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),So=!0;return}}let c=o?"upgrade-only":"full";Bt.info("coze-cli install start",{package:rh,mode:c});try{await r("npm",["i","-g","--prefer-online",rh],{timeout:Ob,maxBuffer:10*1024*1024}),Bt.info("coze-cli install ok")}catch(d){Bt.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(o){So=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:sh}),Bt.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Bt.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:sh}),Bt.info("coze auth login ok")}catch(d){Bt.warn("coze auth login failed",{err:String(d)});return}So=!0}finally{Ki=null}})(),Ki}async function Lb(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Db});return Ra(i)}catch{return}}async function Nb(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Pb});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}dn();Me();var Mb=10*6e4;function oh(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Mb:e}function Io(t){return lr(t??Q().configFile)}function Wi(t,e){return ur(e??Q().configFile,t)}import{randomBytes as nE}from"node:crypto";or();$e();te();import{createReadStream as Bb}from"node:fs";import{mkdir as Fb,readFile as zb,realpath as Ub,stat as qb,writeFile as Gb}from"node:fs/promises";import{basename as Hb,dirname as fd,isAbsolute as jb,join as Kb,relative as Wb,resolve as ah,sep as $b}from"node:path";import{createInterface as Vb}from"node:readline";var dh=H("fs-rpc"),$i=Ze("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function lh(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>$i)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${$i} bytes`);let i=await fh(t.path,e);return await Fb(fd(i),{recursive:!0}),await Gb(i,t.content,"utf8"),dh.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function uh(t,e){let r=await fh(t.path,e),i=await qb(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>$i&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${$i} bytes`);let c;if(o&&i.size>$i)c=await Jb(r,t.line??1,t.limit);else{let d=await zb(r,"utf8");if(o){let u=d.split(`
|
|
102
|
+
`),f=Math.max(0,(t.line??1)-1),x=typeof t.limit=="number"?f+t.limit:void 0;c=u.slice(f,x).join(`
|
|
103
|
+
`)}else c=d}return dh.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Jb(t,e,r){let i=Vb({input:Bb(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,d=[],u=0;try{for await(let f of i)if(u>=o&&u<c&&d.push(f),u++,u>=c)break}finally{i.close()}return d.join(`
|
|
104
|
+
`)}async function fh(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([ch(ah(e)),ch(ah(t))]),o=Wb(r,i);if(Zb(o,$b,jb(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function Zb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function ch(t){let e=[],r=t;for(;r!==fd(r);)try{let i=await Ub(r);return e.length?Kb(i,...e.reverse()):i}catch{e.push(Hb(r)),r=fd(r)}return t}te();var hh=H("prompt-multimodal"),xh=10*1024*1024,Yb=15e3,Xb=6;async function ph(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await Qb(d))}}let o=Array.from({length:Math.min(Xb,t.length)},()=>i());return await Promise.all(o),e}function gh(t){return t.some(e=>e.type==="image")}async function Qb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Li(e.uri))return t;try{let{buf:r,contentType:i}=await tE(e.uri),o=e.mimeType||eE(i)||"application/octet-stream";return hh.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 hh.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function eE(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function tE(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Yb);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>xh)throw new Error(`image too large: ${o.byteLength} bytes (max ${xh})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}ln();$e();te();var W=H("core"),rE=3e4,iE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,sE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",oE="\u5BA1\u6279\u5DF2\u8D85\u65F6",aE=3e4,Ao=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Nr;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=oh(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(),W.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){W.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),W.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){W.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)&&W.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,d)=>{W.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),ji(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){W.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(An(o,{code:Z.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>W.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Z.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){W.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Z.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(po(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&&iE.test(i)?this.currentCozeEnv=i:i&&W.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,Z.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):W.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Lr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Lr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Lr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Z.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):W.warn("drop unknown notification",{method:e.method})}catch(o){W.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(An(r,qi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let f=o.sessions.get(c);if(f?.pendingPermission){let x=r._meta?.cozeTriggerMsgId,g=ao(r._meta);return W.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,f,c,sE,x,g)}}let d=Date.now(),u=!1;try{let f=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,f}finally{W.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Of(i);switch(r){case"session/new":{let c=cE();return W.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return W.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,d=c.sessionId;if(!d)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Zt(e)?Pf(i._meta):void 0;if(u!==void 0&&!Tn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${id(e.framework)}`);let f=await this.ensureRuntime(e,d);if(u!==void 0&&f.permissionMode===void 0&&(f.permissionMode=u,await this.persistSessionMapping(e)),f.replySeq=0,await this.ensureDownstream(e,d,f),!f.downstream||!f.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&f.permissionMode!==void 0&&f.permissionMode!==u){let v=f.permissionMode;f.permissionMode=u,await this.persistSessionMapping(e);try{await f.downstream.setSessionMode({sessionId:f.acpSessionId,modeId:u})}catch(_){throw f.permissionMode=v,await this.persistSessionMapping(e).catch(()=>{}),_}}let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let g=ao(i._meta);if(g?e.activeGroupIds.set(f.acpSessionId,g):e.activeGroupIds.delete(f.acpSessionId),g&&f.cozeGroupId!==g&&(f.cozeGroupId=g,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&gh(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await ph(c.prompt);try{let v=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:m});return f.lastActiveAt=Date.now(),v}catch(v){if(v instanceof T&&v.code==="AGENT_APPROVAL_TIMEOUT"){let _=f.pendingPermission;_&&(_.downstream.respondAgentRequest(_.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(_.upstreamId),f.pendingPermission=void 0);let S=f.acpSessionId,I=S?e.activeTriggers.get(S):void 0,A=S?e.activeGroupIds.get(S):void 0;return W.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:d}),await this.synthesizePromptReply(e,f,d,oE,I,A)}throw v}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let v=f.downstream;v&&(f.downstream=void 0,W.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:f.acpSessionId}),v.stop("reload-after-turn").catch(_=>W.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(_)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,d,f)}}case"session/cancel":{let d=o.sessionId;if(!d)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let f=e.getSessionQueue(d);f.size>0&&(W.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:f.size}),f.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,d=c.sessionId,u=c.modeId,f=ao(i._meta);if(!d)throw new T("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Zt(e))throw e.framework==="openclaw"?new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new T("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Tn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${id(e.framework)}`);if(f)return await this.handleGroupSetMode(e,f,u);let x=e.sessions.get(d)??await this.ensureRuntime(e,d);if(x.permissionMode===u)return{};let g=x.permissionMode;if(x.permissionMode=u,await this.persistSessionMapping(e),x.downstream?.isAlive()&&x.acpSessionId)try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(m){throw x.permissionMode=g,await this.persistSessionMapping(e).catch(()=>{}),m}else W.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:d,modeId:u});return{}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[d,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:d,runtime:u,oldMode:u.permissionMode});if(o.length===0)return W.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};W.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let d of o)d.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let d of o){let u=d.runtime.downstream,f=d.runtime.acpSessionId;u?.isAlive()&&f&&c.push({downstream:u,acpSessionId:f,oldMode:d.oldMode,runtime:d.runtime})}for(let d of c)try{await d.downstream.setSessionMode({sessionId:d.acpSessionId,modeId:i})}catch(u){for(let f of o)f.runtime.permissionMode=f.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return Zt(e)&&(c.permissionMode=e.framework==="claude-code"?dd:K0),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(ht.GEN_MODEL_TOKEN,i,aE);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(ji(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,d=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(d>=o&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let f;try{f=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=d+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(W.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=f,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await f.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),W.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){W.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let g=await f.sessionNew({cwd:e.workspace});i.acpSessionId=g.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let x=await f.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}}catch(x){throw W.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),await f.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,x}if(f.afterSessionEstablished&&i.acpSessionId&&await f.afterSessionEstablished(i.acpSessionId),Zt(e)&&i.acpSessionId&&i.permissionMode)try{await f.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(x){W.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(x)})}}armIdleTimer(e,r,i){if(ji(i),this.isRuntimeBusy(e,i)){W.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)){W.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}W.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=>W.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Or("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,d){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),d&&(u.cozeGroupId=d),await this.upstream.send(Or("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(f=>W.warn("synthesizePromptReply update send failed (ignored)",{err:String(f)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){W.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){W.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(uE(r)){W.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let d=r.update;if(d&&typeof d=="object"&&d.sessionUpdate==="current_mode_update"&&Zt(e)){let g=d.currentModeId;Tn(e.framework,g)&&c.permissionMode!==g?(c.permissionMode=g,this.persistSessionMapping(e).catch(m=>W.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(m)}))):typeof g=="string"&&!Tn(e.framework,g)&&W.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:g})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(u.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(u.cozeGroupId=x),this.upstream.send(Or("session/update",{...r,sessionId:o,_meta:u})).catch(g=>W.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}W.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Z.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},d=await lh(c,o);r.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await uh(c,o);r.respondAgentRequest(i.id,d)}}catch(o){W.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,qi(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,f=u?e.activeTriggers.get(u):void 0,x={cozeAgentId:e.agentId};f&&(x.cozeTriggerMsgId=f);let g=u?e.activeGroupIds.get(u):void 0;g&&(x.cozeGroupId=g);let m=u?this.reverseSessionId(e,u):void 0,v=m?e.sessions.get(m):void 0;v&&(v.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...m?{sessionId:m}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:m}),W.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:m,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(S=>({optionId:S.optionId,kind:S.kind,name:S.name}))}),this.upstream.send(zi(o,"session/request_permission",_)).catch(S=>{this.pendingUpstream.delete(o),W.error("forward permission request failed",{agentId:e.agentId,err:String(S)}),r.respondAgentRequestError(i.id,{code:Z.INTERNAL_ERROR,message:`upstream send failed: ${String(S)}`})})}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?(W.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"&&dE(e.result,o),W.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 xo(e.error)):i.value.resolve(e.result);return}W.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),d=e.get(c);if(d)return W.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,i=rE){let o=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),d(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(zi(o,e,r)).catch(f=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),d(f)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Zt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await oi(e.agentId,r,this.paths)}catch(r){W.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(An(e,{code:r,message:i,data:{bridgeVersion:Nt}}))}};function cE(){return nE(16).toString("hex")}function dE(t,e){if(!t||typeof t!="object"){W.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){W.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"){W.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")&&W.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var lE=["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 uE(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 lE.some(c=>o.startsWith(c))}dn();te();Me();import{randomBytes as fE}from"node:crypto";import{createServer as hE}from"node:http";var xE=1e6,mh=H("ipc"),To=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??Q()}async start(){this.token=fE(32).toString("hex");let e=hE((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(),mh.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 cn(this.paths.portFile,String(this.port)),await cn(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Vi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Vi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await pE(e)}catch(u){Vi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);Vi(r,200,u??{ok:!0})}catch(u){mh.error("IPC handler failed",{key:o,err:String(u)}),Vi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Vi(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}import"node:module";var Mv=Gt(fx(),1),Bv=Gt(Mo(),1),Fv=Gt(qr(),1),zv=Gt(vd(),1),Uv=Gt(Ad(),1),qv=Gt(Pd(),1),Ex=Gt(Uo(),1),Gv=Gt(bx(),1);var vx=Ex.default;$e();te();var{FWS:iS}=Lx(),Le=H("upstream.frontier"),Mx="application/json",Bx="none",sS=15e3;function oS(t){class e extends vx{constructor(i){super(i,Ff,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Le.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(El("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let d=Buffer.from(c.slice(0,128)).toString("hex");Le.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){Le.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var rs=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){Le.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:zf,...Sn(this.opts.ppeOverride)},r=oS(e),i=qf(this.opts.urlOverride),o={url:i,ws:r,fpID:Bf,aID:co,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Mx,force:!0},payloadEncoding:{encoding:Bx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new iS(o),d=!1,u=null,f,x,g=new Promise((_,S)=>{f=_,x=S}),m=_=>{d||(d=!0,u&&(clearTimeout(u),u=null),_?x(_):f())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Le.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&m();for(let S of this.connectHandlers)Promise.resolve(S({initial:_})).catch(I=>Le.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,Le.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Le.warn("frontier error",{code:_.code,msg:_.message}),m(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let v=this.opts.openTimeoutMs??sS;u=setTimeout(()=>{m(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${v}ms (handshake or upgrade slow)`))},v),await c.connect();try{await g}catch(_){try{c.close(1e3,"open failed")}catch(S){Le.warn("fws close during start failure threw (ignored)",{err:String(S)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Le.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Le.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?(Le.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;Fx(c)||Le.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Mx,payloadEncoding:Bx})}catch(u){throw Le.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){Le.debug("drop non-adapter frontier frame",{service:r});return}let i=dS(e);if(!i){Le.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Le.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(d){Le.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;Fx(c)||Le.info("frontier frame in",{logid:cS(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:aS(i)}),Promise.resolve(this.handler(o)).catch(d=>Le.warn("frontier frame handler threw",{err:String(d)}))}};function Fx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var zx=2e3;function aS(t){return t.length<=zx?t:`${t.slice(0,zx)}...<truncated, total ${t.length} chars>`}function cS(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function dS(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}}$e();te();var Md=H("skill-publish"),lS="/api/marketplace/product/skill/publish_with_assets",uS=15e4;async function Ux(t,e={}){let i=`${Rr(Dr(e.handshakeBase))}${lS}`,o=e.timeoutMs??uS,c=new FormData;c.append("skill_id",t.skillId??""),c.append("skill_name",t.skillName),c.append("skill_description",t.description??""),c.append("agent_id",t.agentId),c.append("zip_file",new Blob([t.zip],{type:"application/zip"}),"skill.zip");let d={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Sn(e.ppeOverride),...t.accountId&&t.accountId!=="0"?{"x-coze-account":t.accountId}:{}},u=new AbortController,f=setTimeout(()=>u.abort(),o);Md.info("skill publish start",{url:i,method:"POST",form:{skill_id:t.skillId??"",skill_name:t.skillName,skill_description:t.description??"",agent_id:t.agentId,zip_file_bytes:t.zip.length},headers:{...d,Authorization:`Bearer ${t.patToken.slice(0,8)}...`}});try{let x=await fetch(i,{method:"POST",headers:d,body:c,signal:u.signal}),g=x.headers.get("x-tt-logid")??"";if(!x.ok){let _=await x.text().catch(()=>"");throw new T("UPLOAD_FAILED",`skill publish HTTP ${x.status} logid=${g}: ${_.slice(0,200)}`)}let m=await x.json();if(Md.info("skill publish response",{logid:g,httpStatus:x.status,code:m.code,msg:m.msg,dataSkillId:m.data?.skill_id??"",dataVersion:m.data?.version??""}),m.code!==void 0&&m.code!==0)throw new T("UPLOAD_FAILED",`skill publish code=${m.code} msg=${m.msg??"-"} logid=${g}`);let v={};return m.data?.skill_id!==void 0&&m.data.skill_id!==""&&(v.skillId=String(m.data.skill_id)),m.data?.version&&(v.version=m.data.version),Md.info("skill publish ok",{logid:g,skillId:v.skillId??"",version:v.version??""}),v}catch(x){throw x instanceof T?x:x.name==="AbortError"?new T("UPLOAD_FAILED",`skill publish timeout (${o}ms): ${t.skillName}`):new T("UPLOAD_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}te();var Bd=H("upstream.switchable"),Jo=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()}};te();var Fd=H("upstream"),$r=class{handler=null;async start(){Fd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Fd.info("NoopUpstream stopped",{reason:e})}async send(e){Fd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};$e();te();dn();te();Me();import{promises as fS}from"node:fs";var qx=H("pat-token-store");async function Zo(t=Q()){try{let r=(await fS.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(qx.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):r}catch(e){let r=e?.code;return r!=="ENOENT"&&qx.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function is(t,e=Q()){if(!t)throw new Error("writePatToken: empty patToken");await cn(e.patTokenFile,t,{mode:384})}Me();Me();import{promises as Yo}from"node:fs";import{join as hS}from"node:path";function xS(t,e){return`#!/bin/sh
|
|
103
105
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
104
|
-
`}function
|
|
106
|
+
`}function pS(t,e){return`@echo off\r
|
|
105
107
|
"${e}" "${t}" %*\r
|
|
106
|
-
`}async function
|
|
108
|
+
`}async function Gx(t,e=Q()){let r=e.binDir;await Yo.mkdir(r,{recursive:!0});let i=hS(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?pS(t,o):xS(t,o);return await Yo.readFile(i,"utf8").catch(()=>null)===c||(await Yo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Yo.chmod(i,493)),r}te();Me();import{execSync as Hx}from"node:child_process";import{readFileSync as jx,unlinkSync as gS}from"node:fs";import{mkdir as mS,open as wS,readFile as Kx,unlink as zd,writeFile as _S}from"node:fs/promises";import{dirname as yS}from"node:path";var bS=H("single-instance"),ES=t=>new Promise(e=>setTimeout(e,t)),Xo=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Q().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:r=>Gi(r),isDaemon:r=>this.matchesDaemonTitle(r)},e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();if(e!==null&&e!==this.selfPid&&this.isLiveDaemon(e))return{kind:"already-running",pid:e};let r=await this.withClaimLock(async()=>{let i=await this.readExistingPid();return i!==null&&i!==this.selfPid&&this.isLiveDaemon(i)?{kind:"already-running",pid:i}:(i!==null&&i!==this.selfPid&&bS.warn("removing stale pid file",{stalePid:i}),await _S(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return r.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),r}async release(){if(this.acquired){try{(await Kx(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await zd(this.pidFile)}catch{}this.acquired=!1}}isLiveDaemon(e){return this.probe.isAlive(e)&&this.probe.isDaemon(e)}async readExistingPid(){return this.readPidFrom(this.pidFile)}async readPidFrom(e){try{let r=await Kx(e,"utf8"),i=Number.parseInt(r.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(r){if(r.code==="ENOENT")return null;throw r}}async withClaimLock(e){let r=`${this.pidFile}.lock`;await mS(yS(r),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await wS(r,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let d=await this.readPidFrom(r);if(d!==null&&d!==this.selfPid&&this.probe.isAlive(d)){await ES(this.claimLockIntervalMs);continue}await zd(r).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await zd(r).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${r} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=jx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes(Mr)||r.includes("lib/index.js"))}catch{}try{let r=Hx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes(Mr)||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=Hx(`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{jx(this.pidFile,"utf8").trim()===String(this.selfPid)&&gS(this.pidFile)}catch{}})}};Qo();te();var tr=H("daemon.upstream-watchdog"),RS=12e4,DS=9e5,PS=3e4;function qd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var ea=class{constructor(e){this.opts=e;this.softMs=e.softMs??qd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",RS),this.hardMs=e.hardMs??qd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",DS),this.intervalMs=e.intervalMs??qd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",PS),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?.(),tr.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&&tr.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&&tr.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,tr.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){tr.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,tr.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>tr.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=H("daemon");async function Vx(){let t=Q();if(process.env.COZE_BRIDGE_LOG_MODE!=="legacy"){yl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:D=>Ye(D,t).logs,listAgentIds:()=>xs(t)});try{let{writeFileSync:D}=await import("node:fs");D(t.logFile,`\u8FD0\u884C\u65E5\u5FD7\u5DF2\u8FC1\u79FB\u5230 dated \u6587\u4EF6, \u6B64\u6587\u4EF6 (bridge.log) \u4E0D\u518D\u5199\u5165\u8FD0\u884C\u65E5\u5FD7\u3002
|
|
107
109
|
\u8BF7\u67E5\u770B: ${t.bridgeLogsDir}/bridge-<YYYY-MM-DD>.log
|
|
108
110
|
\u6216\u4F7F\u7528: coze-bridge log [-f] [--lines N]
|
|
109
|
-
`)}catch{}}let e=new ea({processTitle:Mr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Co(),o=i??{};hs({pid:process.pid}),W.info(i?"loaded bridge config":"initialized bridge config");let c=new Xo(new $r),l=null,u=new To({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(N,j,$,oe)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(N,j,$,oe)}}),x=new So({paths:t,config:o,registry:u});l=x;let h,m,E=null,S={},_,v=null,A=null,I=null,D=new Tn;function O(N,j){return D.enqueue(()=>k(N,j))}function y(){A||(A=new na({isConnected:()=>c.isConnected(),forceReconnect:()=>I?O(I,{force:!0}):void 0,onFatal:N=>{if(process.env[os]==="1"){W.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:N});return}W.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:N}),process.exit(1)}})),A.start()}async function k(N,j){let $=N,oe=$?.privatecode;if(!oe)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Qe=Bi($.env),he=$.handshake_url,pe=$.frontier_url,It=Mh($.env,he,pe);if(I=$,!j?.force&&h===oe&&m===It){let we=await bS(t);return u.agents.size===0&&we?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),ia(t,x).catch(Ie=>W.warn("connect-noop auto-revive error (ignored)",{err:String(Ie)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let pt=!!h&&h!==oe,tn=m!==void 0&&m!==It,Ut=pt||tn,nn=await Uc({privatecode:oe,...he?{endpoint:he}:{},ppeOverride:Qe});if(Ut){W.warn("connect config switched, resetting agents",{pcChanged:pt,envChanged:tn,previousPc:h?ra(h):"",nextPc:ra(oe)});for(let we of[...u.agents.values()])await we.dispose("connect config switch").catch(()=>{}),u.agents.delete(we.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new $r,"connect switch").catch(()=>{})}E=nn.deviceId,hs({deviceId:E,pid:process.pid}),cd({patToken:oe,env:$.env}).catch(we=>W.warn("coze-cli setup error (ignored)",{err:String(we)}));let Yr=new is({handshake:nn,privatecode:oe,...pe?{urlOverride:pe}:{},ppeOverride:Qe,getPatTokenForAgent:we=>u.agents.get(we)?.patToken});return await c.swap(Yr,"connect"),h=oe,m=It,S=Qe,_=he,$.mock_scenario!==void 0&&(u.setMockScenario($.mock_scenario),W.info("mock scenario set",{scenario:$.mock_scenario})),v||(v=new Fi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>z.retryPending().catch(we=>W.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:Z})),v.start(),y(),Ut&&ia(t,x).catch(we=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(we)})),ss(oe,t).catch(we=>W.warn("writePatToken after /connect failed (ignored)",{err:String(we)})),W.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async N=>x.createAgent(N.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let L={},U=new po({agents:u.agents,disposeAndMarkDisconnected:async(N,j)=>{let $=u.agents.get(N);if($){await x.cleanupOpenclawSessionProviders($).catch(Qe=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:N,err:String(Qe)}));let oe=!0;try{await $.dispose(`disconnect: ${j}`)}catch(Qe){oe=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:N,err:String(Qe)}),$.status="error"}oe&&($.status="disconnected",u.unregister(N),u.disconnectedAgents.add(N))}else u.disconnectedAgents.add(N)},detailSyncer:async N=>{if(!L.ref)throw new Error("agent-detail-sync not initialized yet");await L.ref.syncOne(N)},cleanupOpenclawProviders:async N=>{await x.cleanupOpenclawSessionProviders(N)},openclawRepair:async(N,j)=>{await x.openclawRepair(N,j)},isRuntimePendingPermission:N=>u.hasPendingPermissionFor(N)});u.registerExtension("_agent/listSkills",N=>U.listSkills(N.params)),u.registerExtension("_agent/addSkills",N=>U.addSkills(N.params)),u.registerExtension("_agent/removeSkills",N=>U.removeSkills(N.params)),u.registerExtension("_agent/getFileTree",N=>U.getFileTree(N.params)),u.registerExtension("_agent/getFileContent",N=>U.getFileContent(N.params)),u.registerExtension("_agent/update",N=>U.updateAgent(N.params)),u.registerExtension("_agent/disconnect",N=>U.disconnectAgent(N.params)),u.registerExtension("_agent/switchModel",N=>U.switchModel(N.params)),u.registerExtension("_agent/reset",N=>U.resetAgent(N.params)),u.registerExtension("_agent/repair",N=>U.repairAgent(N.params)),u.registerExtension("_agent/upgrade",N=>U.upgradeBridge(N.params));let z=new ys({paths:t,handlers:U,agentManager:x,sendDetail:N=>u.sendRequest("_agent/detail",N)});L.ref=z;let Z=async N=>{await Promise.allSettled(N.map(async j=>{try{await U.disconnectAgent({agentId:j.agentId,reason:`auth_failure: code=${j.code} ${j.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:j.agentId,code:j.code,message:j.message})}catch($){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:j.agentId,err:String($)})}}))};c.onConnect(({initial:N})=>{W.info("frontier upstream connected, triggering detail sync",{initial:N}),z.syncAll(N?"initial-connect":"reconnect").catch(j=>W.warn("detail sync top-level error (ignored)",{err:String(j)}))});let V=new Ro({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let N=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[os]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...N?{mockScenario:N}:{}}}},{method:"POST",path:"/pair",handler:async N=>{let j=N,$=j?.privatecode,oe=j?.pairing_code;if(!$||!oe)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Qe=Bi(j.env),he=j.handshake_url,pe=j.frontier_url,It=Mh(j.env,he,pe),pt=!!h&&h!==$,tn=m!==void 0&&m!==It,Ut=pt||tn,nn=await Uc({privatecode:$,...he?{endpoint:he}:{},ppeOverride:Qe});if(Ut){W.warn("pair config switched, resetting agents",{pcChanged:pt,envChanged:tn,previousPc:h?ra(h):"",nextPc:ra($),previousEnvKey:m??"",nextEnvKey:It});for(let Ie of[...u.agents.values()])await Ie.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ie.agentId);u.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new $r,"pair switch").catch(()=>{})}E=nn.deviceId,hs({deviceId:E,pid:process.pid}),cd({patToken:$,env:j.env}).catch(Ie=>W.warn("coze-cli setup error (ignored)",{err:String(Ie)}));let Yr=new is({handshake:nn,privatecode:$,...pe?{urlOverride:pe}:{},ppeOverride:Qe,getPatTokenForAgent:Ie=>u.agents.get(Ie)?.patToken});await c.swap(Yr,"pair");try{let Ie=new Zn;o.frameworksCache=await Ie.detectAll(),await $i(o),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ie){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ie)})}let we=Object.keys(o.frameworksCache??{});try{let Ie=await u.sendRequest("_agent/pair",{pairCode:oe,patToken:$,frameworks:we,_meta:{cozeDeviceId:E}});W.info("_agent/pair ok",{pairResult:Ie}),h=$,m=It,S=Qe,_=he,j.mock_scenario!==void 0&&(u.setMockScenario(j.mock_scenario),W.info("mock scenario set",{scenario:j.mock_scenario})),ss($,t).catch(ke=>W.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),v||(v=new Fi({core:u,getDeviceId:()=>E??"",onTickEnd:()=>z.retryPending().catch(ke=>W.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:Z})),v.start(),y(),Ut&&ia(t,x).catch(ke=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let nr;return j.agent_id&&(nr=await vS(j.agent_id,t,x,ke=>u.sendRequest("_agent/detail",ke),$).catch(ke=>(W.error("--agent-id ensureAgent failed",{agentId:j.agent_id,err:String(ke)}),{ok:!1,agentId:j.agent_id??"",note:String(ke)}))),{ok:!0,note:"paired with cloud",...nr?{agent:nr}:{}}}catch(Ie){return W.error("_agent/pair failed",{err:String(Ie)}),{ok:!1,note:`pair failed: ${String(Ie)}`}}}},{method:"POST",path:"/connect",handler:N=>O(N)},{method:"POST",path:"/_agent/create",handler:async N=>{let j=N;return{ok:!0,result:await x.createAgent(j)}}},{method:"POST",path:"/agent/send",handler:async N=>{let j=N;if(!j?.agentId||!j?.sessionId||!j?.kind||!j?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let $=j;return await($.groupFile?W0:j0)($,{core:u,patToken:h,handshakeBase:_,ppeOverride:S})}catch($){if($ instanceof T)return{ok:!1,code:$.code,message:$.message};throw $}}},{method:"POST",path:"/reload",handler:async N=>{let j=N?.agent_id,$=await u.reloadAgents(j);return W.info("IPC /reload: recycled agent subprocesses",{agentId:j??"(all)",recycled:$}),{ok:!0,recycled:$}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{ae.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ne,token:X}=await V.start();try{await kh(t.libEntry,t)}catch(N){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(N)})}await u.start(),SS({paths:t,core:u,agentManager:x,detectAll:async()=>(o.frameworksCache=await new Zn().detectAll(),await $i(o),o.frameworksCache)}).catch(N=>W.warn("startup warmup error (ignored)",{err:String(N)})),Al().then(async()=>{let{probeAcpVersion:N}=await Promise.resolve().then(()=>(an(),vl));for(let j of["claude-code","codex"]){let $=await N(j);$&&W.info("acp wrapper version",{framework:j,version:$})}}).catch(N=>W.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(N)}));let se=null,ae={port:ne,token:X,core:u,ipc:V,shutdown(N){return se||(W.info("daemon shutdown",{reason:N}),se=(async()=>{v?.stop(),A?.stop(),await u.stop(N),await V.stop(),await e.release()})(),se)}};for(let N of["SIGTERM","SIGINT"])process.on(N,()=>{ae.shutdown(N).then(()=>process.exit(0))});return process.on("exit",()=>c0()),process.on("unhandledRejection",N=>{W.error("unhandledRejection",{reason:N instanceof Error?N.message:String(N),stack:N instanceof Error?N.stack:void 0})}),process.on("uncaughtException",N=>{W.error("uncaughtException (will exit, supervisor will restart)",{message:N.message,stack:N.stack,name:N.name});try{process.stderr.write(`FATAL uncaughtException: ${N.stack??N.message}
|
|
110
|
-
`)}catch{}process.exit(1)}),
|
|
111
|
-
`)){let u=
|
|
112
|
-
`;await
|
|
113
|
-
`).filter(
|
|
114
|
-
`)}async function
|
|
115
|
-
`),1;for(let
|
|
116
|
-
`);return 0}let o=t.date??
|
|
111
|
+
`)}catch{}}let e=new Xo({processTitle:Mr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Io(),o=i??{};fs({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");let c=new Jo(new $r),d=null,u=new Ao({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(D,U,K,ee)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(D,U,K,ee)}}),f=new Eo({paths:t,config:o,registry:u});d=f;let x,g,m=null,v={},_,S=null,I=null,A=null,k=new kn;function P(D,U){return k.enqueue(()=>R(D,U))}function E(){I||(I=new ea({isConnected:()=>c.isConnected()&&!(S?.isLivenessLost()??!1),forceReconnect:()=>A?P(A,{force:!0}):void 0,onFatal:D=>{if(process.env[ss]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:D});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:D}),process.exit(1)}})),I.start()}async function R(D,U){let K=D,ee=K?.privatecode;if(!ee)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let nt=Mi(K.env),xe=K.handshake_url,pe=K.frontier_url,Tt=$x(K.env,xe,pe);if(A=K,!U?.force&&x===ee&&g===Tt){let ye=await OS(t);return u.agents.size===0&&ye?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),na(t,f).catch(Ce=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Ce)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let gt=!!x&&x!==ee,nn=g!==void 0&&g!==Tt,qt=gt||nn,rn=await qc({privatecode:ee,...xe?{endpoint:xe}:{},ppeOverride:nt});if(qt){j.warn("connect config switched, resetting agents",{pcChanged:gt,envChanged:nn,previousPc:x?ta(x):"",nextPc:ta(ee)});for(let ye of[...u.agents.values()])await ye.dispose("connect config switch").catch(()=>{}),u.agents.delete(ye.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new $r,"connect switch").catch(()=>{})}m=rn.deviceId,fs({deviceId:m,pid:process.pid}),ud({patToken:ee,env:K.env}).catch(ye=>j.warn("coze-cli setup error (ignored)",{err:String(ye)}));let Xr=new rs({handshake:rn,privatecode:ee,...pe?{urlOverride:pe}:{},ppeOverride:nt,getPatTokenForAgent:ye=>u.agents.get(ye)?.patToken});return await c.swap(Xr,"connect"),x=ee,g=Tt,v=nt,_=xe,K.mock_scenario!==void 0&&(u.setMockScenario(K.mock_scenario),j.info("mock scenario set",{scenario:K.mock_scenario})),S||(S=new Fi({core:u,getDeviceId:()=>m??"",onTickEnd:()=>N.retryPending().catch(ye=>j.warn("detailSync.retryPending failed (ignored)",{err:String(ye)})),onAuthFailures:J})),S.start(),E(),qt&&na(t,f).catch(ye=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(ye)})),is(ee,t).catch(ye=>j.warn("writePatToken after /connect failed (ignored)",{err:String(ye)})),j.info("/connect: WS established",{deviceId:m}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async D=>f.createAgent(D.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},F=new uo({agents:u.agents,publishSkillToMarketplace:async D=>{let U=u.agents.get(D.agentId)?.patToken??x;if(!U)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");return Ux({patToken:U,zip:D.zip,...D.skillId?{skillId:D.skillId}:{},skillName:D.skillName,...D.description?{description:D.description}:{},agentId:D.agentId,...D.accountId?{accountId:D.accountId}:{}},{handshakeBase:_,ppeOverride:v})},disposeAndMarkDisconnected:async(D,U)=>{let K=u.agents.get(D);if(K){await f.cleanupOpenclawSessionProviders(K).catch(nt=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:D,err:String(nt)}));let ee=!0;try{await K.dispose(`disconnect: ${U}`)}catch(nt){ee=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:D,err:String(nt)}),K.status="error"}ee&&(K.status="disconnected",u.unregister(D),u.disconnectedAgents.add(D))}else u.disconnectedAgents.add(D)},disposeForDelete:async(D,U)=>{let K=u.agents.get(D);K&&(await f.cleanupOpenclawSessionProviders(K).catch(ee=>j.warn("cleanup openclaw providers during delete failed (ignored)",{agentId:D,err:String(ee)})),await K.dispose(`delete: ${U}`).catch(ee=>j.warn("dispose during delete failed (ignored)",{agentId:D,err:String(ee)})),u.unregister(D)),u.disconnectedAgents.delete(D)},detailSyncer:async D=>{if(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(D)},cleanupOpenclawProviders:async D=>{await f.cleanupOpenclawSessionProviders(D)},openclawRepair:async(D,U)=>{await f.openclawRepair(D,U)},isRuntimePendingPermission:D=>u.hasPendingPermissionFor(D)});u.registerExtension("_agent/listSkills",D=>F.listSkills(D.params)),u.registerExtension("_agent/addSkills",D=>F.addSkills(D.params)),u.registerExtension("_agent/removeSkills",D=>F.removeSkills(D.params)),u.registerExtension("_agent/publishSkill",D=>F.publishSkill(D.params)),u.registerExtension("_agent/getFileTree",D=>F.getFileTree(D.params)),u.registerExtension("_agent/getFileContent",D=>F.getFileContent(D.params)),u.registerExtension("_agent/update",D=>F.updateAgent(D.params)),u.registerExtension("_agent/disconnect",D=>F.disconnectAgent(D.params)),u.registerExtension("_agent/switchModel",D=>F.switchModel(D.params)),u.registerExtension("_agent/reset",D=>F.resetAgent(D.params)),u.registerExtension("_agent/repair",D=>F.repairAgent(D.params)),u.registerExtension("_agent/delete",D=>F.deleteAgent(D.params)),u.registerExtension("_agent/upgrade",D=>F.upgradeBridge(D.params));let N=new ms({paths:t,handlers:F,agentManager:f,sendDetail:D=>u.sendRequest("_agent/detail",D)});O.ref=N;let J=async D=>{await Promise.allSettled(D.map(async U=>{try{await F.disconnectAgent({agentId:U.agentId,reason:`auth_failure: code=${U.code} ${U.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:U.agentId,code:U.code,message:U.message})}catch(K){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:U.agentId,err:String(K)})}}))};c.onConnect(({initial:D})=>{j.info("frontier upstream connected, triggering detail sync",{initial:D}),N.syncAll(D?"initial-connect":"reconnect").catch(U=>j.warn("detail sync top-level error (ignored)",{err:String(U)}))});let V=new To({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let D=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[ss]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:m??"",frameworksCache:o.frameworksCache??{},...D?{mockScenario:D}:{}}}},{method:"POST",path:"/pair",handler:async D=>{let U=D,K=U?.privatecode,ee=U?.pairing_code;if(!K||!ee)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let nt=Mi(U.env),xe=U.handshake_url,pe=U.frontier_url,Tt=$x(U.env,xe,pe),gt=!!x&&x!==K,nn=g!==void 0&&g!==Tt,qt=gt||nn,rn=await qc({privatecode:K,...xe?{endpoint:xe}:{},ppeOverride:nt});if(qt){j.warn("pair config switched, resetting agents",{pcChanged:gt,envChanged:nn,previousPc:x?ta(x):"",nextPc:ta(K),previousEnvKey:g??"",nextEnvKey:Tt});for(let Ce of[...u.agents.values()])await Ce.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ce.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new $r,"pair switch").catch(()=>{})}m=rn.deviceId,fs({deviceId:m,pid:process.pid}),ud({patToken:K,env:U.env}).catch(Ce=>j.warn("coze-cli setup error (ignored)",{err:String(Ce)}));let Xr=new rs({handshake:rn,privatecode:K,...pe?{urlOverride:pe}:{},ppeOverride:nt,getPatTokenForAgent:Ce=>u.agents.get(Ce)?.patToken});await c.swap(Xr,"pair");try{let Ce=new Jn;o.frameworksCache=await Ce.detectAll(),await Wi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ce){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ce)})}let ye=Object.keys(o.frameworksCache??{});try{let Ce=await u.sendRequest("_agent/pair",{pairCode:ee,patToken:K,frameworks:ye,_meta:{cozeDeviceId:m}});j.info("_agent/pair ok",{pairResult:Ce}),x=K,g=Tt,v=nt,_=xe,U.mock_scenario!==void 0&&(u.setMockScenario(U.mock_scenario),j.info("mock scenario set",{scenario:U.mock_scenario})),is(K,t).catch(Ne=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Ne)})),S||(S=new Fi({core:u,getDeviceId:()=>m??"",onTickEnd:()=>N.retryPending().catch(Ne=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Ne)})),onAuthFailures:J})),S.start(),E(),qt&&na(t,f).catch(Ne=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ne)}));let nr;return U.agent_id&&(nr=await NS(U.agent_id,t,f,Ne=>u.sendRequest("_agent/detail",Ne),K).catch(Ne=>(j.error("--agent-id ensureAgent failed",{agentId:U.agent_id,err:String(Ne)}),{ok:!1,agentId:U.agent_id??"",note:String(Ne)}))),{ok:!0,note:"paired with cloud",...nr?{agent:nr}:{}}}catch(Ce){return j.error("_agent/pair failed",{err:String(Ce)}),{ok:!1,note:`pair failed: ${String(Ce)}`}}}},{method:"POST",path:"/connect",handler:D=>P(D)},{method:"POST",path:"/_agent/create",handler:async D=>{let U=D;return{ok:!0,result:await f.createAgent(U)}}},{method:"POST",path:"/agent/send",handler:async D=>{let U=D;if(!U?.agentId||!U?.sessionId||!U?.kind||!U?.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 K=U;return await(K.groupFile?th:eh)(K,{core:u,patToken:x,handshakeBase:_,ppeOverride:v})}catch(K){if(K instanceof T)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/reload",handler:async D=>{let U=D?.agent_id,K=await u.reloadAgents(U);return j.info("IPC /reload: recycled agent subprocesses",{agentId:U??"(all)",recycled:K}),{ok:!0,recycled:K}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{se.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ne,token:Y}=await V.start();try{await Gx(t.libEntry,t)}catch(D){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(D)})}await u.start(),MS({paths:t,core:u,agentManager:f,detectAll:async()=>(o.frameworksCache=await new Jn().detectAll(),await Wi(o),o.frameworksCache)}).catch(D=>j.warn("startup warmup error (ignored)",{err:String(D)})),Rl().then(async()=>{let{probeAcpVersion:D}=await Promise.resolve().then(()=>(an(),kl));for(let U of["claude-code","codex"]){let K=await D(U);K&&j.info("acp wrapper version",{framework:U,version:K})}}).catch(D=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(D)}));let ie=null,se={port:ne,token:Y,core:u,ipc:V,shutdown(D){return ie||(j.info("daemon shutdown",{reason:D}),ie=(async()=>{S?.stop(),I?.stop(),await u.stop(D),await V.stop(),await e.release()})(),ie)}};for(let D of["SIGTERM","SIGINT"])process.on(D,()=>{se.shutdown(D).then(()=>process.exit(0))});return process.on("exit",()=>w0()),process.on("unhandledRejection",D=>{j.error("unhandledRejection",{reason:D instanceof Error?D.message:String(D),stack:D instanceof Error?D.stack:void 0})}),process.on("uncaughtException",D=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:D.message,stack:D.stack,name:D.name});try{process.stderr.write(`FATAL uncaughtException: ${D.stack??D.message}
|
|
112
|
+
`)}catch{}process.exit(1)}),j.info("daemon ready",{port:ne,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),FS({cliSpawned:process.env[ss]==="1",readPatToken:()=>Zo(t),connect:P}).catch(D=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(D)})),se}async function OS(t){return xs(t).length>0}function ta(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function $x(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function LS(t,e){let r=xs(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(ln(),gs));for(let c of r){await o(c,t).catch(d=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(d)}));try{let d=await i(c,t);d?.deletedAt?(e.disconnectedAgents.add(c),j.info("agent marked deleted on startup",{agentId:c,deletedAt:d.deletedAt,reason:d.deleteReason??""})):d?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:d.disconnectedAt,reason:d.disconnectReason??""}))}catch(d){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(d)})}}}async function NS(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(ln(),gs)),d=await c(t,e);if(d){if(d.deletedAt)throw new T("AGENT_NOT_FOUND",`agent ${t} \u5DF2\u88AB\u5220\u9664 (deletedAt=${d.deletedAt}), \u4E0D\u80FD\u901A\u8FC7 --agent-id \u590D\u6D3B`);j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let g=Jx(d),m={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...o?{patToken:o}:{},...g?{_meta:g}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:d.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new T("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let f={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(f);let x=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:x?"cloud agent acknowledged":"created from cloud detail"}}async function MS(t){let e=t.logger??j;try{let r=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(r??{})})}catch(r){e.warn("framework detection failed (using cached)",{err:String(r)})}await LS(t.paths,t.core).catch(r=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(r)})),await na(t.paths,t.agentManager).catch(r=>e.warn("auto-revive top-level error (ignored)",{err:String(r)})),await BS(t.paths).catch(r=>e.warn("builtin skill refresh top-level error (ignored)",{err:String(r)}))}async function na(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(()=>(ln(),gs));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,d=0;for(let u of i){let f;try{f=await o(u,t)}catch(x){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(x)}),d+=1;continue}if(!f){d+=1;continue}if(f.deletedAt){j.info("auto-revive: skip deleted agent",{agentId:u,deletedAt:f.deletedAt}),d+=1;continue}if(f.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:f.disconnectedAt}),d+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:f.framework});let x=Jx(f);await e.createAgent({agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...x?{_meta:x}:{}},{revive:!0}),c+=1}catch(x){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:f.framework,err:String(x)}),d+=1}}return j.info("auto-revive: done",{revived:c,skipped:d,total:i.length}),{revived:c,skipped:d,total:i.length}}async function BS(t){let{readdir:e}=await import("node:fs/promises"),r;try{r=await e(t.agentsRoot)}catch{return{refreshed:0,total:0}}if(r.length===0)return{refreshed:0,total:0};let i=0;for(let o of r)try{(await s0(o,t)).status==="refreshed"&&(i+=1)}catch(c){j.warn("refresh builtin skills failed (skipping agent)",{agentId:o,err:String(c)})}return i>0&&j.info("builtin skills refresh on startup done",{refreshed:i,total:r.length}),{refreshed:i,total:r.length}}async function FS(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Jx(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Qo();Me();import{readFile as Zx}from"node:fs/promises";var tn=class{paths;constructor(e){this.paths=e??Q()}async probe(e=1e3){let r=await ra(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:US(i)}}}async request(e){let r=await ra(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,d=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),f=await u.text();return{status:u.status,body:zS(f)}}finally{clearTimeout(d)}}};async function ra(t){try{let[e,r]=await Promise.all([Zx(t.portFile,"utf8"),Zx(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 zS(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function US(t){return t instanceof Error?t.message:String(t)}Jt();te();or();import{spawn as qS}from"node:child_process";import{userInfo as Xx}from"node:os";var Gd="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",GS=new Set(["bash","zsh","sh","dash","ksh"]),Yx=Ze("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),HS=2e3;function jS(t,e=Gd){let r=t.indexOf(e);if(r===-1)return null;let i=t.indexOf(e,r+e.length);if(i===-1)return null;let o=t.slice(r+e.length,i),c={};for(let d of o.split(`
|
|
113
|
+
`)){let u=d.indexOf("=");u<=0||(c[d.slice(0,u)]=d.slice(u+1))}return c}function KS(){let t=(process.env.SHELL??"").trim()||(Xx().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return GS.has(e)?t:null}function WS(t){return new Promise(e=>{let r=`printf '%s' '${Gd}'; env; printf '%s' '${Gd}'`,i;try{i=qS(t,["-ilc",r],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??Xx().homedir}})}catch{e(null);return}let o="",c=!1,d=g=>{try{i.pid&&process.kill(-i.pid,g)}catch{}},u=g=>{c||(c=!0,clearTimeout(f),clearTimeout(x),e(g))};i.stdout?.on("data",g=>{o+=g.toString("utf8")}),i.on("error",()=>u(null)),i.on("close",()=>u(o.length>0?o:null));let f=setTimeout(()=>d("SIGTERM"),Yx),x=setTimeout(()=>{d("SIGKILL"),u(o.length>0?o:null)},Yx+HS)})}async function Hd(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let r=KS();if(!r)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??WS)(r);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=jS(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}Me();function Dn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],d=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,d=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),d=!0;break}}d||r.push(c)}return{value:i,rest:r}}an();import{chmod as $S,copyFile as Qx,mkdir as tp,readFile as ia,rename as ep,rm as jd,stat as np,writeFile as VS}from"node:fs/promises";import{homedir as i3}from"node:os";import{dirname as JS,join as Vr,resolve as Kd,sep as os}from"node:path";import{fileURLToPath as ZS}from"node:url";Jt();te();Me();var Wd=H("dist-install");function YS(t){let e=ZS(t),r=JS(e),i=`${os}src${os}`;if(r.includes(i)||r.endsWith(`${os}src${os}cli`))return null;let o=Kd(r,"index.js"),c=Kd(r,"..","package.json");return{dist:o,pkgJson:c}}async function Vd(t={}){let e=t.paths??Q(),r=YS(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,d;try{let v=JSON.parse(await ia(o,"utf8"));c=v.version??"unknown",d=v.dependencies??{}}catch(v){return Wd.warn("cannot read source package.json,skip dist install",{err:String(v)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(v)}`}}let u=ri.map(v=>`${v}@${d[v]??"latest"}`),f=await Io(e.configFile)??{},x=f.libVersion,g=await ia(e.libEntry).then(()=>!0).catch(()=>!1),m=x===c;if(m&&g&&await $d(e))return{kind:"already-current",libVersion:c};if(!m||!g){await tp(e.libDir,{recursive:!0}),await Qx(i,e.libEntry),await Qx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let v=Kd(e.libDir,"package.json"),_=`${JSON.stringify({type:"module"},null,2)}
|
|
114
|
+
`;await ia(v,"utf8").catch(()=>null)!==_&&await VS(v,_)}return(!m||!await $d(e))&&await(t.installWrappers??XS)(e,u),f.libVersion=c,await Wi(f,e.configFile),Wd.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),m&&g?{kind:"already-current",libVersion:c}:x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function $d(t){for(let e of ri){let r=Vr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await np(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function XS(t,e){await t1(t.installLock,async()=>{if(await $d(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${os}.staging-${process.pid}-${r}`,o=Vr(i,"node_modules"),c=Vr(t.libDir,"node_modules");try{await tp(i,{recursive:!0}),await QS(e,i),await e1(o);let d=`${c}.trash-${r}`;await ep(c,d).catch(()=>{}),await ep(o,c),await jd(d,{recursive:!0,force:!0}).catch(()=>{}),Wd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await jd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function QS(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=st("npm",r,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d.length<8192&&(d+=f.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",f=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(f)}`))}),c.once("close",f=>{clearTimeout(u),f===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${f}: ${d.trim().slice(0,2e3)}`))})})}async function e1(t){for(let e of ri){let r=Vr(t,...e.split("/")),i=JSON.parse(await ia(Vr(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=Vr(t,".bin",o),d=await np(c);process.platform!=="win32"&&!(d.mode&73)&&await $S(c,d.mode|73).catch(()=>{})}}async function t1(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 jd(t,{force:!0}).catch(()=>{})}}Aa();te();Me();import{closeSync as ip,fstatSync as sp,openSync as op,readFileSync as n1,readSync as r1,readdirSync as i1,statSync as s1}from"node:fs";import{join as sa}from"node:path";var o1=new Set(["debug","info","warn","error"]);function ap(t){let e=t,r=Dn(e,"--agent-id");e=r.rest;let i=Dn(e,"--date");e=i.rest;let o=Dn(e,"-n","--lines");e=o.rest;let c=Dn(e,"--level");e=c.rest;let d=Dn(e,"--grep");e=d.rest;let u=o.value===void 0?200:Number(o.value),f=Number.isInteger(u)&&u>=0?u:200,x=c.value&&o1.has(c.value)?c.value:void 0,g={lines:f,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(g.agentId=r.value),i.value&&(g.date=i.value),x&&(g.level=x),d.value&&(g.grep=d.value),g}function a1(t,e){return t.agentId?sa(Ye(t.agentId,e).logs,ar("agent",t.date)):sa(e.bridgeLogsDir,ar("bridge",t.date))}function c1(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function d1(t,e){let r;try{r=i1(t)}catch{return[]}let i=[];for(let o of r){let c=Ia(o,e);if(!c)continue;let d=0;try{d=s1(sa(t,o)).size}catch{}i.push({file:sa(t,o),date:c,size:d})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function cp(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"&&!vl(r,e.level))return!1}return!0}var rp={debug:"90",info:"36",warn:"33",error:"31"},l1=new Set(["ts","level","module","msg"]);function u1(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function dp(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=u1(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&rp[o]&&(c=`\x1B[${rp[o]}m${c}\x1B[0m`);let d=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",f=Object.entries(r).filter(([x])=>!l1.has(x)).map(([x,g])=>` ${x}=${typeof g=="string"?g:JSON.stringify(g)}`).join("");return`${i} ${c} ${d} ${u}${f}`}function f1(t,e,r){let c=n1(t,"utf8").split(`
|
|
115
|
+
`).filter(d=>d.length>0).filter(d=>cp(d,{level:e.level,grep:e.grep}));for(let d of c1(c,e.lines))process.stdout.write(`${dp(d,{raw:e.raw,color:r})}
|
|
116
|
+
`)}async function lp(t,e){let r=e.paths??Q(),i=process.stdout.isTTY===!0;if(t.list){let d=t.agentId?Ye(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",f=d1(d,u);if(f.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${d}
|
|
117
|
+
`),1;for(let x of f)process.stdout.write(`${x.date} ${(x.size/1024).toFixed(1)}KB ${x.file}
|
|
118
|
+
`);return 0}let o=t.date??On(new Date),c=a1({agentId:t.agentId,date:o},r);try{f1(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
117
119
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
118
120
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
119
|
-
`),1}return t.follow&&await
|
|
120
|
-
`);o=
|
|
121
|
-
`)}await new Promise(
|
|
121
|
+
`),1}return t.follow&&await p1(c,t,i),0}var h1=500;function x1(t){try{let e=op(t,"r");try{return sp(e).size}finally{ip(e)}}catch{return 0}}async function p1(t,e,r){let i=x1(t),o="",c=!1,d=()=>{c=!0};process.on("SIGINT",d);try{for(;!c;){let u="";try{let f=op(t,"r");try{let x=sp(f).size;if(x>i){let g=Buffer.allocUnsafe(x-i),m=r1(f,g,0,g.length,i);u=g.subarray(0,m).toString("utf8"),i+=m}}finally{ip(f)}}catch{}if(u){let f=(o+u).split(`
|
|
122
|
+
`);o=f.pop()??"";for(let x of f)x.length>0&&cp(x,{level:e.level,grep:e.grep})&&process.stdout.write(`${dp(x,{raw:e.raw,color:r})}
|
|
123
|
+
`)}await new Promise(f=>setTimeout(f,h1))}}finally{process.off("SIGINT",d)}}import{basename as g1,resolve as m1}from"node:path";Me();var w1=9e4,_1={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,OPERATION_NOT_ALLOWED_FOR_CLOUD:1,METHOD_NOT_FOUND:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1,SKILL_NOT_FOUND:1,SKILL_ZIP_TOO_LARGE:1};function y1(t){return _1[t]??1}async function up(t,e={}){let r=e.paths??Q();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
122
124
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
123
|
-
`),3;let i=await
|
|
124
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
125
|
+
`),3;let i=await ra(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.
|
|
126
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:m1(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 b1(i,"/agent/send",o,w1)}catch(d){return process.stderr.write(`Error: daemon IPC failed: ${d instanceof Error?d.message:String(d)}
|
|
125
127
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
126
|
-
`),
|
|
127
|
-
`);else{let
|
|
128
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
129
|
-
`)}return 0}async function
|
|
130
|
-
`)}function
|
|
128
|
+
`),y1(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
129
|
+
`);else{let d=t.name??g1(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${d} (uri=${u})
|
|
130
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${d} (${E1(c.bytes)})
|
|
131
|
+
`)}return 0}async function b1(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let d=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),u=await d.text(),f=u?JSON.parse(u):null;return f&&typeof f=="object"&&"ok"in f?f:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${d.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function E1(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var yp=H("cli");function We(t,e){let{value:r,rest:i}=Dn(t,e);return{value:r,rest:i}}function ua(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
132
|
+
`)}function W1(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:P}=We(e.slice(1),"--agent-id");return P?{mode:"reload",agentId:P}:{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 $1(e.slice(1));if(e[0]==="log")return{mode:"log",...ap(e.slice(1))};if(e[0]==="connect")return V1(e.slice(1));if(e.includes("--status"))return ua("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ua("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ua("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ua("--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}=We(r,"--pat-token");r=o;let{value:c,rest:d}=We(r,"--pair-code");r=d;let{value:u,rest:f}=We(r,"--env");r=f;let{value:x,rest:g}=We(r,"--handshake-url");r=g;let{value:m,rest:v}=We(r,"--frontier-url");r=v;let{value:_,rest:S}=We(r,"--mock-scenario");r=S;let{value:I}=We(r,"--agent-id"),A=r.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let k={mode:"pair",privatecode:i,pairingCode:c};return u&&(k.env=u),x&&(k.handshakeUrl=x),m&&(k.frontierUrl=m),_&&(k.mockScenario=_),I&&(k.agentId=I),A&&(k.skipRebuildEnv=!0),k}function $1(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}=We(i,"--caption");i=c;let{value:d,rest:u}=We(i,"--name");i=u;let{value:f,rest:x}=We(i,"--agent-id");i=x;let{value:g,rest:m}=We(i,"--session-id");i=m;let{value:v,rest:_}=We(i,"--mime");i=_;let S=i.includes("--group-file");i=i.filter(k=>k!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:r,json:I};return o&&(A.caption=o),d&&(A.name=d),f&&(A.agentId=f),g&&(A.sessionId=g),S&&(A.groupFile=!0),v&&(A.mimeType=v),A}function V1(t){let e=t,{value:r,rest:i}=We(e,"--pat-token");e=i;let{value:o,rest:c}=We(e,"--env");e=c;let{value:d,rest:u}=We(e,"--handshake-url");e=u;let{value:f,rest:x}=We(e,"--frontier-url");e=x;let{value:g,rest:m}=We(e,"--mock-scenario");e=m;let v=e.includes("--skip-rebuild-env"),_={mode:"connect"};return r&&(_.privatecode=r),o&&(_.env=o),d&&(_.handshakeUrl=d),f&&(_.frontierUrl=f),g&&(_.mockScenario=g),v&&(_.skipRebuildEnv=!0),_}var J1=`
|
|
131
133
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
132
134
|
|
|
133
135
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -208,57 +210,57 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
208
210
|
|
|
209
211
|
Internal:
|
|
210
212
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
211
|
-
`.trimStart();async function
|
|
212
|
-
`),0;case"daemon":{try{await
|
|
213
|
-
`),1;if(i.kind==="stale")return await
|
|
213
|
+
`.trimStart();async function bp(t=process.argv,e={}){let r=W1(t);switch(r.mode){case"help":return process.stdout.write(J1),0;case"version":return process.stdout.write(`${Nt}
|
|
214
|
+
`),0;case"daemon":{try{await Vx()}catch(i){return yp.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return Z1(e);case"stop":return vp(e);case"reload":return Q1(r.agentId,e);case"log":return lp(r,e);case"update":return Y1(e);case"purge":return eI(e);case"service-install":return tI(e);case"service-uninstall":return nI(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),rI(r.privatecode,r.pairingCode,e,i,r.agentId,r.skipRebuildEnv)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),iI(r.privatecode,e,i,r.skipRebuildEnv)}case"send":return up({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 Ep(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 Z1(t){let e=t.paths??Q(),r=new tn(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
215
|
+
`),1;if(i.kind==="stale")return await Ep(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
214
216
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
215
217
|
${JSON.stringify(o.body,null,2)}
|
|
216
|
-
`),0}async function
|
|
217
|
-
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(
|
|
218
|
+
`),0}async function vp(t){let e=t.paths??Q(),r=new tn(e),i=t.daemonSweep??(async()=>{let f=_0();return await y0(f),f}),o=async()=>{t.skipProcessKill||await i(e)},c=await cs(t),d=!1;if(c)try{await c.uninstall(),d=!0}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
219
|
+
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(d?`coze-bridge: stopped
|
|
218
220
|
`:`coze-bridge: not running
|
|
219
|
-
`),0;if(u.kind==="stale")return await
|
|
221
|
+
`),0;if(u.kind==="stale")return await Ep(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
220
222
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),await o(),process.stdout.write(`coze-bridge: stopped
|
|
221
|
-
`),0}catch(
|
|
222
|
-
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(
|
|
223
|
-
`),1)}}async function
|
|
224
|
-
`),e(1)})})}async function
|
|
223
|
+
`),0}catch(f){return(await r.probe()).kind!=="connected"?(await o(),process.stdout.write(`coze-bridge: stopped
|
|
224
|
+
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(f)}
|
|
225
|
+
`),1)}}async function Y1(t){return await vp(t),(t.spawnNpx??X1)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function X1(t){return new Promise(e=>{let r=st("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)}
|
|
226
|
+
`),e(1)})})}async function Q1(t,e){let r=new tn(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
225
227
|
`),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
226
228
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
227
229
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
228
230
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
229
|
-
`),1}}async function
|
|
231
|
+
`),1}}async function cs(t){if(t.supervisor){let c=t.supervisor,d={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(d,u),uninstall:()=>c.uninstall(d)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(wp(),mp)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Sp(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??Wx,o=t.waitTimeoutMs??15e3,c=t.sleep??oI,d=t.paths??Q(),u=await cs(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let f=await _p(e,o,c);if(f.kind==="connected")return f;kt(d.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(f){kt(d.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(f)})}kt(d.bridgeLogsDir,"warn","cli","\u79FB\u9664\u5F00\u673A\u81EA\u542F\u914D\u7F6E (supervisor \u63A5\u7BA1\u672A\u6210\u529F, \u56DE\u9000\u624B\u52A8 spawn; \u4E0B\u6B21\u91CD\u542F\u4E0D\u518D\u81EA\u542F, \u9700\u91CD\u65B0 service install)",{platform:u.platform}),await u.uninstall().catch(()=>{}),await sI(d.pidFile,c)}else u&&await u.install({activate:!1}).catch(f=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(f)}
|
|
230
232
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
231
|
-
`),await i({paths:t.paths}),
|
|
232
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
233
|
-
`)}await new Promise(
|
|
234
|
-
`)}catch(
|
|
233
|
+
`),await i({paths:t.paths}),_p(e,o,c)}async function eI(t){let e=new tn(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
234
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
|
|
235
|
+
`)}await new Promise(d=>setTimeout(d,500))}let i=await cs(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
236
|
+
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
235
237
|
`)}let o=t.paths??Q(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
236
|
-
`)}catch(
|
|
238
|
+
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
237
239
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
238
|
-
`),0}async function
|
|
240
|
+
`),0}async function tI(t){let e=await cs(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
239
241
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
240
242
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
241
|
-
`),1}}async function
|
|
243
|
+
`),1}}async function nI(t){let e=await cs(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
242
244
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),
|
|
245
|
-
`),(await
|
|
246
|
-
`)}let
|
|
247
|
-
`),1;let
|
|
245
|
+
`),1}}async function Ip(t,e,r){if(e)return kt(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await r();return i.kind==="ok"?(kt(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(kt(t.bridgeLogsDir,"info","cli","agent-env: rebuild not applicable, use process.env",{reason:i.reason}),process.env):(process.stderr.write(`coze-bridge: \u91CD\u5EFA shell \u73AF\u5883\u5931\u8D25, \u56DE\u9000\u5F53\u524D\u8FDB\u7A0B\u73AF\u5883 (\u53EF\u7528 --skip-rebuild-env \u663E\u5F0F\u8DF3\u8FC7)
|
|
246
|
+
`),kt(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function rI(t,e,r,i={},o,c){let d=new tn(r.paths),u=r.paths??Q(),f=await Ip(u,c,r.reconstructEnv??Hd);if(await td(u,f).catch(m=>kt(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(m)})),!r.skipDistInstall){let m=await Vd({paths:r.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
247
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
248
|
+
`)}let x=await Sp(r,d);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
249
|
+
`),1;let g={privatecode:t,pairing_code:e};i.env&&(g.env=i.env),i.handshakeUrl&&(g.handshake_url=i.handshakeUrl),i.frontierUrl&&(g.frontier_url=i.frontierUrl),i.mockScenario&&(g.mock_scenario=i.mockScenario),o&&(g.agent_id=o);try{let m=await d.request({method:"POST",path:"/pair",body:g,timeoutMs:35e3});if(m.status===200&&m.body?.ok){let v=m.body.agent;return v&&!v.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${v.agentId}): ${v.note}
|
|
248
250
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
249
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
250
|
-
`),1}catch(
|
|
251
|
-
`),1}}async function
|
|
252
|
-
`),(await
|
|
253
|
-
`)}let
|
|
254
|
-
`),1;let
|
|
255
|
-
`),t!==void 0&&await
|
|
256
|
-
`),1)}catch(
|
|
257
|
-
`),1}}async function
|
|
251
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
|
|
252
|
+
`),1}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
|
|
253
|
+
`),1}}async function iI(t,e,r={},i){let o=e.paths??Q(),c=t??await Zo(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let d=new tn(e.paths),u=await Ip(o,i,e.reconstructEnv??Hd);if(await td(o,u).catch(g=>kt(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(g)})),!e.skipDistInstall){let g=await Vd({paths:e.paths});g.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${g.fromVersion} \u2192 ${g.toVersion}
|
|
254
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):g.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${g.libVersion}
|
|
255
|
+
`)}let f=await Sp(e,d);if(f.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
256
|
+
`),1;let x={privatecode:c};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let g=await d.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return g.status===200&&g.body?.ok?(process.stdout.write(`coze-bridge: connected (${g.body.note??"ok"})
|
|
257
|
+
`),t!==void 0&&await is(c,o).catch(m=>yp.warn("writePatToken after connect failed (ignored)",{err:String(m)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(g.body)}
|
|
258
|
+
`),1)}catch(g){return process.stderr.write(`coze-bridge: connect failed: ${String(g)}
|
|
259
|
+
`),1}}async function _p(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 sI(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let d;try{d=await o(t,"utf8")}catch{return}let u=Number.parseInt(d.trim(),10);if(!Number.isFinite(u)||u<=0||!Gi(u))return;await e(i)}}function oI(t){return new Promise(e=>setTimeout(e,t))}te();function aI(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 Ap(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=aI(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
|
|
258
260
|
`),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
259
261
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
260
262
|
npx -y coze-bridge@latest stop
|
|
261
263
|
npx -y coze-bridge@latest connect
|
|
262
264
|
|
|
263
|
-
`)}
|
|
265
|
+
`)}Ap();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&bl("warn");bp(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
264
266
|
`),process.exit(1)});
|