coze-bridge 0.1.99-alpha.1 → 0.1.99
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 +78 -79
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,34 +5,34 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
8
|
+
var Gp=Object.create;var ya=Object.defineProperty;var qp=Object.getOwnPropertyDescriptor;var Hp=Object.getOwnPropertyNames;var jp=Object.getPrototypeOf,Wp=Object.prototype.hasOwnProperty;var le=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var oe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ba=(t,e)=>{for(var r in e)ya(t,r,{get:e[r],enumerable:!0})},Kp=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Hp(e))!Wp.call(t,o)&&o!==r&&ya(t,o,{get:()=>e[o],enumerable:!(i=qp(e,o))||i.enumerable});return t};var St=(t,e,r)=>(r=t!=null?Gp(jp(t)):{},Kp(e||!t||!t.__esModule?ya(r,"default",{value:t,enumerable:!0}):r,t));function Je(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var $r=Ye(()=>{"use strict"});import{createWriteStream as $p,mkdirSync as Vp,readdirSync as Yp,unlinkSync as Jp}from"node:fs";import{join as ol}from"node:path";function In(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Xn(t,e){return`${t}-${e}.log`}function Ea(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Zp(t,e,r){let i=c=>{let[l,f,x]=c.split("-").map(Number);return Date.UTC(l??0,(f??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function is(t,e,r,i){let o;try{o=Yp(t)}catch{return}for(let c of o){let l=Ea(c,e);if(l&&Zp(l,r,i))try{Jp(ol(t,c))}catch{}}}var Vr,va=Ye(()=>{"use strict";Vr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>In(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Vp(this.dir,{recursive:!0});let r=$p(ol(this.dir,Xn(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await _0(o,i,{encoding:"utf8",mode:r.mode}):await _0(o,i,"utf8"),await w0(o,t),r?.mode!==void 0&&await dg(t,r.mode)}catch(c){await w0(o,o).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(o,{force:!0}).catch(()=>{}),c}}var Xr=Ye(()=>{"use strict"});import{promises as y0,readdirSync as xg}from"node:fs";import{homedir as hg}from"node:os";import{sep as pg,join as Te,resolve as b0}from"node:path";function X(t){let e=t??hg(),r=Te(e,".coze"),i=Te(r,"bridge"),o=Te(i,"lib"),c=Te(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Te(o,"index.js"),binDir:Te(i,"bin"),pidFile:Te(i,"bridge.pid"),portFile:Te(i,"bridge.port"),tokenFile:Te(i,"bridge.token"),patTokenFile:Te(i,"pat-token"),agentEnvFile:Te(i,"agent-env.json"),logFile:Te(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Te(c,"daemon-stdio.log"),installLock:Te(i,"install.lock"),configFile:Te(i,"config.json"),agentsRoot:Te(r,"agents")}}function $e(t,e=X()){let r=Te(e.agentsRoot,t);return{root:r,config:Te(r,"config.json"),workspace:Te(r,"workspace"),logs:Te(r,"logs")}}function as(t=X()){try{return xg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Qr(t,e){let r=await y0.realpath(b0(t)).catch(()=>null);if(!r)return!1;let i=await y0.realpath(b0(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+pg)}var Oe=Ye(()=>{"use strict"});var us={};_a(us,{AGENT_CONFIG_FILE_MODE:()=>cs,enforceAgentConfigMode:()=>wg,loadAgentConfig:()=>je,persistAgentSessions:()=>ei,persistAgentSkills:()=>ds,saveAgentConfig:()=>Ze});import{chmod as gg,stat as mg}from"node:fs/promises";function je(t,e){return rr($e(t,e).config)}function Ze(t,e){return ir($e(t.agentId,e).config,t,{mode:cs})}async function wg(t,e){if(process.platform==="win32")return;let r=$e(t,e).config;try{let i=await mg(r);if(!i.isFile())return;let o=i.mode&511;o!==cs&&(await gg(r,cs),E0.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;E0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ei(t,e,r){let i=await je(t,r);i&&(i.sessions=Object.fromEntries(e),await Ze(i,r))}async function ds(t,e,r){let i=await je(t,r);i&&(i.skills=e,await Ze(i,r))}var E0,cs,nn=Ye(()=>{"use strict";Xr();ne();Oe();E0=H("agent-config"),cs=384});var Ta=se((VS,A0)=>{A0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var fs=se(C0=>{var T0={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 vg(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(T0))C0[t]=vg(T0[t])});var N0=se((YS,O0)=>{var Sg=ue("fs"),Ne=ue("path"),D0=Ta(),Ig=fs(),Ag=typeof process=="object"&&process.platform==="win32",R0=t=>typeof t=="object"&&t!==null,k0=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function ve(t){this.sep=Ne.sep,this.fs=Sg,R0(t)&&R0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}O0.exports=ve;ve.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var u;try{u=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(u&&u.isFile())throw Ig.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var u=Ne.dirname(t);o.fs.existsSync(u)||o.makeDir(u);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};ve.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(u){if(u&&!r)return o(!1);c.fs.stat(t,function(f,x){if(u&&x.isDirectory())return o(!1);var p=Ne.dirname(t);c.fs.exists(p,function(b){b||c.makeDir(p),c.fs.open(t,"w",438,function(E,T){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):T?c.fs.write(T,e,0,e.length,0,function(){c.fs.close(T,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let u=[];return e.fs.readdirSync(i).forEach(function(f){let x=Ne.join(i,f),p=e.fs.statSync(x);(!o||o.test(x))&&u.push(Ne.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(u=u.concat(r(x,o,c)))}),u}return r(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let u=c.length;if(!u)return e(null,i);c.forEach(function(f){f=Ne.join(t,f),r.fs.stat(f,function(x,p){if(x)return e(x);p&&(i.push(Ne.normalize(f)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(f,function(b,E){if(b)return e(b);i=i.concat(E),--u||e(null,i)}):--u||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return k0[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case D0.STORED:return"STORED ("+t+")";case D0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.posix.join(".",e)};ve.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ve.sanitize=function(t,e){t=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)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};ve.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};ve.isWin=Ag;ve.crcTable=k0});var L0=se((ZS,P0)=>{var Tg=ue("path");P0.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=Tg.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 B0=se((XS,M0)=>{M0.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var ar=se((QS,or)=>{or.exports=N0();or.exports.Constants=Ta();or.exports.Errors=fs();or.exports.FileAttr=L0();or.exports.decoder=B0()});var z0=se((e2,F0)=>{var rn=ar(),z=rn.Constants;F0.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,u=0,f=0,x=0,p=0,b=0,E=0,T=0,y=0,v=0;t|=rn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},S=_=>Math.max(0,_)>>>0,D=_=>Math.max(0,_)&65535,P=_=>Math.max(0,_)&255;return o=rn.fromDate2DOS(new Date),{get made(){return t},set made(_){t=_},get version(){return e},set version(_){e=_},get flags(){return r},set flags(_){r=_},get flags_efs(){return(r&z.FLG_EFS)>0},set flags_efs(_){_?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(_){_?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(_){switch(_){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=_},get time(){return rn.fromDOS2Date(this.timeval)},set time(_){_=new Date(_),this.timeval=rn.fromDate2DOS(_)},get timeval(){return o},set timeval(_){o=S(_)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(_){c=S(_)},get compressedSize(){return u},set compressedSize(_){u=S(_)},get size(){return f},set size(_){f=S(_)},get fileNameLength(){return x},set fileNameLength(_){x=_},get extraLength(){return p},set extraLength(_){p=_},get extraLocalLength(){return I.extraLen},set extraLocalLength(_){I.extraLen=_},get commentLength(){return b},set commentLength(_){b=_},get diskNumStart(){return E},set diskNumStart(_){E=S(_)},get inAttr(){return T},set inAttr(_){T=S(_)},get attr(){return y},set attr(_){y=S(_)},get fileAttr(){return(y||0)>>16&4095},get offset(){return v},set offset(_){v=S(_)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+x+p+b},get realDataOffset(){return v+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(_){var R=_.slice(v,v+z.LOCHDR);if(R.readUInt32LE(0)!==z.LOCSIG)throw rn.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 k=v+z.LOCHDR+I.fnameLen,B=k+I.extraLen;return _.slice(k,B)},loadFromBinary:function(_){if(_.length!==z.CENHDR||_.readUInt32LE(0)!==z.CENSIG)throw rn.Errors.INVALID_CEN();t=_.readUInt16LE(z.CENVEM),e=_.readUInt16LE(z.CENVER),r=_.readUInt16LE(z.CENFLG),i=_.readUInt16LE(z.CENHOW),o=_.readUInt32LE(z.CENTIM),c=_.readUInt32LE(z.CENCRC),u=_.readUInt32LE(z.CENSIZ),f=_.readUInt32LE(z.CENLEN),x=_.readUInt16LE(z.CENNAM),p=_.readUInt16LE(z.CENEXT),b=_.readUInt16LE(z.CENCOM),E=_.readUInt16LE(z.CENDSK),T=_.readUInt16LE(z.CENATT),y=_.readUInt32LE(z.CENATX),v=_.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(z.LOCHDR);return _.writeUInt32LE(z.LOCSIG,0),_.writeUInt16LE(e,z.LOCVER),_.writeUInt16LE(r,z.LOCFLG),_.writeUInt16LE(i,z.LOCHOW),_.writeUInt32LE(o,z.LOCTIM),_.writeUInt32LE(c,z.LOCCRC),_.writeUInt32LE(u,z.LOCSIZ),_.writeUInt32LE(f,z.LOCLEN),_.writeUInt16LE(x,z.LOCNAM),_.writeUInt16LE(I.extraLen,z.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(z.CENHDR+x+p+b);return _.writeUInt32LE(z.CENSIG,0),_.writeUInt16LE(t,z.CENVEM),_.writeUInt16LE(e,z.CENVER),_.writeUInt16LE(r,z.CENFLG),_.writeUInt16LE(i,z.CENHOW),_.writeUInt32LE(o,z.CENTIM),_.writeUInt32LE(c,z.CENCRC),_.writeUInt32LE(u,z.CENSIZ),_.writeUInt32LE(f,z.CENLEN),_.writeUInt16LE(x,z.CENNAM),_.writeUInt16LE(p,z.CENEXT),_.writeUInt16LE(b,z.CENCOM),_.writeUInt16LE(E,z.CENDSK),_.writeUInt16LE(T,z.CENATT),_.writeUInt32LE(y,z.CENATX),_.writeUInt32LE(v,z.CENOFF),_},toJSON:function(){let _=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:rn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(u),size:_(f),fileNameLength:_(x),extraLength:_(p),commentLength:_(b),diskNumStart:E,inAttr:T,attr:y,offset:v,centralHeaderSize:_(z.CENHDR+x+p+b)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var H0=se((t2,U0)=>{var cr=ar(),_e=cr.Constants;U0.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 cr.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=cr.readBigUInt64LE(c,_e.ZIP64SUB),e=cr.readBigUInt64LE(c,_e.ZIP64TOT),r=cr.readBigUInt64LE(c,_e.ZIP64SIZE),i=cr.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(u,f){let x=u.toString(16).toUpperCase();for(;x.length<f;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Da=se(Ca=>{Ca.EntryHeader=z0();Ca.MainHeader=H0()});var j0=se((r2,q0)=>{q0.exports=function(t){var e=ue("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],u=0;o.on("data",function(f){c.push(f),u+=f.length}),o.on("end",function(){var f=Buffer.alloc(u),x=0;f.fill(0);for(var p=0;p<c.length;p++){var b=c[p];b.copy(f,x),x+=b.length}i&&i(f)}),o.end(t)}}}});var K0=se((i2,G0)=>{var Cg=+(process.versions?process.versions.node:"").split(".")[0]||0;G0.exports=function(t,e){var r=ue("zlib");let i=Cg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),u=[],f=0;c.on("data",function(x){u.push(x),f+=x.length}),c.on("end",function(){var x=Buffer.alloc(f),p=0;x.fill(0);for(var b=0;b<u.length;b++){var E=u[b];E.copy(x,p),p+=E.length}o&&o(x)}),c.end(t)}}}});var Y0=se((s2,J0)=>{"use strict";var{randomFillSync:W0}=ue("crypto"),Dg=fs(),Rg=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}),V0=(t,e)=>Math.imul(t,e)>>>0,$0=(t,e)=>Rg[(t^e)&255]^t>>>8,ti=()=>typeof W0=="function"?W0(Buffer.alloc(12)):ti.node();ti.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var xs={genSalt:ti};function hs(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])}hs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=$0(e[0],t),e[1]+=e[0]&255,e[1]=V0(e[1],134775813)+1,e[2]=$0(e[2],e[1]>>>24),t};hs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return V0(t,t^1)>>8&255};function kg(t){let e=new hs(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 Og(t){let e=new hs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let u=e.next();i[o++]=c^u,e.updateKeys(c)}return i}}function Ng(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=kg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Dg.WRONG_PASSWORD();return i(t.slice(12))}function Pg(t){Buffer.isBuffer(t)&&t.length>=12?xs.genSalt=function(){return t.slice(0,12)}:t==="node"?xs.genSalt=ti.node:xs.genSalt=ti}function Lg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Og(r),c=xs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let u=Buffer.alloc(t.length+12);return o(c,u),o(t,u,12)}J0.exports={decrypt:Ng,encrypt:Lg,_salter:Pg}});var Z0=se(ps=>{ps.Deflater=j0();ps.Inflater=K0();ps.ZipCrypto=Y0()});var ka=se((a2,X0)=>{var oe=ar(),Mg=Da(),Se=oe.Constants,Ra=Z0();X0.exports=function(t,e){var r=new Mg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,u=null,f=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let b=t,E=typeof b.decoder=="object"?b.decoder:oe.decoder;p=E.hasOwnProperty("efs")?E.efs:!1;function T(){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(oe.crc32(_)!==r.localHeader.crc)return!1}else{let R={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Se.LOCSIG||e.readUInt32LE(k)==Se.CENSIG)throw oe.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Se.EXTSIG)R.crc=e.readUInt32LE(k+Se.EXTCRC),R.compressedSize=e.readUInt32LE(k+Se.EXTSIZ),R.size=e.readUInt32LE(k+Se.EXTLEN);else if(e.readUInt16LE(k+12)===19280)R.crc=e.readUInt32LE(k+Se.EXTCRC-4),R.compressedSize=e.readUInt32LE(k+Se.EXTSIZ-4),R.size=e.readUInt32LE(k+Se.EXTLEN-4);else throw oe.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw oe.Errors.DESCRIPTOR_FAULTY();if(oe.crc32(_)!==R.crc)return!1}return!0}function v(_,R,k){if(typeof R>"u"&&typeof _=="string"&&(k=_,_=void 0),c)return _&&R&&R(Buffer.alloc(0),oe.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=T();if(B.length===0)return _&&R&&R(B),B;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw oe.Errors.INVALID_PASS_PARAM();B=Ra.ZipCrypto.decrypt(B,r,k)}var F=Buffer.alloc(r.size);switch(r.method){case oe.Constants.STORED:if(B.copy(F),y(F))return _&&R&&R(F),F;throw _&&R&&R(F,oe.Errors.BAD_CRC()),oe.Errors.BAD_CRC();case oe.Constants.DEFLATED:var V=new Ra.Inflater(B,r.size);if(_)V.inflateAsync(function(J){J.copy(J,0),R&&(y(J)?R(J):R(J,oe.Errors.BAD_CRC()))});else{if(V.inflate(F).copy(F,0),!y(F))throw oe.Errors.BAD_CRC(`"${E.decode(i)}"`);return F}break;default:throw _&&R&&R(Buffer.alloc(0),oe.Errors.UNKNOWN_METHOD()),oe.Errors.UNKNOWN_METHOD()}}function I(_,R){if((!u||!u.length)&&Buffer.isBuffer(e))return _&&R&&R(T()),T();if(u.length&&!c){var k;switch(r.method){case oe.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(u.length),u.copy(k),_&&R&&R(k),k;default:case oe.Constants.DEFLATED:var B=new Ra.Deflater(u);if(_)B.deflateAsync(function(V){k=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(k),R&&R(k)});else{var F=B.deflate();return r.compressedSize=F.length,F}B=null;break}}else if(_&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function S(_,R){return oe.readBigUInt64LE(_,R)}function D(_){try{for(var R=0,k,B,F;R+4<_.length;)k=_.readUInt16LE(R),R+=2,B=_.readUInt16LE(R),R+=2,F=_.slice(R,R+B),R+=B,Se.ID_ZIP64===k&&P(F)}catch{throw oe.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(_){var R,k,B,F;_.length>=Se.EF_ZIP64_SCOMP&&(R=S(_,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=R)),_.length>=Se.EF_ZIP64_RHO&&(k=S(_,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=k)),_.length>=Se.EF_ZIP64_DSN&&(B=S(_,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=B)),_.length>=Se.EF_ZIP64_DSN+4&&(F=_.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(_){i=oe.toBuffer(_,E.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return f},set extra(_){f=_,r.extraLength=_.length,D(_)},get comment(){return E.decode(o)},set comment(_){if(o=oe.toBuffer(_,E.encode),r.commentLength=o.length,o.length>65535)throw oe.Errors.COMMENT_TOO_LONG()},get name(){var _=E.decode(i);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(_){I(!0,_)},setData:function(_){u=oe.toBuffer(_,oe.decoder.encode),!c&&u.length?(r.size=u.length,r.method=oe.Constants.DEFLATED,r.crc=oe.crc32(_),r.changed=!0):r.method=oe.Constants.STORED},getData:function(_){return r.changed?u:v(!1,null,_)},getDataAsync:function(_,R){r.changed?_(u):v(!0,_,R)},set attr(_){r.attr=_},get attr(){return r.attr},set header(_){r.loadFromBinary(_)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=f.length;var _=r.centralHeaderToBinary(),R=oe.Constants.CENHDR;return i.copy(_,R),R+=i.length,f.copy(_,R),R+=r.extraLength,o.copy(_,R),_},packLocalHeader:function(){let _=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let R=r.localHeaderToBinary(),k=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(k,_),_+=R.length,i.copy(k,_),_+=i.length,x.copy(k,_),_+=x.length,k},toJSON:function(){let _=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),data:_(u)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var tu=se((c2,eu)=>{var Q0=ka(),Bg=Da(),Ge=ar();eu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Bg.MainHeader,u=!1,f=null;let x=new Set,p=e,{noSort:b,decoder:E}=p;t?v(p.readEntries):u=!0;function T(){let S=new Set;for(let D of Object.keys(i)){let P=D.split("/");if(P.pop(),!!P.length)for(let _=0;_<P.length;_++){let R=P.slice(0,_+1).join("/")+"/";S.add(R)}}for(let D of S)if(!(D in i)){let P=new Q0(p);P.entryName=D,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function y(){if(u=!0,i={},c.diskEntries>(t.length-c.offset)/Ge.Constants.CENHDR)throw Ge.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,D=0;D<r.length;D++){var P=S,_=new Q0(p,t);_.header=t.slice(P,P+=Ge.Constants.CENHDR),_.entryName=t.slice(P,P+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(P,P+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(P,P+_.header.commentLength)),S+=_.header.centralHeaderSize,r[D]=_,i[_.entryName]=_}x.clear(),T()}function v(S){var D=t.length-Ge.Constants.ENDHDR,P=Math.max(0,D-65535),_=P,R=t.length,k=-1,B=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),D;D>=_;D--)if(t[D]===80){if(t.readUInt32LE(D)===Ge.Constants.ENDSIG){k=D,B=D,R=D+Ge.Constants.ENDHDR,_=D-Ge.Constants.END64HDR;continue}if(t.readUInt32LE(D)===Ge.Constants.END64SIG){_=P;continue}if(t.readUInt32LE(D)===Ge.Constants.ZIP64SIG){k=D,R=D+Ge.readBigUInt64LE(t,D+Ge.Constants.ZIP64SIZE)+Ge.Constants.ZIP64LEAD;break}}if(k==-1)throw Ge.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,R)),c.commentLength&&(o=t.slice(B+Ge.Constants.ENDHDR)),S&&y()}function I(){r.length>1&&!b&&r.sort((S,D)=>S.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return u||y(),r.filter(S=>!x.has(S))},get comment(){return E.decode(o)},set comment(S){o=Ge.toBuffer(S,E.encode),c.commentLength=o.length},getEntryCount:function(){return u?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return u||y(),i[S]||null},setEntry:function(S){u||y(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,D=!0){u||y();let P=i[S];this.getEntryChildren(P,D).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){u||y();let D=i[S],P=r.indexOf(D);P>=0&&(r.splice(P,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,D=!0){if(u||y(),typeof S=="object")if(S.isDirectory&&D){let P=[],_=S.entryName;for(let R of r)R.entryName.startsWith(_)&&P.push(R);return P}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let D=this.getEntryChildren(S);return D.includes(S)?D.length-1:D.length}return 0},compressToBuffer:function(){u||y(),I();let S=[],D=[],P=0,_=0;c.size=0,c.offset=0;let R=0;for(let F of this.entries){let V=F.getCompressedData();F.header.offset=_;let J=F.packLocalHeader(),te=J.length+V.length;_+=te,S.push(J),S.push(V);let Q=F.packCentralHeader();D.push(Q),c.size+=Q.length,P+=te+Q.length,R++}P+=c.mainHeaderSize,c.offset=_,c.totalEntries=R,_=0;let k=Buffer.alloc(P);for(let F of S)F.copy(k,_),_+=F.length;for(let F of D)F.copy(k,_),_+=F.length;let B=c.toBinary();return o&&o.copy(B,Ge.Constants.ENDHDR),B.copy(k,_),t=k,u=!1,k},toAsyncBuffer:function(S,D,P,_){try{u||y(),I();let R=[],k=[],B=0,F=0,V=0;c.size=0,c.offset=0;let J=function(te){if(te.length>0){let Q=te.shift(),Ee=Q.entryName+Q.extra.toString();P&&P(Ee),Q.getCompressedDataAsync(function(he){_&&_(Ee),Q.header.offset=F;let O=Q.packLocalHeader(),j=O.length+he.length;F+=j,R.push(O),R.push(he);let K=Q.packCentralHeader();k.push(K),c.size+=K.length,B+=j+K.length,V++,J(te)})}else{B+=c.mainHeaderSize,c.offset=F,c.totalEntries=V,F=0;let Q=Buffer.alloc(B);R.forEach(function(he){he.copy(Q,F),F+=he.length}),k.forEach(function(he){he.copy(Q,F),F+=he.length});let Ee=c.toBinary();o&&o.copy(Ee,Ge.Constants.ENDHDR),Ee.copy(Q,F),t=Q,u=!1,S(Q)}};J(Array.from(this.entries))}catch(R){D(R)}}}}});var iu=se((d2,ru)=>{var be=ar(),ye=ue("path"),Fg=ka(),zg=tu(),An=(...t)=>be.findLast(t,e=>typeof e=="boolean"),nu=(...t)=>be.findLast(t,e=>typeof e=="string"),Ug=(...t)=>be.findLast(t,e=>typeof e=="function"),Hg={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};ru.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Hg);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 zg(r,i),{canonical:u,sanitize:f,zipnamefix:x}=be;function p(y){if(y&&c){var v;if(typeof y=="string"&&(v=c.getEntry(ye.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(v=c.getEntry(y.entryName)),v)return v}return null}function b(y){let{join:v,normalize:I,sep:S}=ye.posix;return v(ye.isAbsolute(y)?"/":".",I(S+y.split("\\").join(S)+S))}function E(y){return y instanceof RegExp?(function(v){return function(I){return v.test(I)}})(y):typeof y!="function"?()=>!0:y}let T=(y,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",ye.relative(y,v)+I};return{readFile:function(y,v){var I=p(y);return I&&I.getData(v)||null},childCount:function(y){let v=p(y);if(v)return c.getChildCount(v)},readFileAsync:function(y,v){var I=p(y);I?I.getDataAsync(v):v(null,"getEntry failed for:"+y)},readAsText:function(y,v){var I=p(y);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(y,v,I){var S=p(y);S?S.getDataAsync(function(D,P){if(P){v(D,P);return}D&&D.length?v(D.toString(I||"utf8")):v("")}):v("")},deleteFile:function(y,v=!0){var I=p(y);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(y){var v=p(y);v&&c.deleteEntry(v.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,v){var I=p(y);I&&(I.comment=v)},getZipEntryComment:function(y){var v=p(y);return v&&v.comment||""},updateFile:function(y,v){var I=p(y);I&&I.setData(v)},addLocalFile:function(y,v,I,S){if(o.fs.existsSync(y)){v=v?b(v):"";let D=ye.win32.basename(ye.win32.normalize(y));v+=I||D;let P=o.fs.statSync(y),_=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,_,S,P)}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,v){y=typeof y=="object"?y:{localPath:y};let I=ye.resolve(y.localPath),{comment:S}=y,{zipPath:D,zipName:P}=y,_=this;o.fs.stat(I,function(R,k){if(R)return v(R,!1);D=D?b(D):"";let B=ye.win32.basename(ye.win32.normalize(I));if(D+=P||B,k.isFile())o.fs.readFile(I,function(F,V){return F?v(F,!1):(_.addFile(D,V,S,k),setImmediate(v,void 0,!0))});else if(k.isDirectory())return D+=o.sep,_.addFile(D,Buffer.alloc(0),S,k),setImmediate(v,void 0,!0)})},addLocalFolder:function(y,v,I){if(I=E(I),v=v?b(v):"",y=ye.normalize(y),o.fs.existsSync(y)){let S=o.findFiles(y),D=this;if(S.length)for(let P of S){let _=ye.join(v,T(y,P));I(_)&&D.addLocalFile(P,ye.dirname(_))}}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,v,I,S){S=E(S),I=I?b(I):"",y=ye.normalize(y);var D=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,be.Errors.FILE_NOT_FOUND(y));else if(P)v(void 0,P);else{var _=o.findFiles(y),R=-1,k=function(){if(R+=1,R<_.length){var B=_[R],F=T(y,B).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(F)?o.fs.stat(B,function(V,J){V&&v(void 0,V),J.isFile()?o.fs.readFile(B,function(te,Q){te?v(void 0,te):(D.addFile(I+F,Q,"",J),k())}):(D.addFile(I+F+"/",Buffer.alloc(0),"",J),k())}):process.nextTick(()=>{k()})}else v(!0,void 0)};k()}})},addLocalFolderAsync2:function(y,v){let I=this;y=typeof y=="object"?y:{localPath:y},localPath=ye.resolve(b(y.localPath));let{zipPath:S,filter:D,namefix:P}=y;D instanceof RegExp?D=(function(k){return function(B){return k.test(B)}})(D):typeof D!="function"&&(D=function(){return!0}),S=S?b(S):"",P=="latin1"&&(P=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=k=>k);let _=k=>ye.join(S,P(T(localPath,k))),R=k=>ye.win32.basename(ye.win32.normalize(P(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?v(void 0,be.Errors.FILE_NOT_FOUND(localPath)):k?v(void 0,k):o.findFilesAsync(localPath,function(B,F){if(B)return v(B);F=F.filter(V=>D(_(V))),F.length||v(void 0,!1),setImmediate(F.reverse().reduce(function(V,J){return function(te,Q){if(te||Q===!1)return setImmediate(V,te,!1);I.addLocalFileAsync({localPath:J,zipPath:ye.dirname(_(J)),zipName:R(J)},V)}},v))})})},addLocalFolderPromise:function(y,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},v),(D,P)=>{D&&S(D),P&&I(this)})})},addFile:function(y,v,I,S){y=x(y);let D=p(y),P=D!=null;P||(D=new Fg(i),D.entryName=y),D.comment=I||"";let _=typeof S=="object"&&S instanceof o.fs.Stats;_&&(D.header.time=S.mtime);var R=D.isDirectory?16:0;let k=D.isDirectory?16384:32768;return _?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=D.isDirectory?493:420,R=(R|k<<16)>>>0,D.attr=R,D.setData(v),P||c.setEntry(D),D},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return p(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,v,I,S,D,P){S=An(!1,S),D=An(!1,D),I=An(!0,I),P=nu(D,P);var _=p(y);if(!_)throw be.Errors.NO_ENTRY();var R=u(_.entryName),k=f(v,P&&!_.isDirectory?P:I?R:ye.basename(R));if(_.isDirectory){var B=c.getEntryChildren(_);return B.forEach(function(J){if(J.isDirectory)return;var te=J.getData();if(!te)throw be.Errors.CANT_EXTRACT_FILE();var Q=u(J.entryName),Ee=f(v,I?Q:ye.basename(Q));let he=D?J.header.fileAttr:void 0;o.writeFileTo(Ee,te,S,he)}),!0}var F=_.getData(c.password);if(!F)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!S)throw be.Errors.CANT_OVERRIDE();let V=D?y.header.fileAttr:void 0;return o.writeFileTo(k,F,S,V),!0},test:function(y){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(y);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(y,v,I,S){if(I=An(!1,I),S=nu(I,S),v=An(!1,v),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(D){var P=f(y,u(D.entryName));if(D.isDirectory){o.makeDir(P);return}var _=D.getData(S);if(!_)throw be.Errors.CANT_EXTRACT_FILE();let R=I?D.header.fileAttr:void 0;o.writeFileTo(P,_,v,R);try{o.fs.utimesSync(P,D.header.time,D.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,v,I,S){if(S=Ug(v,I,S),I=An(!1,I),v=An(!1,v),!S)return new Promise((k,B)=>{this.extractAllToAsync(y,v,I,function(F){F?B(F):k(this)})});if(!c){S(be.Errors.NO_ZIP());return}y=ye.resolve(y);let D=k=>f(y,ye.normalize(u(k.entryName))),P=(k,B)=>new Error(k+': "'+B+'"'),_=[],R=[];c.entries.forEach(k=>{k.isDirectory?_.push(k):R.push(k)});for(let k of _){let B=D(k),F=I?k.header.fileAttr:void 0;try{o.makeDir(B),F&&o.fs.chmodSync(B,F),o.fs.utimesSync(B,k.header.time,k.header.time)}catch{S(P("Unable to create folder",B))}}R.reverse().reduce(function(k,B){return function(F){if(F)k(F);else{let V=ye.normalize(u(B.entryName)),J=f(y,V);B.getDataAsync(function(te,Q){if(Q)k(Q);else if(!te)k(be.Errors.CANT_EXTRACT_FILE());else{let Ee=I?B.header.fileAttr:void 0;o.writeFileToAsync(J,te,v,Ee,function(he){he||k(P("Unable to write file",J)),o.fs.utimes(J,B.header.time,B.header.time,function(O){O?k(P("Unable to set times",J)):k()})})}})}}},S)()},writeZip:function(y,v){if(arguments.length===1&&typeof y=="function"&&(v=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(y,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(y,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((D,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let R=k=>k?D(k):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,_,I,S,R)},P)})},toBufferPromise:function(){return new Promise((y,v)=>{c.toAsyncBuffer(y,v)})},toBuffer:function(y,v,I,S){return typeof y=="function"?(c.toAsyncBuffer(y,v,I,S),null):c.compressToBuffer()}}}});import{execFile as k_,spawn as O_,spawnSync as EA}from"node:child_process";import{promisify as N_}from"node:util";function L_(t){if(process.platform!=="win32")return!1;if(Xl.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Xl,"").toLowerCase();return P_.has(r)}function Ql(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return L_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function dt(t,e=[],r={}){return O_(t,e,Ql(t,r))}function ef(t,e=[],r={}){return M_(t,e,Ql(t,r))}var P_,Xl,M_,_n=Ye(()=>{"use strict";P_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Xl=/\.(cmd|bat|ps1)$/i;M_=N_(k_)});var Xf=se(Me=>{"use strict";var M=U;(function(t,e){let r=U,i=t();for(;;)try{if(-parseInt(r(1105))/1*(parseInt(r(946))/2)+-parseInt(r(1823))/3*(-parseInt(r(724))/4)+parseInt(r(1889))/5+-parseInt(r(1160))/6+parseInt(r(391))/7*(parseInt(r(1281))/8)+-parseInt(r(750))/9*(-parseInt(r(1095))/10)+parseInt(r(1618))/11===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Co,907431);var Db=Object[M(1270)+M(1876)],Rb=Object["getOwnPropertyNa"+M(1305)],$f=(t,e)=>function(){return t&&(e=(0,t[Rb(t)[0]])(t=0)),e},kb=(t,e)=>{let r={ygRal:function(o,c,u,f){return o(c,u,f)}};for(var i in e)r.ygRal(Db,t,i,{get:e[i],enumerable:!0})};function Ob(){return qf||(qf=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Nb(){let t=M;return jf||(jf=[IDBCursor[t(1427)+"e"][t(577)],IDBCursor[t(1427)+"e"][t(427)],IDBCursor[t(1427)+"e"][t(427)+t(721)+"ey"]])}function Pb(t){let e=M,r={hqPzk:function(o,c){return o(c)},QXPvk:function(o,c){return o(c)},XsZYD:"nBRcw",SIdKs:"success",cOhOq:e(503),mgApI:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let u=e,f={CHVGD:r[u(964)],qMUYB:u(503)},x=()=>{let E=u;t[E(794)+E(380)+E(1432)](f[E(784)],p),t[E(794)+E(380)+E(1432)](f[E(914)],b)},p=()=>{let E=u;r[E(905)](o,r[E(1014)](Lt,t[E(1080)])),x()},b=()=>{let E=u;if(E(1114)===r[E(1056)])r.hqPzk(c,t[E(503)]),x();else return _0x209db6||(_0x8b19ec=[_0x13c2db,_0x157543,_0x540602,_0x360eea,_0x4bad6a])};t[u(1603)+u(400)](r.SIdKs,p),t[u(1603)+"Listener"](r.cOhOq,b)});return i[e(1822)](o=>{let c=e;r[c(1131)](o,IDBCursor)&&sd[c(1906)](o,t)})[e(799)](()=>{}),Ao[e(1906)](i,t),i}function Lb(t){let e=M,r={vzvUY:function(o){return o()},kOuHA:function(o,c){return o(c)},RaSJw:e(477)+"or",nCcAe:function(o){return o()},VWftR:e(669),wxoIA:"error"};if(Io[e(1006)](t))return;let i=new Promise((o,c)=>{let u=e,f={RNEyx:r[u(622)],MJGDe:r[u(637)],rHsfw:u(959)},x=()=>{let E=u;t[E(794)+"entListener"](f[E(1879)],p),t["removeEv"+E(380)+E(1432)](f[E(563)],b),t[E(794)+E(380)+E(1432)](f[E(446)],b)},p=()=>{r[u(979)](o),x()},b=()=>{let E=u;r[E(1133)](c,t[E(503)]||new DOMException(r[E(1078)],E(477)+"or")),r[E(1692)](x)};t.addEventListener(r[u(622)],p),t[u(1603)+u(400)](r[u(637)],b),t[u(1603)+u(400)](u(959),b)});Io[e(1906)](t,i)}function U(t,e){t=t-380;let r=Co(),i=r[t];if(U.pEFurU===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",b="",E="";for(let T=0,y,v,I=0;v=x.charAt(I++);~v&&(y=T%4?y*64+v:v,T++%4)?b+=String.fromCharCode(255&y>>(-2*T&6)):0)v=p.indexOf(v);for(let T=0,y=b.length;T<y;T++)E+="%"+("00"+b.charCodeAt(T).toString(16)).slice(-2);return decodeURIComponent(E)};U.hFYtct=o,U.XAALEh={},U.pEFurU=!0}let c=r[0],u=t+c,f=U.XAALEh[u];return f?i=f:(i=U.hFYtct(i),U.XAALEh[u]=i),i}function Mb(t){To={PxOCL:function(i,o){return i(o)}}[M(960)](t,To)}function Bb(t){let e=M,r={myIqp:function(i,o){return i(o)},vyXMy:function(i,o){return i(o)},vTxSX:function(i,o){return i(o)},FsCjm:function(i,o){return i(o)},wNXxl:function(i,o){return i(o)},aVVSN:function(i,o){return i===o},csVlE:function(i,o){return i in o}};return r[e(1957)](t,IDBDatabase[e(1427)+"e"][e(1695)+e(1634)])&&!r[e(1670)]("objectSt"+e(422),IDBTransaction.prototype)?function(i,...o){let c=e,u=t.call(r[c(1086)](Ui,this),i,...o);return id[c(1906)](u,i.sort?i[c(518)]():[i]),r.vyXMy(Lt,u)}:Nb().includes(t)?function(...i){let o=e;return t[o(842)](r[o(1622)](Ui,this),i),r[o(574)](Lt,sd[o(734)](this))}:function(...i){let o=e;return r.wNXxl(Lt,t[o(842)](Ui(this),i))}}function Fb(t){let e=M,r={DVGWb:function(i,o){return i===o},IhBKY:e(1132),PBptf:function(i,o){return i(o)},SKevf:function(i){return i()}};return r[e(898)](typeof t,r[e(833)])?r.PBptf(Bb,t):(t instanceof IDBTransaction&&Lb(t),Vf(t,r[e(1506)](Ob))?new Proxy(t,To):t)}function Lt(t){let e=M,r={yxUsE:function(o,c){return o(c)},MxCJz:function(o,c){return o(c)},fyVVH:function(o,c){return o!==c}};if(t instanceof IDBRequest)return r.yxUsE(Pb,t);if(vo[e(1006)](t))return vo[e(734)](t);let i=r[e(925)](Fb,t);return r[e(731)](i,t)&&(vo[e(1906)](t,i),Ao[e(1906)](i,t)),i}var Vf,qf,jf,sd,Io,id,vo,Ao,To,Ui,Gf=$f({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={sLPrJ:"Fgvjd",leOwT:"ZAATp",mRdsm:function(r,i){return r instanceof i},SfpcJ:function(r,i){return r!==i},vQPoj:t(820),pbcfU:function(r,i){return r===i},QaPaF:"done",FAWIR:function(r,i){return r===i},jHyor:t(1187)+t(422),soRRh:function(r,i){return r(i)},KNTHu:function(r,i){return r instanceof i},ypZWK:function(r,i){return r===i},NsOIw:function(r,i){return r===i},uOFWa:"store",uEoNR:function(r,i){return r in i}};Vf=(r,i)=>i[t(1224)](o=>r instanceof o),sd=new WeakMap,Io=new WeakMap,id=new WeakMap,vo=new WeakMap,Ao=new WeakMap,To={get(r,i,o){let c=t;if(e.sLPrJ!==e[c(747)]){if(e[c(1443)](r,IDBTransaction))if(e[c(680)](e.vQPoj,c(820)))_0x4fbabd.d=(u,f)=>{let x=c;for(var p in f)_0x1c1076.o(f,p)&&!_0x5025e9.o(u,p)&&_0x4ed031[x(1270)+x(1876)](u,p,{enumerable:!0,get:f[p]})};else{if(e.pbcfU(i,e[c(1758)]))return Io[c(734)](r);if(e[c(1562)](i,e[c(1010)]))return r[c(1187)+"oreNames"]||id.get(r);if(i==="store")return o[c(1187)+"oreNames"][1]?void 0:o[c(1187)+c(457)](o["objectSt"+c(422)][0])}return e.soRRh(Lt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e.KNTHu(r,IDBTransaction)&&(e[o(529)](i,e.QaPaF)||e[o(756)](i,e[o(1745)]))?!0:e[o(751)](i,r)}},Ui=r=>Ao.get(r)}}),Jf={};kb(Jf,{deleteDB:()=>Ub,openDB:()=>zb,unwrap:()=>Ui,wrap:()=>Lt});function zb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let u=M,f={zrfZS:function(b,E,T,y,v){return b(E,T,y,v)},AaqLD:function(b,E){return b(E)},PjmZh:"close",BgzHP:u(1517)+u(1537),PXgeW:function(b,E){return b===E},CrdLT:u(1018)+u(600)},x=indexedDB.open(t,e),p=f[u(1486)](Lt,x);return i&&(f[u(865)]("XWVUP",u(1288))?(this[u(1532)]=_0x22a3e8,this[u(621)]=null):x[u(1603)+"Listener"](f[u(1306)],b=>{let E=u;f[E(708)](i,f[E(1486)](Lt,x[E(1080)]),b[E(420)+"on"],b[E(1341)+"on"],f[E(1486)](Lt,x[E(1695)+"ion"]))})),r&&x[u(1603)+u(400)](u(1277),()=>r()),p.then(b=>{let E=u;c&&b[E(1603)+E(400)](f[E(943)],()=>c()),o&&b[E(1603)+E(400)](f[E(1441)],()=>o())}).catch(()=>{}),p}function Ub(t,{blocked:e}={}){let r=M,i={BUgVx:r(1277),JiypW:function(c,u){return c(u)}},o=indexedDB[r(539)+r(1572)](t);return e&&o[r(1603)+"Listener"](i[r(1778)],()=>e()),i[r(1890)](Lt,o)[r(1822)](()=>{})}function Kf(t,e){let r=M,i={RwayP:function(x,p){return x|p},qhLxV:function(x,p){return x<<p},wRtpJ:function(x,p){return x|p},HAARG:function(x,p){return x|p},EYnia:function(x,p){return x|p},LvDIv:function(x,p){return x<<p},qOVZO:function(x,p){return x-p},lkixi:function(x,p){return x instanceof p},vNSfz:function(x,p){return x in p},BxJgE:function(x,p){return x===p},HDxNN:r(1358),RujXH:function(x,p){return x!==p},npYpg:function(x,p){return x!==p},GyipI:"TYHXY",PZyjh:r(1941)};if(!(i.lkixi(t,IDBDatabase)&&!i.vNSfz(e,t)&&i[r(1997)](typeof e,i.HDxNN)))return i.RujXH(r(1345),r(941))?void 0:new _0x3909f5(i[r(1850)](i.RwayP(_0x5d827b[0]|i[r(568)](_0x558763[1],8),i[r(568)](_0x5b0084[2],16)),i.qhLxV(_0x592f65[3],24)),i[r(1910)](i[r(1169)](i.EYnia(_0x43a91b[4],i.LvDIv(_0xac4882[5],8)),_0x8ceb42[6]<<16),i[r(568)](_0x22182a[7],24)),_0x56a123);if(So[r(734)](e))return So[r(734)](e);let o=e[r(656)](/FromIndex$/,""),c=i[r(501)](e,o),u=Zf[r(872)](o);if(!(o in(c?IDBIndex:IDBObjectStore).prototype)||!(u||Yf[r(872)](o))){if(i[r(496)](i[r(1704)],i[r(1407)]))return;{let x=_0x11079a[r(464)+"g"](0,i[r(1164)](4,_0x3190da[_0x91699d].length)),p=x[r(1717)](_0x2dfa06);_0x2ee29a=_0x389d7c[r(1717)](p)}}let f=async function(x,...p){let b=r,E=this[b(1695)+b(1634)](x,u?b(859)+"e":b(940)),T=E[b(1066)];return c&&(T=T[b(935)](p[b(1434)]())),(await Promise[b(1936)]([T[o](...p),u&&E.done]))[0]};return So[r(1906)](e,f),f}var Yf,Zf,So,Hb=$f({"node_modules/idb/build/index.js"(){let t=M,e={LQOVf:t(1764),UkoUD:"add",uHOcj:"delete",ydPos:t(734),ilxUm:t(785),AduqR:t(1116),zJNQb:t(595)+"ys",TLrrt:t(1284),EPuau:function(o,c){return o(c)},IJVRm:function(o){return o()}},r=(t(1396)+t(1914))[t(657)]("|"),i=0;for(;;){switch(r[i++]){case"0":Zf=[e.LQOVf,e[t(1253)],e.uHOcj,t(1498)];continue;case"1":Yf=[e[t(1845)],e[t(1422)],e.AduqR,e[t(462)],e[t(1947)]];continue;case"2":Gf();continue;case"3":So=new Map;continue;case"4":e[t(601)](Mb,o=>({...o,get:(c,u,f)=>Kf(c,u)||o[t(734)](c,u,f),has:(c,u)=>!!Kf(c,u)||o[t(1006)](c,u)}));continue;case"5":e[t(606)](Gf);continue}break}}}),qb={idb:function(t){let e=M;t.exports=Promise[e(1391)]()[e(1822)](()=>(Hb(),Jf))[e(1822)](function(r){return r})}},Wf={};function Pt(t){let e=M;var r=Wf[t];if(r!==void 0)return r[e(882)];var i=Wf[t]={exports:{}};return qb[t](i,i[e(882)],Pt),i[e(882)]}Pt.d=(t,e)=>{let r=U;for(var i in e)Pt.o(e,i)&&!Pt.o(t,i)&&Object["definePr"+r(1876)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Pt.o=(e,r)=>Object[t(1427)+"e"][t(843)+"operty"].call(e,r)})(),(()=>{let t=M,e={wmTya:function(r,i){return r!=i},CprGH:t(1549)+"d"};Pt.r=r=>{let i=t;e[i(1736)](e.CprGH,typeof Symbol)&&Symbol[i(1490)+i(894)]&&Object["definePr"+i(1876)](r,Symbol[i(1490)+"Tag"],{value:i(638)}),Object[i(1270)+"operty"](r,i(779)+"le",{value:!0})}})();var De={};function Co(){let t=["tfjqD0G","sufeAuy","BezSDxnO","yKvstxO","zxjHDg9Y","q3j4r2G","z3vKv3G","Dw5KzwzPBMu","rNfgA1O","yK1xru8","t2TLCwW","rKTzDe8","su5Jshu","DMfSDwu","EgXwrgu","EM5NwMy","lcbTyxGGCMu","BwvKAwf0zwW","C1ztqw4","swTVrMm","rKfxsvi","D3nZoI8V","A25Zqvu","x3bPBMDqB24","CMvJB25Uzwm","BhvPsgy","r295wxy","yKTRrgy","AxrmqvK","wxDvru0","DgfIyxnL","y2XVC2u","CfDuBuS","BgnAAfO","ww5Xt0W","x21PBMLoyxy","DhzAvwK","mNWZFdf8mhW","CM92AwrLige","CKPhENC","vw95Egu","zu51qKm","sNvYrwK","Au5wuxK","zNjVBuHHC2G","zfzrtgK","tg9Nsuq","y0vLC1q","zKfJvMK","ywDLsgLKzq","Au9VB1i","y1zmu1y","Bwf4tg9ZC0m","mhWYFdv8mxW","ywrKq291BNq","yvfnrKm","DcbSAw1PDa","C3nHz2vfDMu","qMz6vvK","DeLUDgvYy2u","C2vUzf9Hy2S","ywrKrxzLBNq","D2LSBfjLy28","CKLHC1y","Ae1ZCg0","sMDOBxO","BNrLCG","AwXK","zw1LBNq","teHsze4","C2vYDMLJzs0","BgLTAxq","BNvHEem","DfjcEeS","A2v5","r0joEKK","mteWnZe1mtfdzxPXt2q","r3n1Ehe","B1H3wMq","C2v0sxrLBq","DLr4u1G","q1frr3y","yxv0BW","z2rSEwe","uK9kvKW","C2vUza","zNjVBujPDhm","yxnZAwDU","DhjPBq","y1HrzuG","x2LZqNjVD3m","BM5NyLu","Aw9U","su5tvefova","zv9ZDwnJzxm","B3bLBKrc","uLLzvw8","wevov1K","x3bYzwzPEa","CgfYC2u","DMfS","t1DVtM4","qwP5yNi","o2nOyxjZzxq","reLMwu0","qwvTBwu","Cw9Zx18","z2vrDwv1zuW","sKj2vhm","x2LZtM9Kzq","ruvIsuS","Dg9cExrLCW","zxjYtM8","vw5Oyw5KBgu","A1rkEum","AwLfvuq","y3D4zhe","qxDpug0","tgLwBuG","zvvIB2y","Agnlq3i","AgXKAKK","uuPyywu","A0z6yvm","rfDHtLy","zxjFywnRx20","uwzbBgC","DeXjCei","y3nwBeu","rffkqM8","vKvktgq","vw5PBxbSzw0","q1v3yva","BxnN","r3Lur3q","CLjnAu0","q0jMzwK","EgPYz2K","AvblENC","D2j5zMC","DvP3Awu","DwXlsge","revuwfK","DxbKyxrLq3u","AefJA01LC3m","vwHMEM4","Dw5ZAwDUzwq","zMzLCG","x3bPBMC","AMHxweu","BKnJqwu","zgv2AwnLx2K","CNzHBfzHBhu","DhjHBNnHy3q","sgj1zg8","zxPRBKm","zgzwzKq","uNLezva","tg5st2O","z1bzsxi","B2nRzxrtDwm","A0f2tKu","r3LPCeK","AwDHDg9Yt24","ywDLu2HVDW","BMvJDa","BNvTyMvY","uuvkuMS","B29fAgO","ALvTz1a","rxbhCvi","rKjeEem","CM92AwrLihC","rerAtMW","DxDkDfO","y29Uy2f0","A09Ryxq","vu1ZtNe","zwnVBM5Ly3q","y3vZDg9Tshq","Aw9Sz0u","sKLmA0S","x2LZtwLUAvC","s09RDxO","zgf0yq","D3jPDgu","reXbzuy","svrSA2y","CgXLyxnLiha","D3HZufG","uxfiCgG","ru5Qq2u","uNHOu1e","DMrZwfm","D21uEwe","tg9NsurozxC","rvfRqve","CfPUvgC","v2PJsem","x2rLC3rYB3K","tuvtu0fhrv8","ihrYEsbYzwm","BhP1z0u","Du9gv2e","uKLTAe0","uMvHzcbWyxm","rvvIrLy","ig1LC3nHz2u","A3HiEuO","A05xswq","zhzxDg8","rujIswO","C3vJy2vZCW","CgLUz19VBMm","vfrXs2S","qKDiyMm","uwfqyuy","CK1lrM4","B0PRBg8","ywzjs1G","qMn0Cem","vuznyKK","Chv0","DuzeDM0","tfPVvhm","BMCGDxjSoIa","zgrjrcWGzgu","qLvxvuK","Aw5PDcbrB1m","rgjuvve","y1DNCwS","y2fSBa","BNruCMLLC0m","BgvUz3rO","uunNwKe","Cenryvq","qLvNvNG","tePoA1G","tu1JCgi","C2jYt3y","yM9L","DMvY","x2vUzhbVAw4","tLPNwu8","CLfcsLu","BeHHBMrSzxi","CMPRwxy","uLr6CKK","v2vIu29JA2u","D0LAC3C","DxrMofDYAxq","txnuAuy","BKLHDwm","Bg9IywXty28","BwLZzq","C2vYDMLJzq","Effmve4","y2XVC2veqG","BxnNsuq","ywnOzwqSihC","sg9oBxO","suHNEwy","CMjgB1u","v0DUDM0","qKjNCeq","zxj2AwnL","AxnrB1nby2S","Euflsvu","wvHmCgO","A3jPwwy","qw1mz04","AgvHzgvYCW","sLb1v2m","te1Muhi","z09dvuq","CMLLC0nVDw4","A2v5CW","lcbxzwjtB2m","uvrWtMS","DNjMy08","DgHLBG","mte3DKX5vw13","BgfsB2i","yvzpqKu","svDKDNO","DvLes3O","CeTesuO","zxjFCw9Z","DhjPzxmGCMu","rvngEva","ywXSzwqGBxu","mhWXFdn8ohW","B3jpBMXPBMu","Ae5HEuy","uhvxzwu","AgvKtwf4uMu","AxnFywnR","CNfWsgq","CxDrzNa","nNWXmhW3","CK96t04","BgLUzw5V","s2v5r3y","EwrqB3m","su5yD2u","C3H3ueK","mdaWmdaWmda","y2uGBM90igK","uNDHEva","DMLJzuLeig8","zMzMzG","uxLlBhy","vhPWtMm","B25LCNjVCG","zgLZywjSzue","rM9qu2C","DxP6tMO","CgHovNm","B3jRig9MzMW","Bg9N","ChL5B2S","zvvvC3i","x2jPBMfYEvq","DxrVuMvJB24","Dg9iyxnO","D24GCMvHC28","x2DLDeLUDgu","yw51Ce1LC3m","yMLUyxj5vhK","CLbQz2S","rKvuA3e","BIWGAg9ZDg4","C0nVDw50zxi","svnftMS","B3bLCNr5","ChPPCeW","uhzLCge","uK5fExG","rwLLuKO","rMnOEgW","swzPsuO","CerktNm","wgrfs3a","yxnJCMLWDa","u2zKB20","rgLVtvi","A3jArKC","mJK4ndu1DgLmDvPm","sML5CfC","BKH0z0C","D01cqKu","whbkDfu","y29UC3rYDwm","ruPiDeS","AffLELm","x194x21Zz18","ALHQz1y","v1LpCeO","y2XVC2uSihC","zgnzAKu","y2HHCKnVzgu","CMfNzvn5BMm","ywXSq3vYC28","AM9PBG","C2v0","Bfv0rfa","EhHbu3y","wvLKDfi","D1j0CeO","BMfTzq","uNrOCKm","s3nADNm","m3W0","C3PWvNq","EMDfEM8","sLnptLa","v2LUzg93","Bwf4uMv0CMK","CwH3sxC","DeLK","BuPHvLy","BMCGzMfPBgu","tLbQt3q","Cg93","BMDuAw1LCG","AMPxv0W","zxjVsKW","vLfHExa","q09otKvdveK","z2u6ia","tKzUtgC","x29Ut3bLBG","z2jvsMy","sgX6wNO","ywXS","wMDnENa","yxbWzw5Kq2G","CMfTzq","rvnVBNi","BKH1Cu4","C1nmrxe","uhn1yM4","vND1wLa","y1bvAMG","qwjlteC","veXYCNq","x3bYB3rVy28","BMX3C3q","Bg9Nsurhzw4","AwXLx25HBwu","zgvS","AxjLza","C21vveq","thbxt1e","Dwj5suy","yvzwu04","D3Lfv0W","zgvJB2rLzey","senIA1C","ENjMuve","mhW0Fdf8nxW","uM1irg8","rKLmrv9ot1q","quTXy0e","uuPVEu0","z3H1rwi","wKjADuu","zcWGDw5RBM8","rhbeAfy","tg1ywM8","A0nltwq","BMnVzgLUzW","y2Pht28","CgPVwKK","CKzbq1u","q1joy0y","q0z0BhK","tu1eAum","DhbizwfKzxi","EMHsuKS","tvPzq0O","veDRwe0","sxPSyMS","DuvtCKi","y29UBMvJDgK","Cu5tD3e","x2n1CNnVCK4","m3W0Fdb8mxW","u3vjsgq","A3nTyLi","se9ttvq","AMXcD00","CMv0CNLdB3u","y2HnyxHuCMK","twXfExO","qNHkz0u","v2vPEgLUsLm","DhDVCMTdAge","uNzZuxK","tKHVAve","BKjxCM0","BNHvzLK","x25HDMLNyxq","B3LoCNu","CMvJzwL2zwq","zw50tgLZDgu","B2zMC2v0","EgfhBLq","C05hCuG","C2Tbsgq","u2vYDMLJzvC","t1bftG","y3jLyxrLt3a","uLLLuwe","zufJAW","EhfAtvC","n3bAyxHLyG","uhb4Bhu","BwXSzhy","zvvYBa","CNnVCL92ywW","zuD5vuq","r3bvt2y","uLLIANG","yKfttuu","tgLZDgvUzxi","Bgvzwhi","A2fxwMO","BhLSBKm","Exrfv1G","svb1vLi","uhbLzLa","zM9Yy2u","ChPXvhC","BgvY","BMCGB3iGyw4","igzHAwWSig0","yMLUza","B25TzxnZywC","B29zueS","BvjbrKK","BfDptgy","Aw47y2HHCNm","wM9nrNy","sLHNtK4","B2XKvMvYC2K","y29UBMvJDa","B3jLtMfTzxm","AhL1CKO","z3PzrMS","s3n0t0W","x2DLBMvYyxq","y29UDgLUDwu","wgHxqw4","AMDfCgO","vufnA3C","y2vZC0HHBMq","x3jLywr5q2W","v3DXEKe","CMfUzg9T","s3bHrKu","ysbTDxn0igi","rffLAKK","B25VCgvU","EhHXBui","Ef9MCM9UDgK","Be1bBLe","x2nVBM5Ly3q","zMLSzw5HBwu","Cgf5Bg9Hzeu","ihrVihjLDhi","CKHZzNC","q29Kzq","wNDzqMi","q3frsKm","Bvj4BxO","y0zuBgW","Eg5ttLC","z0fbt3G","BwvY","wu1HtMG","q3PsweW","B3jL","CvjNrhm","C2TvyxC","Eg5Vsuu","tLrwAvC","EKPouwi","seLuCMm","C3vIC3rYAw4","yKXpBhe","EvPUv0G","z2v0sxrLBq","yxKSihrYEsa","tNLLswq","suj4sgW","y1rdC2i","yxrLq291BNq","EgLZCem","B3nLrxzLBNq","vKjwwwm","yNL0zu9MzNm","qwjVCNrfCNi","yvvAtxq","wgHKEhe","yxbWBgLJyxq","Cgf5Bg9Hzfq","s2HOzum","zw5JB2rLrNi","BxbYDvq","D2Dwyum","q0Xpu0ve","Cg9W","B3nQEMy","z2v0u3rVCMe","z1rPBwvVDxq","icSG","sMjHBLu","twLZC2LUzYa","ugzwvMy","x2nYzwf0zvm","BNbzCgC","zxvTD1O","BM5Ly3q","s0v0D04","z0jtBNG","uNvQweG","zM9YrwfJAa","zxjYB3i","Axn2CLu","wxrOvwO","Dxrjza","Eun1z0C","Dw9ZEem","z2znz1u","CgngCui","tKfusvzfx0u","AfLYsMe","x0vysvnu","Axnby2TdBgu","BLDqtfK","ze1YB0u","yxjYyxLIDwy","C29YDa","txHvB0i","x2HHBMrSzvi","ChjVDg9JB2W","zxH0zw5ZAw8","x2LUDgvYDMe","r3z3uwu","rwjTt1u","shn4D3G","Cuzsteu","uhDStMG","ExbAv0S","zMzmAw5L","Dhr3Awq","zgLZCgf0y2G","y29Kzq","zwn0","wfjiqxq","zLPqAhO","vfvhsum","ug52Dvi","zgvSzxrLrge","sNDUthi","Aw1LCYbPBIa","Bg93","BgHivNO","weDUAuC","yNvMzMvYzwq","l3DZl3yY","ihzHBgLKigq","uKH3Duu","x0rctMfTzq","zMLUza","Eg1SAMK","yuDWq24","rgv6CuS","EgL5u00","wwH3vwi","A2L1CMu","rNHVCgm","C2v0u3rVCMe","zw1PDa","CKzSz0C","BM9Uzv9UB24","tMD1wxK","tuPhrgu","B2fK","reLuseC","DfDfueO","Cg9PBNrbBMq","CwHmEfy","r3z6q3e","yxvSr0u","DMPAA3m","x29UtwvZC2e","x2TLEvbHDgG","rNndAM0","ugz6tey","BwLAq3e","ywr2yw5Jzq","y3H5B3K","r1zxA3O","zLzvs0O","wgf0tui","B2nRzxq","BfbXB2m","DgLLCKPtt04","x2LUAxq","Cg9PBNrdB24","EuL6vgG","wg9kzxe","B21ODfy","CLzHBhvLCW","qvzSEKK","B25mAw5L","vgfmqKG","C2vYDMvYvgK","z2v0qwXSs2u","t1bftL9fuLi","uvvbBfu","B0fWEuK","CfjAvMi","zwvKzwq","rvb1yxu","DLfUuKy","AevYCM9Yrxy","x3DZ","z2v0q3vYCMu","suPwuM0","tM1evfu","Efrurw52","CgLUz0LUDgu","CMvQzwn0","aaaaaaaaaaa","AevwAg0","Bwv0Ag9K","B25nzxnZywC","B09yt3O","BwvZC2fNztO","Dw5RBM93BIa","FdH8nhWXmhW","v252ywO","tvjmCK4","DgfYz2v0","vLDMDfi","CgfNzwHPzgu","q29UzMLN","CMvZzxruCMK","CgfRBgO","B2zMBgLUzq","rxjYB3jdB2q","uLvxrgO","mdaWma","z1vTugi","rLDt","x2rItMfTzq","zxrxB3jRq2G","yKfICuy","x2LZtwLUAvq","D3HVsue","tw9KDwXL","uhbMreG","whDuweq","ywzUD0e","ENrqyxG","y2HnyxHdB3u","Aw5KzxGGB3u","Cg5Uqu4","qw1TDu8","vuXWvKu","qM9Or2W","CMTLCKDSB2i","EefWqNy","ALPdrfm","ruHwCNe","CNnVCL9Uyw0","DM91rvm","tuLoCgi","CMvWBgfJzq","C3bSAxq","D0HLq1y","y3jLyxrLtwu","Ae1LC3nHz2u","rK1VBNK","ChnnrLy","mNWXFdq","EhDXveC","svLSD2q","rK5Twue","wxjiENG","CgvYC2LZDgu","y29TCgXLDgu","wKDZsg0","u3Hdv3m","yMfSu2nVCgu","ALrvBfu","uNzJAKq","zuvotLG","CNjVCK1LC3m","y3vYC29Y","x3nVy2TLDa","t2fjwvG","u2zWy0O","A1PWD0C","z29PBMCGyxC","ywXPzcb1CMW","zvnAB2O","x3bPBMDmB3m","zw5HyMXLuw8","venNwKu","DwDzCLq","CM9btKO","EwPODMy","rxjezxC","AgrjBg8","CM92AwrLihy","te5VruS","whLXt3u","y3jLyxrLt2i","x3jLBw92zvC","veXdDhq","CgLUz0XVC3m","vfbdyvK","yNL0zuXLBMC","qwPQELK","AwvxCxe","zgvSzxrL","D2DesNy","BfbnweO","rMH3rvq","ENjMwLm","zhP5qui","z1bxrem","yMrlDLu","q01TuLm","ChPKDei","DuHKthu","v0LMD1K","y3vYDMfSDwu","Dw50","r2LKENy","C0jf","rxr2sg0","uhjPBwfYEuS","wgvtyxu","rvjst1i","ndC3mZjpy1b1sum","yw5ZzM9YBvq","B3vUDa","DwzHrwe","BMjkEu0","B25pCgvU","zur2qvu","zNLwvKG","Eu1mqva","x2rLyNvN","z2v0","y2HLy2Tszwe","CMvZzxrdB3u","vxbKyxrLq28","uePhzKm","BgLtC28","yNL0zxm","AxmGDw5Kzwy","DMvUDa","Berishu","BwjuqLm","C1LPAfO","r0rYy3e","BgvpD1q","tvv5A1K","z3jRyMi","mta4r0n4zfLZ","DuvVtLi","nNWXmxW3FdK","Be1SDMK","BKXPBMu","Dgv4Dc9WBge","tNnpsxC","qvzIAw0","zu1etge","CgLUz1rPBwu","v3rPEfC","DNj3B20","EKjcrhG","Dg9cExrLC0i","rMfHzw4","A3nWAKy","EhfOyNq","B25Uzwn0Aw4","thbZtuO","tvHtrhi","C2DoshC","BePps04","uMTgrw4","A294s2q","CNjmuhm","C3vIyxjYyxK","yvzUC3i","q09oveLovuu","x2n1CNnVCKy","x19LC01Vzhu","ChbL","rLDvtgu","q3vZDg9Trxi","CYbPBNn0yw4","q0Hwr0q","z2v0s2v5","rhfjwui","D0TpBw0","uLjpuG","z3zPCKC","B1LrzvG","D1vduKC","wKDtwfy","AM14EeO","CMvTB3zLrxy","AMPwz2W","BMvLzf9Hy2S","igfYCMf5yNu","uNnfCNK","y2f0y2G","yxnkCxa","yLbTz0G","CgjICdi","teXTuvq","Dg9mB3DLCKm","ign1CNnVCIa","s0HuzNi","weDyzMy","C3rLBMvYCW","qwXQC2m","CuLOtue","z0HzDw0","Aw5N","DNH4DuC","y3ruAw1LB3u","oxWYFdr8nxW","C1z3ENq","zMLN","zND0Axe","quv1y3q","ENfoBw8","y3vYC29YlNm","BKXfBNC","yKPXAuG","qw1VDw50","reiGzMfPBgu","tK1ozhi","zMvY","x2zVCM1HDeu","AwrI","u3rYyxrLz3K","B3jMALC","BMrLEa","swHcs1K","zw5fDMvUDa","DKnzr0m","zw50","AerVC28","zNbmC2y","yLf6zuu","v3PNCgu","C2vUDa","yxbWBhK","AgfZt3DUuhi","rfbHwuG","BwfUDwfSihi","twLurKq","zezJrwu","A01ws0i","B2jNB3K","Dg5wC0q","wevjBg4","seTxuey","ywWGy3vYC28","ww5Xzxq","BMDLza","yxv0B21HDgK","u2HMqLe","t2fXBK8","CMvHzhDYAxq","vezeB3y","tMfTzq","vfnfthK","qNvgAxK","yND3DLG","ufHNzvC","suPbA2y","DK9us28","x29Uq2XVC2u","tMXTshC","BwfW","Ec11C2uT","Aw5JBhvKzxm","Dvf2CwK","BgLUzq","zgPTs1K","vNjxq1O","B25tDg9Wsw0","A1n0yxr1C0m","yNLL","EwvgwKu","Chn6C1C","zxHWB3j0CW","ChvZAa","u1nOCLm","ywrKt25L","vxHAEw0","s3zICKu","DMvYC2LVBG","BwrgB3C","ELHAzhy","qKTKy2C","y29UBMvJDfm","nNW1Fdn8mhW","vgfN","DuLdquC","tKPhChK","x3nLBMrby2S","rfzhv2i","BMnLq2XVC2u","Aw5QqLq","s2zwENi","Dhj1y3rVCIa","tgTOwMe","yxH2Evm","AhfqEMS","AgLNAa","A2jls3C","y3vYC29Yx2y","s3zyr2K","veTWyuG","BvLQvKe","y3jLyxrLq2W","t3bLBKv2zw4","Cu1vwui","t3DhtuW","y051rKG","AuvwA0C","z2n6z3y","x3DHAxq","DKfoywu","BwHiCLO","DMnWv1C","Eu9xBLO","B2nRzxrgywK","txHdsNO","y1vbrNK","y3jLyxrLrxi","s2f2AeO","EgT4y1m","tMLVz2e","zNjVBuj5Dgu","BMrWB2LUDfq","Cgf5Bg9Hza","C0PKtu4","Aw5KzxG","y2XLyxjtDg8","txHTzvi","ywnOzwq","tuPIBxG","CMvHzg9UBhK","ELfHwMq","tg9JAW","ugPTwMG","tu9eqLm","quXm","ntiXnZjqy2r2z0i","zcWG","C0XPC3rLBMu","zw5NDgG","qNfiDNm","DhjTshe","BwjjvKW","DMTRvu0","C2v0q3vYC28","x3bHDgHlzxK","t2Xcqvm","tLj5vNe","yw5Nzq","ywjVCNq","uhHpq0W","Bg9Iyvi","q0fVyLu","wunyt3q","u0LKs3m","id4G","EvjLy29UBMu","x3jLy29UBMu","CMvTB3zLq2G","uK9LCKO","B3bLBG","AMjJCNa","C3rYAw5NAwy","CMvWBgfJzui","se1Zqwm","BwLUzW","DcbVzIbYyw4","rLLtweW","q1LqDwW","DNP2vvK","BNrfBMrWB2K","rKTnEvO","z01Huw0","r09RvLy","CNnVCKzPBgu","x2LZsw5PDa","CLPOrKK","C2DPza","zwvsCKO","uvfcq2m","Du1rBNO","wujXDgi","Aw5KzxHpzG","wMfJzM4","CgLUz09Uy2u","vxfwuKi","uhDHrNO","wK91zfy","x3nLCuLK","EuLLtLa","tMrmrLu","jMPZy2fSBgi","B25SAw5L","zurQwgS","v2jyqxq","suvtx0vsuK8","AgfZ","Bg5grwq","De1HBMfNzxi","zvHXCw8","AKH5B3i","vhfJA3G","x29UugfNzu4","teH1q3C","uvHqDMS","CMvHzhLtDge","pxv0zI04","CMvUDevUzha","DxbNCMfKzw4","A1LtqKK","DMzMr0G","B25JBg9Zzq","sNbOELe","y2HLy2TdDxi","ihn1y2nLC3m","tvPxs0K","igzPzwXKoIa","u2r5Du4","zxH0ugf5Bg8","yuLhueq","EKjou3q","C3LLvfm","x2LZv29YA2u","EMjvCgu","zNjVBNrPzxi","zNjry3C","sefNsvq","BM9mDgS","uuzltum","ihbYB3rVy28","rLjptLrjrvi","s3nkz0K","q0Xpu0LorW","vuH6Dem","zLDhANK","AxnAzxjV","BeT3wum","BfnVBKq","AerZvM8","z1rHwu0","z21ps24","EfD6tvK","ruLwrKi","EMzyyvy","tfneqMK","vwXkyKu","whnAwuq","q2jYuvi","x29UvgLTzw8","ENDtrve","BNrbBMrvCgq","Ahr0Chm6","yw1LoIa","x2rPC3bHDgm","uNPMz0C","DgvZDa","C3rVCMu","wvziChO","re5tyKS","zw50zwqGDhK","yLfQyxu","uwf1tKO","Bg9NsurozxC","BwXRzxq","CwvhuMi","CMvHzfvjBNq","EK5jDhG","DxLWrMC","uMftsNC","BM93","CMvZDwX0","zgLPChy","yxnL","x2LUAxrqCM8","AfHkBM8","CwXnA2u","BxLjCxa","BKH3DKe","Ae10v1i","u3jSCw0","v0T3she","wfvjrum","y2PuBxy","ANbSvKe","rffZDLa","nJCZnJKWAeDnufPx","DgHpy00","CfbqCvi","zg9Uzq","A3ncweu","ALjhzwq","r2f4Dge","tLLXCKq","u2jWu00","q2ntsKC","mtjHzfviuem","z3PyAhK","yLDYq3u","CwjtveW","r09kCgS","AgTVDMu","AvrwsLG","Cgu6ia","Dg9VigXHCMC","BKjsy3C","r0XnAgK","z2v0qwXS","B25szwnLAxy","t2jQzwn0","z3DpAK8","uvHYq28","Dgv4DfbHEwW","CMvHC29U","Buv0u1q","s1fYvwi","r2rrBg8","q2vftem","z2vtEw5J","BwvZC2fNzq","x2rYB3bhBg8","zMTiC1q","BwDbCeK","zNvUy3rPB24","A091see","uKjttKe","C2fNzq","zevbAfu","rvvNte0","Avv0s0S","y3vYCMvUDeu","z0rqyuy","zNjHBwvuExa","uNblvwi","BgLZDgvUtMu","vfPLDMG","zwzIBfG","Be90DM4","yLHTA1G","u1P5zhO","y3r4","y1nAAK8","vw9TAK8","wK1QsvK","s0LfzM0","qMPTthO","AwXLtMfTzq","ywzL","wMTpDgy","CvD5Cgu","zw5KCg9PBNq","ody0nJm1ne91wvjTuq","ywnRDxbfBMq","x1fVu01HBMe","ChrVCG","Cu9wwK8","C2D3zfO","y29SBM8","CKrSqxC","qvLHBuq","sefbuKC","C2DNA2K","rfjOExu","ihrPBwvVDxq","zw5JB2rPBMC","DvjpwM4","t2Lhtw0","ruXyqxm","DLzXB1q","ChzzwMi","sLfhEKi","ywj3y0i","vNHhtxK","rNjVBNrPzxi","yNLyuvC","x29WDgLVBNm","Aw9UvgLTzw8","yxzMEMm","B2jQzwn0u3q","DxjS","seHmquS","r2DiwhG","B0jTs3K","C2n4Bfe","wKDTu0y","yLblBhK","uwfHu1y","tMzLrKi","DMDIshK","qM9tBKu","qNjPzgDL","B3jRzxjhBg8","zvH0s0K","su9xrMK","yMLUyxj5","wg1qC1i","y0jpCK0","uxvLDwu","rMPOAxu","shfdtMO","rgvKAwnHDgu","zxjYtxnN","Dhz5u04","EgfdBKC","BfrPBwvVDxq","BML0AwfSAxO","Bhm6ia","BwHSBuG","CMvKDwnL","zNDZxZeUmc4","v0fNtLO","EMPVu0y","DhjPzxm","Dhvfz0u","ywX3yxLZ","C29Tzq","vgLTzw91Da","lcbOB3n0BMe","t3HOzfK","ywXSB2nvBNm","yw5Hz2vY","z3HvAuS","zxq9DxrMltG","rfPyENa","ww5SruW","AxnbCNjHEq","q0fQzxK","vfn1vKK","veP1AgK","wgfivgq","uNzXDxG","B25fCNjVCG","EvD5qKW","uMvJB25Uzwm","AxfVv3q","vurszM4","zwrPyxrLBhK","DgLTzw91Da","CeHZDwu","sNDLzee","x29UrxjYB3i","ywDLrxzLBNq","yxGGCMv0CMK","qw1lshq","vwTVvuq","wKnlBLm","AvLPAu8","yMrFzgLK","tfPUEK8","y3P2q2m","yLrXwvy","BwLUAvbYB2C","C1LNr1e","t2vNBei","vLnAtue","ugLlwvK","Cfnhrfq","q0fguKW","DMfSDwvZ","y3jLyxrLuMu","wwPJAeu","zgvMAw5Luhi","x21LC3nHz2u","s3noyLe","t1Lzrfm","C2XPy2u","ueT5zLm","B2zM","yMXVy2TLza","qMzesLe","DenhBM0","EhjkwuC","mJu3mJeYmfnvrMP0sq","tMz0quC","yw1L","y291BNq","CLrttM0","x3fVC0rc","rgnnu2y","rhPbvMu","D05oBgK","DgjjuNq","C3rVCcbPBw0","sePOCey","yNvMzMvY","vfbpEuC","y29UDgv4Da","zwjgBum","uNfdB3O","EsbJBg9Zzwq","ihrPBwvZ","tfPqv3q","EejQAKu","AuLXDfa","y0vUthm","txfLDK8","BwvZ","q3jKtfq","wePZzgi","wLzIzNO","ExbL","Dwfou3C","Dg9cExrLC0W","we1tuuC","Axj4q0G","yKH3CKC","shHetg4","ufL2s2K","igXHCMDLCIa","AxnmB25N","ihzHBgLKihm","vLz3qK8","zvj5uNi","zMLSDgvY","zxD6uMO","zw5XDwv1zq","EwL5tui","AgvHzgvY","vfPrEfe","zfDVCMTLCKC","wLjIt2i","q3vZDg9Tq2W","ywrK","qxn3wfq","mNWZFdb8mxW","ExbiB3y","x2n1CNnVCK0","uuLhugu","rhD3r2m","Bfrdqui","CMvXDwLYzwq","x2nSzwfYvgK","BMv3vMvYC2K","B0riwKi","v2Lvs2u","rNDVuue","zxHuqwu","x3DZsw5ZDge","AwrlBgu","yMfSrxzLBNq","y09Wzw4","CwDkDuG","twfvrve","AenSB3nLrxy","vw5MtKu","Ec1TC2CTy3u","zxr2C2u","yw1RzLG","wKjnwLq","C3rYAw5N","D2fZq2XLyw4","wvjtq1y","t0newgi","rNv4ueK","BNjxCgK","B25ozxr3B3i","z2v0q3vYC28","Aw9Ul2PZB24","zM10twq","BhrPCgXLihq","twvZC2fNzuu","z3j0uxK","y29UBMvJDeu","C3LNyLy","BKvHtgO","ugPlsxK","sgfSDMy","s2HHyxq","yxrHlcbKyxq","y1vlvhy","rLrtD3G","uNvAB08","EeDSD3u","sMH3Aui","B2LUDfjLywm","wwT4wwW","AxnrB1nnzxm","zNjVBu51Bwi","reH2Bxu","zMjsr1G","wuH4Cxu","x2XPC3rLBMu","CMvZB2X2zq","z3PAsNq","zv90Aw1LB3u","DhDHDMi","rMX0sxK","mNW1Fdf8mhW","x2HHBMrSzva","rxzLBNq","CM9YrxzLBNq","rK9hrwy","vNz4v3u","r09wsKS","z3ryvxC","B3bLBIa","DfPMyva","vLbUseq","ufP5AMG","x2LUAxrhBg8","wKfLDhC","C3bSAwnL","Dev2zw50","DuH0B3m","t0L1BMm","ExzHz0i","DxLjD0S","twDSEwu","AfbXs1G","C0Xf","ugTUywO","CuXQtKm","EfL1vuS","AwX4vw0","tufyx1jfvfi","D3jPDgvvAw4","y3Dksxa","BLbkAxu","ChjVDg90Exa","ywnR","BwvZC2fNzv8","q2LZCvK","u2vXsuq","BMvY","EvDhvKO","C2HPzNq","sxHPzM0","thD1u00","y3vYCMvUDeK","thjWwfC","Eg9XDvK","yuztDhK","qMD6sfa","yMfkDui","BvjKC20","q291BNq","CgfNzxnOB3C","yLPIuKO","EK5wq2u","zuH0tuG","Cercrxa","AhfcCve","zxmGCMvHy2G","zxzvEhq","wK5hA2G","vKnMALi","CMvJzxzPzwq","u0jiC2O","shHRz0q","B2nfAhu","vufRufu","zw5HyMXLvhi","zLfbBKC","x3vYBa","te1Yr3K","x2rPC2nVBM4","CwnXDMi","y1rvs24","Dg9oDw1Izxi","y29UBMvJDca","C2jpq3y","CMvZzxrfBMq","D1HSyLi","CYbWyxjHBxm","u1LAwwC","y1f5EMS","B25tDgfYDfi","qMHeBvC","v0ncA1e","ru9bBxe","C2nYAxb0","vfP6y0W","wMnTueu","DKLqBxK","B2LSC3a","m3WYFdr8mhW","z25RALC","qwfXteq","zgvYse0","ANjQt2S","zvDwugu","Dg9tDhjPBMC","v0Lnthy","AxnszwfKEq","x2nSzwfYugK","zfr0rwC","su9HtLq","v09wDw0","z2vY","y2XLyxi","zNjVBunOyxi","zxjFDhrS","tMjqAg4","DgnzuNK","q1jZCgu","shjHzhy","D0jlENO","u0TLDMy","reXLz1i","CKfpB1m","x2HHBMrSzu8","qwXnuMy","ugH3sMy","qu1UuuC","u2TPCcbWyxm","BwHwqMq","B3nLza","DLjlzw8","DMvYC2LVBMm","rfPLDwK","z2vjBMzVu3K","yM9KEq","x2fKzfDZtgK","qK9hq2y","z2fSEvi","zcbLCNjVCI4","wfbTz1O","CNzHBa","zhDTt0m","uwr2r1y","s1PHreC","ywDL","sej1seq","DhLWzq","DNjxAe8","C3rHCNq","qNngB3y","y3vYC29Yx24","AgfUz2u","A01ACLa","Dg9Y","u0XVEeG","BwLmzwy"];return Co=function(){return t},Co()}(()=>{let t=M,e={DETXY:function(a,n){return a(n)},grtQy:function(a,n){return a+n},OaIYX:function(a,n){return a+n},PpefP:function(a,n){return a+n},YBqtb:function(a,n){return a*n},mhlmH:function(a,n){return a*n},koxKd:t(1018)+t(600),RYbjx:function(a,n){return a===n},gfMgU:t(1942),NfeFB:function(a,n){return a(n)},HCbkW:function(a,n,s){return a(n,s)},uzzNj:function(a,n){return a+n},jUmgP:t(630),yckxW:t(1852),krZFG:t(617)+t(1122),Wnvaj:function(a,n){return a!==n},CNajr:t(1435),IxkIp:t(1848)+t(1848)+t(1848)+t(1848),gPYIr:function(a,n){return a-n},Jghmz:t(1579)+"4",FKMyZ:function(a,n){return a>n},MqevO:function(a,n){return a<n},oApyI:t(1186),xiySM:t(1115),rTSNm:function(a,n){return a>n},hqBqQ:function(a,n){return a!==n},cEzwJ:t(1731),TTqKk:t(1886),lhHVz:function(a,n){return a!==n},Uhfzn:function(a,n){return a-n},HJhpF:function(a,n){return a!==n},fbRGX:function(a,n){return a<n},INXwe:function(a,n){return a===n},FKYtO:function(a,n){return a<n},JbanU:function(a,n){return a!==n},xispC:function(a,n){return a-n},hQezS:function(a,n){return a!==n},dFcEe:function(a,n,s){return a(n,s)},EOAmq:function(a,n,s){return a(n,s)},FBDxC:function(a,n,s){return a(n,s)},eHtMH:function(a,n){return a(n)},kEfPI:function(a,n){return a!==n},ROerJ:t(715),HHLAK:function(a,n){return a>>>n},DIfYM:function(a,n){return a(n)},WjcHC:function(a,n){return a&n},BctpC:function(a,n){return a===n},miZCq:function(a,n){return a===n},UDRfn:function(a,n){return a(n)},zBNSt:function(a,n,s){return a(n,s)},DHvmu:t(491),vgbHy:t(965),KsZvs:function(a,n){return a||n},AAyMr:t(796),BoSnE:function(a,n){return a||n},cNuFH:"ack_code",tcYRy:function(a,n){return a===n},PXSki:t(1495),CBfei:t(571),DioMR:t(1110),fkHsT:function(a,n,s){return a(n,s)},jjWWL:t(463),uESrB:function(a,n,s){return a(n,s)},DNSbK:t(399),KavhJ:function(a,n,s){return a(n,s)},EUbFV:function(a,n,s){return a(n,s)},SuIHd:function(a,n){return a(n)},DZXzp:function(a,n){return a!==n},jjVgl:t(1459),qRgDs:function(a,n,s){return a(n,s)},zXZdv:function(a,n){return a!==n},HAgIT:function(a,n,s){return a(n,s)},aNAjk:function(a,n,s){return a(n,s)},ypHov:function(a,n,s){return a(n,s)},RHwuE:function(a,n){return a(n)},SxCWs:function(a,n){return a!==n},SYZYg:function(a,n){return a!==n},Psubn:function(a,n){return a!==n},FOGEf:function(a,n,s){return a(n,s)},XJsdb:function(a,n,s){return a(n,s)},hIohN:function(a,n){return a!==n},gTaYM:function(a,n,s){return a(n,s)},BjmLz:function(a,n){return a!==n},AmLgN:function(a,n,s){return a(n,s)},itLAY:function(a,n){return a===n},ZCKnS:t(1814),liSso:function(a,n,s){return a(n,s)},zNItx:function(a,n){return a(n)},rHuFL:function(a,n){return a(n)},TLCtt:function(a,n,s){return a(n,s)},skAHd:function(a,n){return a(n)},MMcpb:function(a,n){return a(n)},wgDJv:function(a,n,s){return a(n,s)},XEIln:function(a,n){return a(n)},PiKYY:function(a,n,s){return a(n,s)},xPyOM:function(a,n){return a(n)},vcpWW:function(a,n){return a(n)},iUtKK:function(a,n){return a(n)},DITHG:function(a,n,s){return a(n,s)},QFKMC:function(a,n){return a===n},ugYrT:t(493)+t(1339)+" field: "+t(1431),dMroE:t(493)+"required"+t(1026)+t(1588),cxyoy:function(a,n){return a===n},RUWDj:t(493)+t(1339)+t(1026)+t(1797),JILkK:function(a,n){return a===n},XdEKp:function(a,n){return a+n},NTViW:function(a,n){return a&n},IWshX:function(a,n){return a(n)},pKDIJ:function(a,n){return a>>n},FhwET:function(a,n){return a===n},cVLSV:t(1753),hRNmK:function(a,n){return a===n},wHeCV:function(a,n){return a+n},YXLpj:t(1513)+"t limit",hEVhm:function(a,n){return a===n},vRKeo:t(867),kMZrP:"LuLTw",RvsQy:function(a,n){return a>=n},CeELC:t(1747)+t(1598),Tqckx:function(a,n){return a+n},vYSka:"1|2|0|5|"+t(1914),xoquY:function(a,n){return a>>n},SdyuN:function(a,n){return a+n},mpruT:function(a,n){return a<<n},IYlwd:function(a,n){return a&n},kNWId:function(a,n){return a&n},QdvGV:function(a,n){return a|n},lFixz:function(a,n){return a>>n},mlldv:function(a,n){return a|n},zbUpe:function(a,n){return a&n},twavb:function(a,n){return a|n},mbIVL:function(a,n){return a&n},RTzrI:t(1977),irxCH:function(a,n){return a&n},Faaen:function(a,n){return a(n)},mRxmz:function(a,n){return a===n},ESonr:function(a,n){return a===n},kspjF:"FYlEr",hNayF:function(a,n){return a+n},xxASv:function(a,n){return a<<n},fWGjy:function(a,n){return a&n},OwGML:function(a,n){return a&n},yCugG:function(a,n){return a<n},nOYQu:function(a,n){return a>=n},eeRrJ:function(a,n){return a+n},FltIy:function(a,n){return a<<n},WYOpJ:function(a,n){return a&n},PhwJf:function(a,n){return a&n},rQBJU:function(a,n){return a&n},JQGzB:function(a,n){return a>=n},FqFkZ:function(a,n){return a<=n},qwQfp:function(a,n){return a&n},bQjau:function(a,n){return a+n},CNAGG:t(1303),ebFmC:function(a,n){return a+n},iolgE:function(a,n){return a+n},cwJIp:function(a,n){return a!==n},bKkDf:function(a,n){return a&n},OeglB:function(a,n){return a|n},WiUKe:function(a,n){return a<<n},RyDeP:function(a,n){return a<<n},xmlji:function(a,n){return a|n},lUtDP:function(a,n){return a|n},gmOKn:function(a,n){return a>>n},GvzCq:function(a,n){return a+n},xwqTG:function(a,n){return a*n},KsNbQ:function(a,n){return a>>>n},yMLAP:function(a,n){return a<n},sggki:function(a,n){return a>=n},obgoy:function(a,n){return a+n},frQcw:function(a,n){return a<<n},LRPwH:function(a,n){return a<n},ZGSXV:function(a,n){return a<n},xrJYG:function(a,n){return a<n},WzdQp:t(1993),NbPhn:t(757),lMAnQ:function(a,n){return a<n},BqHvs:function(a,n){return a|n},TFDov:function(a,n){return a&n},kiure:function(a,n){return a|n},HxDLn:function(a,n){return a&n},gzXhy:function(a,n){return a|n},ErDew:function(a,n){return a&n},bLOlq:function(a,n){return a>>n},idKle:function(a,n){return a!==n},DjCuB:t(1878),tvySN:t(1436),Halvf:function(a,n){return a(n)},gbUJf:function(a,n){return a&n},ULpVE:"3|1|0|4|2",sgNHw:t(1573),dVQLi:t(1128),kriYf:function(a,n){return a(n)},gvHFC:function(a,n){return a&n},xGlwu:function(a,n){return a&n},pjoZI:t(1420),tRBxK:function(a,n){return a<<n},VBVYc:function(a,n){return a&n},HKWPF:function(a,n){return a(n)},osjzf:function(a,n){return a<<n},DezqK:function(a,n){return a&n},nBWrm:function(a,n){return a<<n},ITlkf:function(a,n){return a&n},BUWUI:function(a,n){return a&n},ZXUOC:function(a,n){return a(n)},lylnC:function(a,n){return a<<n},qcqvb:function(a,n){return a&n},AlMRf:function(a,n){return a<<n},OiGMm:function(a,n){return a>>>n},rAOoS:function(a,n){return a!==n},dpoie:t(1147),HqCNj:function(a,n){return a>>>n},WIMLv:function(a,n){return a<<n},qNSwq:function(a,n){return a===n},hyurJ:function(a,n){return a<n},eroJL:function(a,n){return a+n},bdKvU:function(a,n){return a&n},aGpCn:function(a,n){return a|n},BhDmW:function(a,n){return a>>>n},eDvAU:function(a,n){return a>>>n},pPPqR:function(a,n){return a!==n},RImhM:function(a,n){return a&n},gtXUw:function(a,n){return a+n},xvPep:function(a,n){return a&n},oJklo:function(a,n){return a!==n},KEtwN:function(a,n){return a>>>n},eWVPe:function(a,n){return a&n},nPJiu:function(a,n){return a>>>n},Khaat:function(a,n){return a>>>n},PzqZM:function(a,n){return a&n},dEAhU:function(a,n){return a+n},YVHpz:function(a,n){return a|n},trmHq:function(a,n){return a>>>n},JhwiB:function(a,n){return a!==n},IHgyf:function(a,n){return a|n},RBSNA:function(a,n){return a&n},TzpNc:function(a,n){return a|n},yiyMB:"UCEry",rJGzw:function(a,n){return a|n},afIKX:function(a,n){return a&n},cWgqk:function(a,n){return a<n},kMVKB:function(a,n){return a|n},ZwYBb:function(a,n){return a|n},WbXAt:function(a,n){return a===n},RYYUo:t(1290),QauNJ:t(1302),nDIFV:"SEexY",fwtiq:function(a,n){return a|n},uICAG:function(a,n){return a<<n},LiVmH:function(a,n){return a<<n},hYrJa:function(a,n){return a<<n},ZVbfz:function(a,n){return a<<n},qeGRb:function(a,n){return a==n},pWTmK:t(1358),BfDJQ:function(a,n,s,d){return a(n,s,d)},IfiIJ:function(a,n){return a===n},YCXOt:t(1235),KHTfr:function(a,n){return a|n},eGyUD:function(a,n){return a|n},PjKIy:function(a,n){return a|n},aVOBE:function(a,n){return a<<n},xBjjE:function(a,n){return a<<n},eRyRr:function(a,n){return a|n},pszsW:function(a,n){return a<<n},Nioga:function(a,n){return a<<n},ZRbOb:function(a,n){return a>>>n},UlMss:function(a,n){return a|n},fpLsf:function(a,n){return a|n},BOGCf:function(a,n){return a|n},lzugE:function(a,n){return a<<n},LSDBi:function(a,n){return a<<n},vCYGC:function(a,n){return a<<n},TCgZE:function(a,n){return a+n},eENNX:function(a,n){return a!==n},FZeYL:function(a,n){return a&n},GOkVV:function(a,n){return a!==n},YnlEL:function(a,n){return a!==n},xaGnT:function(a,n){return a>>>n},WAgNZ:function(a,n){return a&n},TPOyG:function(a,n){return a&n},dzyAB:function(a,n){return a>>>n},CYPul:function(a,n){return a&n},FHhgL:function(a,n){return a<n},pDBEp:function(a,n,s){return a(n,s)},NZgYO:t(503),cxxvw:function(a,n){return a!==n},cEesT:"ebiDv",VQayp:t(1356),yWyBL:function(a,n){return a>=n},nHtgG:function(a,n){return a+n},pRZVb:function(a,n){return a%n},UnfNE:function(a,n){return a/n},JXgNN:function(a,n){return a*n},bAbqF:function(a,n){return a===n},aQMFC:function(a,n){return a&n},DGgXh:function(a,n){return a&n},VrWCZ:function(a,n){return a+n},ISENk:function(a,n){return a>>>n},pyyok:function(a,n){return a|n},RxhSQ:function(a,n){return a===n},bRFoH:function(a,n){return a>>>n},VwuZP:function(a,n){return a>>>n},mlket:function(a,n){return a===n},AKqcA:function(a,n){return a===n},TaLBH:function(a,n){return a+n},phNVs:function(a,n){return a!==n},RkFEn:t(452),DLegR:function(a,n){return a&n},nWPLY:function(a,n){return a>>>n},eZjwK:function(a,n){return a>>>n},UFMbI:function(a,n){return a>>>n},Okeql:function(a,n){return a&n},WljER:function(a,n){return a>>>n},Ajybr:function(a,n){return a>>>n},TGkXM:function(a,n){return a&n},HBuHD:function(a,n){return a>>>n},sgwdZ:t(511)+"RROR",JwedA:t(1742)+"ERROR",KeyGv:t(1930)+"NG_ERROR",xjrgi:t(596)+"OR",GVWkz:t(1423)+t(1005)+"R",etvse:function(a,n){return a||n},QJXae:function(a,n){return a!==n},KdIHG:t(982),EtvHm:t(1361),Uoyxe:function(a,n){return a>=n},XGniG:function(a,n){return a===n},yIzTh:function(a,n){return a===n},PXGer:t(1954),BGHbc:t(745),efblX:function(a,n){return a instanceof n},Aljsc:t(1655)+t(1524),uROZn:function(a,n){return a===n},UTtdD:function(a,n){return a===n},WOVum:function(a,n){return a<n},cSZjO:function(a,n,s){return a(n,s)},jmZDt:function(a,n){return a===n},HOSMT:t(1098),oiKMS:t(1187)+t(422),PKAxp:function(a,n){return a===n},lKwYC:t(1257),iiEUD:function(a,n){return a===n},hMtWR:function(a,n){return a===n},yOWnZ:function(a,n){return a===n},XyqOu:"open",MsTiF:function(a,n,s){return a(n,s)},syeTS:function(a,n,s){return a(n,s)},EpGqR:t(1247),tZfaP:t(1433),roANJ:function(a,n){return a(n)},yXNac:function(a,n){return a(n)},LpWOQ:function(a,n){return a+n},cXQeH:t(1461),ieWqq:function(a,n){return a+n},fZPhz:function(a,n){return a(n)},hDsVo:function(a){return a()},JBvTs:function(a,n){return a!==n},sueIW:t(846),leYXr:function(a,n){return a!==n},oKhnt:t(1996),uHdLu:function(a,n){return a(n)},dwEAb:"wYUbH",pRnWR:t(415),gwOjO:function(a,n){return a||n},gJpMz:function(a,n){return a!=n},czvCc:"undefined",LCgEP:"3|2|0|1|4",eXtKI:function(a,n){return a!=n},PaObX:function(a,n){return a===n},lTCAB:function(a,n){return a+n},oilsp:function(a,n){return a instanceof n},xlVDe:function(a,n){return a instanceof n},QXrCo:t(480)+t(1366),GHVOT:"XYCYX",QfAlg:function(a,n,s,d){return a(n,s,d)},gzZJt:t(429),tRfJE:function(a,n){return a<n},DQejI:function(a,n){return a===n},bQzeE:function(a,n){return a===n},dwmOC:function(a,n){return a&n},QJoyM:function(a,n){return a<n},gUmPb:function(a,n){return a&n},CMmRS:function(a,n){return a<n},cTCsb:function(a,n){return a|n},BKdcg:function(a,n){return a<<n},kFzaS:function(a,n){return a&n},qepmw:function(a,n){return a-n},DQsvP:function(a,n){return a|n},HWvwJ:function(a,n){return a|n},PfzLF:function(a,n){return a<<n},eXqqo:function(a,n){return a&n},FwoQA:function(a,n){return a<<n},Jhnkd:function(a,n){return a&n},INcHu:function(a,n){return a&n},IOWFi:function(a,n){return a+n},aEQCN:function(a,n){return a&n},jZCDS:t(2003),KjHPx:t(1057),Kaaje:function(a,n){return a<n},jbcrp:function(a,n){return a|n},gxuEb:function(a,n){return a&n},RvcjD:function(a,n){return a===n},wXlbR:function(a,n){return a===n},hdHbh:t(1962)+"3|2",wUCRG:function(a,n){return a+n},mhVBd:function(a,n){return a<<n},vIPmy:function(a,n){return a>>n},hUeCJ:function(a,n){return a&n},mbTBS:function(a,n){return a&n},WwqzA:function(a,n){return a>>n},gPWDC:function(a,n){return a&n},kOkat:function(a,n){return a>>n},noLtk:function(a,n){return a>>n},jSbno:t(638),SbpSM:"__esModule",iPKzw:t(390),nIauc:function(a,n){return a==n},kYSBI:"EuUtK",ewzRj:t(589),gzYFk:function(a,n){return a(n)},YnqOL:function(a,n){return a instanceof n},kTJyC:t(780),gczgv:t(500),uFDvm:t(1479),bTqYV:"text/jav"+t(1885),EieRJ:t(1001)+"ack=fron"+t(584)+"P",MZYCJ:t(1809),TPCaY:"tIaGh",xkxcS:t(1409),CUwaP:t(1125),qFRLE:"gkthB",ubyIF:"idb",xaCnG:function(a,n){return a+n},AEuct:function(a,n){return a===n},sbOCv:t(555),evUxt:function(a,n,s,d){return a(n,s,d)},Izlbk:t(993),kzeiK:"AEBaj",NPjOt:t(1754),Wzgpe:"ping_once_timeout",pzdtB:function(a,n){return a(n)},fgLtZ:t(1755)+t(1636)+"s",RqwzN:t(1146),OZyoF:t(1137),KfVzr:function(a,n){return a===n},wNNli:function(a,n){return a===n},XPmgZ:t(1176),rFACU:function(a,n){return a!==n},jKEtl:t(1535),TUGIC:function(a,n){return a-n},zwSEQ:t(1239),Hradv:t(1220),wBKzz:function(a,n){return a||n},miLef:function(a,n){return a===n},uZwie:t(1474),AwOPm:function(a,n){return a||n},YMGXA:function(a,n){return a||n},xApBv:function(a,n){return a instanceof n},dfVfD:t(755)+t(417)+t(1231),ksBXE:"none_none",CAobU:t(1203),KIEfm:function(a,n){return a===n},QTpNk:t(1709),Gsuxq:function(a,n){return a!==n},galyR:"iEVkG",TjOTo:function(a,n){return a||n},uypFg:function(a,n){return a===n},IPuVR:function(a,n){return a||n},bPmgH:function(a,n){return a||n},JurEi:function(a,n){return a!==n},cjGOo:"FBoKs",mEtST:function(a,n){return a||n},CFtly:function(a,n){return a!=n},pnnAN:t(1770)+t(825)+"d",yOyDi:function(a,n,s){return a(n,s)},NMNdr:"qos",eDjXk:t(1429)+"id",zXfxh:function(a,n){return a===n},SZydz:t(666),Hsxwx:function(a,n,s){return a(n,s)},UWumE:function(a,n){return a===n},XmPsR:t(1237),PJGfC:function(a,n){return a===n},Gaxta:t(803),FWULe:t(1144),jXjgV:function(a,n){return a<n},ZGsHm:function(a,n){return a-n},NmyZt:t(1243),GBNzI:function(a,n,s,d){return a(n,s,d)},tnVsD:function(a,n,s,d){return a(n,s,d)},ezknC:t(440)+t(1667)+t(987),luiHf:t(1838),lnFEd:function(a,n){return a&&n},aWcWp:"ack_id",bWrCu:function(a){return a()},GDrcq:t(2006),yIeNP:function(a){return a()},ZcmPE:function(a,n){return a(n)},iOooR:function(a,n){return a(n)},kbKKw:function(a,n){return a instanceof n},zhRRK:"applicat"+t(1366)+t(1645)+t(1016),uaNSw:function(a,n){return a<n},gdlya:function(a,n){return a>n},cBOrM:function(a,n){return a&n},AMnQG:"FOpOP",RuZoO:function(a,n){return a||n},YnAHP:function(a,n){return a>>>n},EIVFB:function(a,n){return a+n},kdCkD:function(a,n){return a>n},POxIg:"integer "+t(1113)+"e",rBhlt:function(a,n){return a>=n},NlmHw:function(a,n){return a&n},derHM:function(a,n,s,d){return a(n,s,d)},pzqTw:t(1320),injBT:function(a,n,s){return a(n,s)},nuaxC:function(a,n){return a<<n},mdFow:t(1989)+"2",AsMkQ:function(a,n){return a+n},pvYZb:function(a,n){return a+n},XUIEC:function(a,n){return a+n},OaqnO:function(a,n){return a===n},OWoNn:t(1043),gxUiK:"jCqxl",KQrUb:function(a,n){return a|n},OlJVZ:function(a,n){return a|n},ogNFM:function(a,n){return a<<n},YMaNh:function(a,n){return a+n},zBBDx:function(a,n){return a|n},EHVrq:function(a,n){return a|n},QrbUm:function(a,n){return a|n},Mglye:function(a,n){return a+n},HMsAc:function(a,n){return a+n},DPaYH:function(a,n){return a<<n},jmxxJ:function(a,n){return a>>>n},ddKAZ:function(a,n){return a&n},XeSau:function(a,n){return a>>>n},MZWKI:function(a,n){return a+n},nHwvA:function(a,n){return a+n},jRGed:function(a,n){return a+n},iTVJX:function(a,n){return a+n},hDoso:function(a,n){return a<<n},xWzMY:function(a,n){return a<<n},AbKLG:function(a,n){return a&n},CQQGv:function(a,n){return a<n},zfXaV:function(a,n){return a>n},qjrxD:function(a,n){return a&n},YthUj:function(a,n){return a&n},ppocP:"3|2|5|1|"+t(752)+t(618)+"0",bERMz:function(a,n){return a<n},QQBCc:function(a,n){return a>>>n},Ctjuw:function(a,n){return a<<n},abwcB:function(a,n){return a|n},HjzKX:function(a,n){return a>n},jIwlw:t(662),KhheC:function(a,n){return a instanceof n},ZgMzp:function(a,n){return a+n},RmHDo:function(a,n){return a|n},vffGH:function(a,n){return a&n},djmKY:function(a,n){return a<<n},ykzqb:function(a,n){return a&n},XoJeq:function(a,n){return a>>n},IwsjO:function(a,n){return a+n},yvagB:t(903),grkbb:t(1611),XpJtU:"zRKtn",aVniE:t(620),NOvQu:t(1326),UqVRB:t(1612)+t(1911),ESFyP:t(716),ooEhj:t(908)+t(1951),NyeId:function(a,n){return a<n},XwTXD:function(a,n,s){return a(n,s)},RYeQa:function(a,n,s){return a(n,s)},lnjSB:t(1964)+t(513),gAAOx:t(1536)+t(1283),PKyfS:function(a,n){return a!==n},SLoxH:t(1266),iNVQy:t(1041),deYvQ:t(1635),IADiF:"CONTINUE",NmDTU:function(a,n){return a!=n},bZbRJ:function(a,n){return a(n)},ZBZuE:"setcursor",AswXT:function(a,n){return a!==n},SBHsj:function(a,n){return a&n},lobaR:function(a,n){return a&n},IkoFc:function(a,n){return a!==n},NRyVq:"dwDbQ",kAvNE:function(a,n){return a!==n},JphzQ:"KzOki",fVkyb:t(510),sxdLr:t(451),LmXZo:"TkDsl",cTUKn:function(a,n){return a||n},ztPax:function(a,n){return a!==n},qbSTL:t(1683),KvbrE:function(a,n){return a===n},NguYy:"code",bHwrG:t(440)+"er_msgid",wkuJF:function(a,n){return a(n)},zgEzo:t(440)+t(1500),MUykY:"x-msg-qos",CrdEe:function(a,n,s){return a(n,s)},DWaNV:t(1354)+t(653)+"e",cUKTv:function(a,n){return a(n)},gudWx:function(a,n,s){return a(n,s)},DbTUQ:t(1354)+t(395)+"ue",KstOL:function(a){return a()},eUbof:"nWfYL",aIGPD:function(a){return a()},AjjzY:function(a){return a()},ufaEa:function(a,n,s){return a(n,s)},HxkgD:function(a,n){return a===n},wbyfg:function(a,n){return a&&n},DqIYB:function(a){return a()},CcSJG:"yHWpD",eSSgy:function(a,n){return a(n)},PwaFz:function(a){return a()},eumwZ:function(a,n){return a<n},NYqrD:function(a,n){return a===n},cwxdq:function(a){return a()},vdsXS:function(a,n,s,d){return a(n,s,d)},HEkkJ:function(a,n){return a===n},ZGmSF:function(a,n){return a===n},KWfiv:t(1223),vrwom:function(a,n){return a===n},eMDLa:t(1624),dGdVT:function(a,n,s){return a(n,s)},cxQGA:function(a,n){return a===n},YYdtR:t(1279),oYQeX:t(1871),Jlyig:"hBIYO",Dvecp:t(397),CrxGh:function(a,n,s){return a(n,s)},GOVJK:function(a,n){return a!==n},EGCFJ:t(478),kxHyJ:t(1652),asJqp:t(517)+t(827),rRMiM:t(802),oOXOz:function(a,n){return a==n},pjbGN:t(1730)+t(693)+t(683),paklj:function(a,n){return a(n)},sNGqH:t(1730)+t(1714)+t(1472)+t(1819)+"ket cons"+t(902)+t(741)+"ined",JwnLr:t(1566)+"t",wIZsw:t(1291)+t(1245)+" reconnect",pCQaT:t(1002),YrHzx:t(623),cjTmv:function(a,n){return a!==n},lMlvi:"PDlIv",wMBBE:t(627),MxmeR:"pageshow",tWEPJ:function(a,n){return a===n},WGnvm:"HyCBX",qhwIw:function(a,n){return a!==n},QUAlU:function(a,n){return a!==n},fvqNO:function(a,n){return a===n},HlzZz:t(1093),vEmLQ:"https:",Fchxl:"wss://",lJOKN:t(1256),LJNkX:t(1693)+"d",scxlQ:function(a,n){return a==n},EtJvi:function(a){return a()},FLUqE:"web",Ppxlu:t(1218)+"0",HoNmz:function(a){return a()},gDPaF:function(a,n){return a===n},QIGPe:"uxude",CisqY:function(a,n,s){return a(n,s)},qlMke:function(a,n){return a||n},qIhMA:function(a,n,s){return a(n,s)},FuogM:t(1534),nngbU:function(a,n){return a>n},tLIpB:function(a,n){return a(n)},SShrS:function(a,n){return a(n)},knsAU:t(1040)+">",vVqoT:"timeout",NAYks:t(682)+t(468)+t(1566)+"ting ser"+t(1783),jEsUL:function(a,n){return a+n},CqQJC:"zngZf",vxxuG:function(a,n){return a<n},GyTGt:function(a,n){return a|n},XaHTd:function(a,n){return a&n},LuMYS:function(a,n){return a|n},PfVVf:function(a,n){return a|n},iYiiO:function(a,n){return a<<n},WKwHq:function(a,n){return a&n},ymTDx:function(a,n){return a>=n},QqHph:function(a,n){return a<<n},HfBYZ:function(a,n){return a&n},mYjVA:t(1e3),hMspm:"timeout,"+t(1743)+t(767)+"g",rbFoU:function(a,n){return a===n},gnkjW:t(1602),XRHAt:"1|4|3|0|2",wgVaC:t(1333)+"4",EJHtK:function(a,n){return a+n},VCfjR:function(a,n,s){return a(n,s)},DpDhV:function(a,n){return a&n},BGtrM:"LVgNV",UAMkw:t(460),BfzUY:t(560),TSuVI:"ogamk",nLEnw:function(a,n){return a===n},JiXnK:function(a,n,s){return a(n,s)},XENWY:"going away, netw"+t(1860)+"ine",VEJLd:function(a,n){return a>>n},nbJyM:function(a,n){return a|n},EQkAQ:t(1227),woRLl:t(1372),FETkq:t(1428),qVnKl:function(a,n){return a===n},MaUEQ:t(1900)+"s alread"+t(1298),uYDKz:function(a,n){return a==n},MJbmx:t(1730)+t(1580)+t(547)+t(1377)+t(436)+"e a stri"+t(410)+t(797)+t(1689),dcYjE:function(a,n){return a==n},ZMjIY:t(1708),DcMSf:function(a,n){return a(n)},DZeui:t(841),vouES:function(a,n){return a<n},uQvqi:t(1324),cPUjh:function(a,n){return a!==n},PdtTj:function(a,n){return a!==n},rqpHd:t(1662),NJGpy:function(a,n){return a+n},UomjO:function(a,n){return a+n},AmmuO:"QbWPD",bPKly:function(a,n){return a===n},lSonD:t(1438),wjnwZ:t(1484)+"1",xqhbt:function(a,n,s){return a(n,s)},JtQqE:t(1413),sbrOv:function(a,n){return a+n},LNoEK:function(a,n){return a<<n},pzipL:function(a,n){return a+n},dTtEg:t(1477),pSGDT:function(a,n){return a(n)},TKpaH:t(519),orfjW:t(611),HyXbg:function(a,n){return a*n},WtixW:function(a,n){return a!=n},lDHHu:t(1918),xxqmB:function(a,n){return a!=n},ShfBQ:function(a,n){return a===n},vkkUM:t(1118),uosxC:t(1209)+t(1328)+t(1795)+"pe",PuWee:function(a,n){return a===n},aFSty:function(a,n){return a===n},bwwvX:t(385)+t(1200)+t(672),KZaDG:function(a,n){return a!=n},MZiSP:function(a,n){return a===n},kZpwG:function(a,n){return a!=n}};Pt.r(De),Pt.d(De,{FWS:()=>Lp,CustomErrorEvent:()=>jd,createCloseEvent:()=>xt,ReconnectEvent:()=>qd,createErrorEvent:()=>ot,decodedFrame:()=>Zt,createOpenEvent:()=>Jd,CustomCloseEvent:()=>Gd,createReconnectEvent:()=>aa,FrontierMessageEvent:()=>Wd,encodeFrame:()=>Bt,createMessageEvent:()=>Vd,OpenEvent:()=>$d,ErrorCode:()=>Qt,Event:()=>Vn,MessageEvent:()=>Kd});let r="";function i(a=""){let n=t,s="02",d=""+Date.now(),l=r||(r=e.DETXY(x,a)),h=Math[n(434)]()[n(1490)](16)[n(1274)](-6);return e.grtQy(e[n(679)](e.grtQy(s,d),l),h)}function o(){let a=t;return e.PpefP(e[a(991)](1e4,Date[a(1079)]()),Math.floor(e[a(1216)](1e4,Math[a(434)]())))}function c(a){let n=t,s={Tcdky:function(d,l){return e[U(1684)](d,l)},uMQnz:function(d,l){return e[U(1684)](d,l)},TZQxQ:e[n(773)]};if(e.RYbjx(n(1942),e[n(509)]))return(e[n(1196)](Array,8)[n(1905)]("0")+e.HCbkW(parseInt,a,10).toString(2))[n(1274)](-8);_0x37a054[n(1603)+n(400)](iuxGWk[n(1327)],d=>{let l=n;_0x19ee51(iuxGWk.Tcdky(_0x349441,_0xce5ae4[l(1080)]),d[l(420)+"on"],d[l(1341)+"on"],iuxGWk[l(990)](_0x1d355c,_0x4582ca[l(1695)+l(1634)]))})}function u(a){let n=t;return e[n(679)](e[n(1196)](Array,4)[n(1905)]("0"),e[n(1960)](parseInt,a,2)[n(1490)](16)).slice(-4)}function f(a){let n=t,s=a[n(657)](/\./)[n(870)](h=>c(h)),d=[];return d[0]=e[n(1684)](u,e[n(1370)](s[0],s[1])),d[1]=e[n(1196)](u,e[n(1858)](s[2],s[3])),[n(630),e[n(1711)],e[n(1711)],n(630),n(630),e.yckxW,d[0],d[1]][n(1905)]("")}function x(a){let n=t;if(e.Wnvaj("GvWEx",e.CNajr)){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(1065)](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(1065)](a);return s?f(a):d?e[n(1684)](p,a):e.IxkIp}else _0x49b481[n(1034)+"JSONP"]=void 0,_0x2c66f8(e[n(1888)])}function p(a){let n=t,s={jhWXE:e[n(1607)]},d="",l=[],h=0,g=0,w=!0,m=e.jUmgP;if(e[n(981)](a[n(992)]("::"),-1)){let L=a[n(657)]("::");for(let W=0;e.MqevO(W,L[n(1775)]);W++)if(e[n(598)]!==e[n(554)]){let Y=L[W];if(e[n(1285)](Y[n(992)](":"),0))if(e[n(1450)](e.cEzwJ,e[n(1756)])){let de=Y[n(657)](":");w&&(h=de[n(1775)]),g+=de[n(1775)];for(let pe=0;e[n(1304)](pe,de.length);pe++)if(e[n(543)](4,de[pe][n(1775)])){let Qe=m[n(464)+"g"](0,e[n(1687)](4,de[pe][n(1775)])),Zn=Qe[n(1717)](de[pe]);l.push(Zn)}else l[n(883)](de[pe]);w=!1}else{let de=s[n(1691)].split("|"),pe=0;for(;;){switch(de[pe++]){case"0":_0x17b350[_0x5b022d](A,A[n(882)],_0x39ca7e);continue;case"1":var A=_0x38e8f9[_0x1ddf15]={exports:{}};continue;case"2":var N=_0x69171b[_0x5242b5];continue;case"3":if(N!==void 0)return N[n(882)];continue;case"4":return A[n(882)]}break}}else{if(e.HJhpF(4,Y.length)){let de=m[n(464)+"g"](0,4-Y[n(1775)]),pe=de.concat(Y);l.push(pe)}else l[n(883)](Y);w&&(h+=1),g+=1,w=!1}}else{let Y=_0x445f3a[n(464)+"g"](0,e.gPYIr(4,_0x52c638[n(1775)])),de=Y[n(1717)](_0x7cf46a);_0x100641[n(883)](de)}let q="";for(let W=0;e[n(1304)](W,e[n(1687)](8,g));W++)q=q[n(1717)](m);for(let W=0;e[n(1388)](W,l.length);W++)e[n(1846)](W,h)&&(d=d[n(1717)](q)),d=d[n(1717)](l[W]);return d}{let L=a[n(657)](":");for(let q=0;e[n(1553)](q,L.length);q++){let W=L[q];if(e.JbanU(4,L[q][n(1775)])){let Y=m.substring(0,e[n(473)](4,L[q].length)),de=Y[n(1717)](W);d=d.concat(de)}else d=d[n(1717)](W)}return d}}function b(a,n){let s=t,d=a[s(1616)];e[s(1896)](void 0,d)&&(e[s(847)](fe,n,10),e[s(1478)](j,n,d));let l=a[s(1555)];e[s(619)](void 0,l)&&(fe(n,18),e.FBDxC(j,n,l))}function E(a){let n=t,s={};e:for(;!e.eHtMH(J,a);)if(e.kEfPI(n(1776),e[n(969)])){let d=le(a);switch(e[n(1189)](d,3)){case 0:break e;case 1:s[n(1616)]=e[n(847)](O,a,le(a));break;case 2:s[n(1555)]=O(a,e[n(1646)](le,a));break;default:e[n(847)](D,a,e[n(1740)](7,d))}}else return _0x3fee6c||(_0x3eb511=_0xb6fb7d[n(1391)]()[n(1822)](_0x3b0dbc[n(412)](_0x604ff4,n(829)))),_0x184191;if(e[n(1762)](void 0,s[n(1616)]))throw new Error(n(493)+n(1339)+n(1026)+n(1616));if(e[n(576)](void 0,s.value))throw new Error(n(493)+"required field: "+n(1555));return s}function T(a){let n=t,s=R();return y(a,s),e[n(1244)](F,s)}function y(a,n){let s=t,d={DQJBo:e.AAyMr,ocEhu:s(1838),Fjhiu:function(l,h){return l&&h},GoyYv:function(l,h){return e[s(1198)](l,h)},hWRrB:e[s(916)],dvWto:function(l){return l()}};if(e.tcYRy(e.PXSki,e[s(1678)])){let l=e[s(1030)](_0xea541b,_0xa18c6a,_0x35eaad);return _0x5ad03b[s(740)][s(775)](l,l+_0x159387)}else{let l=a[s(1431)];if(e.hQezS(void 0,l))if(e[s(1887)]!=="veqph")e.HCbkW(fe,n,8),e[s(1130)](ft,n,l);else return _0x357e30(e.OaIYX(e[s(406)](e.uzzNj(s(644)+s(976)+s(1931),_0x416d04)+e[s(1387)]+(_0x43fe9e||1),e.vgbHy),_0x3cc4dd));let h=a.LogID;if(e[s(619)](void 0,h))if(e[s(1927)]!==s(1421))e[s(1130)](fe,n,16),e[s(1985)](ft,n,h);else{let pe=_0x497f13(_0x16b35f);this._ws&&this[s(604)][s(1015)+"te"]===this.OPEN&&(this._ws&&this[s(604)][s(1627)](pe),this[s(733)](s(1602),_0x359819))}let g=a[s(1797)];if(e.kEfPI(void 0,g))if(e.Wnvaj(s(538),e[s(1068)]))e[s(928)](fe,n,24),e.EUbFV(ft,n,e[s(1990)](P,g));else{let{enableAutoAck:pe}=this[s(1184)],Qe=_0x23c0c8(_0x22436f[s(1128)][s(1813)],d[s(1671)],"1"),Zn=_0x3b7466(_0x26cf21.message[s(1813)],d.ocEhu,"1"),pa=_0x342951[s(1773)](this,_0x4c89d6);if(d[s(1207)](pe,Qe)){let{SeqID:ga,LogID:Wr,service:ma,LogIDNew:Xn,method:$r}=_0x468f86[s(1128)];this._sendAck({SeqID:ga,LogID:Wr,LogIDNew:Xn,service:ma,method:$r,headers:[{key:d[s(1458)],value:"1"},{key:"ack_id",value:d[s(1568)](Xn,"")},{key:d.hWRrB,value:"0"}]})}Zn&&!pa.isQoSAck&&this["_dispatc"+s(1686)+s(1250)](_0xeafb67),d[s(1752)](_0x40eb68)}let w=a[s(613)];e[s(1232)](void 0,w)&&(e[s(1896)](e.jjVgl,e[s(795)])?e[s(1030)](_0x3340da,_0x4a9e6b,this[s(1868)+s(1694)+"e"](_0x174746)):(e[s(458)](fe,n,32),e[s(1478)](ft,n,P(w))));let m=a[s(1813)];if(e[s(890)](void 0,m))for(let pe of m){e[s(1036)](fe,n,42);let Qe=R();b(pe,Qe),e.aNAjk(fe,n,Qe.limit),e[s(1334)](K,n,Qe),e[s(548)](k,Qe)}let A=a[s(444)+s(1973)];e[s(671)](void 0,A)&&(e[s(1036)](fe,n,50),e[s(1985)](j,n,A));let N=a[s(481)+s(1309)];e.SYZYg(void 0,N)&&(fe(n,58),j(n,N));let L=a[s(933)];e.Psubn(void 0,L)&&(e[s(1400)](fe,n,66),e[s(1960)](fe,n,L[s(1775)]),e[s(1307)](he,n,L));let q=a[s(1737)];e[s(1292)](void 0,q)&&(e[s(1713)](fe,n,74),e[s(458)](j,n,q));let W=a[s(594)+s(975)];e.hIohN(void 0,W)&&(e.gTaYM(fe,n,82),e[s(1985)](j,n,W));let Y=a[s(1800)];e[s(1154)](void 0,Y)&&(e[s(1812)](fe,n,90),e[s(1036)](j,n,Y));let de=a[s(1141)+"e"];if(e.HJhpF(void 0,de))if(e[s(1570)](e[s(1254)],e[s(1254)]))e[s(739)](fe,n,96),ft(n,e[s(1448)](P,de));else{let pe=this._qosDB.getItem(this[s(1640)]),Qe=_0x86169b[s(1641)](e[s(1913)](pe,"{}"));return _0x56607f.values(Qe)}}}function v(a){let n=t;return e[n(1076)](I,e[n(548)](B,a))}function I(a){let n=t,s={};e:for(;!e.rHuFL(J,a);){let d=e[n(548)](le,a);switch(e[n(1189)](d,3)){case 0:break e;case 1:s[n(1431)]=e.FOGEf(vt,a,!0);break;case 2:s.LogID=e[n(698)](vt,a,!0);break;case 3:s.service=le(a);break;case 4:s[n(613)]=le(a);break;case 5:{let l=e[n(384)](S,a);(s[n(1813)]||(s.headers=[]))[n(883)](e[n(1780)](E,a)),a[n(1613)]=l;break}case 6:s[n(444)+"ncoding"]=e.wgDJv(O,a,e.XEIln(le,a));break;case 7:s[n(481)+n(1309)]=e.PiKYY(O,a,le(a));break;case 8:s[n(933)]=e[n(1264)](Ee,a,e.xPyOM(le,a));break;case 9:s[n(1737)]=e[n(1049)](O,a,le(a));break;case 10:s[n(594)+n(975)]=O(a,e[n(922)](le,a));break;case 11:s[n(1800)]=O(a,le(a));break;case 12:s[n(1141)+"e"]=e[n(1138)](le,a);break;default:e[n(565)](D,a,7&d)}}if(e[n(1038)](void 0,s.SeqID))throw new Error(e[n(688)]);if(s.LogID===void 0)throw new Error(e[n(516)]);if(e[n(578)](void 0,s.service))throw new Error(e[n(629)]);if(e[n(1723)](void 0,s.method))throw new Error(n(493)+n(1339)+n(1026)+n(613));return s}function S(a){let n=t,s=e.iUtKK(le,a),d=a[n(1613)];return a[n(1613)]=e[n(1884)](a[n(381)],s),d}function D(a,n){let s=t;switch(n){case 0:for(;e[s(461)](128,e.IWshX(ie,a)););break;case 2:e[s(458)](V,a,e[s(1244)](le,a));break;case 5:e.AmLgN(V,a,4);break;case 1:e[s(1036)](V,a,8);break;default:throw new Error(e[s(679)](s(1673)+s(1069)+s(1112),n))}}function P(a){return a|=0,{low:a,high:e.pKDIJ(a,31),unsigned:a>=0}}let _=[];function R(){let a=t,n=_[a(487)]();return n?(n.offset=n[a(1613)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){_.push(a)}function B(a){let n=t;if(e.FhwET(e[n(1593)],"EBbIj"))return{bytes:a,offset:0,limit:a[n(1775)]};this[n(1271)+n(1206)][n(883)](_0x2883e9),this._debug(n(1324),_0x3886af)}function F(a){let n=t,s=a[n(740)],d=a[n(1613)];return e.hRNmK(s[n(1775)],d)?s:s[n(775)](0,d)}function V(a,n){let s=t;if(e[s(658)](a[s(381)],n)>a[s(1613)])throw new Error(e[s(1810)]);a[s(381)]+=n}function J(a){let n=t;return e[n(612)](e[n(1516)],e[n(1538)])?this["currentE"+n(932)+n(1817)+"t"]:e[n(2e3)](a[n(381)],a[n(1613)])}function te(a,n){let s=t,d=a.bytes,l=a[s(381)],h=a.limit,g=e.grtQy(l,n);if(e[s(1285)](g,d[s(1775)])){let w=new Uint8Array(e.mhlmH(2,g));w[s(1906)](d),a[s(740)]=w}return a[s(381)]=g,g>h&&(a.limit=g),l}function Q(a,n){let s=t,d=a.offset;if(d+n>a.limit)throw new Error(e[s(1126)]);return a[s(381)]+=n,d}function Ee(a,n){let s=t,d=Q(a,n);return a[s(740)][s(775)](d,e[s(1011)](d,n))}function he(a,n){let s=t,d=e[s(698)](te,a,n[s(1775)]);a[s(740)][s(1906)](n,d)}function O(a,n){let s=t,d={DwwGc:function(A){return A()}},l=e.KavhJ(Q,a,n),h=String["fromChar"+s(447)],g=a.bytes,w="\uFFFD",m="";for(let A=0;A<n;A++)if(e[s(1789)]===s(504))_0x16fe7b(_0x3f1987[s(503)]),IqqPFz[s(1337)](_0x260953);else{let N=g[A+l],L,q,W,Y;if(e.tcYRy(e[s(1313)](128,N),0))m+=e[s(764)](h,N);else if(e[s(450)](224&N,192))if(e[s(2e3)](A+1,n))m+=w;else if(e[s(1940)](s(921),e[s(765)])){this[s(1493)+s(1926)](),this["_pingPon"+s(490)+"Id"]=_0x2518fa(this[s(1690)][s(412)](this),this[s(1184)][s(609)+s(1526)]);return}else L=g[e[s(1835)](A+l,1)],e.irxCH(192,L)!==128?m+=w:(Y=e.QdvGV(e[s(1908)](e[s(1044)](31,N),6),e[s(915)](63,L)),e[s(507)](Y,128)?m+=w:(m+=e[s(384)](h,Y),A++));else if((240&N)==224)e.nOYQu(e.eeRrJ(A,2),n)?m+=w:(L=g[e[s(1370)](e.uzzNj(A,l),1)],q=g[e[s(1884)](e.SdyuN(A,l),2)],e[s(1943)](e[s(1394)](L,e[s(1395)](q,8))&49344,32896)?m+=w:(Y=e[s(393)](e[s(393)](e[s(484)](e.WYOpJ(15,N),12),e[s(484)](e[s(1511)](63,L),6)),e.rQBJU(63,q)),e[s(1553)](Y,2048)||e[s(1179)](Y,55296)&&e[s(1550)](Y,57343)?m+=w:(m+=e[s(1684)](h,Y),A+=2)));else if(e[s(1840)](248,N)==240)if(e[s(1070)](A,3)>=n)m+=w;else if(e[s(707)](e.CNAGG,s(1303)))L=g[e[s(1296)](A,l)+1],q=g[e.XdEKp(A,l)+2],W=g[e[s(1722)](A+l,3)],e.cwJIp(e.bKkDf(e[s(1262)](L|e[s(1343)](q,8),e[s(1699)](W,16)),12632256),8421504)?m+=w:(Y=e[s(1262)](e[s(551)](e[s(1907)](e[s(1313)](7,N)<<18,e[s(1343)](e[s(1313)](63,L),12)),e[s(1395)](e[s(1899)](63,q),6)),e.kNWId(63,W)),Y<65536||e.rTSNm(Y,1114111)?m+=w:(Y-=65536,m+=e[s(1748)](h,e[s(1050)](Y,10)+55296,e.GvzCq(e[s(1840)](1023,Y),56320)),A+=3));else{let de=e.vYSka[s(657)]("|"),pe=0;for(;;){switch(de[pe++]){case"0":_0x5eb25e[_0x5ab200++]=e[s(1439)](_0x478c6f,18)|240;continue;case"1":_0x229e52=e[s(1011)](e[s(1027)](65536,e[s(484)](e[s(665)](1023,_0x2ddae6),10)),e[s(1751)](1023,_0x35a934));continue;case"2":++_0x1f1c51;continue;case"3":_0x22e7d6[_0xf57c55++]=e[s(1528)](e[s(1740)](e.lFixz(_0x40f6ab,6),63),128);continue;case"4":_0x37fae7[_0x2d033b++]=e[s(393)](e[s(1033)](63,_0x50307f),128);continue;case"5":_0xe48eb4[_0x9c1159++]=e[s(1394)](e[s(952)](e[s(1828)](_0x36d433,12),63),128);continue}break}}else m+=w}return m}function j(a,n){let s=t,d={EBKvK:function(m,A){return m+A},XETJd:function(m,A){return e.xwqTG(m,A)},UlJbE:function(m,A){return e[U(1272)](m,A)},LyOHs:function(m,A){return m>>>A},DnQqL:function(m,A){return e[U(1070)](m,A)},HMQoe:function(m,A){return m*A}},l=n[s(1775)],h=0;for(let m=0;e[s(732)](m,l);m++){let A=n[s(1902)+"At"](m);e.sggki(A,55296)&&e[s(1550)](A,56319)&&e[s(1388)](e[s(849)](m,1),l)&&(A=e[s(1687)](e[s(679)](e[s(1035)](A,10),n[s(1902)+"At"](++m)),56613888)),h+=e[s(1542)](A,128)?1:e[s(1542)](A,2048)?2:A<65536?3:4}e.HAgIT(fe,a,h);let g=e[s(1307)](te,a,h),w=a[s(740)];for(let m=0;e[s(792)](m,l);m++){let A=n[s(1902)+"At"](m);if(A>=55296&&A<=56319&&e.fbRGX(m+1,l)&&(A=e[s(1011)](A<<10,n[s(1902)+"At"](++m))-56613888),e[s(1280)](A,128))w[g++]=A;else{if(e[s(1502)](e.WzdQp,e[s(1501)]))return this[s(1688)]?d.EBKvK(d.XETJd(d[s(1055)](this[s(906)],0),_0x1adad2),d.LyOHs(this[s(542)],0)):d.DnQqL(d.HMQoe(this[s(906)],_0x2ac8e0),this.low>>>0);e[s(441)](A,2048)?w[g++]=e[s(950)](e.TFDov(e.lFixz(A,6),31),192):(e[s(1388)](A,65536)?w[g++]=e[s(551)](e[s(1033)](e[s(1050)](A,12),15),224):(w[g++]=e[s(556)](e[s(1315)](A>>18,7),240),w[g++]=e[s(1106)](e[s(691)](e[s(465)](A,12),63),128)),w[g++]=e[s(1262)](A>>6&63,128)),w[g++]=e[s(1106)](e[s(1569)](63,A),128)}}}function K(a,n){let s=t,d=te(a,n.limit),l=a[s(740)],h=n[s(740)];for(let g=0,w=n.limit;e[s(507)](g,w);g++)l[e[s(658)](g,d)]=h[g]}function ie(a){let n=t;return a[n(740)][e[n(1307)](Q,a,1)]}function Je(a,n){let s=t,d=e[s(1030)](te,a,1);a[s(740)][d]=n}function le(a){let n=t;if(e[n(1347)](e.DjCuB,e[n(1211)])){let s=0,d=0,l;do l=e[n(1375)](ie,a),e[n(507)](s,32)&&(d|=e[n(1908)](e[n(1786)](127,l),s)),s+=7;while(e.OwGML(128,l));return d}else return this[n(1286)]?.[n(1906)]({message_id:_0xa1131d,timestamp:_0x5c1762})}function fe(a,n){let s=t;for(n>>>=0;e[s(2e3)](n,128);)e[s(1478)](Je,a,e[s(556)](e[s(1934)](127,n),128)),n>>>=7;e[s(1334)](Je,a,n)}function vt(a,n){let s=t,d={ngHRi:e[s(647)],PYvKi:e[s(770)],gOCUD:e[s(1587)]},l=0,h=0,g=0,w;if(w=e[s(1811)](ie,a),l=e.kNWId(127,w),128&w&&(w=e[s(1244)](ie,a),l|=e.WiUKe(127&w,7),e.gvHFC(128,w)&&(w=e[s(851)](ie,a),l|=e[s(1343)](e[s(1381)](127,w),14),e[s(691)](128,w))))if(e[s(492)](e[s(1975)],s(807)))w=e.SuIHd(ie,a),l|=e[s(1615)](127&w,21),128&w&&(w=ie(a),h=e[s(475)](127,w),e[s(915)](128,w)&&(w=e.HKWPF(ie,a),h|=e[s(488)](e[s(915)](127,w),7),e[s(553)](128,w)&&(w=ie(a),h|=e[s(488)](127&w,14),128&w&&(w=e[s(1138)](ie,a),h|=e[s(2002)](127&w,21),e[s(475)](128,w)&&(w=e.Halvf(ie,a),g=e[s(1729)](127,w),e[s(1769)](128,w)&&(w=e.ZXUOC(ie,a),g|=e[s(403)](e[s(1465)](127,w),7)))))));else{let m=d.ngHRi[s(657)]("|"),A=0;for(;;){switch(m[A++]){case"0":this[s(604)][s(1603)+"Listener"](d[s(1316)],this[s(868)]);continue;case"1":this[s(604)][s(1603)+s(400)]("open",this[s(1933)]);continue;case"2":this[s(604)][s(1603)+s(400)](s(503),this[s(1249)]);continue;case"3":if(!this[s(604)])return;continue;case"4":this[s(604)].addEventListener(d[s(1816)],this[s(572)+"ge"]);continue}break}}return{low:e[s(556)](l,e[s(1510)](h,28)),high:e.OeglB(e.OiGMm(h,4),g<<24),unsigned:n}}function ft(a,n){let s=t;if(e.rAOoS(e.dpoie,s(1147)))_0x10e51d[s(1520)][s(968)+s(1609)](_0xe68ba9),_0xd50228[s(1034)+s(1917)]=void 0,e[s(1196)](_0x3b013d,_0x31405f&&_0x50a5cb[s(1675)]||e.krZFG);else{let d=e[s(1189)](n[s(542)],0),l=e.gzXhy(e[s(1208)](n[s(542)],28),e[s(1491)](n[s(906)],4))>>>0,h=e[s(1189)](n[s(906)],24),g=e[s(450)](0,h)?e[s(1987)](0,l)?e[s(792)](d,16384)?e[s(1280)](d,128)?1:2:e[s(792)](d,2097152)?3:4:e[s(1542)](l,16384)?e[s(423)](l,128)?5:6:e[s(1553)](l,2097152)?7:8:e[s(423)](h,128)?9:10,w=e[s(1307)](te,a,g),m=a.bytes;switch(g){case 10:m[e.eroJL(w,9)]=e.kNWId(h>>>7,1);case 9:m[e.SdyuN(w,8)]=g!==9?128|h:e[s(711)](127,h);case 8:m[e[s(1884)](w,7)]=g!==8?e[s(552)](e[s(1476)](l,21),128):e[s(730)](l,21)&127;case 7:m[e[s(849)](w,6)]=e[s(1097)](7,g)?l>>>14|128:e[s(1746)](l>>>14,127);case 6:m[e[s(1403)](w,5)]=e[s(543)](6,g)?e[s(1907)](e.BhDmW(l,7),128):e.xvPep(l>>>7,127);case 5:m[w+4]=e[s(492)](5,g)?e.xmlji(128,l):e[s(1786)](127,l);case 4:m[w+3]=e[s(1760)](4,g)?e[s(499)](d,21)|128:e[s(1489)](e[s(1426)](d,21),127);case 3:m[e[s(1296)](w,2)]=g!==3?e[s(1376)](d,14)|128:e.PzqZM(e[s(1272)](d,14),127);case 2:m[e[s(1136)](w,1)]=g!==2?e[s(1067)](e[s(951)](d,7),128):e[s(915)](d>>>7,127);case 1:m[w]=e[s(1382)](1,g)?e[s(1803)](128,d):e[s(1134)](127,d)}}}function Zt(a){return v(a)}function Bt(a){return T(a)}let Xt=65536,jr=e[t(831)],we=e[t(664)](Xt,Xt),Ae=e.HyXbg(we,we),$n=e[t(1353)](Ae,2),ke=String.prototype[t(1902)+"At"];class ce{constructor(n,s,d){let l=t;this[l(1318)]=!0,this[l(542)]=0|n,this[l(906)]=e[l(1854)](0,s),this[l(1688)]=!!d}static[t(1318)](n){let s=t;if(e[s(1325)]!==e[s(1325)]){let d={GFADb:function(l,h){return l(h)}};return function(l,...h){let g=s,w=_0x55ad22.call(d.GFADb(_0x49ac17,this),l,...h);return _0xd768f5.set(w,l[g(518)]?l[g(518)]():[l]),_0x1b16f2(w)}}else return n&&e[s(450)](!0,n[s(1318)])}static[t(1628)](n,s,d){let l=t,h={smpwF:function(g,w){return e.FqFkZ(g,w)},FTSwx:function(g,w){return g<w},eNuBC:function(g,w){return g+w},AYamD:function(g,w){return g-w},GvwQe:function(g,w){return g<<w},MMDiC:function(g,w){return e[U(1581)](g,w)},fVUKJ:function(g,w){return e[U(1761)](g,w)},lPMXJ:function(g,w){return e[U(1772)](g,w)},FuxPI:function(g,w){return e.kMVKB(g,w)},qgJuH:function(g,w){return e.pKDIJ(g,w)},pDJNs:function(g,w){return e[U(1528)](g,w)},AtWgo:function(g,w){return g>>w},oDHZB:function(g,w){return e.ZwYBb(g,w)}};if(e[l(1004)](e[l(1638)],l(1290)))return new ce(n,s,d);{let g=_0x2ca432[l(1902)+"At"](_0x187cc1);g>=55296&&WlSTOF.smpwF(g,56319)&&WlSTOF[l(1379)](WlSTOF[l(1583)](_0x468f25,1),_0x309aee)&&(g=WlSTOF[l(1168)](WlSTOF[l(524)](g,10)+_0x56450b[l(1902)+"At"](++_0x1ba8af),56613888)),g<128?_0x28c055[_0x2a7b79++]=g:(g<2048?_0x83ef73[_0x5ea723++]=WlSTOF[l(1979)](WlSTOF[l(580)](g>>6,31),192):(WlSTOF[l(706)](g,65536)?_0x3d9212[_0x1b92b8++]=WlSTOF[l(1979)](WlSTOF.fVUKJ(g>>12,15),224):(_0x1b4473[_0x219da8++]=WlSTOF[l(1362)](WlSTOF[l(1350)](g,18)&7,240),_0xba46c5[_0x484e10++]=WlSTOF[l(1362)](WlSTOF[l(1350)](g,12)&63,128)),_0x56092a[_0x16cfc2++]=WlSTOF[l(1883)](WlSTOF.AtWgo(g,6)&63,128)),_0x176460[_0x4ec507++]=WlSTOF[l(1342)](63&g,128))}}static[t(931)+"s"](n,s,d){let l=t;return d?ce[l(931)+"sLE"](n,s):ce[l(931)+l(719)](n,s)}static[t(931)+t(1418)](n,s){let d=t,l={IWdvz:function(h,g,w){return e[U(705)](h,g,w)},ENjCe:function(h,g){return h(g)}};if(e[d(1071)]!==e.nDIFV)return new ce(e[d(848)](e[d(818)](e.mlldv(n[0],e[d(895)](n[1],8)),e[d(1660)](n[2],16)),e[d(512)](n[3],24)),e[d(1528)](e.TzpNc(e[d(556)](n[4],e[d(488)](n[5],8)),e[d(1308)](n[6],16)),e.hYrJa(n[7],24)),s);_0x3db112(_0x1e7e35,96),wrbQMY[d(1826)](_0x528fa8,_0x43734d,wrbQMY[d(1733)](_0x28e803,_0xb526e1))}static[t(931)+"sBE"](n,s){let d=t,l={Gidzv:function(h,g){return e[U(1074)](h,g)},RqCoz:e[d(1574)],TZzcL:function(h,g,w,m){return e[d(1278)](h,g,w,m)}};if(e[d(1882)](e[d(963)],e[d(963)]))return new ce(e[d(806)](e.ZwYBb(e.eGyUD(n[4]<<24,e.WIMLv(n[5],16)),e.mpruT(n[6],8)),n[7]),e[d(1394)](e[d(393)](e[d(1374)](e[d(1825)](n[0],24),e[d(2002)](n[1],16)),e[d(1301)](n[2],8)),n[3]),s);if(l[d(718)](l[d(1297)],typeof _0x4748be)){let h=new _0x383811(_0x2e64b3(_0x33557d));return l[d(1480)](_0x5bb424,_0x10b5d4,h,0),h}return _0x3721e8 instanceof _0x5cbdfa?new _0x546eea(_0x2e21f3):new _0x4254f1(_0x9345f9[d(1293)],_0x276394[d(476)+"et"],_0x350a65[d(701)+"th"])}static[t(1586)](n){let s=t;return e[s(576)](n,jr)?Hd:new ce((e[s(551)](e[s(1321)](ke.call(n,0),ke[s(1773)](n,1)<<8),e[s(881)](ke.call(n,2),16))|e[s(930)](ke.call(n,3),24))>>>0,e[s(1329)](e.UlMss(e[s(838)](e[s(1522)](ke[s(1773)](n,4),e.aVOBE(ke[s(1773)](n,5),8)),e[s(1744)](ke[s(1773)](n,6),16)),e[s(1054)](ke[s(1773)](n,7),24)),0),!0)}[t(1866)](){let n=t,s={DRhyu:function(d,l){return d>>>l},QyKlv:function(d,l){return d|l},gHYum:function(d,l){return e[U(835)](d,l)},nlwst:function(d,l){return d>>>l},PpfDH:function(d,l){return e[U(441)](d,l)},eUUsr:function(d,l){return e[U(1304)](d,l)},rDlAw:function(d,l){return e[U(423)](d,l)},CzRXL:function(d,l){return e.qcqvb(d,l)},IBxHl:function(d,l){return e.TCgZE(d,l)},KpaFE:function(d,l){return d|l},LMfPr:function(d,l){return e[U(675)](d,l)},sVwzt:function(d,l){return e.FZeYL(d,l)},rIasV:function(d,l){return e.SYZYg(d,l)},RqVFQ:function(d,l){return d!==l},hldjI:function(d,l){return d|l},LpsMJ:function(d,l){return e[U(1934)](d,l)},rjkYv:function(d,l){return e[U(983)](d,l)},jrjOk:function(d,l){return e[U(658)](d,l)},AmKHt:function(d,l){return d|l},szpVt:function(d,l){return d>>>l},FMony:function(d,l){return e.HJhpF(d,l)}};if(e[n(1233)](n(2005),n(2005))){let d=FvgNyK.DRhyu(_0x371b1a.low,0),l=FvgNyK[n(1171)](FvgNyK[n(1853)](FvgNyK[n(1171)](_0x5bc734.low,28),FvgNyK[n(811)](_0x114da1.high,4)),0),h=FvgNyK[n(1949)](_0xae8783[n(906)],24),g=h===0?l===0?d<16384?FvgNyK[n(639)](d,128)?1:2:FvgNyK[n(1863)](d,2097152)?3:4:l<16384?FvgNyK.PpfDH(l,128)?5:6:FvgNyK[n(1167)](l,2097152)?7:8:FvgNyK[n(1167)](h,128)?9:10,w=_0x8ad53(_0x38ffa4,g),m=_0x4b188f[n(740)];switch(g){case 10:m[w+9]=FvgNyK[n(456)](FvgNyK.DRhyu(h,7),1);case 9:m[FvgNyK[n(470)](w,8)]=g!==9?FvgNyK[n(435)](128,h):FvgNyK[n(456)](127,h);case 8:m[FvgNyK.IBxHl(w,7)]=FvgNyK[n(1815)](8,g)?FvgNyK.nlwst(l,21)|128:FvgNyK[n(816)](l>>>21,127);case 7:m[FvgNyK[n(470)](w,6)]=FvgNyK[n(1605)](7,g)?FvgNyK[n(1949)](l,14)|128:FvgNyK[n(1949)](l,14)&127;case 6:m[FvgNyK.IBxHl(w,5)]=FvgNyK.RqVFQ(6,g)?FvgNyK[n(1663)](FvgNyK[n(1171)](l,7),128):FvgNyK[n(456)](l>>>7,127);case 5:m[FvgNyK.IBxHl(w,4)]=g!==5?128|l:FvgNyK[n(768)](127,l);case 4:m[FvgNyK.IBxHl(w,3)]=FvgNyK[n(1788)](4,g)?FvgNyK[n(1171)](d,21)|128:FvgNyK[n(816)](FvgNyK.nlwst(d,21),127);case 3:m[FvgNyK[n(1488)](w,2)]=FvgNyK.RqVFQ(3,g)?FvgNyK[n(1252)](FvgNyK.nlwst(d,14),128):FvgNyK[n(768)](FvgNyK.szpVt(d,14),127);case 2:m[w+1]=FvgNyK[n(661)](2,g)?FvgNyK.szpVt(d,7)|128:FvgNyK[n(816)](FvgNyK[n(1915)](d,7),127);case 1:m[w]=FvgNyK[n(1605)](1,g)?128|d:127&d}}else return String[n(1499)+n(447)](255&this[n(542)],e[n(553)](e[n(382)](this[n(542)],8),255),this.low>>>16&255,e[n(1208)](this[n(542)],24),e[n(1219)](255,this.high),e[n(1294)](e[n(709)](this[n(906)],8),255),e[n(978)](e[n(1329)](this.high,16),255),this.high>>>24)}static[t(1386)+"er"](n,s=!0){let d=t;if(e.cxxvw(e[d(1589)],e.cEesT)){let l=0,h=[];for(;e.FHhgL(l,_0x2cae09[d(701)+"th"]);){let{offset:g}=e[d(739)](_0x20657b,_0x1e7637,l);l=g;let w={cursor_name:"",cursor:0,service:0},{value:m,offset:A}=e[d(1449)](_0x230b86,_0x2ac443,l);w[d(1797)]=m,l=A;let{value:N,offset:L}=e.DITHG(_0x2aec7d,_0x4385ae,l);l=L,w["cursor_n"+d(1283)]=_0x1a3dfb(_0x3c0637,l,e[d(569)](l,N)),l+=N;let{value:q,offset:W}=_0x2bc24e(_0x3d9096,l);w[d(677)]=q[d(1467)](),l=W,h[d(883)](w)}return h}else{if(e.xPyOM(isNaN,n))return s?$h:Hd;if(s){if(e[d(2e3)](n,Ae))return Jh}else if(e[d(1232)](e[d(1929)],d(1356))){let l=e[d(1985)](_0x5be476,e.NZgYO,{message:this["_formatE"+d(676)+d(1530)](_0x294550)});this[d(559)](e[d(1785)],l);let h=_0x119742(e[d(770)],{reason:this[d(828)+"rrorMess"+d(1530)](_0x543748)});this[d(559)](e.sgNHw,h)}else{if(n<=-$n)return Yh;if(e[d(1241)](e.nHtgG(n,1),$n))return Vh}return ce.fromBits(e[d(448)](e[d(599)](n,we),0),e[d(1528)](e[d(1353)](n,we),0),s)}}[t(1467)](){let n=t;return this[n(1688)]?e.TCgZE(e[n(419)](e[n(730)](this[n(906)],0),we),this[n(542)]>>>0):e[n(664)](this[n(906)],we)+e[n(1208)](this.low,0)}[t(1045)](){let n=t;return e[n(635)](0,this[n(906)])&&e[n(1004)](0,this[n(542)])}[t(1331)](n){let s=t;ce[s(1318)](n)||(n=ce[s(1386)+"er"](n));let d=this[s(906)]>>>16,l=e[s(1597)](65535,this.high),h=e[s(1175)](this.low,16),g=65535&this.low,w=n[s(906)]>>>16,m=e.DGgXh(65535,n[s(906)]),A=e.KsNbQ(n[s(542)],16),N=e[s(1729)](65535,n.low),L=0,q=0,W=0,Y=0;return Y+=e.VrWCZ(g,N),W+=e[s(1208)](Y,16),Y&=65535,W+=e[s(988)](h,A),q+=e[s(1875)](W,16),W&=65535,q+=e[s(1027)](l,m),L+=q>>>16,q&=65535,L+=d+w,L&=65535,ce[s(1628)](e.pyyok(e[s(835)](W,16),Y),e.OeglB(e[s(1343)](L,16),q),this[s(1688)])}equals(n){let s=t;return ce[s(1318)](n)||(n=ce[s(1386)+"er"](n)),e.YnlEL(this[s(1688)],n[s(1688)])&&e[s(1734)](e.bRFoH(this[s(906)],31),1)&&e[s(1038)](e[s(1944)](n[s(906)],31),1)?!1:e[s(1073)](this.high,n[s(906)])&&e[s(1965)](this[s(542)],n[s(542)])}[t(885)](){let n=t;return e[n(1570)](-1,this.low)&&e[n(635)](-1,this.high)?ce[n(1628)](0,0,this[n(1688)]):this.low===-1?ce[n(1628)](0,e[n(593)](this[n(906)],1),this[n(1688)]):ce[n(1628)](e.GvzCq(this[n(542)],1),this[n(906)],this[n(1688)])}[t(1653)](n){return n?this[t(1311)+"E"]():this.toBytesBE()}[t(1311)+"E"](){let n=t;if(e[n(1859)](e[n(772)],e[n(772)]))return _0x162d58[n(1391)]();{let s=this[n(906)],d=this.low;return[255&d,e[n(952)](d>>>8,255),d>>>16&255,d>>>24,e[n(1507)](255,s),e.NTViW(e[n(1944)](s,8),255),e.ITlkf(s>>>16,255),e[n(515)](s,24)]}}[t(763)+"E"](){let n=t,s=this[n(906)],d=this[n(542)];return[e.eZjwK(s,24),e[n(1763)](s,16)&255,e[n(1552)](e.WljER(s,8),255),e[n(1934)](255,s),d>>>24,e[n(1786)](e[n(1644)](d,16),255),e[n(1983)](e[n(1531)](d,8),255),e[n(1597)](255,d)]}}let Hd=new ce(0,0,!1),$h=new ce(0,0,!0),Vh=ce[t(1628)](-1,2147483647,!1),Jh=ce[t(1628)](-1,-1,!0),Yh=ce[t(1628)](0,-2147483648,!1);var Qt=(function(a){let n=t,s=(n(1595)+"3|4")[n(657)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(1165)]]=5001]=e[n(1165)];continue;case"1":a[a[e[n(1248)]]=5004]=e[n(1248)];continue;case"2":a[a[e[n(1844)]]=5002]=e[n(1844)];continue;case"3":a[a[e[n(1679)]]=5005]=e[n(1679)];continue;case"4":return a;case"5":a[a[e[n(579)]]=5003]=e[n(579)];continue}break}})({});class Vn{constructor(n){let s=t;this.type=n,this[s(621)]=null}}class qd extends Vn{constructor(n,s){let d=t;super(n),this[d(1128)]=s&&s[d(1128)]||null}}class jd extends Vn{constructor(n,s){let d=t,l=(d(893)+d(663)).split("|"),h=0;for(;;){switch(l[h++]){case"0":this[d(443)]=s&&s[d(443)]||"";continue;case"1":this[d(1128)]=s&&s[d(1128)]||"";continue;case"2":this[d(1843)]=s&&s[d(1843)]||0;continue;case"3":this[d(1166)]=s&&s[d(1166)]||0;continue;case"4":this[d(533)]=s&&s[d(533)]||5001;continue;case"5":this.error=s&&s[d(503)]||null;continue;case"6":super(n);continue}break}}}class Gd extends Vn{constructor(n,s){let d=t;super(n),this[d(533)]=s&&s.code||0,this[d(1122)]=s&&s[d(1122)]||"",this[d(1359)]=s&&s.wasClean||!1,this[d(1604)+d(498)]=s&&s[d(1604)+d(498)]||!1}}class Kd extends Vn{constructor(n,s){let d=t;super(n),this[d(1726)]=s&&s.data||null}}class Wd extends Kd{constructor(n,s){let d=t;super(n),this[d(1726)]=s&&s[d(1726)]||null,this[d(1128)]=s&&s[d(1128)]||null}}class $d extends Vn{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1726)]||null}}function ot(a,{message:n,code:s,error:d}){return new jd(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:l}){return new Gd(a,{code:n,reason:s,wasClean:d,willReconnect:l})}function Vd(a,{data:n,message:s}){let d=t;if(e[d(1664)](e.KdIHG,e[d(720)]))return new Wd(a,{data:n,message:s});{let l=this[d(1286)][d(489)+d(1519)+"nc"](this[d(1640)]),h=_0xa92aa1[d(1641)](e[d(1355)](l,"{}"));return _0x54ca49.keys(h)}}function Jd(a,{data:n}){return new $d(a,{data:n})}function aa(a,{message:n}){return new qd(a,{message:n})}class Yd{constructor(n,s){let d=t;this[d(1159)+"s"]=n,this[d(1919)+"es"]=s,this[d(1437)+d(832)]=0,this[d(1139)+d(932)+d(1817)+"t"]=0}["resetEnd"+t(586)+t(817)](){let n=t;this[n(1437)+n(832)]=0,this[n(1139)+n(932)+n(1817)+"t"]=0}[t(625)+"es"](){let n=t;this["currentE"+n(932)+"riesCount"]=0}["getCurre"+t(980)+"nt"](){let n=t;return this.endpoints[this[n(1437)+n(832)]]}["getCurre"+t(980)+t(1774)+t(726)](){let n=t;return this[n(1139)+"ndpointT"+n(1817)+"t"]}[t(735)+t(1995)+"es"](){let n=t;return!!(e.Uoyxe(this[n(1437)+n(832)],this[n(1159)+"s"].length)||e[n(544)](this[n(1437)+n(832)],e[n(1701)](this[n(1159)+"s"][n(1775)],1))&&e.AKqcA(this[n(1139)+n(932)+"riesCount"],this.maxRetries))}[t(1023)+"rentEndp"+t(1383)+t(1837)+t(1221)](){let n=t;return this["currentI"+n(832)]==this[n(1159)+"s"][n(1775)]?!0:this[n(1139)+n(932)+"riesCount"]>this[n(1919)+"es"]}[t(973)+"ackupEnd"+t(567)+t(737)+t(717)](){let n=t;return this[n(1139)+"ndpointTriesCount"]=1,this[n(1437)+n(832)]++,this[n(1159)+"s"][this[n(1437)+n(832)]]}[t(605)+t(980)+t(1060)+"ateCount"](){let n=t;return this[n(1139)+n(932)+n(1817)+"t"]++,this[n(605)+n(980)+"nt"]()}}let Jn=(e[t(760)](e[t(1258)],typeof globalThis)&&e.FhwET(e[t(743)],globalThis[t(1894)+t(1539)][t(1911)])||e[t(439)](t(1549)+"d",typeof window)&&e[t(857)](e.lDHHu,window[t(1894)+"tor"][t(1911)]))&&e[t(439)](e[t(1258)],typeof document),Sn=e[t(439)](e.czvCc,typeof globalThis)&&(e[t(1471)](e.vkkUM,globalThis["construc"+t(1539)][t(1911)])||e[t(544)](e.uosxC,globalThis[t(1894)+t(1539)][t(1911)]))&&e.CFtly(e[t(1258)],typeof tt),Gr=(e[t(1258)]!=typeof globalThis&&e[t(1004)](e[t(953)],globalThis[t(1894)+t(1539)][t(1911)])||e[t(1258)]==typeof globalThis||e[t(1258)]!=typeof globalThis&&!!globalThis[t(1998)+t(1199)])&&e[t(439)](e.czvCc,typeof wx),Kr=e[t(607)](e.czvCc,typeof globalThis)&&(e[t(1836)](e[t(508)],globalThis["construc"+t(1539)][t(1911)])||e[t(1440)]("SharedWo"+t(649)+"alScope",globalThis[t(1894)+t(1539)][t(1911)])||e[t(1174)](e[t(864)],globalThis[t(1894)+t(1539)][t(1911)]))&&e[t(760)](e[t(1258)],typeof self),Zh=e.KZaDG(e[t(1258)],typeof globalThis)&&e.MZiSP(e.vkkUM,globalThis[t(1894)+t(1539)][t(1911)])&&e[t(1529)](t(1549)+"d",typeof global)&&e[t(1289)](e.vkkUM,global[t(1894)+t(1539)].name)&&e[t(1258)]!=typeof process&&!!process[t(888)];class ca{constructor(){this._listeners={}}emit(n,...s){let d=t,l={zNVCe:function(g,w,m){return g(w,m)}},h=this._listeners[n];if(h)h[d(1274)]()[d(502)](g=>g.fn[d(842)](g[d(1149)],s));else if(e[d(587)](e[d(1785)],n)&&!this[d(1855)])if(e.PXGer!==e[d(1757)]){let g=s[d(1775)]&&s[0];if(e[d(1145)](g,Error))throw g;let w=new Error(e[d(406)](e.Aljsc,g?e[d(1884)](" (",g.message)+")":""));throw w[d(1295)]=g,g}else _0x179506(_0x4f5002,66),daqJsQ[d(1447)](_0x188820,_0x4c2594,_0x4a2021[d(1775)]),daqJsQ[d(1447)](_0x22f6d7,_0x27f237,_0x3ee9eb);return this}[t(1276)](n,s){let d=t;if(e[d(1174)](void 0,n))this[d(1390)+"rs"]={};else if(e.UTtdD(void 0,s))this[d(1390)+"rs"][n]=null;else{let l=this[d(1390)+"rs"][n];if(l)for(let h=0;e[d(1496)](h,l[d(1775)]);)e[d(1987)](l[h].fn,s)?l[d(1410)](h,1):++h}return this}on(n,s,d){let l=t;return(this[l(1390)+"rs"][n]||(this[l(1390)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this}}class Xh extends ca{[t(828)+"rrorMess"+t(1530)](n){let s=t;return n[s(1210)]||n[s(1654)]?(s(616)+" "+(n.errMsg||"")+" code: "+(n.errNo||""))[s(1630)]():JSON[s(972)+"y"](n)}constructor(n,s,d){let l=t;super(),this[l(678)]=null,Gr&&wx[l(892)+l(582)]&&(this[l(678)]=wx[l(892)+"ocket"]({url:n,protocols:s,header:d,fail:this[l(495)+"ocketFai"+l(1787)][l(412)](this),success:this["_createS"+l(1702)+l(431)+l(409)][l(412)](this)})),Sn&&tt[l(892)+l(582)]&&(this[l(678)]=tt[l(892)+l(582)]({url:n,protocols:s,header:d,fail:this[l(495)+l(924)+"lHandler"].bind(this),success:this[l(495)+l(1702)+l(431)+l(409)][l(412)](this)}))}[t(495)+"ocketSuc"+t(431)+t(409)](){let n=t;Promise[n(1391)]()[n(1822)](()=>{let s=n;this[s(1521)+s(808)]()})}[t(495)+t(924)+t(1787)](n){let s=t,d={axvyS:function(l,h,g){return e[U(1150)](l,h,g)},DDZNl:e[s(1785)],vrWhO:e.sgNHw,JIJqC:function(l,h){return l instanceof h},vANae:function(l,h){return e.jmZDt(l,h)},EbmOU:e[s(1992)],tzISr:e.oiKMS,tuEgE:function(l,h){return e.PKAxp(l,h)},VvxWu:function(l,h){return l(h)}};if(e[s(544)](e[s(1046)],e[s(1046)]))Promise.resolve()[s(1822)](()=>{let l=s,h=d[l(904)](ot,d[l(1715)],{message:this._formatErrorMessage(n)});this.emit(d[l(1715)],h);let g=xt(d[l(1533)],{reason:this[l(828)+l(676)+"age"](n)});this[l(559)](l(1573),g)});else{if(mbwVBO.JIJqC(_0xdb48c6,_0x4e9074)){if(mbwVBO[s(920)](_0x3951c8,mbwVBO[s(525)]))return _0x4adf16[s(734)](_0x5a5a6f);if(mbwVBO[s(920)](_0x513034,mbwVBO.tzISr))return _0x47c70e[s(1187)+"oreNames"]||_0x1c98d0[s(734)](_0x393f29);if(mbwVBO[s(1222)](_0x11d8ef,s(1066)))return _0x2d241b[s(1187)+"oreNames"][1]?void 0:_0x1a32d5[s(1187)+s(457)](_0x4bf060[s(1187)+s(422)][0])}return mbwVBO[s(1401)](_0x1ec881,_0x5c90e2[_0x512114])}}["_addWsLi"+t(808)](){let n=t;if(e[n(398)](e[n(1712)],e[n(1405)]))return e[n(1657)](-1,this[n(542)])&&e[n(1088)](-1,this[n(906)])?_0x41b9ba[n(1628)](0,0,this.unsigned):e[n(923)](-1,this.low)?_0x2d54eb[n(1628)](0,e[n(1884)](this[n(906)],1),this[n(1688)]):_0x36c031[n(1628)](this.low+1,this[n(906)],this[n(1688)]);this[n(678)][n(729)](s=>{let d=n;this[d(559)](e.XyqOu,e[d(1264)](Jd,e[d(695)],{...s,data:s[d(1210)]||""}))}),this[n(678)].onClose(s=>{let d=n;this[d(559)](e.sgNHw,e[d(1307)](xt,e[d(770)],{...s}))}),this[n(678)][n(614)+"e"](s=>{let d=n;this[d(559)](d(1128),e[d(1793)](Vd,e[d(1587)],{...s}))}),this._socket[n(1240)](s=>{let d=n;this.emit(e.NZgYO,e[d(1031)](ot,e[d(1785)],{...s,message:s.errMsg||""}))})}[t(1627)](n){let s=t,d={NftAG:e[s(1785)],XyBHN:function(l,h,g){return l(h,g)},ZOudV:function(l,h,g){return e[s(1985)](l,h,g)}};if(e[s(1145)](n,Uint8Array))if(e[s(1631)]===e.cXQeH){let l=n[s(1293)][s(1274)](n.byteOffset,e[s(703)](n[s(701)+"th"],n.byteOffset));this[s(678)]&&this[s(678)][s(1627)]({data:l,fail:h=>{let g=s;this[g(559)](d[g(1282)],d.XyBHN(ot,d[g(1282)],{message:this["_formatErrorMess"+g(1530)](h)}))}})}else{let l=_0x5abfa5[s(657)](/\./)[s(870)](w=>_0x467c20(w)),h=[];return h[0]=e[s(689)](_0x27ab2b,e[s(1884)](l[0],l[1])),h[1]=e.yXNac(_0x293e39,e[s(1955)](l[2],l[3])),[e.jUmgP,e[s(1711)],e[s(1711)],e.jUmgP,e.jUmgP,e.yckxW,h[0],h[1]][s(1905)]("")}else this[s(678)]&&this[s(678)][s(1627)]({data:n,fail:l=>{let h=s;this[h(559)](d[h(1282)],d[h(997)](ot,d[h(1282)],{message:this[h(828)+"rrorMess"+h(1530)](l)}))}})}[t(1573)](n,s){let d=t;this._socket&&this[d(678)][d(1573)]({code:n,reason:s})}["addEvent"+t(400)](n,s){let d=t;e[d(1650)](d(1363),e.sueIW)?this.on(n,s):(this[d(985)]=!1,e.fZPhz(_0x5b3be4,this[d(442)+d(1185)+"utId"]),e[d(1048)](_0x3455be))}[t(794)+"entListe"+t(1432)](n,s){this[t(1276)](n,s)}get[t(1015)+"te"](){return this._socket.readyState}get[t(1870)+"pe"](){return this[t(678)].binaryType}set[t(1870)+"pe"](n){}get[t(1188)](){let n=t,s={ZBMZT:function(d,l){return e.RHwuE(d,l)}};if(e.leYXr(e.oKhnt,"kDMmd"))return this._socket[n(1188)];{let d=_0x4ac2ae[n(1773)](QcsYTr[n(1357)](_0x529f74,this),_0x142c07,..._0x108e64);return _0x54edfa[n(1906)](d,_0x243c8e[n(518)]?_0x6e2500[n(518)]():[_0xf61ecd]),_0x57240a(d)}}get[t(521)](){return this[t(678)].protocol}get[t(522)+"ns"](){let n=t,s={afnwA:function(d,l){return e[U(384)](d,l)},fAcVi:function(d,l){return e[U(714)](d,l)}};return e[n(1425)](e.dwEAb,e.pRnWR)?this[n(678)].extensions:EjMzhK[n(641)](_0x28c64a,_0x299ded.apply(EjMzhK[n(1590)](_0x4f1cf5,this),_0x2b7fb9))}get[t(545)+t(824)](){return 0}}function Qh(a,n){let s=t;if(n)return new n(a[s(1188)],a.protocol);if(Gr||Sn)return new Xh(a[s(1188)],a[s(521)],a.headers);if(e[s(1119)](Jn,Kr)&&e.gJpMz(e.czvCc,typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(521)+"s"])}function ep(a){let n=t,s=e.LCgEP[n(657)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(Sn&&tt[n(892)+n(582)])return!0;continue;case"1":if((Jn||Kr)&&e[n(1201)](e[n(1258)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":if(Gr&&wx[n(892)+n(582)])return!0;continue;case"3":if(a)return!0;continue;case"4":return!1}break}}function Zd(a,n,s){let d=t;if(e[d(401)](e.GHVOT,d(1725))){let l=-1;async function h(g){let w=d;return g<=l?Promise[w(610)](new Error("next() c"+w(1832)+w(1368)+w(541)+"process")):(l=g,e.PaObX(g,s[w(1775)])?Promise[w(1391)]():s[g][w(412)](a)(n,h[w(412)](null,e[w(1338)](g,1))))}e[d(384)](h,0)}else return e[d(1574)]!=typeof _0x4ad060&&(e[d(1483)](_0xb20390,_0x449ed6)||_0x670fd6[d(1293)]&&e[d(1556)](_0xe27bea[d(1293)],_0x2156d6))||d(1358)!=typeof _0x325af3?"":(_0x2a1129.parse(_0x49eaba),e[d(1120)])}function Xd(a){let n=t;if(e.gzZJt!==e[n(1392)])throw _0x1c9a40=_0x568a55[n(1775)],e[n(1668)](_0x4f2654,_0x5010c7,10,_0x4fbcd1[n(1775)]);{let s=0,d=0;for(let l=0;l<a[n(1775)];++l)d=a[n(1902)+"At"](l),d<128?s+=1:e.tRfJE(d,2048)?s+=2:e[n(437)](e[n(1840)](64512,d),55296)&&e[n(839)](e[n(1527)](64512,a[n(1902)+"At"](e.SdyuN(l,1))),56320)?(++l,s+=4):s+=3;return s}}function Qd(a,n,s){let d=t;if(e.tRfJE(s-n,1))return"";let l="";for(let h=n;e[d(1966)](h,s);){let g=a[h++];if(g<=127)l+=String["fromChar"+d(447)](g);else if(e.nOYQu(g,192)&&e[d(1553)](g,224))l+=String[d(1499)+d(447)](e.Okeql(31,g)<<6|e[d(631)](63,a[h++]));else if(g>=224&&e[d(712)](g,240))l+=String[d(1499)+"Code"](e[d(471)]((15&g)<<12,e[d(891)](e[d(1665)](63,a[h++]),6))|e[d(1786)](63,a[h++]));else if(e[d(1170)](g,240)){let w=e.qepmw(e[d(1094)](e.HWvwJ(e.aVOBE(7&g,18)|e[d(575)](e[d(1009)](63,a[h++]),12),e[d(1344)](e.Jhnkd(63,a[h++]),6)),e[d(1554)](63,a[h++])),65536);l+=String[d(1499)+d(447)](55296+e[d(1439)](w,10)),l+=String["fromChar"+d(447)](e[d(1202)](56320,e.aEQCN(1023,w)))}}return l}function da(a,n,s){let d=t;if(e[d(651)]!==e.KjHPx){let l=s,h,g;for(let w=0;e[d(712)](w,a[d(1775)]);++w)if(h=a.charCodeAt(w),e.Kaaje(h,128))n[s++]=h;else if(h<2048)n[s++]=e[d(971)](e.gmOKn(h,6),192),n[s++]=e[d(1967)](63,h)|128;else if(e[d(674)](e[d(860)](64512,h),55296)&&e[d(1471)](e.RImhM(64512,g=a.charCodeAt(e[d(849)](w,1))),56320)){let m=e.hdHbh.split("|"),A=0;for(;;){switch(m[A++]){case"0":h=e.wUCRG(65536+e[d(1514)](1023&h,10),e[d(1769)](1023,g));continue;case"1":n[s++]=e[d(1482)](h,18)|240;continue;case"2":n[s++]=e[d(806)](e.hUeCJ(63,h),128);continue;case"3":n[s++]=e.rJGzw(e[d(744)](e[d(433)](h,6),63),128);continue;case"4":++w;continue;case"5":n[s++]=e[d(710)](e[d(1718)](h,12),63)|128;continue}break}}else n[s++]=e[d(551)](h>>12,224),n[s++]=e[d(551)](e[d(1037)](h,6)&63,128),n[s++]=e[d(665)](63,h)|128;return s-l}else _0x3aaca6=KqmfPq[d(689)](_0x543522,_0x45b6c1)}async function e0(a){let n=t;if(e[n(492)](e[n(1680)],e.iPKzw))this._initPromise=null;else{if(e[n(1794)](n(1358),typeof a))if(e[n(1019)]!==e[n(1323)]){let s=new Uint8Array(e[n(424)](Xd,a));return e[n(1278)](da,a,s,0),s}else n(1549)+"d"!=typeof _0x2eb2e0&&_0x21080c[n(1490)+n(894)]&&_0x41a894[n(1270)+n(1876)](_0xbcd24d,_0x2b0d5c["toString"+n(894)],{value:KqmfPq.jSbno}),_0x47e79f[n(1270)+n(1876)](_0x1ee085,KqmfPq[n(1103)],{value:!0});return e[n(1576)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1293)],a[n(476)+"et"],a[n(701)+"th"])}}function tp(a){let n=t;try{return e.gJpMz(e.pWTmK,typeof a)&&(e[n(1556)](a,ArrayBuffer)||a[n(1293)]&&a.buffer instanceof ArrayBuffer)||e.gJpMz(e[n(1574)],typeof a)?"":(JSON[n(1641)](a),n(480)+n(1366))}catch{return e.pWTmK==typeof a?n(755)+"in;charset=utf-8":""}}let np=(a,n)=>{let s=t;switch(a){case s(1782):case e[s(1656)]:return{[s(871)+a]:1,"x-tt-env":n};default:return{}}};class rp{constructor(n){let s=t;e[s(1940)](e[s(918)],s(1415))?this[s(1521)+"steners"]():(this[s(1594)+s(726)]=n,this.count=0)}[t(1596)](){this.count++}[t(735)+"chMaxCount"](){let n=t;return e.yWyBL(this[n(1284)],this[n(1594)+n(726)])}[t(736)+t(1608)](n=0){let s=t;this[s(1594)+s(726)]=n,this[s(1284)]=0}}async function ip(a){let n=t;return e[n(929)]!==e[n(1674)]?new Promise(s=>{let d=n,l={Ynqet:e[d(1888)],zrfQQ:function(h,g){return h!==g},bMWEO:function(h,g,w){return e.DITHG(h,g,w)}};if(!Jn)return e[d(536)](s,d(617)+"reason");try{let h=document["createEl"+d(1610)](e[d(1765)]);window[d(1034)+d(1917)]=g=>{let w=d;document[w(1520)][w(968)+w(1609)](h),window[w(1034)+w(1917)]=void 0,s(g&&g[w(1675)]||l[w(854)])},h[d(1532)]=e[d(1259)],h.src=a[d(656)](/^ws/,"http")+e[d(1880)];try{document.body[d(1938)+d(1609)](h)}catch{if(e.hQezS(e[d(1982)],e[d(700)]))document[d(1520)][d(968)+d(1609)](h);else{let g=_0x4aba6a.key;uXWltt[d(1961)](void 0,g)&&(uXWltt[d(1551)](_0xf87f7c,_0xd7c4ca,10),uXWltt[d(1551)](_0x22c8de,_0x107f4d,g));let w=_0x2c07af[d(1555)];w!==void 0&&(_0xb8e1c9(_0x53dccc,18),_0x282717(_0x498aad,w))}}}catch{window["frontier"+d(1917)]=void 0,s(e[d(1888)])}}):this[n(1286)]?.[n(734)](_0x30a6a9)}function en(a,n,s){let d=t;if(e[d(527)]===e[d(527)])return!!a?.[d(550)](l=>l[d(1616)]===n&&l.value===s);_0x3ab07c[d(1391)]()[d(1822)](()=>{let l=d;this[l(1521)+l(808)]()})}function Yn(a,n){let s=t;return a?.[s(550)](d=>d[s(1616)]===n)?.[s(1555)]}let ua=null;async function sp(){let a=t;return ua||(ua=Promise[a(1391)]()[a(1822)](Pt.bind(Pt,e[a(1956)]))),ua}class op extends ca{constructor(n,s){let d=t;super(),this[d(633)]=n,this[d(573)]=s,this._qosDB=void 0,this[d(1083)+"mise"]=null}async[t(1637)](){await this[t(585)]()}async[t(585)](){let n=t,s={sGjyt:e[n(1785)],ZNGkh:function(d,l){return e[n(1556)](d,l)},PUOgG:function(d,l){return d+l},YHxqu:n(1655)+n(1524),csBBN:function(d,l){return e[n(1212)](d,l)},hPqKX:function(d,l){return e[n(819)](d,l)},cUtos:e[n(1469)],MJLKK:function(d){return e[n(1048)](d)},FvjSQ:function(d,l,h,g){return e[n(1452)](d,l,h,g)}};if(e[n(1508)](e[n(1984)],e.kzeiK)){if(this[n(1286)])return;if(this[n(1083)+n(1796)])return this[n(1083)+n(1796)];try{let d=this[n(633)],l=this[n(573)];this[n(1083)+"mise"]=(async()=>{let h=n,g={Pknaj:s.sGjyt,IPkEr:function(m,A){return s[U(1453)](m,A)},Fxopc:function(m,A){return s.PUOgG(m,A)},YRSCV:s[h(1389)],FYSXL:function(m,A){return s.csBBN(m,A)},RpKUb:function(m,A){return s[h(1417)](m,A)},OlBAS:s.cUtos},{openDB:w}=await s.MJLKK(sp);this._qosDB=await s.FvjSQ(w,h(1034)+"_"+d,1,{upgrade(m){let A=h;if(g[A(1142)](g.OlBAS,g[A(956)]))m[A(696)+"jectStore"](d,{keyPath:l});else{let N=this[A(1390)+"rs"][_0x5b043c];if(N)N[A(1274)]().forEach(L=>L.fn[A(842)](L.ctx,_0x2218bb));else if(bkgBEG[A(1419)]===_0x1b5ecb&&!this[A(1855)]){let L=_0x58883e.length&&_0x4ffb3b[0];if(bkgBEG.IPkEr(L,_0x2f662d))throw L;let q=new _0x1d5515(bkgBEG[A(557)](bkgBEG[A(1360)],L?bkgBEG[A(977)](bkgBEG[A(557)](" (",L[A(1128)]),")"):""));throw q[A(1295)]=L,L}return this}}})})(),await this[n(1083)+n(1796)]}catch(d){console.log(d)}finally{this[n(1083)+"mise"]=null}}else this[n(1594)+n(726)]=_0x3491c2,this[n(1284)]=0}async[t(734)](n){let s=t;if(e.RqwzN!=="Tuiei")try{return await this._init(),this[s(1286)]?.[s(734)](this[s(633)],n)}catch(d){if(e.miZCq(s(1728),e.OZyoF)){let l={YwUEM:e[s(1924)],gpoSC:e[s(840)],RKHTD:function(w,m){return e[s(713)](w,m)}};this[s(1493)+s(1926)](),this["_pingPon"+s(490)+"Id"]=e[s(739)](_0xe88c38,this[s(1690)].bind(this),this._options[s(609)+s(1526)]);let h=()=>{let w=s;_0x56e98f(l[w(1571)]),this.off(w(1755)+w(1636)+"s",h),this[w(1276)](l.gpoSC,g)},g=()=>{let w=s;l.RKHTD(_0x2f2751,w(1246)),this[w(1276)](w(1755)+w(1636)+"s",h),this[w(1276)](l.gpoSC,g)};this.on(e.fgLtZ,h),this.on("ping_onc"+s(1393)+"t",g),this[s(1690)]()}else console.log(d)}else{let d=this[s(1286)][s(467)](this[s(1640)]),l=_0x1336d3[s(1641)](e[s(1355)](d,"{}"));return l[_0x1408b9]=void 0,this[s(1286)][s(1621)](this[s(1640)],_0x206ac2[s(972)+"y"](l))}}async[t(1906)](n,s){let d=t;return await this._init(),this[d(1286)]?.put(this[d(633)],n)}async del(n){let s=t;try{return await this[s(585)](),this[s(1286)]?.[s(704)](this[s(633)],n)}catch(d){console.log(d)}}async[t(1498)](){let n=t;try{return await this[n(585)](),this[n(1286)]?.[n(1498)](this._dbName)}catch(s){console[n(1861)](s)}}async[t(1818)](){return await this._init(),this._qosDB?.getAllKeys(this._dbName)}async[t(1116)](){let n=t;return await this[n(585)](),this[n(1286)]?.getAll(this[n(633)])}async[t(1799)](){let n=t;if(e[n(901)](n(1300),n(1300)))try{e[n(1289)](e[n(1525)],n(570))?_0x5cd0e8.body.appendChild(_0x577978):(this[n(1286)]?.[n(1573)](),this[n(1286)]=void 0)}catch(s){console.log(s)}else return e.JQGzB(_0x2cd257.offset,_0x5327b6[n(1613)])}get[t(1492)](){let n=t;try{return!!this[n(1286)]}catch(s){return console.log(s),!1}}}class ap{constructor(n,s){let d=t;if(e[d(1976)](e.jKEtl,d(1647)))this[d(549)]=n,this[d(955)]=s,this._qosDB=localStorage;else return this[d(1784)+d(1008)]?.[d(605)+d(980)+d(1774)+d(726)]()||0}async[t(1637)](){}get[t(1640)](){let n=t,s={uHtos:function(d,l){return e[U(537)](d,l)}};if(e[n(1059)]===e[n(1059)])return n(1034)+"_"+this[n(549)];{let d=_0x148861[n(464)+"g"](0,AlHEbH[n(1412)](4,_0x1969ea[_0x396689][n(1775)])),l=d[n(1717)](_0x2ed3a7[_0x5a3340]);_0x10896b[n(883)](l)}}async[t(734)](n){let s=t,d=this[s(1286)][s(467)](this[s(1640)]);return JSON[s(1641)](d||"{}")[n]}async[t(1906)](n,s){let d=t;if(e[d(1882)](e[d(1504)],e.Hradv)){let l=this[d(1286)][d(467)](this._prefix),h=JSON.parse(e[d(1505)](l,"{}"));return h[s||n[this[d(955)]]]=n,this._qosDB.setItem(this[d(1640)],JSON.stringify(h)),s||n[this[d(955)]]}else{if(e[d(543)](4,_0x11d03c[d(1775)])){let l=_0x1221f2.substring(0,4-_0x47dced.length),h=l[d(1717)](_0x2b3279);_0x2f9201[d(883)](h)}else _0xfa9a9b[d(883)](_0x1f831e);_0x45e203&&(_0x1ba6ad+=1),_0x47ce09+=1,_0x56d6fb=!1}}async[t(1952)](n){let s=t,d=this._qosDB.getItem(this[s(1640)]),l=JSON.parse(e[s(1119)](d,"{}"));return l[n]=void 0,this[s(1286)].setItem(this._prefix,JSON[s(972)+"y"](l))}async clear(){return this._qosDB.clear()}async keys(){let n=t,s={Xhdxq:function(d,l,h){return e.HAgIT(d,l,h)}};if(e[n(1541)](e[n(1682)],e.uZwie)){let d=this._qosDB[n(467)](this[n(1640)]),l=JSON[n(1641)](e[n(1659)](d,"{}"));return Object[n(1818)](l)}else cZRBeD[n(479)](_0x38b2fd,_0xe42b6b,50),_0x300785(_0x25cc5c,_0x3a52dd)}async[t(1116)](){let n=t,s=this[n(1286)].getItem(this[n(1640)]),d=JSON[n(1641)](e.YMGXA(s,"{}"));return Object[n(1267)](d)}[t(1799)](){return Promise.resolve()}get[t(1492)](){let n=t;if(e[n(1153)](e[n(1820)],e[n(1820)]))return!!this[n(1286)];{let s=e.xApBv(this[n(1184)][n(444)+n(1973)],_0x2976af)?{force:!!this[n(1184)][n(444)+n(1973)][n(407)],encoding:this._options[n(444)+n(1973)].encoding?this._options[n(444)+"ncoding"][n(1173)].replace(/\s/g,"")[n(804)+n(1082)]():""}:{force:!1,encoding:this[n(1184)][n(444)+n(1973)]?this[n(1184)][n(444)+"ncoding"][n(656)](/\s/g,"")[n(804)+n(1082)]():""},d=_0x5b88cd[n(444)+"ncoding"]?_0x4a2670[n(444)+n(1973)].replace(/\s/g,"")[n(804)+"ase"]():"",l=e[n(650)](this._options[n(481)+n(1309)],_0x25c810)?{force:!!this[n(1184)][n(481)+"ype"].force,type:this[n(1184)][n(481)+n(1309)][n(1532)]?this[n(1184)][n(481)+n(1309)].type[n(656)](/\s/g,"")[n(804)+"ase"]():""}:{force:!1,type:this._options[n(481)+n(1309)]?this[n(1184)][n(481)+n(1309)].replace(/\s/g,"")[n(804)+n(1082)]():""},h=_0x4ab5cc[n(481)+n(1309)]?_0x4bfbc7[n(481)+"ype"][n(656)](/\s/g,"")[n(804)+"ase"]():"",g=l[n(407)]?l[n(1532)]:h||l[n(1532)],w=s.force?s[n(1173)]:d||s.encoding,m=[e[n(1698)],e[n(1120)],n(480)+"ion/json"+n(1645)+n(1016),e[n(1574)]],A=[e[n(1099)],e[n(962)]];this[n(1184)][n(1460)+n(725)+n(1028)+"ad"]&&m[n(872)](g)&&(!w||A[n(872)](w))?_0x286280[n(1121)+n(564)]=e[n(1278)](_0x340c51,_0x36e28a[n(933)],0,_0x2fde0c[n(933)][n(701)+"th"]):_0x2a04b8[n(1121)+n(564)]=""}}}class cp{constructor(n,s){let d=t;if(e[d(1619)](e[d(1523)],d(917)))return(this[d(1390)+"rs"][_0x422510]||(this[d(1390)+"rs"][_0x2eb029]=[])).push({fn:_0x3bad21,ctx:_0x46dc56||this}),this;this._DBName=n,this[d(955)]=s,this[d(1286)]=Sn?tt:Gr?wx:null}async openDB(){}get[t(1640)](){let n=t;return n(1034)+"_"+this[n(549)]}async[t(734)](n){let s=t,d=this[s(1286)][s(489)+s(1127)](this._prefix);return JSON[s(1641)](e.AwOPm(d,"{}"))[n]}async[t(1906)](n,s){let d=t,l=this[d(1286)][d(489)+d(1127)](this[d(1640)]),h=JSON[d(1641)](e.TjOTo(l,"{}"));return h[s||n[this[d(955)]]]=n,this._qosDB[d(558)+d(1127)](this[d(1640)],JSON.stringify(h)),s||n[this[d(955)]]}async[t(1952)](n){let s=t,d=this[s(1286)]["getStora"+s(1127)](this._prefix),l=JSON[s(1641)](d||"{}");return l[n]=void 0,this._qosDB[s(558)+s(1127)](this[s(1640)],JSON.stringify(l))}async[t(1498)](){let n=t;return this[n(1286)][n(936)+n(1903)]()}async[t(1818)](){let n=t;if(e[n(1077)]("IJAkf",n(866))){let s=this._qosDB.getStorageInfoSync(this[n(1640)]),d=JSON[n(1641)](e[n(405)](s,"{}"));return Object.keys(d)}else{let s=this[n(1784)+n(1008)]?.[n(605)+n(980)+"nt"]();this[n(1063)+n(1352)+n(836)](_0x5aea0a(n(1573),{code:1006,reason:n(1468)+s+(" timeout"+n(1558)+n(1830)+n(938)),wasClean:!0}))}}async[t(1116)](){let n=t,s=this[n(1286)][n(489)+n(1519)+"nc"](this._prefix),d=JSON[n(1641)](e[n(801)](s,"{}"));return Object[n(1267)](d)}[t(1799)](){return Promise[t(1391)]()}get[t(1492)](){let n=t,s={lcZhZ:function(d,l){return d||l},BjriQ:function(d,l){return d!=l}};if(e[n(1584)](e[n(1974)],e[n(1974)])){if(_0x5681b0)return new _0x59e4f3(_0x593ca2.url,_0x47ef34.protocol);if(nQmZvl[n(1575)](_0x5e8c81,_0xe7b954))return new _0x59fdea(_0x564b3f.url,_0x3ed074.protocol,_0x355c33[n(1813)]);if(nQmZvl[n(1575)](_0x7bce3d,_0x51633d)&&nQmZvl.BjriQ("undefined",typeof _0x5698d0)&&_0xee0762)return new _0x47c288(_0xceca56[n(1188)],_0x49dc06.protocols)}else return!!this[n(1286)]}}function t0(a,n){let s=t;if(e[s(1123)](Sn,Sn))return new cp(a,n);if(e.KsZvs(Jn,Kr)&&e[s(1258)]!=typeof indexedDB)return new op(a,n);if((Jn||Kr)&&e[s(1978)](e.czvCc,typeof localStorage))return new ap(a,n);throw new Error(e[s(645)])}class dp{constructor(){let n=t;this[n(523)+n(1213)+"Id"]=null,this._interval=36e5,this._qosDB=e.yOyDi(t0,e[n(826)],e[n(1003)])}async[t(523)+t(1544)](){let n=t;clearInterval(this[n(523)+"lTimeoutId"]),this[n(523)+n(1213)+"Id"]=setInterval(()=>{this["flushExp"+n(1953)]()},this._interval)}async[t(1637)](){let n=t;e.zXfxh(n(666),e[n(1148)])?await this[n(1286)].openDB().then(()=>{let s=n;this[s(523)+s(1544)]()}):(_0x4ac2d4(_0x5677d9,74),e[n(1960)](_0x3bc329,_0xbdbb36,_0x19ea74))}async["flushExp"+t(1953)](){let n=t;e.UWumE(e[n(1204)],e[n(1204)])?(await this[n(1286)]?.[n(1116)]()||[]).filter(({timestamp:l})=>l<Date[n(1079)]()).forEach(l=>{let h=n;this[h(1286)]?.del(l[h(1429)+"id"])}):this[n(559)](e[n(1785)],e[n(526)](_0x4a0b60,e[n(1785)],{..._0x343f55,message:_0x1ab558.errMsg||""}))}async[t(1952)](n){let s=t;return this[s(1286)]?.[s(1952)](n)}async[t(1906)](n,s){let d=t;return this[d(1286)]?.[d(1906)]({message_id:n,timestamp:s})}async get(n){let s=t;if(e[s(738)](e[s(1101)],e[s(781)]))_0xc58522=_0x1df878&&e[s(1794)](s(1061),_0x725147.protocol)?s(1563):"ws://",_0x5991c7=_0x4d5ba4.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x55161a=/^wss(.*:\/\/)/[s(1065)](_0x4f507b)?_0x3cac34:""+_0x1ccd7b+_0x4617a8;else return this[s(1286)]?.[s(734)](n)}async[t(1799)](){let n=t;e[n(852)](clearInterval,this[n(523)+n(1213)+"Id"]),await this[n(1286)]?.closeDB()}get isReady(){let n=t;return this[n(1286)]?.[n(1492)]}}function la(a){let n=t,s={NFnLg:function(d,l){return e[U(1898)](d,l)},rrLPs:function(d,l){return e[U(670)](d,l)}};if(e.NmyZt==="iqoWt"){let d=!!this[n(1184)][n(686)+"S"];if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e[n(1617)](en,a[n(1128)][n(1813)],n(440)+n(1829),"2"),h=l&&e[n(850)](en,a[n(1128)].headers,n(440)+"er_qos_ack","1"),g=l&&en(a[n(1128)][n(1813)],n(440)+"er_is_ack","1"),w=g?e.DITHG(Yn,a[n(1128)][n(1813)],e[n(1697)])?.[n(657)](",")[n(1322)](Boolean)||[]:[];return{enabled:d,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:g,ackMsgIds:w}}else{let d=_0x235681[n(657)](":");_0x1c2c08&&(_0xde5925=d[n(1775)]),_0x29d041+=d.length;for(let l=0;SImGEr[n(1932)](l,d[n(1775)]);l++)if(d[l][n(1775)]!==4){let h=_0x336568[n(464)+"g"](0,SImGEr[n(774)](4,d[l].length)),g=h.concat(d[l]);_0x4609ca.push(g)}else _0x2e5536.push(d[l]);_0x20a7ec=!1}}async function n0(){let a=t;return this[a(1162)+a(1497)]||(this._QoSManager=new dp),this._QoSManager.isReady||await this[a(1162)+a(1497)].openDB(),this[a(1162)+a(1497)]}async function up(a,n){let s=t,{enableAutoAck:d}=this[s(1184)],l=en(a[s(1128)].headers,s(796),"1"),h=en(a[s(1128)][s(1813)],e[s(1567)],"1"),g=la[s(1773)](this,a);if(e[s(1007)](d,l)){let{SeqID:w,LogID:m,service:A,LogIDNew:N,method:L}=a[s(1128)];this[s(897)]({SeqID:w,LogID:m,LogIDNew:N,service:A,method:L,headers:[{key:e.luiHf,value:"1"},{key:e.aWcWp,value:e.bPmgH(N,"")},{key:e[s(916)],value:"0"}]})}h&&!g[s(1808)]&&this[s(1063)+s(1686)+s(1250)](a),e[s(1107)](n)}async function lp(a,n){let s=t;this[s(733)](e[s(746)],a[s(1128)]),e[s(999)](n)}async function fp(a,n){let s=t,d=e[s(1481)](Zt,await e[s(1592)](e0,a[s(1726)]));try{if(e[s(1576)](d[s(933)],Uint8Array)){let l=this[s(1184)]["payloadE"+s(1973)]instanceof Object?{force:!!this._options[s(444)+s(1973)][s(407)],encoding:this[s(1184)]["payloadE"+s(1973)][s(1173)]?this[s(1184)][s(444)+"ncoding"][s(1173)].replace(/\s/g,"")[s(804)+s(1082)]():""}:{force:!1,encoding:this[s(1184)]["payloadE"+s(1973)]?this[s(1184)][s(444)+s(1973)].replace(/\s/g,"")[s(804)+s(1082)]():""},h=d[s(444)+"ncoding"]?d[s(444)+s(1973)][s(656)](/\s/g,"")[s(804)+"ase"]():"",g=e[s(907)](this[s(1184)][s(481)+s(1309)],Object)?{force:!!this[s(1184)][s(481)+s(1309)][s(407)],type:this[s(1184)]["payloadT"+s(1309)][s(1532)]?this._options[s(481)+"ype"].type.replace(/\s/g,"")[s(804)+s(1082)]():""}:{force:!1,type:this[s(1184)][s(481)+s(1309)]?this._options[s(481)+s(1309)][s(656)](/\s/g,"")["toLowerC"+s(1082)]():""},w=d["payloadT"+s(1309)]?d[s(481)+s(1309)][s(656)](/\s/g,"")[s(804)+s(1082)]():"",m=g[s(407)]?g[s(1532)]:w||g.type,A=l[s(407)]?l[s(1173)]:h||l[s(1173)],N=[e[s(1698)],e[s(1120)],e[s(1981)],"string"],L=[s(561)+"e",s(1203)];this._options[s(1460)+s(725)+s(1028)+"ad"]&&N.includes(m)&&(!A||L[s(872)](A))?d[s(1121)+s(564)]=Qd(d[s(933)],0,d.payload[s(701)+"th"]):d[s(1121)+s(564)]=""}else d[s(1121)+s(564)]=""}catch(l){d[s(1121)+s(564)]="",console[s(1861)](l)}a[s(1128)]=d,n()}function xp(a,n,s){let d=t,l={AjtdV:function(h,g){return h<g},yjhvf:function(h,g){return e[U(1965)](h,g)}};if(e[d(1896)]("FOpOP",e[d(1512)])){let h=this[d(1390)+"rs"][_0xca8f74];if(h)for(let g=0;KTMkMo.AjtdV(g,h[d(1775)]);)KTMkMo[d(690)](h[g].fn,_0x5483ea)?h[d(1410)](g,1):++g}else{let h=e[d(1380)](s,8192),g=e.YnAHP(h,1),w=null,m=h;return function(A){let N=d;if(e[N(1310)](A,1)||e[N(1625)](A,g))return e.DETXY(a,A);e[N(1285)](m+A,h)&&(w=e[N(1076)](a,h),m=0);let L=n.call(w,m,m+=A);return e[N(1205)](7,m)&&(m=e[N(687)](e[N(1106)](7,m),1)),L}}}let hp=4294967295;function pp(a,n,s){let d=t;return e.gzYFk(RangeError,e[d(1052)](e[d(1296)](e[d(876)](e.Tqckx("index ou"+d(976)+d(1931)+a,e[d(1387)]),e[d(1198)](n,1)),e[d(1197)]),s))}function gp(a,n,s){let d=t;if(e.kdCkD(s,hp))throw new Error(e.POxIg);let l=3;for(;e.rBhlt(l,0);){let h=e[d(869)](255,s);e[d(1487)](xa,h,a,n+l),s>>>=8,l--}return e[d(1891)](n,4)}function mp(a,n){let s=t;if(e[s(1541)]("gyNvc",e[s(408)]))_0x2ddda8.push(_0x1adb89);else{let d=0,l=n,h=n+4;for(;e[s(1898)](l,h);){let{value:g,offset:w}=e[s(900)](fa,a,l);l=w,d=e[s(1614)](d,8)>>>0,d+=g}return{value:d,offset:h}}}function wp(a,n,s){let d=t,l=e[d(889)][d(657)]("|"),h=0;for(;;){switch(l[h++]){case"0":if(n.utf8Write)return e.AsMkQ(n[d(1792)+"e"](a,s),s);continue;case"1":if(n.write)return e[d(1178)](n[d(1727)](a,s),s);continue;case"2":return e[d(1202)](e.QfAlg(da,a,n,s),s);case"3":if(!a)return s;continue;case"4":if(e[d(1280)](a[d(1775)],40))return e[d(1091)](e[d(1487)](da,a,n,s),s);continue}break}}function _p(a,n){let s=t;if(e[s(858)](e[s(1643)],e[s(1230)]))this[s(1864)+s(1309)]=_0x23d08c,this[s(604)]&&(this[s(604)].binaryType=_0x777c98);else{let d=new ce(e[s(1124)](e.OlJVZ(a[e[s(569)](n,4)]<<24,e[s(1395)](a[n+5],16)),e.ogNFM(a[e[s(455)](n,6)],8))|a[n+7],e[s(762)](e[s(652)](e.QrbUm(a[e[s(1416)](n,0)]<<24,e[s(835)](a[e.HMsAc(n,1)],16)),e[s(844)](a[e[s(988)](n,2)],8)),a[e[s(703)](n,3)]),!0);return n+=8,{value:d,offset:e[s(791)](n,8)}}}function yp(a,n,s){let d=t,l=a[d(542)],h=a[d(906)];return n[s]=e.jmxxJ(h,24),n[s+1]=e.ddKAZ(h>>>16,255),n[e[d(974)](s,2)]=e[d(1899)](e[d(722)](h,8),255),n[e[d(1025)](s,3)]=e[d(1552)](255,h),n[e[d(1087)](s,4)]=l>>>24,n[e[d(1011)](s,5)]=e[d(1315)](e[d(793)](l,16),255),n[e[d(1100)](s,6)]=l>>>8&255,n[e[d(1111)](s,7)]=255&l,s+=8,s}function fa(a,n){let s=t,d={eSZoj:function(l,h){return e[U(1907)](l,h)},cUAFy:function(l,h){return e[U(837)](l,h)},kQZaZ:function(l,h){return e[U(1051)](l,h)},ROJVL:function(l,h){return e[U(1934)](l,h)},sVSAn:function(l,h){return e[U(1946)](l,h)},yeFZE:function(l,h){return e[U(1623)](l,h)},tiaZD:function(l,h){return e[U(1053)](l,h)},dhsVN:function(l,h){return l+h},bsGrv:function(l,h){return e.lFixz(l,h)}};if(e[s(1088)]("UxZym",s(886)))return a[s(1075)+"8"]?{value:a[s(1075)+"8"](n),offset:e[s(988)](n,1)}:{value:e.VBVYc(255,a[n]),offset:n+1};_0xb9d5a8=bJbUsf[s(684)](bJbUsf.cUAFy(7&_0x212d85,18)|bJbUsf[s(926)](63&_0x543023,12),bJbUsf.kQZaZ(bJbUsf[s(1626)](63,_0x221a14),6))|bJbUsf[s(1560)](63,_0xcef58a),bJbUsf[s(880)](_0x376fc1,65536)||bJbUsf.tiaZD(_0x4279de,1114111)?_0x514122+=_0x211d49:(_0x3a8db9-=65536,_0x4655e7+=_0x1fb41a(bJbUsf.dhsVN(bJbUsf.bsGrv(_0x217094,10),55296),(1023&_0x43a89c)+56320),_0x467955+=3)}function xa(a,n,s){let d=t;return n[d(1424)+"t8"]?n[d(1424)+"t8"](a,s):n[s]=e[d(915)](255,a),e.iTVJX(s,1)}let bp=function(a){return new Uint8Array(a)},Ep=e[t(681)]("undefined",typeof Buffer)?Buffer[t(1228)+t(1156)]:e.uESrB(xp,bp,Uint8Array.prototype[t(775)]);(()=>{let a=t,n={KvXGi:e.ppocP,rOzON:function(s,d){return s|d},bJqiH:function(s,d){return e.bERMz(s,d)},fmtMd:function(s,d){return e[U(1527)](s,d)},Xogth:function(s,d){return e[U(1304)](s,d)},ksmbR:function(s,d){return s>>>d},MODBS:function(s,d){return e[U(989)](s,d)},OYYDS:function(s,d){return e.Ctjuw(s,d)},LnROj:function(s,d){return e[U(1009)](s,d)},PtOzS:function(s,d){return s|d},FoPSg:function(s,d){return e[U(1180)](s,d)},IyNTx:function(s,d){return s<<d},CtVjj:function(s,d){return e[U(1044)](s,d)},Srlqm:function(s,d){return s|d},sgSTb:function(s,d){return e.HjzKX(s,d)},aVnsr:function(s,d,l,h){return e[U(1617)](s,d,l,h)}};if(e.jIwlw!==a(1958)){let s=4294967295;return function(d,l,h=!0){let g=a,w=n[g(909)][g(657)]("|"),m=0;for(;;){switch(w[m++]){case"0":return{value:h?s:n[g(1842)](0,s),offset:l};case"1":if(n[g(823)](d[l++],128))return{value:h?s:0|s,offset:l};continue;case"2":if(d[l++]<128)return{value:h?s:0|s,offset:l};continue;case"3":s=n[g(1367)](127,d[l])>>>0;continue;case"4":if(n.Xogth(d[l++],128))return{value:h?s:0|s,offset:l};continue;case"5":s=n[g(1991)](n[g(1842)](s,(127&d[l])<<7),0);continue;case"6":s=n[g(944)](n[g(1842)](s,n[g(1273)](n[g(1700)](127,d[l]),14)),0);continue;case"7":s=n[g(1991)](n.PtOzS(s,n[g(1367)](127,d[l])<<21),0);continue;case"8":s=n[g(944)](n[g(1857)](s,n.IyNTx(n.CtVjj(15,d[l]),28)),0);continue;case"9":if(d[l++]<128)return{value:h?s:n[g(1089)](0,s),offset:l};continue;case"10":if(n.sgSTb(l+=5,d[g(1775)]))throw l=d[g(1775)],n[g(776)](pp,l,10,d[g(1775)]);continue;case"11":if(n[g(823)](d[l++],128))return{value:h?s:0|s,offset:l};continue}break}}}else{let s=0,d=0,l;do l=_0x25f8ef(_0x3f28b9),e[a(1496)](s,32)&&(d|=e[a(1825)](e.qjrxD(127,l),s)),s+=7;while(e[a(505)](128,l));return d}})();let vp=16,ha=32;function Sp(a){let n=t;if(e[n(1414)]===e[n(749)]){let s=_0x93241f[n(1775)]&&_0x42e8d7[0];if(e[n(482)](s,_0x1861cb))throw s;let d=new _0x13744e(e[n(1858)](e[n(809)],s?e.uzzNj(e[n(1937)](" (",s[n(1128)]),")"):""));throw d[n(1295)]=s,s}else{let s=0,d={};for(let l=0;e[n(1966)](l,a[n(1775)]);l++)if(e.JhwiB(e[n(1893)],e.aVniE))d[a[l][n(1536)+n(1283)]]=e[n(764)](Xd,a[l][n(1536)+n(1283)]),s+=e.jRGed(14,d[a[l][n(1536)+n(1283)]]);else{let h=e[n(537)](e[n(1963)](e[n(552)](e[n(895)](e[n(1020)](7,_0xd2076c),18),e[n(915)](63,_0x17c22e[_0x376ab6++])<<12)|e.djmKY(e.WYOpJ(63,_0x69b47a[_0x16543b++]),6),e.ykzqb(63,_0x4a4fb6[_0x5c7b55++])),65536);_0x5724c8+=_0x4ac8c8[n(1499)+n(447)](e[n(1884)](55296,e[n(588)](h,10))),_0x5f251e+=_0x3e269b[n(1499)+n(447)](e.IwsjO(56320,e[n(1511)](1023,h)))}return[s,d]}}function r0(a,n,s){let d=t,l={ZkOtf:function(A,N,L,q){return e[U(1278)](A,N,L,q)},CRspe:function(A,N,L,q){return A(N,L,q)},Ogilr:e.NOvQu,vrfcO:e[d(995)],ytEWX:e[d(1831)],nEaLj:d(1797),byXQW:function(A,N,L,q){return e.QfAlg(A,N,L,q)}},[h,g]=e[d(1592)](Sp,a),w=Ep(h),m=0;return a[d(502)](A=>{let N=d,L=(N(1833)+N(815)+N(1841))[N(657)]("|"),q=0;for(;;){switch(L[q++]){case"0":console[N(1861)](N(821)+"ervice",A,A[N(1797)]);continue;case"1":m=l[N(1157)](xa,0,w,m);continue;case"2":m=l[N(1503)](xa,g[A[N(1536)+"ame"]],w,m);continue;case"3":console[N(1861)](l.Ogilr,m);continue;case"4":console[N(1861)](l[N(1821)],m);continue;case"5":m=l.ZkOtf(wp,A[N(1536)+N(1283)],w,m);continue;case"6":console[N(1861)](N(1911),m);continue;case"7":console.log(l[N(404)],m);continue;case"8":m=gp(w,m,A[N(1797)]||0);continue;case"9":console[N(1861)](l[N(1373)],m);continue;case"10":m=l[N(1183)](yp,ce[N(1386)+"er"](A[N(677)]||n),w,m);continue}break}}),{frameType:ha,headers:[{key:e[d(1710)],value:s}],payload:w}}function Ip(a){let n=t,s=0,d=[];for(;e[n(469)](s,a[n(701)+"th"]);){let{offset:l}=e[n(698)](fa,a,s);s=l;let h={cursor_name:"",cursor:0,service:0},{value:g,offset:w}=e.XwTXD(mp,a,s);h[n(1797)]=g,s=w;let{value:m,offset:A}=e[n(388)](fa,a,s);s=A,h[n(1536)+"ame"]=e[n(1278)](Qd,a,s,s+m),s+=m;let{value:N,offset:L}=e.XJsdb(_p,a,s);h.cursor=N.toNumber(),s=L,d[n(883)](h)}return d}function Ap(){return{frameType:ha,headers:[{key:e[t(1710)],value:e.lnjSB}],payload:void 0}}class Tp{constructor(n,s,d){let l=t;this[l(1988)+"ameSpace"]=n,this[l(778)+l(1155)]=s,this["_message"+l(830)]=d,this[l(1286)]=e[l(640)](t0,this[l(1988)+"ameSpace"],e[l(453)])}async[t(1637)](){let n=t;if(e[n(1275)](e[n(1540)],e[n(1585)]))await this[n(1286)][n(1637)]();else return this[n(1139)+"ndpointT"+n(1817)+"t"]=1,this[n(1437)+"ndex"]++,this[n(1159)+"s"][this[n(1437)+n(832)]]}async[t(1365)+"rs"](){let n=t;if(!this[n(1286)][n(1492)])return;let s=this[n(1271)+n(830)],d=await this[n(1286)][n(1116)]();switch(console[n(1861)](n(1904)+n(590),d),s){case n(945):return d&&d[n(1775)]?e[n(1487)](r0,d,0,this["_cursorF"+n(1155)]):void 0;case e.deYvQ:return;case e[n(1543)]:return d&&d.length?e.BfDJQ(r0,d,0,this[n(778)+n(1155)]):e.bWrCu(Ap)}}async[t(1906)](n,s,d){let l=t;return console[l(1861)]("setdb",n,s,d),this[l(1286)].set({cursor_name:n,cursor:s,service:d})}async[t(954)+"rs"](n){let s=t,d=e[s(1446)](Ip,n);for(let l of d)if(e[s(1382)](s(934),"sJdMN"))try{return e[s(607)]("string",typeof _0xc07c38)&&(_0x4a86f1 instanceof _0x1bb0de||_0x22c3a0[s(1293)]&&_0x20301f[s(1293)]instanceof _0x3b7ec5)||e.CFtly(e[s(1574)],typeof _0x332161)?"":(_0x46ef79[s(1641)](_0x20c0f1),s(480)+s(1366))}catch{return e[s(1794)](s(1358),typeof _0x43eebd)?e[s(1698)]:""}else console[s(1861)](e[s(1968)],d),await this._qosDB.set(l)}async[t(734)](n){let s=t;if(e[s(1561)](e[s(957)],e[s(957)]))_0x32014d=_0x42f351[e[s(1928)](e.TCgZE(_0x4cf810,_0x1062b4),1)],e[s(1332)](192&_0x53aa9f,128)?_0x43ccca+=_0x5016cd:(_0x3326b2=e[s(448)](e[s(1051)](e[s(1456)](31,_0x7963b3),6),e[s(961)](63,_0x34001e)),_0x2ec8a8<128?_0x269a76+=_0x57f2c0:(_0x596729+=_0x308d93(_0x229cfb),_0x265369++));else return(await this[s(1286)][s(734)](n))?.[s(677)]}async[t(1799)](){let n=t,s={PwlNh:e.sgNHw};e[n(1703)](e[n(1022)],e.fVkyb)?await this[n(1286)][n(1799)]():(this.emit(s[n(528)],_0x24895e),this[n(1021)]&&this.onclose(_0x58e542))}[t(1685)+t(984)+t(861)](n){let s=t;this["_cursorF"+s(1155)]=n}get[t(1492)](){let n=t;if(e[n(1650)](e.sxdLr,e[n(1971)]))return this[n(1286)][n(1492)];this[n(604)]&&this[n(604)].close(_0x24bcf1,_0x236245)}}let Cp=t(1897)+t(1648);async function i0(a){let n=t;if(!this[n(1184)].enableQoS)return null;let{aID:s,fpID:d,messageStrategy:l}=this[n(1184)],h=e[n(1466)](a,Cp);try{return this["_cursorM"+n(1229)]?e[n(642)](n(416),e[n(1108)])?a&&this[n(1335)+n(1229)][n(1685)+n(984)+n(861)](a):(_0x546453[n(1121)+n(564)]="",_0x283c0a[n(1861)](_0x194539)):this["_cursorM"+n(1229)]=new Tp(d+"_"+s+"_"+h,h,l),this[n(1335)+n(1229)][n(1492)]||await this[n(1335)+n(1229)][n(1637)](),this._cursorManager}catch{if(e[n(887)](n(1181),n(1912))){let g=_0x522839[_0x103a52];if(e[n(1382)](4,_0x26e0c7[_0x59403d].length)){let w=_0x92ac14[n(464)+"g"](0,4-_0x219e59[_0x52e758].length),m=w.concat(g);_0x41452f=_0x598a03[n(1717)](m)}else _0x2fe99b=_0x58de4b[n(1717)](g)}else return null}}async function Dp(a,n){let s=t,d=e.derHM(en,a[s(1128)][s(1813)],e[s(562)],"-1"),l=en(a[s(1128)][s(1813)],e.luiHf,"1"),h=e.ypHov(Yn,a[s(1128)].headers,e[s(1314)]),g=e.wkuJF(Number,e[s(698)](Yn,a[s(1128)][s(1813)],e[s(1916)]))||0,w=la.call(this,a),m=e[s(850)](en,a[s(1128)][s(1813)],e[s(748)],"2"),A=e.CrdEe(Yn,a[s(1128)].headers,e[s(1666)]),N=e[s(1378)](Number,e[s(1548)](Yn,a[s(1128)][s(1813)],e[s(1771)]));if(w.isQoSAck)return e[s(425)](n);let L=w["isQoSMes"+s(1135)]?await n0[s(1773)](this):null;if(a.message[s(1797)]>0&&l&&!d||e.kdCkD(a[s(1128)].service,0)){if(h&&w[s(1385)+s(1135)]&&L)return e[s(1450)](e[s(1661)],e[s(1661)])?!!this[s(1286)]:(!!!await L[s(734)](h)&&(this["_dispatc"+s(660)+s(1398)](a),await L.set(h,e[s(849)](Date.now(),g))),e[s(999)](n));if(m){let q=await i0[s(1773)](this);if(!q)return this[s(1063)+s(660)+"Event"](a),n();let W=await q[s(734)](A)??-1;if(e[s(1545)](W,N))this["_dispatc"+s(660)+"Event"](a),q.set(A,N,a.message.service);else throw new Error(s(1455)+s(1749)+s(805)+N+(s(1317)+"than loc"+s(853)+"r ")+W);return e[s(1029)](n)}return this[s(1063)+s(660)+s(1398)](a),n()}}async function Rp(a,n){let s=t,d=la[s(1773)](this,a);if(!d[s(1385)+s(1135)])return n();let l=await n0[s(1773)](this);if(d[s(514)+s(1869)+s(1530)]&&d.ackMsgIds[s(1775)])for(let h of d.ackMsgIds)await l[s(1952)](h);e[s(702)](n)}async function kp(a,n){let s=t,d=e[s(1457)](a.message[s(1141)+"e"],vp),l=a[s(1128)].frameType===ha;if(e[s(1681)](!d,!l))return e[s(1048)](n);let h=Yn(a[s(1128)].headers,e.ooEhj);if(!h)return e[s(786)](n);let g=await i0[s(1773)](this,h);if(!g)return n();if(d)if(e.bQzeE(e[s(1104)],s(1766))){let w="connect "+_0x1ac4e4+(s(1172)+s(1558)+s(1830)+s(938));this._debug(w),this["_dispatc"+s(603)+s(836)](e.ufaEa(_0x50d010,e[s(1785)],{message:w,code:_0x3c8d5b[s(1423)+s(1005)+"R"]}));return}else{let w=await g[s(1365)+"rs"](),m={frameType:w?.[s(1141)+"e"],SeqID:ce[s(1386)+"er"](this[s(998)]++),LogID:ce[s(1386)+"er"](this[s(1184)]["logIDGen"+s(1546)]()),service:9e3,method:5,headers:w?.headers,payload:w?.[s(933)]},A=e[s(851)](T,m);this[s(604)]&&this._ws[s(1015)+"te"]&&this._ws[s(1627)](A)}if(l){let w=a.message[s(933)];w&&g[s(954)+"rs"](w)}}let Op=async function(a,n){let s=t;this._isInit=!1,e.eSSgy(clearTimeout,this[s(442)+s(1185)+"utId"]),n()},Np=async function(a,n){let s=t;if(!this[s(604)]||e.cwJIp(this._ws[s(1015)+"te"],this[s(386)]))return e[s(996)](n);let{pingInterval:d}=this._options;this[s(1784)+s(1008)]?.[s(1470)+s(586)+s(817)]();for(let h=0;e[s(497)](h,this[s(1271)+s(1206)].length);h++){let g=this[s(1271)+"Queue"][h];if(e[s(1102)](this._ws.readyState,this[s(386)])&&e[s(1508)](null,g))this[s(604)]&&this[s(604)][s(1627)](g),this[s(1271)+s(1206)][h]=null;else break}this[s(1271)+"Queue"]=this[s(1271)+s(1206)][s(1322)](h=>!!h),this._pingPongTimeoutId=setTimeout(()=>this[s(1690)](),d),this._dispatchOpenEvent(a),this._isBrowser&&this[s(604)]&&(this[s(604)][s(1870)+"pe"]=this["_binaryT"+s(1309)]);let l=this[s(1784)+s(1008)]?.[s(605)+s(980)+"nt"]();this[s(733)](s(1404)+l+s(1024)),n()},Pp=async function(a,n){let s=t,d=this[s(1784)+s(1008)]?.[s(605)+s(980)+"nt"]();this._debug("open "+d),e[s(1658)](n)};class Lp extends ca{constructor(n){let s=t,d={xhikI:function(l,h){return e[U(450)](l,h)},hXJno:e.Jlyig,diipv:function(l,h,g,w){return l(h,g,w)},rMKFn:function(l,h,g){return l(h,g)},MXSDr:function(l,h){return e[U(1794)](l,h)},LHuCw:e.dfVfD,pZnTg:function(l,h){return l<h},sYgGQ:function(l,h){return l+h},rZhFI:e.Dvecp,mJaVV:e.NZgYO,sxwPI:function(l,h,g){return e[U(1547)](l,h,g)},XMSQG:e[s(770)],uwJtZ:function(l,h,g){return e[s(1334)](l,h,g)},YkxYl:function(l,h){return e.lhHVz(l,h)},Hbudo:function(l,h,g){return l(h,g)},MINpb:function(l,h){return e[s(1402)](l,h)}};if(e[s(901)](e.EGCFJ,e[s(1750)]))try{e[s(1735)](_0x105597,this,_0x21822f,[_0xc196e3,_0x52a2c9,_0x4106bb])}catch(l){let h=_0x3abbb8(e[s(1785)],{message:l[s(1128)],code:_0x548ee8.OPEN_ERROR,error:l});this[s(1063)+"hErrorEvent"](h)}else{super(),this[s(1577)+"igatorOn"+s(874)]=!0,this._isBrowser=Jn,this[s(1651)]=Zh,this._isMiniTT=Sn,this[s(1724)+"X"]=Gr,this[s(1032)+"r"]=Kr,this["_message"+s(1206)]=[],this["_endpoin"+s(1008)]=null,this[s(432)+s(1515)]=!1,this["_binaryT"+s(1309)]=e[s(800)],this._connectLock=!1,this[s(442)+s(1185)+"utId"]=null,this[s(967)+"ctTimeoutId"]=null,this[s(1565)+s(490)+"Id"]=null,this[s(998)]=0,this[s(985)]=!1,this[s(1462)]="",this["_QoSMana"+s(1497)]=null,this[s(1335)+"anager"]=null,this[s(685)+s(1874)]=null,this[s(1948)+"ls"]=e[s(1677)],this[s(486)]=3,this[s(1930)+"NG"]=0,this[s(386)]=1,this[s(1042)]=2,this[s(1933)]=w=>{let m=s;if(d.xhikI(d[m(1084)],d[m(1084)]))try{d[m(1081)](Zd,this,w,[Op,Np,Pp])}catch(A){let N=d.rMKFn(ot,"error",{message:A[m(1128)],code:Qt[m(596)+"OR"],error:A});this["_dispatchErrorEv"+m(836)](N)}else return new _0x2d9ca0(_0x324d0a)},this[s(572)+"ge"]=async w=>{let m=s,{pingInterval:A,pingFrequency:N}=this[m(1184)];if((e.HEkkJ("hi",w.data)&&e[m(1193)](e.KWfiv,N)||e[m(761)](e[m(758)],N))&&(this[m(1493)+m(1926)](),this[m(559)]("ping_once_success",e.NPjOt),this[m(1565)+m(490)+"Id"]=e.dGdVT(setTimeout,this[m(1690)][m(412)](this),A)),!e.cxQGA("hi",w.data))try{if(e[m(901)](e[m(1909)],e[m(790)]))return uKyygA[m(769)](m(1358),typeof _0x2eff78)?uKyygA[m(1013)]:"";e[m(1617)](Zd,this,w,[fp,up,Rp,kp,Dp,lp])}catch(L){let q=ot(e[m(1785)],{message:L.message,code:Qt[m(1742)+m(723)],error:L});this[m(1063)+m(603)+m(836)](q)}},this._onError=w=>{let m=s;if(d[m(986)]!==d[m(986)]){let A=uKyygA[m(1759)](_0x381ccd,_0x79ab9b,_0x39e964.limit),N=_0x33f33b[m(740)],L=_0x2bf691.bytes;for(let q=0,W=_0x426353.limit;uKyygA[m(1739)](q,W);q++)N[uKyygA[m(1261)](q,A)]=L[q]}else{let A=this["_endpoin"+m(1008)]?.["checkRea"+m(1995)+"es"](),N=this[m(1784)+"tManager"]?.["getCurre"+m(980)+"nt"]();if(A&&!w[m(1128)]){let L=m(1468)+N+(m(411)+m(1251)+m(1451)+"ed");this[m(1063)+m(603)+m(836)](ot(m(503),{message:L,code:Qt[m(1423)+m(1005)+"R"],error:w}));return}this[m(604)]&&this[m(604)][m(1015)+"te"]===this[m(386)]&&this[m(1464)+m(534)](),this["_dispatc"+m(603)+m(836)](d[m(1759)](ot,d[m(1922)],{message:w.message,code:Qt[m(511)+m(788)],error:w}))}},this[s(868)]=async w=>{let m=s;this[m(1340)+m(454)](),this[m(1493)+m(1926)](),this["_removeW"+m(948)+"rs"](),this[m(604)]=null,this[m(442)+m(942)]=!1;let A=this._endpointManager?.[m(735)+"chMaxTries"]();if(!A&&this[m(2004)+m(1834)]()&&!this._readyClosed){let N=this[m(1784)+m(1008)]?.[m(605)+"ntEndpoint"](),L=this[m(1184)][m(1566)+m(1601)+m(1163)](w[m(533)],w[m(1122)]);this[m(1063)+"hCloseEv"+m(836)](d[m(1847)](xt,d[m(1312)],{code:1006,reason:w[m(1122)]||m(1986)+m(1923)+m(1969)+"wn reaso"+m(1873)+m(1062)+N,willReconnect:L})),L&&this[m(442)]();return}if(w[m(533)]!==1e3&&this[m(432)+m(1515)]){this[m(1063)+m(1352)+m(836)](d.uwJtZ(xt,d.XMSQG,{code:1e3,reason:m(879)})),this[m(1784)+m(1008)]?.[m(1470)+m(586)+"fig"](),this[m(685)+"sCounter"]?.resetCounter();return}if(d[m(1384)](1e3,w[m(533)])&&A){let N=this[m(1784)+m(1008)]?.[m(605)+"ntEndpoint"](),L=w[m(1122)];L||(L=await ip(this[m(1462)])),L=m(1986)+m(1923)+m(947)+L+(m(1226)+"me: ")+N+(m(1558)+"tries re"+m(938)),this["_dispatc"+m(1352)+m(836)](d[m(1696)](xt,d.XMSQG,{code:w[m(533)],reason:L}));let q=m(1468)+N+(m(411)+m(1251)+m(1451)+"ed");this[m(1063)+m(603)+m(836)](ot(d[m(1922)],{message:q,code:Qt[m(1423)+"IES_ERROR"]})),this["_endpoin"+m(1008)]?.["resetEnd"+m(586)+"fig"](),this[m(685)+m(1874)]?.[m(736)+"nter"]();return}if(d[m(655)](1e3,w[m(533)])&&!w.reason){let N=this["_endpoin"+m(1008)]?.[m(605)+m(980)+"nt"]();this[m(1063)+"hCloseEv"+m(836)](d[m(1716)](xt,d.XMSQG,{code:w.code,reason:m(1986)+"ng faile"+m(1969)+m(1867)+"n, hostname: "+N})),this[m(1784)+m(1008)]?.[m(1470)+m(586)+m(817)](),this[m(685)+m(1874)]?.[m(736)+m(1608)]();return}this["_dispatchCloseEv"+m(836)](w),this[m(1784)+m(1008)]?.[m(1470)+m(586)+"fig"](),this[m(685)+m(1874)]?.[m(736)+"nter"]()},this[s(1021)]=null,this[s(1855)]=null,this[s(413)+"e"]=null,this[s(438)]=null,this[s(1475)+s(1720)]=null,this[s(1117)+s(389)]=null,this["onStopIm"+s(1559)+s(966)+"ct"]=null,this["_handleO"+s(754)]=this[s(1509)+s(754)].bind(this),this[s(1509)+"ffLine"]=this["_handleO"+s(530)][s(412)](this),this[s(1397)+s(1591)]=this["_handleP"+s(1591)][s(412)](this),this[s(1397)+s(1706)]=this[s(1397)+"ageShow"].bind(this),this[s(1184)]={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(1624),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(777),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:h}=n,g=Array[s(1234)](l)?l:e[s(615)](e.pWTmK,typeof l)?[l]:[];if(!g||g[s(1775)]===0)throw new Error(e.pjbGN);if(!e[s(626)](ep,h))throw new Error(e[s(383)]);Object[s(1629)](this[s(1184)],n),this[s(1784)+"tManager"]=new Yd(g,this[s(1184)].maxRetries),this[s(685)+"sCounter"]=new rp(this[s(1184)][s(699)+s(1444)]),this[s(1184)][s(856)+s(1349)]&&(this._isInit=!0,this._connect()),this._options.listenNetworkChanged&&(this[s(636)+"T"]||this[s(1724)+"X"]?this["_onPageN"+s(634)+s(958)]():this[s(1632)+"er"]&&this[s(1408)+s(1348)+s(400)]())}}["_handleO"+t(754)](){let n=t;this[n(1184)][n(1856)+n(1865)+n(1707)]||this[n(432)+n(1515)]||this[n(520)+"econnect"]()}[t(1509)+t(530)](){let n=t;this[n(1741)+"WebSocket"]();let s=e[n(1036)](aa,e.JwnLr,{message:e[n(1791)]});this[n(877)+n(1559)+n(966)+"ct"]&&this[n(877)+n(1559)+n(966)+"ct"](s)}[t(1408)+t(1348)+t(400)](){let n=t;this[n(1632)+"er"]&&window["addEvent"+n(400)](e[n(1777)],this[n(1509)+n(754)]),this[n(1632)+"er"]&&window[n(1603)+n(400)](n(627),this[n(1509)+n(530)]),this[n(1632)+"er"]&&window[n(1603)+n(400)](e[n(667)],this[n(1397)+"ageHide"]),this._isBrowser&&window[n(1603)+n(400)](n(1445),this[n(1397)+n(1706)])}[t(1129)+t(1348)+"Listener"](){let n=t;e[n(1092)](e[n(753)],"LuGlo")?(this[n(1632)+"er"]&&window[n(794)+n(380)+n(1432)](e.pCQaT,this[n(1509)+"nLine"]),this[n(1632)+"er"]&&window[n(794)+n(380)+n(1432)](e[n(1892)],this[n(1509)+n(530)]),this[n(1632)+"er"]&&window[n(794)+n(380)+n(1432)](n(623),this[n(1397)+n(1591)]),this._isBrowser&&window[n(794)+n(380)+n(1432)](e[n(937)],this[n(1397)+n(1706)])):this[n(1286)]?.[n(1952)](_0x3c7f28.message_id)}[t(1397)+t(1591)](n){let s=t;!n[s(668)+"d"]&&(this[s(1632)+"er"]&&window["removeEv"+s(380)+s(1432)](e[s(667)],this[s(1397)+"ageHide"]),this[s(1632)+"er"]&&window["removeEv"+s(380)+s(1432)](e[s(937)],this["_handleP"+s(1706)]),this[s(1573)]()),this._isBrowser&&window[s(794)+"entListener"](s(1002),this["_handleO"+s(754)]),this._isBrowser&&window[s(794)+s(380)+"ner"](e[s(1892)],this[s(1509)+"ffLine"])}[t(1397)+"ageShow"](n){let s=t;e[s(566)](e[s(1805)],e.WGnvm)?n.persisted&&(this["_navigat"+s(1834)]()&&(!this[s(604)]||e[s(1920)](this[s(604)][s(1015)+"te"],this.OPEN)||e[s(597)](this[s(604)][s(1015)+"te"],this[s(1930)+"NG"]))&&this[s(1509)+s(754)](),this[s(1632)+"er"]&&window.addEventListener(e[s(1777)],this[s(1509)+"nLine"]),this[s(1632)+"er"]&&window["addEvent"+s(400)]("offline",this["_handleO"+s(530)])):this[s(1276)](_0x261f8a,_0x191651)}async[t(426)+t(394)](n){let s=t,{fpID:d,deviceID:l,bddID:h,ttwID:g,accessKey:w,aID:m,customParams:A={},enableAutoAck:N,enableQoS:L,QoSLevel:q,env:W}=this[s(1184)],Y,de,pe;this[s(1632)+"er"]||this[s(1724)+"X"]||this[s(636)+"T"]?e.fvqNO(e.HlzZz,e[s(1935)])?(Y=location&&e[s(1074)](e.vEmLQ,location[s(521)])?e[s(1881)]:"ws://",de=n[s(656)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),pe=/^wss(.*:\/\/)/[s(1065)](n)?n:""+Y+de):(this[s(1493)+s(1926)](),this[s(559)](e.fgLtZ,s(1754)),this[s(1565)+s(490)+"Id"]=e[s(526)](_0x237ec1,this[s(1690)][s(412)](this),_0x3a4ba3)):(Y=e[s(1881)],de=n[s(656)](/(^http)((?:[s]*:\/\/))/,""),pe=/(^ws)((?:[s]*:\/\/))/[s(1065)](de)?de:""+Y+de);let Qe=h?e[s(771)]:g?s(531):e[s(1779)],Zn=h||g||l;if(e[s(801)](!Zn,!Qe))throw new Error(s(1730)+"rovide b"+s(1768)+s(1851)+"r ttwID");let pa=e[s(1192)](s(1132),typeof A)?await e.EtJvi(A):A,ga=W?e[s(1812)](np,W.xUseEnv,W[s(608)]):{},Wr=Object[s(1629)]({device_platform:e.FLUqE,version_code:e[s(392)],access_key:w,fpid:d,aid:m,[Qe]:Zn,xsack:N?1:0,xaack:N?1:0,xsqos:L?1:0,qos_level:L?q:void 0,qos_sdk_version:2,...ga},pa),ma=Object[s(1818)](Wr).reduce((Xn,$r)=>Wr[$r]!==void 0?""+Xn+(Xn?"&":"?")+$r+"="+Wr[$r]:Xn,"");return pe+s(546)+ma}async[t(442)](){let n=t,s={xQLTN:function(d){return e[U(1802)](d)}};if(!(this[n(442)+"Lock"]||this["_readyCl"+n(1515)])){this[n(442)+"Lock"]=!0;try{if(e[n(1140)](e[n(1336)],n(1972))){let d=this["_endpoin"+n(1008)]?.[n(605)+"ntEndpoint"]();this[n(733)](n(1404)+d),AGpwsX[n(1798)](_0x2f1284)}else{let d=this[n(1784)+n(1008)]?.[n(1023)+n(1017)+n(1383)+n(1837)+n(1221)](),{timeoutInterval:l}=this[n(1184)];if(d){let g=this[n(1784)+"tManager"]?.["getCurre"+n(980)+"nt"](),w=this["_endpoin"+n(1008)]?.[n(973)+n(1161)+n(567)+"UpdateCo"+n(717)](),m=this[n(1784)+n(1008)]?.[n(605)+n(980)+"ntTriesC"+n(726)]();if(w){let A=n(1468)+g+(n(1172)+n(1558)+n(1830)+n(1801)+"ill use backup endpoint ")+w+(n(445)+"y"),N=e[n(1430)](ot,e[n(1785)],{message:A,code:Qt[n(1423)+n(1005)+"R"]});this[n(733)](A),this._dispatchErrorEvent(N),this[n(1462)]=await this["_generat"+n(394)](w),this[n(733)](n(1468)+w+" "+m+" times"),this[n(697)+"sListeners"]()}else{let A="connect "+g+(n(1172)+", max retries re"+n(938));this[n(733)](A),this[n(1063)+n(603)+n(836)](e.DITHG(ot,n(503),{message:A,code:Qt[n(1423)+"IES_ERROR"]}));return}}else{let g=this[n(1784)+n(1008)]?.[n(605)+"ntEndpoi"+n(1060)+n(472)](),w=this[n(1784)+"tManager"]?.[n(605)+n(980)+n(1774)+n(726)]();this[n(1462)]=await this[n(426)+n(394)](e[n(1085)](g,"")),this._debug(n(1468)+g+" "+w+n(1299)),this[n(697)+n(948)+"rs"]()}if(this[n(985)])this[n(985)]=!1;else if(n(1406)!=="EaXsT"){let g=e[n(810)](aa,e[n(540)],{message:e.FuogM});this[n(1475)+n(1720)]&&this[n(1475)+n(1720)](g)}else return{bytes:_0x1bf458,offset:0,limit:_0x5a45e5.length};let h=this["_endpoin"+n(1008)]?.[n(605)+n(980)+n(1774)+n(726)]()||0;e[n(1633)](h,1)&&await this[n(919)](e[n(1687)](h,1)),this[n(733)](n(1986)+n(1767)+this[n(1462)]+(n(1039)+n(1215))+this[n(1948)+"ls"]),this[n(604)]=e[n(1307)](Qh,{url:this[n(1462)],protocols:[this._protocols],headers:this[n(1184)][n(1260)+"ramParams"][n(1721)+n(1980)]},this[n(1184)].ws),(this[n(1632)+"er"]||this[n(1032)+"r"])&&this[n(604)]&&(this._ws.binaryType=this[n(1864)+n(1309)]),this[n(1521)+n(808)](),this[n(442)+"ionTimeo"+n(506)]=setTimeout(this[n(1058)+"ut"][n(412)](this),l)}}catch(d){throw this._connectLock=!1,d}}}["_clearTi"+t(454)](){let n=t;e[n(1669)](clearTimeout,this[n(442)+n(1185)+n(506)]),this["_connectionTimeo"+n(506)]=null}[t(1493)+t(1926)](){let n=t;e[n(922)](clearTimeout,this[n(1565)+n(490)+"Id"]),e[n(884)](clearTimeout,this["_reconnectTimeou"+n(1921)]),this[n(1565)+"gTimeoutId"]=null,this[n(967)+n(814)+n(1921)]=null}_debug(...n){let s=t;this[s(1184)].debug&&console.log[s(842)](console,[e[s(1564)],...n])}[t(1868)+t(1694)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:l,reconnectIntervalGrowFactor:h}=this._options,g=e[s(991)](d,Math[s(1925)](h,n-1));return e.zfXaV(g,l)?l:g}_ping(){let n=t;if(this[n(604)]&&this[n(604)][n(1015)+"te"]===this.CONNECTING){this[n(1493)+n(1926)](),this["_pingPon"+n(490)+"Id"]=setTimeout(this[n(1690)].bind(this),this[n(1184)][n(609)+n(1526)]);return}if(!this[n(604)]||e[n(1473)](this[n(604)][n(1015)+"te"],this.OPEN))return void this[n(520)+n(1720)]();this[n(604)]&&this._ws[n(1627)]("hi"),this[n(967)+n(814)+n(1921)]=setTimeout(this[n(520)+n(1720)+n(1225)][n(412)](this),this[n(1184)][n(759)+"outInter"+n(1642)])}["_handleR"+t(1720)+t(1225)](){let n=t;this[n(685)+n(1874)]?.addCount(),this[n(559)](e.Wzgpe,e[n(1177)]),this[n(685)+n(1874)]?.[n(735)+n(643)+"nt"]()?this[n(520)+n(1720)]():this[n(1690)]()}[t(2004)+t(1834)](){let n=t;return this[n(636)+"T"]||this._isMiniWX?this[n(1577)+n(1705)+n(874)]:(this[n(1632)+"er"]||this[n(1032)+"r"])&&this[n(1184)][n(1143)+n(1999)+n(855)]?navigator[n(592)]:!0}[t(520)+t(1720)](){let n=t;!this["_navigat"+n(1834)]()||this[n(432)+n(1515)]||(this[n(1784)+n(1008)]?.[n(1470)+"pointCon"+n(817)](),this[n(685)+n(1874)]?.["resetCou"+n(1608)](),this[n(604)]?this[n(1464)+n(534)](1001,e.NAYks,!0):this[n(442)]())}[t(1012)+t(634)+"ange"](){let n=t;this[n(636)+"T"]?tt[n(1364)+n(878)+n(1537)](({isConnected:s})=>{let d=n;this[d(1577)+d(1705)+d(874)]=s,s?this[d(1509)+"nLine"]():this[d(1509)+d(530)]()}):this[n(1724)+"X"]&&wx[n(1364)+"kStatusC"+n(1537)](({isConnected:s})=>{let d=n;this[d(1577)+"igatorOnline"]=s,s?this[d(1509)+d(754)]():this._handleOffLine()})}[t(919)](n){let s=t;if(e[s(839)](e[s(449)],s(1557)))return new Promise(d=>{setTimeout(d,this["_getInte"+s(1694)+"e"](n))});{let d=e[s(1990)](_0x4826b0,_0x2bc950),l=_0x2879c6[s(1613)];return _0x4c5e6e[s(1613)]=e.jEsUL(_0x3b027c[s(381)],d),l}}_disconnect(n=1e3,s="",d=!1){let l=t;if(e[l(1541)](e[l(911)],e.mYjVA)){if(!this[l(604)])return;this[l(1741)+l(1790)+"t"](n,s,d)}else{let h=_0x393370[_0x4e258b++];if(e[l(1550)](h,127))_0xe2acf1+=_0xc148cd[l(1499)+l(447)](h);else if(h>=192&&e[l(813)](h,224))_0x4a479e+=_0x4a76db[l(1499)+l(447)](e[l(1676)](e[l(875)](31&h,6),e[l(1238)](63,_0x5e81cf[_0x21a04e++])));else if(e[l(1582)](h,224)&&h<240)_0x183928+=_0x446be3["fromChar"+l(447)](e.LuMYS(e[l(494)](e[l(1255)](15&h,12),e[l(1308)](e[l(1090)](63,_0x1eaba9[_0x3c85f6++]),6)),e.XaHTd(63,_0x46465e[_0x44e38f++])));else if(e.ymTDx(h,240)){let g=(e[l(1862)](e[l(1180)](e[l(1732)](7&h,18),e[l(512)](e.HfBYZ(63,_0x3bc5b9[_0x48a70e++]),12)),e[l(1825)](63&_0x520a50[_0x54f1a3++],6))|63&_0x18cb17[_0xce3fda++])-65536;_0x381d82+=_0x3d8e73[l(1499)+l(447)](e.ZgMzp(55296,g>>10)),_0x56710e+=_0x5df1ce.fromCharCode(56320+e[l(1769)](1023,g))}}}_onTimeout(){let n=t,s=this[n(1784)+n(1008)]?.[n(605)+n(980)+"nt"]();this[n(733)](n(1468)+s+n(1172)),this[n(1464)+"ect"](1001,e[n(1606)],!0)}_sendAck(n){let s=t,d=e[s(1446)](Bt,n);this[s(604)]&&e[s(1804)](this[s(604)].readyState,this.OPEN)&&(this[s(604)]&&this[s(604)][s(1627)](d),this[s(733)](e[s(1485)],n))}[t(697)+"sListeners"](){let n=t,s=e[n(535)][n(657)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(604)][n(794)+n(380)+n(1432)](e[n(1587)],this._onMessage);continue;case"1":if(!this[n(604)])return;continue;case"2":this[n(604)]["removeEventListe"+n(1432)](e.NZgYO,this[n(1249)]);continue;case"3":this[n(604)][n(794)+n(380)+n(1432)](n(1573),this[n(868)]);continue;case"4":this[n(604)][n(794)+"entListener"](e.XyqOu,this[n(1933)]);continue}break}}["_addWsLi"+t(808)](){let n=t,s=e[n(485)][n(657)]("|"),d=0;for(;;){switch(s[d++]){case"0":this._ws[n(1603)+n(400)]("close",this[n(868)]);continue;case"1":this[n(604)][n(1603)+n(400)](e.dVQLi,this[n(572)+"ge"]);continue;case"2":if(!this[n(604)])return;continue;case"3":this[n(604)][n(1603)+n(400)](e[n(695)],this[n(1933)]);continue;case"4":this[n(604)]["addEvent"+n(400)](e.NZgYO,this[n(1249)]);continue}break}}[t(1346)+t(899)](n=1e3,s=""){let d=t;try{this._ws&&this._ws[d(1573)](n,s)}catch{}}["_destroy"+t(1790)+"t"](n=1e3,s="",d=!1){let l=t,h={lPqoc:e[l(667)],hdIlo:e[l(937)],RsEry:e[l(1777)],GOJpk:function(g,w){return g&w},BuFiy:function(g,w){return e.fWGjy(g,w)},oXwZd:function(g,w){return e[l(722)](g,w)},GgHXx:function(g,w){return e[l(1970)](g,w)},wKOmm:function(g,w){return g&w},TSELy:function(g,w){return e[l(793)](g,w)},KNkyU:function(g,w){return g>>>w}};if(e.BGtrM===e[l(430)]){let{offset:g}=e[l(1793)](_0x2fd8db,_0x1a4faf,_0x3c108c);_0x1cd226=g;let w={cursor_name:"",cursor:0,service:0},{value:m,offset:A}=_0x4242be(_0x5abb1b,_0x1e12ec);w.service=m,_0x4b45eb=A;let{value:N,offset:L}=_0x10c424(_0x3b521f,_0x220873);_0xb3a0d5=L,w[l(1536)+l(1283)]=e[l(1617)](_0x264ab0,_0x137ffc,_0x386a60,e[l(1895)](_0x40549f,N)),_0x19bde3+=N;let{value:q,offset:W}=e[l(1454)](_0x1fb0a3,_0x1cd9dc,_0x1e4eae);w[l(677)]=q[l(1467)](),_0x3c3835=W,_0x1d0621[l(883)](w)}else{if(this[l(1493)+l(1926)](),this[l(1340)+"mer"](),this[l(697)+l(948)+"rs"](),this[l(1346)+l(899)](1e3,s),this[l(442)+l(942)]=!1,d&&this[l(2004)+l(1834)]()&&!this[l(432)+l(1515)]){if(this[l(1784)+l(1008)]?.[l(735)+l(1995)+"es"]())if(e[l(1619)](e[l(1600)],e[l(1236)])){let w=this["_endpoin"+l(1008)]?.[l(605)+l(980)+"nt"]();this["_dispatchCloseEv"+l(836)](e[l(705)](xt,l(1573),{code:1006,reason:l(1468)+w+(l(1172)+l(1558)+l(1830)+l(938)),wasClean:!0}))}else!_0x185b93[l(668)+"d"]&&(this[l(1632)+"er"]&&_0x17208f["removeEv"+l(380)+l(1432)](BbMyMl[l(583)],this[l(1397)+l(1591)]),this._isBrowser&&_0x5532d6["removeEv"+l(380)+l(1432)](BbMyMl[l(692)],this[l(1397)+"ageShow"]),this.close()),this[l(1632)+"er"]&&_0x372623[l(794)+"entListe"+l(1432)](BbMyMl[l(798)],this[l(1509)+l(754)]),this[l(1632)+"er"]&&_0x4bf7b9[l(794)+l(380)+l(1432)]("offline",this["_handleO"+l(530)]);else{if(e[l(822)](l(1191),l(789)))return _0x1ba0b5["fromChar"+l(447)](BbMyMl[l(1109)](255,this[l(542)]),this.low>>>8&255,BbMyMl[l(863)](BbMyMl[l(1620)](this.low,16),255),BbMyMl[l(1620)](this.low,24),BbMyMl[l(1190)](255,this.high),BbMyMl[l(787)](BbMyMl[l(862)](this[l(906)],8),255),BbMyMl[l(1190)](BbMyMl[l(1620)](this[l(906)],16),255),BbMyMl.KNkyU(this.high,24));{let w=this[l(1184)]["reconnec"+l(1601)+l(1163)](n,s);this[l(1063)+"hCloseEv"+l(836)](e[l(727)](xt,e.sgNHw,{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this[l(442)]()}}return}this[l(2004)+l(1834)]()||this._readyClosed?this[l(1063)+l(1352)+l(836)](e.JiXnK(xt,l(1573),{code:n,reason:"bye"})):this[l(1063)+"hCloseEvent"](xt(l(1573),{code:1006,reason:e[l(1639)]})),this[l(604)]=null,this._endpointManager?.[l(1470)+l(586)+l(817)](),this["_pingLos"+l(1874)]?.[l(736)+"nter"]()}}_dispatchOpenEvent(n){let s=t;this[s(559)](s(970),n),this[s(438)]&&this[s(438)](n)}[t(1063)+t(660)+t(1398)](n){let s=t;this[s(559)](e.dVQLi,n),this.onmessage&&this[s(413)+"e"](n)}["_dispatc"+t(1686)+t(1250)](n){let s=t,d={YjchE:function(l,h){return l|h},yZnWH:function(l,h){return e[U(1672)](l,h)},UMsNq:function(l,h){return e[U(728)](l,h)},DMRLw:function(l,h){return e[U(711)](l,h)},KRika:function(l,h){return e.aQMFC(l,h)}};e[s(1738)]!==e.woRLl?(this[s(559)](e[s(1872)],n),this[s(1117)+s(389)]&&this[s(1117)+s(389)](n)):(_0x17c373[_0x2b6fba++]=uotxRY[s(1269)](uotxRY[s(466)](_0xd795d7,12),224),_0x1c5952[_0x4ffd91++]=uotxRY[s(1719)](uotxRY.DMRLw(_0x27824f>>6,63),128),_0x1da159[_0x4d4c16++]=uotxRY[s(1719)](uotxRY.KRika(63,_0x445db2),128))}[t(1063)+t(603)+t(836)](n){let s=t;this[s(559)](e[s(1785)],n),this.onerror&&this[s(1855)](n)}["_dispatc"+t(1352)+t(836)](n){let s=t;this.emit("close",n),this[s(1021)]&&this[s(1021)](n)}get binaryType(){let n=t;return this._ws?this[n(604)][n(1870)+"pe"]:this[n(1864)+"ype"]}set[t(1870)+"pe"](n){let s=t;this[s(1864)+s(1309)]=n,this[s(604)]&&(this._ws[s(1870)+"pe"]=n)}get[t(1994)+"nt"](){let n=t;return this[n(1784)+"tManager"]?.[n(605)+n(980)+n(1774)+n(726)]()||0}get[t(545)+t(824)](){let n=t;return this[n(1271)+n(1206)][n(1217)]((d,l)=>(d+=l&&l[n(701)+"th"]||0,d),0)+(this[n(604)]?this[n(604)]["buffered"+n(824)]:0)}get[t(522)+"ns"](){let n=t;return this._ws?this[n(604)][n(522)+"ns"]:""}get[t(521)](){let n=t;return this[n(604)]?this[n(604)][n(521)]:""}get[t(1015)+"te"](){let n=t;return this[n(604)]?this[n(604)][n(1015)+"te"]:this[n(1184)][n(856)+"cOpen"]?this[n(1930)+"NG"]:this.CLOSED}get url(){let n=t;return this[n(604)]?this[n(604)][n(1188)]:this._url}[t(1573)](n=1e3,s){let d=t;if(this[d(432)+d(1515)]=!0,this._clearTimer(),this["_clearPi"+d(1926)](),this[d(1129)+d(1348)+d(400)](),this["_QoSMana"+d(1497)]?.[d(1799)](),!this[d(604)])return void this[d(733)](d(1900)+d(783)+d(1849)+d(1214)+"ed");if(e.qVnKl(this[d(604)][d(1015)+"te"],this[d(486)])||this._ws[d(1015)+"te"]===this.CLOSING)return void this._debug(e[d(1351)]);this._destroyWebSocket(n,s)}async[t(1627)](n,s){let d=t;if(e[d(1827)](null,n))throw new Error(e[d(939)]);e[d(1901)](e[d(1152)],typeof n)&&(n=JSON[d(972)+"y"](n)),e[d(1201)](e[d(1574)],typeof n)&&!e[d(1145)](n,ArrayBuffer)&&!(n[d(1293)]&&e[d(1483)](n[d(1293)],ArrayBuffer))&&(n=JSON[d(972)+"y"](n));let l=await e[d(1592)](e0,n),h=e[d(851)](tp,n),{method:g=0,service:w=this[d(1184)][d(1797)],logID:m=this._options[d(1950)+d(1546)](),headers:A=this._options[d(1813)],payloadEncoding:N=this[d(1184)][d(444)+"ncoding"],payloadType:L=this._options["payloadT"+d(1309)],logIDNew:q=this[d(1184)][d(1072)+d(624)].enableAutoGenerateLogIDNew?e[d(1287)](i,this[d(1184)][d(1072)+d(624)].userIp):""}=e[d(405)](s,{});if(!w)throw new Error("please provide a"+d(1319)+d(1807));let W={SeqID:ce.fromNumber(this[d(998)]++),LogID:ce[d(1386)+"er"](m),service:w,method:g,headers:A,payloadEncoding:e[d(1576)](N,Object)?N[d(1173)]?N[d(1173)]:"":N,payloadType:e.YnqOL(L,Object)?L[d(1532)]?L[d(1532)]:h:L||h,payload:l,LogIDNew:q},Y=e[d(1646)](Bt,W);return this[d(604)]&&e[d(1940)](this[d(604)][d(1015)+"te"],this[d(386)])?(this._ws&&this[d(604)][d(1627)](Y),this[d(733)](e[d(1518)],W)):e[d(654)](this[d(1271)+d(1206)][d(1775)],this[d(1184)]["maxMessa"+d(1649)+d(949)])?(this[d(1271)+d(1206)][d(883)](Y),this._debug(e[d(873)],W)):(this[d(1271)+d(1206)][d(1434)](),this["_message"+d(1206)].push(Y)),{seqID:this[d(998)],logID:m,logIDNew:q}}async reconnect(n){let s=t,{url:d}=e[s(1913)](n,{}),l=Array[s(1234)](d)?d:e[s(1574)]==typeof d?[d]:[];n&&Object[s(1629)](this[s(1184)],n),l&&l[s(1775)]?this["_endpoin"+s(1008)]=new Yd(l,this[s(1184)][s(1919)+"es"]):this[s(1784)+s(1008)]?.[s(1470)+s(586)+s(817)](),this[s(685)+s(1874)]?.[s(736)+s(1608)](this[s(1184)][s(699)+s(1444)]),this[s(432)+"osed"]=!1,this[s(604)]&&e[s(1945)](this[s(604)].readyState,this.CLOSED)?this[s(1464)+"ect"](1e3,s(845)+s(1720)+s(812),!0):e.PdtTj(e[s(1839)],"hcKCr")?(e.RHwuE(_0x84bb9c,this["_connect"+s(1185)+s(506)]),this[s(442)+s(1185)+s(506)]=null):(this[s(985)]=!0,this._connect())}async[t(421)](){let n=t;if(e.wXlbR("QbWPD",e[n(646)])){if(!this[n(442)+n(942)])if(e[n(1194)](e[n(1047)],e[n(1047)])){let s=e.wjnwZ[n(657)]("|"),d=0;for(;;){switch(s[d++]){case"0":this._isInit=!0;continue;case"1":this._connect();continue;case"2":this["_pingLos"+n(1874)]?.["resetCou"+n(1608)]();continue;case"3":this[n(1784)+n(1008)]?.[n(1470)+n(586)+n(817)]();continue;case"4":this[n(432)+n(1515)]=!1;continue}break}}else{let d=""+_0x3ddd0f.now(),l=_0x5163a3||(_0xea8572=e[n(1375)](_0x65a5c9,_0x48b318)),h=_0x2a7a78[n(434)]().toString(16)[n(1274)](-6);return e[n(896)](e[n(1151)](e.SdyuN("02",d),l),h)}}else{let s=_0x5bf1b2(_0x271f71,_0x51048f[n(1775)]);_0x28d031[n(740)][n(1906)](_0x32f569,s)}}[t(1603)+"Listener"](n,s){let d=t;d(1413)===e.JtQqE?this.on(n,s):this[d(559)](e.NZgYO,e[d(766)](_0x1cf1b5,d(503),{message:this[d(828)+d(676)+d(1530)](_0x59f9a8)}))}[t(532)+t(1398)](n){let{type:s}=n;this.emit(s,n)}[t(794)+t(380)+t(1432)](n,s){let d=t,l={jTUlU:function(h,g){return h|g},kaWZj:function(h,g){return e[U(1781)](h,g)},NIAMg:function(h,g){return h<<g},vQnRF:function(h,g){return e[U(694)](h,g)},RzfgG:function(h,g){return e[U(1338)](h,g)},NHoiQ:function(h,g){return e[U(396)](h,g)},qWype:function(h,g){return e[U(1660)](h,g)},dXkLw:function(h,g){return h<<g},ZoMFv:function(h,g){return e[U(1877)](h,g)}};if(e[d(1494)]!==e[d(1494)]){let h=new _0xaf657d(EgsjdS.jTUlU(EgsjdS[d(673)](_0x5e99d4[EgsjdS.kaWZj(_0x577090,4)]<<24|EgsjdS.NIAMg(_0x2a18bf[EgsjdS.kaWZj(_0x27571b,5)],16),EgsjdS[d(602)](_0x564f91[EgsjdS[d(402)](_0x94c73,6)],8)),_0x2af782[EgsjdS.RzfgG(_0x243218,7)]),EgsjdS[d(2001)](EgsjdS[d(673)](EgsjdS.NHoiQ(EgsjdS[d(1158)](_0xc8230f[_0x4a0b62+0],24),_0x17c943[EgsjdS.RzfgG(_0x2bc92a,1)]<<16),EgsjdS.dXkLw(_0x261d61[EgsjdS[d(418)](_0x1a9d09,2)],8)),_0x482c81[EgsjdS[d(1064)](_0x3bb229,3)]),!0);return _0x11f2bc+=8,{value:h,offset:_0x17e95a+8}}else this[d(1276)](n,s)}[t(994)](){let n=t,s={laRob:function(d,l){return e[U(1265)](d,l)},HJtuk:e[n(1924)],thOcM:n(1755)+n(1393)+"t",BBgpD:function(d,l,h){return e.EUbFV(d,l,h)},LMrGy:e[n(1785)],tvZUi:e[n(910)],skUaw:n(1755)+n(1636)+"s"};return new Promise((d,l)=>{let h=n,g={XhWAn:function(A,N,L){return s[U(1806)](A,N,L)},KHEJJ:s[h(1463)],QaaSV:"close",CkoZk:function(A,N){return A!==N},baJuB:s[h(1578)],xVemw:function(A,N){return A(N)},dDIJz:h(1246),VSZMA:s.skUaw,ooYPK:s[h(1096)]};this[h(1493)+"ngTimer"](),this[h(1565)+h(490)+"Id"]=setTimeout(this[h(1690)][h(412)](this),this[h(1184)][h(609)+"rval"]);let w=()=>{let A=h;s[A(1824)](d,s.HJtuk),this[A(1276)]("ping_onc"+A(1636)+"s",w),this[A(1276)](s.thOcM,m)},m=()=>{let A=h,N={AVlzI:function(L,q,W){return g[U(428)](L,q,W)},XatMB:g.KHEJJ,BohGl:g[A(1195)]};g.CkoZk(g[A(1442)],A(519))?_0x2a538f[A(1391)]()[A(1822)](()=>{let L=A,q=doLmZj[L(591)](_0x37d356,doLmZj[L(581)],{message:this[L(828)+"rrorMess"+L(1530)](_0x48ebbb)});this[L(559)](L(503),q);let W=_0x50d354(doLmZj[L(648)],{reason:this[L(828)+L(676)+L(1530)](_0xd75af4)});this[L(559)](L(1573),W)}):(g.xVemw(l,g.dDIJz),this[A(1276)](g[A(1263)],w),this[A(1276)](g[A(414)],m))};this.on(s[h(459)],w),this.on(s[h(1096)],m),this._ping()})}}})(),Me[M(1330)+M(474)]=De[M(1330)+"oseEvent"],Me[M(782)+"rorEvent"]=De["CustomEr"+M(1399)],Me.ErrorCode=De[M(628)+"e"],Me[M(1398)]=De[M(1398)],Me.FWS=De[M(632)],Me[M(1182)+M(1369)+M(742)]=De[M(1182)+M(1369)+M(742)],Me[M(1369)+M(742)]=De[M(1369)+M(742)],Me.OpenEvent=De[M(913)+"t"],Me[M(1242)+"tEvent"]=De[M(1242)+M(1411)],Me[M(912)+M(474)]=De[M(912)+M(474)],Me["createEr"+M(1399)]=De[M(927)+"rorEvent"],Me[M(659)+"ssageEvent"]=De["createMe"+M(1599)+"nt"],Me[M(387)+M(834)]=De["createOp"+M(834)],Me[M(1268)+M(1371)+M(742)]=De["createRe"+M(1371)+"vent"],Me["decodedF"+M(1939)]=De[M(1959)+M(1939)],Me.encodeFrame=De[M(483)+M(1283)];for(Eo in De)[M(1330)+M(474),"CustomEr"+M(1399),M(628)+"e",M(1398),M(632),M(1182)+M(1369)+M(742),M(1369)+M(742),M(913)+"t",M(1242)+M(1411),M(912)+M(474),M(927)+M(1399),M(659)+M(1599)+"nt",M(387)+M(834),M(1268)+M(1371)+"vent",M(1959)+M(1939),"encodeFrame"][M(992)](Eo)===-1&&(Me[Eo]=De[Eo]);var Eo;Object["definePr"+M(1876)](Me,"__esModule",{value:!0})});var Wt=se((JC,tx)=>{"use strict";var Qf=["nodebuffer","arraybuffer","fragments"],ex=typeof Blob<"u";ex&&Qf.push("blob");tx.exports={BINARY_TYPES:Qf,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ex,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Hi=se((YC,Do)=>{"use strict";var{EMPTY_BUFFER:jb}=Wt(),od=Buffer[Symbol.species];function Gb(t,e){if(t.length===0)return jb;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 od(r.buffer,r.byteOffset,i):r}function nx(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function rx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Kb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ad(t){if(ad.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new od(t):ArrayBuffer.isView(t)?e=new od(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ad.readOnly=!1),e}Do.exports={concat:Gb,mask:nx,toArrayBuffer:Kb,toBuffer:ad,unmask:rx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");Do.exports.mask=function(e,r,i,o,c){c<48?nx(e,r,i,o,c):t.mask(e,r,i,o,c)},Do.exports.unmask=function(e,r){e.length<32?rx(e,r):t.unmask(e,r)}}catch{}});var ox=se((ZC,sx)=>{"use strict";var ix=Symbol("kDone"),cd=Symbol("kRun"),dd=class{constructor(e){this[ix]=()=>{this.pending--,this[cd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[cd]()}[cd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ix])}}};sx.exports=dd});var Or=se((XC,ux)=>{"use strict";var qi=ue("zlib"),ax=Hi(),Wb=ox(),{kStatusCode:cx}=Wt(),$b=Buffer[Symbol.species],Vb=Buffer.from([0,0,255,255]),ko=Symbol("permessage-deflate"),$t=Symbol("total-length"),Rr=Symbol("callback"),bn=Symbol("buffers"),kr=Symbol("error"),Ro,ud=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Ro){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ro=new Wb(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Rr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Ro.add(o=>{this._decompress(e,r,(c,u)=>{o(),i(c,u)})})}compress(e,r,i){Ro.add(o=>{this._compress(e,r,(c,u)=>{o(),i(c,u)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,u=typeof this.params[c]!="number"?qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=qi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[ko]=this,this._inflate[$t]=0,this._inflate[bn]=[],this._inflate.on("error",Yb),this._inflate.on("data",dx)}this._inflate[Rr]=i,this._inflate.write(e),r&&this._inflate.write(Vb),this._inflate.flush(()=>{let c=this._inflate[kr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let u=ax.concat(this._inflate[bn],this._inflate[$t]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$t]=0,this._inflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,u)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,u=typeof this.params[c]!="number"?qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=qi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[$t]=0,this._deflate[bn]=[],this._deflate.on("data",Jb)}this._deflate[Rr]=i,this._deflate.write(e),this._deflate.flush(qi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=ax.concat(this._deflate[bn],this._deflate[$t]);r&&(c=new $b(c.buffer,c.byteOffset,c.length-4)),this._deflate[Rr]=null,this._deflate[$t]=0,this._deflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};ux.exports=ud;function Jb(t){this[bn].push(t),this[$t]+=t.length}function dx(t){if(this[$t]+=t.length,this[ko]._maxPayload<1||this[$t]<=this[ko]._maxPayload){this[bn].push(t);return}this[kr]=new RangeError("Max payload size exceeded"),this[kr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[kr][cx]=1009,this.removeListener("data",dx),this.reset()}function Yb(t){if(this[ko]._inflate=null,this[kr]){this[Rr](this[kr]);return}t[cx]=1007,this[Rr](t)}});var Nr=se((QC,Oo)=>{"use strict";var{isUtf8:lx}=ue("buffer"),{hasBlob:Zb}=Wt(),Xb=[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 Qb(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ld(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function eE(t){return Zb&&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:eE,isValidStatusCode:Qb,isValidUTF8:ld,tokenChars:Xb};if(lx)Oo.exports.isValidUTF8=function(t){return t.length<24?ld(t):lx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");Oo.exports.isValidUTF8=function(e){return e.length<32?ld(e):t(e)}}catch{}});var gd=se((eD,_x)=>{"use strict";var{Writable:tE}=ue("stream"),fx=Or(),{BINARY_TYPES:nE,EMPTY_BUFFER:xx,kStatusCode:rE,kWebSocket:iE}=Wt(),{concat:fd,toArrayBuffer:sE,unmask:oE}=Hi(),{isValidStatusCode:aE,isValidUTF8:hx}=Nr(),No=Buffer[Symbol.species],ut=0,px=1,gx=2,mx=3,xd=4,hd=5,Po=6,pd=class extends tE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||nE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[iE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ut}_write(e,r,i){if(this._opcode===8&&this._state==ut)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new No(i.buffer,i.byteOffset+e,i.length-e),new No(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 No(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case ut:this.getInfo(e);break;case px:this.getPayloadLength16(e);break;case gx:this.getPayloadLength64(e);break;case mx:this.getMask();break;case xd:this.getData(e);break;case hd:case Po: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[fx.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=px:this._payloadLength===127?this._state=gx: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=mx:this._state=xd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=xd}getData(e){let r=xx;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=hd,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[fx.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 u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(u);return}this._fragments.push(c)}this.dataMessage(r),this._state===ut&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ut;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=fd(i,r):this._binaryType==="arraybuffer"?o=sE(fd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ut):(this._state=Po,setImmediate(()=>{this.emit("message",o,!0),this._state=ut,this.startLoop(e)}))}else{let o=fd(i,r);if(!this._skipUTF8Validation&&!hx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===hd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ut):(this._state=Po,setImmediate(()=>{this.emit("message",o,!1),this._state=ut,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,xx),this.end();else{let i=e.readUInt16BE(0);if(!aE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new No(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!hx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=ut;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ut):(this._state=Po,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ut,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let u=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(u,this.createError),u.code=c,u[rE]=o,u}};_x.exports=pd});var _d=se((nD,Ex)=>{"use strict";var{Duplex:tD}=ue("stream"),{randomFillSync:cE}=ue("crypto"),yx=Or(),{EMPTY_BUFFER:dE,kWebSocket:uE,NOOP:lE}=Wt(),{isBlob:Pr,isValidStatusCode:fE}=Nr(),{mask:bx,toBuffer:Hn}=Hi(),lt=Symbol("kByteLength"),xE=Buffer.alloc(4),Lo=8*1024,qn,Lr=Lo,Et=0,hE=1,pE=2,md=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Et,this.onerror=lE,this[uE]=void 0}static frame(e,r){let i,o=!1,c=2,u=!1;r.mask&&(i=r.maskBuffer||xE,r.generateMask?r.generateMask(i):(Lr===Lo&&(qn===void 0&&(qn=Buffer.alloc(Lo)),cE(qn,0,Lo),Lr=0),i[0]=qn[Lr++],i[1]=qn[Lr++],i[2]=qn[Lr++],i[3]=qn[Lr++]),u=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||u)&&r[lt]!==void 0?f=r[lt]:(e=Buffer.from(e),f=e.length):(f=e.length,o=r.mask&&r.readOnly&&!u);let x=f;f>=65536?(c+=8,x=127):f>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(o?f+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(f,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],u?[p,e]:o?(bx(e,i,p,c,f),[p]):(bx(e,i,e,0,f),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=dE;else{if(typeof e!="number"||!fE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+f),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let u={[lt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Et?this.enqueue([this.dispatch,c,!1,u,o]):this.sendFrame(t.frame(c,u),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,u,i]):this.getBlobData(e,!1,u,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,u,i]):this.sendFrame(t.frame(e,u),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,u,i]):this.getBlobData(e,!1,u,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,u,i]):this.sendFrame(t.frame(e,u),i)}send(e,r,i){let o=this._extensions[yx.extensionName],c=r.binary?2:1,u=r.compress,f,x;typeof e=="string"?(f=Buffer.byteLength(e),x=!1):Pr(e)?(f=e.size,x=!1):(e=Hn(e),f=e.length,x=Hn.readOnly),this._firstFragment?(this._firstFragment=!1,u&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=o._threshold),this._compress=u):(u=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[lt]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:u};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==Et?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[lt],this._state=pE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(wd,this,f,o);return}this._bufferedBytes-=i[lt];let u=Hn(c);r?this.dispatch(u,r,i,o):(this._state=Et,this.sendFrame(t.frame(u,i),o),this.dequeue())}).catch(c=>{process.nextTick(gE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[yx.extensionName];this._bufferedBytes+=i[lt],this._state=hE,c.compress(e,i.fin,(u,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");wd(this,x,o);return}this._bufferedBytes-=i[lt],this._state=Et,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===Et&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][lt],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Ex.exports=md;function wd(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 gE(t,e,r){wd(t,e,r),t.onerror(e)}});var kx=se((rD,Rx)=>{"use strict";var{kForOnEventAttribute:ji,kListener:yd}=Wt(),vx=Symbol("kCode"),Sx=Symbol("kData"),Ix=Symbol("kError"),Ax=Symbol("kMessage"),Tx=Symbol("kReason"),Mr=Symbol("kTarget"),Cx=Symbol("kType"),Dx=Symbol("kWasClean"),Vt=class{constructor(e){this[Mr]=null,this[Cx]=e}get target(){return this[Mr]}get type(){return this[Cx]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var jn=class extends Vt{constructor(e,r={}){super(e),this[vx]=r.code===void 0?0:r.code,this[Tx]=r.reason===void 0?"":r.reason,this[Dx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[vx]}get reason(){return this[Tx]}get wasClean(){return this[Dx]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Br=class extends Vt{constructor(e,r={}){super(e),this[Ix]=r.error===void 0?null:r.error,this[Ax]=r.message===void 0?"":r.message}get error(){return this[Ix]}get message(){return this[Ax]}};Object.defineProperty(Br.prototype,"error",{enumerable:!0});Object.defineProperty(Br.prototype,"message",{enumerable:!0});var Gi=class extends Vt{constructor(e,r={}){super(e),this[Sx]=r.data===void 0?null:r.data}get data(){return this[Sx]}};Object.defineProperty(Gi.prototype,"data",{enumerable:!0});var mE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[ji]&&o[yd]===e&&!o[ji])return;let i;if(t==="message")i=function(c,u){let f=new Gi("message",{data:u?c:c.toString()});f[Mr]=this,Mo(e,this,f)};else if(t==="close")i=function(c,u){let f=new jn("close",{code:c,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Mr]=this,Mo(e,this,f)};else if(t==="error")i=function(c){let u=new Br("error",{error:c,message:c.message});u[Mr]=this,Mo(e,this,u)};else if(t==="open")i=function(){let c=new Vt("open");c[Mr]=this,Mo(e,this,c)};else return;i[ji]=!!r[ji],i[yd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[yd]===e&&!r[ji]){this.removeListener(t,r);break}}};Rx.exports={CloseEvent:jn,ErrorEvent:Br,Event:Vt,EventTarget:mE,MessageEvent:Gi};function Mo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Bo=se((iD,Ox)=>{"use strict";var{tokenChars:Ki}=Nr();function Mt(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,u,f,x=-1,p=-1,b=-1,E=0;for(;E<t.length;E++)if(p=t.charCodeAt(E),u===void 0)if(b===-1&&Ki[p]===1)x===-1&&(x=E);else if(E!==0&&(p===32||p===9))b===-1&&x!==-1&&(b=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);b===-1&&(b=E);let y=t.slice(x,b);p===44?(Mt(e,y,r),r=Object.create(null)):u=y,x=b=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(f===void 0)if(b===-1&&Ki[p]===1)x===-1&&(x=E);else if(p===32||p===9)b===-1&&x!==-1&&(b=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);b===-1&&(b=E),Mt(r,t.slice(x,b),!0),p===44&&(Mt(e,u,r),r=Object.create(null),u=void 0),x=b=-1}else if(p===61&&x!==-1&&b===-1)f=t.slice(x,E),x=b=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(Ki[p]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:i||(i=!0),o=!1}else if(c)if(Ki[p]===1)x===-1&&(x=E);else if(p===34&&x!==-1)c=!1,b=E;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(p===34&&t.charCodeAt(E-1)===61)c=!0;else if(b===-1&&Ki[p]===1)x===-1&&(x=E);else if(x!==-1&&(p===32||p===9))b===-1&&(b=E);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);b===-1&&(b=E);let y=t.slice(x,b);i&&(y=y.replace(/\\/g,""),i=!1),Mt(r,f,y),p===44&&(Mt(e,u,r),r=Object.create(null),u=void 0),f=void 0,x=b=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");b===-1&&(b=E);let T=t.slice(x,b);return u===void 0?Mt(e,T,r):(f===void 0?Mt(r,T,!0):i?Mt(r,f,T.replace(/\\/g,"")):Mt(r,f,T),Mt(e,u,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(u=>u===!0?o:`${o}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ox.exports={format:_E,parse:wE}});var Ho=se((aD,Gx)=>{"use strict";var yE=ue("events"),bE=ue("https"),EE=ue("http"),Lx=ue("net"),vE=ue("tls"),{randomBytes:SE,createHash:IE}=ue("crypto"),{Duplex:sD,Readable:oD}=ue("stream"),{URL:bd}=ue("url"),En=Or(),AE=gd(),TE=_d(),{isBlob:CE}=Nr(),{BINARY_TYPES:Nx,CLOSE_TIMEOUT:DE,EMPTY_BUFFER:Fo,GUID:RE,kForOnEventAttribute:Ed,kListener:kE,kStatusCode:OE,kWebSocket:He,NOOP:Mx}=Wt(),{EventTarget:{addEventListener:NE,removeEventListener:PE}}=kx(),{format:LE,parse:ME}=Bo(),{toBuffer:BE}=Hi(),Bx=Symbol("kAborted"),vd=[8,13],Jt=["CONNECTING","OPEN","CLOSING","CLOSED"],FE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,me=class t extends yE{constructor(e,r,i){super(),this._binaryType=Nx[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]),Fx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Nx.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 AE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new TE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[He]=this,c[He]=this,e[He]=this,o.on("conclude",HE),o.on("drain",qE),o.on("error",jE),o.on("message",GE),o.on("ping",KE),o.on("pong",WE),c.onerror=$E,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Hx),e.on("data",Uo),e.on("end",qx),e.on("error",jx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[En.extensionName]&&this._extensions[En.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ux(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){Sd(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){Sd(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){Sd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[En.extensionName]||(o.compress=!1),this._sender.send(e||Fo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(me,"CONNECTING",{enumerable:!0,value:Jt.indexOf("CONNECTING")});Object.defineProperty(me.prototype,"CONNECTING",{enumerable:!0,value:Jt.indexOf("CONNECTING")});Object.defineProperty(me,"OPEN",{enumerable:!0,value:Jt.indexOf("OPEN")});Object.defineProperty(me.prototype,"OPEN",{enumerable:!0,value:Jt.indexOf("OPEN")});Object.defineProperty(me,"CLOSING",{enumerable:!0,value:Jt.indexOf("CLOSING")});Object.defineProperty(me.prototype,"CLOSING",{enumerable:!0,value:Jt.indexOf("CLOSING")});Object.defineProperty(me,"CLOSED",{enumerable:!0,value:Jt.indexOf("CLOSED")});Object.defineProperty(me.prototype,"CLOSED",{enumerable:!0,value:Jt.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[Ed])return e[kE];return null},set(e){for(let r of this.listeners(t))if(r[Ed]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ed]:!0})}})});me.prototype.addEventListener=NE;me.prototype.removeEventListener=PE;Gx.exports=me;function Fx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:DE,protocolVersion:vd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!vd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${vd.join(", ")})`);let c;if(e instanceof bd)c=e;else try{c=new bd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let u=c.protocol==="wss:",f=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!u&&!f?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;zo(t,I);return}let p=u?443:80,b=SE(16).toString("base64"),E=u?bE.request:EE.request,T=new Set,y;if(o.createConnection=o.createConnection||(u?UE:zE),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":b,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new En({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=LE({[En.extensionName]:y.offer()})),r.length){for(let I of r){if(typeof I!="string"||!FE.test(I)||T.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),f){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=u,t._originalHostOrSocketPath=f?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,D]of Object.entries(I))i.headers[S.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let I=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!u)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{st(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Bx]||(v=t._req=null,zo(t,I))}),v.on("response",I=>{let S=I.headers.location,D=I.statusCode;if(S&&o.followRedirects&&D>=300&&D<400){if(++t._redirects>o.maxRedirects){st(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new bd(S,e)}catch{let R=new SyntaxError(`Invalid URL: ${S}`);zo(t,R);return}Fx(t,P,r,i)}else t.emit("unexpected-response",v,I)||st(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,D)=>{if(t.emit("upgrade",I),t.readyState!==me.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){st(t,S,"Invalid Upgrade header");return}let _=IE("sha1").update(b+RE).digest("base64");if(I.headers["sec-websocket-accept"]!==_){st(t,S,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],k;if(R!==void 0?T.size?T.has(R)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":T.size&&(k="Server sent no subprotocol"),k){st(t,S,k);return}R&&(t._protocol=R);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!y){st(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=ME(B)}catch{st(t,S,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(F);if(V.length!==1||V[0]!==En.extensionName){st(t,S,"Server indicated an extension that was not requested");return}try{y.accept(F[En.extensionName])}catch{st(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[En.extensionName]=y}t.setSocket(S,D,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function zo(t,e){t._readyState=me.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function zE(t){return t.path=t.socketPath,Lx.connect(t)}function UE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Lx.isIP(t.host)?"":t.host),vE.connect(t)}function st(t,e,r){t._readyState=me.CLOSING;let i=new Error(r);Error.captureStackTrace(i,st),e.setHeader?(e[Bx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(zo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Sd(t,e,r){if(e){let i=CE(e)?e.size:BE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Jt[t.readyState]})`);process.nextTick(r,i)}}function HE(t,e){let r=this[He];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[He]!==void 0&&(r._socket.removeListener("data",Uo),process.nextTick(zx,r._socket),t===1005?r.close():r.close(t,e))}function qE(){let t=this[He];t.isPaused||t._socket.resume()}function jE(t){let e=this[He];e._socket[He]!==void 0&&(e._socket.removeListener("data",Uo),process.nextTick(zx,e._socket),e.close(t[OE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Px(){this[He].emitClose()}function GE(t,e){this[He].emit("message",t,e)}function KE(t){let e=this[He];e._autoPong&&e.pong(t,!this._isServer,Mx),e.emit("ping",t)}function WE(t){this[He].emit("pong",t)}function zx(t){t.resume()}function $E(t){let e=this[He];e.readyState!==me.CLOSED&&(e.readyState===me.OPEN&&(e._readyState=me.CLOSING,Ux(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ux(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Hx(){let t=this[He];if(this.removeListener("close",Hx),this.removeListener("data",Uo),this.removeListener("end",qx),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[He]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Px),t._receiver.on("finish",Px))}function Uo(t){this[He]._receiver.write(t)||this.pause()}function qx(){let t=this[He];t._readyState=me.CLOSING,t._receiver.end(),this.end()}function jx(){let t=this[He];this.removeListener("error",jx),this.on("error",Mx),t&&(t._readyState=me.CLOSING,this.destroy())}});var Vx=se((dD,$x)=>{"use strict";var cD=Ho(),{Duplex:VE}=ue("stream");function Kx(t){t.emit("close")}function JE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Wx(t){this.removeListener("error",Wx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function YE(t,e){let r=!0,i=new VE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,u){let f=!u&&i._readableState.objectMode?c.toString():c;i.push(f)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Kx,i);return}let u=!1;t.once("error",function(x){u=!0,c(x)}),t.once("close",function(){u||c(o),process.nextTick(Kx,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,u){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,u)});return}t.send(o,u)},i.on("end",JE),i.on("error",Wx),i}$x.exports=YE});var Id=se((uD,Jx)=>{"use strict";var{tokenChars:ZE}=Nr();function XE(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let u=t.charCodeAt(o);if(i===-1&&ZE[u]===1)r===-1&&(r=o);else if(o!==0&&(u===32||u===9))i===-1&&r!==-1&&(i=o);else if(u===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let f=t.slice(r,i);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Jx.exports={parse:XE}});var nh=se((fD,th)=>{"use strict";var QE=ue("events"),qo=ue("http"),{Duplex:lD}=ue("stream"),{createHash:ev}=ue("crypto"),Yx=Bo(),Gn=Or(),tv=Id(),nv=Ho(),{CLOSE_TIMEOUT:rv,GUID:iv,kWebSocket:sv}=Wt(),ov=/^[+/0-9A-Za-z]{22}==$/,Zx=0,Xx=1,eh=2,Ad=class extends QE{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:rv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:nv,...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=av(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,u)=>{this.handleUpgrade(o,c,u,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Zx}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===eh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Wi,this);return}if(e&&this.once("close",e),this._state!==Xx)if(this._state=Xx,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(Wi,this):process.nextTick(Wi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Wi(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",Qx);let c=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!ov.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){$i(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=tv.parse(x)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let b=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&b!==void 0){let T=new Gn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Yx.parse(b);y[Gn.extensionName]&&(T.accept(y[Gn.extensionName]),E[Gn.extensionName]=T)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let T={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(T,(y,v,I,S)=>{if(!y)return $i(r,v||401,I,S);this.completeUpgrade(E,c,p,e,r,i,o)});return}if(!this.options.verifyClient(T))return $i(r,401)}this.completeUpgrade(E,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,u,f){if(!c.readable||!c.writable)return c.destroy();if(c[sv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Zx)return $i(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ev("sha1").update(r+iv).digest("base64")}`],b=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(p.push(`Sec-WebSocket-Protocol: ${E}`),b._protocol=E)}if(e[Gn.extensionName]){let E=e[Gn.extensionName].params,T=Yx.format({[Gn.extensionName]:[E]});p.push(`Sec-WebSocket-Extensions: ${T}`),b._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&is(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 Xp,mkdirSync as Qp}from"node:fs";import{join as eg}from"node:path";function cl(t){let e=t.retentionDays??rg,r=t.clock??(()=>In(new Date));os={bridgeSink:new Vr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Vr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();is(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])is(t.agentLogsDir(o),"agent",i,e)}function ig(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function dl(t){Sa=t}function ll(t){return Qn[Sa]<=Qn[t]}function fl(t,e){let r=Qn[t];return r===void 0?!0:r>=Qn[e]}function as(t){al={...t}}function ul(t){let e=(f,x=2)=>String(f).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${In(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Yr(t,e,r,i,o){try{let c=`${JSON.stringify({ts:ul(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;Qp(t,{recursive:!0}),Xp(eg(t,Xn("bridge",In(new Date))),c)}catch{}}function sg(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function ss(t,e,r,i,o){if(Qn[t]<Qn[Sa])return;let c=`${JSON.stringify({ts:ul(new Date),level:t,module:e,msg:r,...al,...i})}
|
|
12
|
+
`;if(os){let l=sg(o,i),f=l?ig(os,l):os.bridgeSink;try{f.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?ng.write(c):tg.write(c)}function j(t,e){return{debug:(r,i)=>ss("debug",t,r,i,e),info:(r,i)=>ss("info",t,r,i,e),warn:(r,i)=>ss("warn",t,r,i,e),error:(r,i)=>ss("error",t,r,i,e),child:r=>j(`${t}.${r}`,e),forAgent:r=>j(t,r)}}var Qn,Sa,tg,ng,al,rg,os,ne=Ye(()=>{"use strict";$r();va();Qn={debug:10,info:20,warn:30,error:40},Sa=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),tg=process.stdout,ng=process.stderr,al={},rg=Je("COZE_BRIDGE_LOG_RETENTION_DAYS",30),os=null});var T,Ke=Ye(()=>{"use strict";T=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var gl={};ba(gl,{ACP_WRAPPER_NPM_PACKAGES:()=>Zr,_resetAcpInstallerForTests:()=>fg,_setBinaryPathCacheForTests:()=>ug,buildAcpSpawn:()=>Xr,ensureAcpInstalled:()=>er,getAcpBinaryPath:()=>cs,pickWhichLine:()=>Ta,probeAcpVersion:()=>lg,resolveAcpCommand:()=>pl});import{readFileSync as xl}from"node:fs";import{createRequire as og}from"node:module";import{dirname as ag,resolve as cg}from"node:path";function Ta(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 dg(t){let e=hl.resolve(`${t.npmPackage}/package.json`),r=ag(e),i=JSON.parse(xl(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 cg(r,o)}async function er(t,e){let r=Ia[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Jr.get(t);if(i)return i;try{let o=dg(r);return Jr.set(t,o),Aa.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw Aa.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 lg(t){let e=Ia[t];if(e)try{let r=hl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(xl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){Aa.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function cs(t){return Jr.get(t)}function pl(t,e){if(e)return e;let r=cs(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 Xr(t,e,r){if(e)return{command:e,args:[...r]};let i=pl(t);return{command:process.execPath,args:[i,...r]}}function fg(){Jr.clear()}function ug(t,e){Jr.set(t,e)}var Aa,Ia,Zr,hl,Jr,nn=Ye(()=>{"use strict";Ke();ne();Aa=j("agents.acp-installer"),Ia={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Zr=Object.values(Ia).filter(t=>t!==void 0).map(t=>t.npmPackage),hl=og(import.meta.url),Jr=new Map});import{chmod as hg,mkdir as pg,readFile as gg,rename as _l,writeFile as yl}from"node:fs/promises";import{dirname as mg}from"node:path";async function tr(t){try{let e=await gg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nr(t,e,r){await pg(mg(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await yl(o,i,{encoding:"utf8",mode:r.mode}):await yl(o,i,"utf8"),await _l(o,t),r?.mode!==void 0&&await hg(t,r.mode)}catch(c){await _l(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Qr=Ye(()=>{"use strict"});import{promises as bl,readdirSync as wg}from"node:fs";import{homedir as _g}from"node:os";import{sep as yg,join as Ie,resolve as El}from"node:path";function X(t){let e=t??_g(),r=Ie(e,".coze"),i=Ie(r,"bridge"),o=Ie(i,"lib"),c=Ie(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ie(o,"index.js"),binDir:Ie(i,"bin"),pidFile:Ie(i,"bridge.pid"),portFile:Ie(i,"bridge.port"),tokenFile:Ie(i,"bridge.token"),patTokenFile:Ie(i,"pat-token"),agentEnvFile:Ie(i,"agent-env.json"),logFile:Ie(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ie(c,"daemon-stdio.log"),installLock:Ie(i,"install.lock"),configFile:Ie(i,"config.json"),agentsRoot:Ie(r,"agents")}}function Ze(t,e=X()){let r=Ie(e.agentsRoot,t);return{root:r,config:Ie(r,"config.json"),workspace:Ie(r,"workspace"),logs:Ie(r,"logs")}}function ds(t=X()){try{return wg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ei(t,e){let r=await bl.realpath(El(t)).catch(()=>null);if(!r)return!1;let i=await bl.realpath(El(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+yg)}var ke=Ye(()=>{"use strict"});var us={};ba(us,{AGENT_CONFIG_FILE_MODE:()=>ls,enforceAgentConfigMode:()=>vg,loadAgentConfig:()=>He,persistAgentSessions:()=>ti,persistAgentSkills:()=>fs,saveAgentConfig:()=>Xe});import{chmod as bg,stat as Eg}from"node:fs/promises";function He(t,e){return tr(Ze(t,e).config)}function Xe(t,e){return nr(Ze(t.agentId,e).config,t,{mode:ls})}async function vg(t,e){if(process.platform==="win32")return;let r=Ze(t,e).config;try{let i=await Eg(r);if(!i.isFile())return;let o=i.mode&511;o!==ls&&(await bg(r,ls),vl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;vl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ti(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await Xe(i,r))}async function fs(t,e,r){let i=await He(t,r);i&&(i.skills=e,await Xe(i,r))}var vl,ls,rn=Ye(()=>{"use strict";Qr();ne();ke();vl=j("agent-config"),ls=384});var Ra=oe((J1,Tl)=>{Tl.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var hs=oe(Rl=>{var Cl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Cg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Cl))Rl[t]=Cg(Cl[t])});var Nl=oe((X1,Pl)=>{var Rg=le("fs"),Oe=le("path"),Dl=Ra(),Dg=hs(),kg=typeof process=="object"&&process.platform==="win32",kl=t=>typeof t=="object"&&t!==null,Ol=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ee(t){this.sep=Oe.sep,this.fs=Rg,kl(t)&&kl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Pl.exports=Ee;Ee.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(l&&l.isFile())throw Dg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ee.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Oe.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};Ee.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(f,x){if(l&&x.isDirectory())return o(!1);var h=Oe.dirname(t);c.fs.exists(h,function(_){_||c.makeDir(h),c.fs.open(t,"w",438,function(w,S){w?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(b,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(f){let x=Oe.join(i,f),h=e.fs.statSync(x);(!o||o.test(x))&&l.push(Oe.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};Ee.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(f){f=Oe.join(t,f),r.fs.stat(f,function(x,h){if(x)return e(x);h&&(i.push(Oe.normalize(f)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(f,function(_,w){if(_)return e(_);i=i.concat(w),--l||e(null,i)}):--l||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Ol[(t^e)&255]^t>>>8};Ee.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ee.crc32update(r,t[i++]);return~r>>>0};Ee.methodToString=function(t){switch(t){case Dl.STORED:return"STORED ("+t+")";case Dl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.posix.join(".",e)};Ee.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ee.sanitize=function(t,e){t=Oe.resolve(Oe.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Oe.normalize(Oe.join(t,r.slice(i,o).join(Oe.sep)));if(c.indexOf(t)===0)return c}return Oe.normalize(Oe.join(t,Oe.basename(e)))};Ee.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ee.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ee.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Ee.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Ee.isWin=kg;Ee.crcTable=Ol});var Ml=oe((Q1,Ll)=>{var Og=le("path");Ll.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Og.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Fl=oe((e2,Bl)=>{Bl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=oe((t2,ir)=>{ir.exports=Nl();ir.exports.Constants=Ra();ir.exports.Errors=hs();ir.exports.FileAttr=Ml();ir.exports.decoder=Fl()});var Ul=oe((n2,zl)=>{var sn=sr(),q=sn.Constants;zl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,f=0,x=0,h=0,_=0,w=0,S=0,b=0,v=0;t|=sn.isWin?2560:768,r|=q.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=sn.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(y){y?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(y){y?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return i},set method(y){switch(y){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}i=y},get time(){return sn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=sn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return l},set compressedSize(y){l=A(y)},get size(){return f},set size(y){f=A(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return h},set extraLength(y){h=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return _},set commentLength(y){_=y},get diskNumStart(){return w},set diskNumStart(y){w=A(y)},get inAttr(){return S},set inAttr(y){S=A(y)},get attr(){return b},set attr(y){b=A(y)},get fileAttr(){return(b||0)>>16&4095},get offset(){return v},set offset(y){v=A(y)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+_},get realDataOffset(){return v+q.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var R=y.slice(v,v+q.LOCHDR);if(R.readUInt32LE(0)!==q.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=R.readUInt16LE(q.LOCVER),I.flags=R.readUInt16LE(q.LOCFLG),I.flags_desc=(I.flags&q.FLG_DESC)>0,I.method=R.readUInt16LE(q.LOCHOW),I.time=R.readUInt32LE(q.LOCTIM),I.crc=R.readUInt32LE(q.LOCCRC),I.compressedSize=R.readUInt32LE(q.LOCSIZ),I.size=R.readUInt32LE(q.LOCLEN),I.fnameLen=R.readUInt16LE(q.LOCNAM),I.extraLen=R.readUInt16LE(q.LOCEXT);let D=v+q.LOCHDR+I.fnameLen,B=D+I.extraLen;return y.slice(D,B)},loadFromBinary:function(y){if(y.length!==q.CENHDR||y.readUInt32LE(0)!==q.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(q.CENVEM),e=y.readUInt16LE(q.CENVER),r=y.readUInt16LE(q.CENFLG),i=y.readUInt16LE(q.CENHOW),o=y.readUInt32LE(q.CENTIM),c=y.readUInt32LE(q.CENCRC),l=y.readUInt32LE(q.CENSIZ),f=y.readUInt32LE(q.CENLEN),x=y.readUInt16LE(q.CENNAM),h=y.readUInt16LE(q.CENEXT),_=y.readUInt16LE(q.CENCOM),w=y.readUInt16LE(q.CENDSK),S=y.readUInt16LE(q.CENATT),b=y.readUInt32LE(q.CENATX),v=y.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(q.LOCHDR);return y.writeUInt32LE(q.LOCSIG,0),y.writeUInt16LE(e,q.LOCVER),y.writeUInt16LE(r,q.LOCFLG),y.writeUInt16LE(i,q.LOCHOW),y.writeUInt32LE(o,q.LOCTIM),y.writeUInt32LE(c,q.LOCCRC),y.writeUInt32LE(l,q.LOCSIZ),y.writeUInt32LE(f,q.LOCLEN),y.writeUInt16LE(x,q.LOCNAM),y.writeUInt16LE(I.extraLen,q.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(q.CENHDR+x+h+_);return y.writeUInt32LE(q.CENSIG,0),y.writeUInt16LE(t,q.CENVEM),y.writeUInt16LE(e,q.CENVER),y.writeUInt16LE(r,q.CENFLG),y.writeUInt16LE(i,q.CENHOW),y.writeUInt32LE(o,q.CENTIM),y.writeUInt32LE(c,q.CENCRC),y.writeUInt32LE(l,q.CENSIZ),y.writeUInt32LE(f,q.CENLEN),y.writeUInt16LE(x,q.CENNAM),y.writeUInt16LE(h,q.CENEXT),y.writeUInt16LE(_,q.CENCOM),y.writeUInt16LE(w,q.CENDSK),y.writeUInt16LE(S,q.CENATT),y.writeUInt32LE(b,q.CENATX),y.writeUInt32LE(v,q.CENOFF),y},toJSON:function(){let y=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(f),fileNameLength:y(x),extraLength:y(h),commentLength:y(_),diskNumStart:w,inAttr:S,attr:b,offset:v,centralHeaderSize:y(q.CENHDR+x+h+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ql=oe((r2,Gl)=>{var or=sr(),we=or.Constants;Gl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return we.ENDHDR+o},loadFromBinary:function(c){if((c.length!==we.ENDHDR||c.readUInt32LE(0)!==we.ENDSIG)&&(c.length<we.ZIP64HDR||c.readUInt32LE(0)!==we.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===we.ENDSIG?(t=c.readUInt16LE(we.ENDSUB),e=c.readUInt16LE(we.ENDTOT),r=c.readUInt32LE(we.ENDSIZ),i=c.readUInt32LE(we.ENDOFF),o=c.readUInt16LE(we.ENDCOM)):(t=or.readBigUInt64LE(c,we.ZIP64SUB),e=or.readBigUInt64LE(c,we.ZIP64TOT),r=or.readBigUInt64LE(c,we.ZIP64SIZE),i=or.readBigUInt64LE(c,we.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(we.ENDHDR+o);return c.writeUInt32LE(we.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,we.ENDSUB),c.writeUInt16LE(e,we.ENDTOT),c.writeUInt32LE(r,we.ENDSIZ),c.writeUInt32LE(i,we.ENDOFF),c.writeUInt16LE(o,we.ENDCOM),c.fill(" ",we.ENDHDR),c},toJSON:function(){let c=function(l,f){let x=l.toString(16).toUpperCase();for(;x.length<f;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ka=oe(Da=>{Da.EntryHeader=Ul();Da.MainHeader=ql()});var jl=oe((s2,Hl)=>{Hl.exports=function(t){var e=le("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),x=0;f.fill(0);for(var h=0;h<c.length;h++){var _=c[h];_.copy(f,x),x+=_.length}i&&i(f)}),o.end(t)}}}});var Kl=oe((o2,Wl)=>{var Pg=+(process.versions?process.versions.node:"").split(".")[0]||0;Wl.exports=function(t,e){var r=le("zlib");let i=Pg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],f=0;c.on("data",function(x){l.push(x),f+=x.length}),c.on("end",function(){var x=Buffer.alloc(f),h=0;x.fill(0);for(var _=0;_<l.length;_++){var w=l[_];w.copy(x,h),h+=w.length}o&&o(x)}),c.end(t)}}}});var Zl=oe((a2,Jl)=>{"use strict";var{randomFillSync:$l}=le("crypto"),Ng=hs(),Lg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Yl=(t,e)=>Math.imul(t,e)>>>0,Vl=(t,e)=>Lg[(t^e)&255]^t>>>8,ni=()=>typeof $l=="function"?$l(Buffer.alloc(12)):ni.node();ni.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ps={genSalt:ni};function gs(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}gs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Vl(e[0],t),e[1]+=e[0]&255,e[1]=Yl(e[1],134775813)+1,e[2]=Vl(e[2],e[1]>>>24),t};gs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Yl(t,t^1)>>8&255};function Mg(t){let e=new gs(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Bg(t){let e=new gs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Fg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Mg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Ng.WRONG_PASSWORD();return i(t.slice(12))}function zg(t){Buffer.isBuffer(t)&&t.length>=12?ps.genSalt=function(){return t.slice(0,12)}:t==="node"?ps.genSalt=ni.node:ps.genSalt=ni}function Ug(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Bg(r),c=ps.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Jl.exports={decrypt:Fg,encrypt:Ug,_salter:zg}});var Xl=oe(ms=>{ms.Deflater=jl();ms.Inflater=Kl();ms.ZipCrypto=Zl()});var Pa=oe((d2,Ql)=>{var ae=sr(),Gg=ka(),ve=ae.Constants,Oa=Xl();Ql.exports=function(t,e){var r=new Gg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let _=t,w=typeof _.decoder=="object"?_.decoder:ae.decoder;h=w.hasOwnProperty("efs")?w.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function b(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ae.crc32(y)!==r.localHeader.crc)return!1}else{let R={},D=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(D)==ve.LOCSIG||e.readUInt32LE(D)==ve.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(D)==ve.EXTSIG)R.crc=e.readUInt32LE(D+ve.EXTCRC),R.compressedSize=e.readUInt32LE(D+ve.EXTSIZ),R.size=e.readUInt32LE(D+ve.EXTLEN);else if(e.readUInt16LE(D+12)===19280)R.crc=e.readUInt32LE(D+ve.EXTCRC-4),R.compressedSize=e.readUInt32LE(D+ve.EXTSIZ-4),R.size=e.readUInt32LE(D+ve.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(y)!==R.crc)return!1}return!0}function v(y,R,D){if(typeof R>"u"&&typeof y=="string"&&(D=y,y=void 0),c)return y&&R&&R(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=S();if(B.length===0)return y&&R&&R(B),B;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw ae.Errors.INVALID_PASS_PARAM();B=Oa.ZipCrypto.decrypt(B,r,D)}var G=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(B.copy(G),b(G))return y&&R&&R(G),G;throw y&&R&&R(G,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var Y=new Oa.Inflater(B,r.size);if(y)Y.inflateAsync(function(J){J.copy(J,0),R&&(b(J)?R(J):R(J,ae.Errors.BAD_CRC()))});else{if(Y.inflate(G).copy(G,0),!b(G))throw ae.Errors.BAD_CRC(`"${w.decode(i)}"`);return G}break;default:throw y&&R&&R(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function I(y,R){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&R&&R(S()),S();if(l.length&&!c){var D;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(l.length),l.copy(D),y&&R&&R(D),D;default:case ae.Constants.DEFLATED:var B=new Oa.Deflater(l);if(y)B.deflateAsync(function(Y){D=Buffer.alloc(Y.length),r.compressedSize=Y.length,Y.copy(D),R&&R(D)});else{var G=B.deflate();return r.compressedSize=G.length,G}B=null;break}}else if(y&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,R){return ae.readBigUInt64LE(y,R)}function C(y){try{for(var R=0,D,B,G;R+4<y.length;)D=y.readUInt16LE(R),R+=2,B=y.readUInt16LE(R),R+=2,G=y.slice(R,R+B),R+=B,ve.ID_ZIP64===D&&P(G)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var R,D,B,G;y.length>=ve.EF_ZIP64_SCOMP&&(R=A(y,ve.EF_ZIP64_SUNCOMP),r.size===ve.EF_ZIP64_OR_32&&(r.size=R)),y.length>=ve.EF_ZIP64_RHO&&(D=A(y,ve.EF_ZIP64_SCOMP),r.compressedSize===ve.EF_ZIP64_OR_32&&(r.compressedSize=D)),y.length>=ve.EF_ZIP64_DSN&&(B=A(y,ve.EF_ZIP64_RHO),r.offset===ve.EF_ZIP64_OR_32&&(r.offset=B)),y.length>=ve.EF_ZIP64_DSN+4&&(G=y.readUInt32LE(ve.EF_ZIP64_DSN),r.diskNumStart===ve.EF_ZIP64_OR_16&&(r.diskNumStart=G))}return{get entryName(){return w.decode(i)},get rawEntryName(){return i},set entryName(y){i=ae.toBuffer(y,w.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return f},set extra(y){f=y,r.extraLength=y.length,C(y)},get comment(){return w.decode(o)},set comment(y){if(o=ae.toBuffer(y,w.encode),r.commentLength=o.length,o.length>65535)throw ae.Errors.COMMENT_TOO_LONG()},get name(){var y=w.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){l=ae.toBuffer(y,ae.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ae.Constants.DEFLATED,r.crc=ae.crc32(y),r.changed=!0):r.method=ae.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,R){r.changed?y(l):v(!0,y,R)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=f.length;var y=r.centralHeaderToBinary(),R=ae.Constants.CENHDR;return i.copy(y,R),R+=i.length,f.copy(y,R),R+=r.extraLength,o.copy(y,R),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let R=r.localHeaderToBinary(),D=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(D,y),y+=R.length,i.copy(D,y),y+=i.length,x.copy(D,y),y+=x.length,D},toJSON:function(){let y=function(R){return"<"+(R&&R.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var nf=oe((l2,tf)=>{var ef=Pa(),qg=ka(),je=sr();tf.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new qg.MainHeader,l=!1,f=null;let x=new Set,h=e,{noSort:_,decoder:w}=h;t?v(h.readEntries):l=!0;function S(){let A=new Set;for(let C of Object.keys(i)){let P=C.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let R=P.slice(0,y+1).join("/")+"/";A.add(R)}}for(let C of A)if(!(C in i)){let P=new ef(h);P.entryName=C,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function b(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,C=0;C<r.length;C++){var P=A,y=new ef(h,t);y.header=t.slice(P,P+=je.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),A+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}x.clear(),S()}function v(A){var C=t.length-je.Constants.ENDHDR,P=Math.max(0,C-65535),y=P,R=t.length,D=-1,B=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(P=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===je.Constants.ENDSIG){D=C,B=C,R=C+je.Constants.ENDHDR,y=C-je.Constants.END64HDR;continue}if(t.readUInt32LE(C)===je.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(C)===je.Constants.ZIP64SIG){D=C,R=C+je.readBigUInt64LE(t,C+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(D==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,R)),c.commentLength&&(o=t.slice(B+je.Constants.ENDHDR)),A&&b()}function I(){r.length>1&&!_&&r.sort((A,C)=>A.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||b(),r.filter(A=>!x.has(A))},get comment(){return w.decode(o)},set comment(A){o=je.toBuffer(A,w.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||b(),i[A]||null},setEntry:function(A){l||b(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,C=!0){l||b();let P=i[A];this.getEntryChildren(P,C).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||b();let C=i[A],P=r.indexOf(C);P>=0&&(r.splice(P,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,C=!0){if(l||b(),typeof A=="object")if(A.isDirectory&&C){let P=[],y=A.entryName;for(let R of r)R.entryName.startsWith(y)&&P.push(R);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let C=this.getEntryChildren(A);return C.includes(A)?C.length-1:C.length}return 0},compressToBuffer:function(){l||b(),I();let A=[],C=[],P=0,y=0;c.size=0,c.offset=0;let R=0;for(let G of this.entries){let Y=G.getCompressedData();G.header.offset=y;let J=G.packLocalHeader(),te=J.length+Y.length;y+=te,A.push(J),A.push(Y);let Q=G.packCentralHeader();C.push(Q),c.size+=Q.length,P+=te+Q.length,R++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=R,y=0;let D=Buffer.alloc(P);for(let G of A)G.copy(D,y),y+=G.length;for(let G of C)G.copy(D,y),y+=G.length;let B=c.toBinary();return o&&o.copy(B,je.Constants.ENDHDR),B.copy(D,y),t=D,l=!1,D},toAsyncBuffer:function(A,C,P,y){try{l||b(),I();let R=[],D=[],B=0,G=0,Y=0;c.size=0,c.offset=0;let J=function(te){if(te.length>0){let Q=te.shift(),be=Q.entryName+Q.extra.toString();P&&P(be),Q.getCompressedDataAsync(function(he){y&&y(be),Q.header.offset=G;let O=Q.packLocalHeader(),W=O.length+he.length;G+=W,R.push(O),R.push(he);let $=Q.packCentralHeader();D.push($),c.size+=$.length,B+=W+$.length,Y++,J(te)})}else{B+=c.mainHeaderSize,c.offset=G,c.totalEntries=Y,G=0;let Q=Buffer.alloc(B);R.forEach(function(he){he.copy(Q,G),G+=he.length}),D.forEach(function(he){he.copy(Q,G),G+=he.length});let be=c.toBinary();o&&o.copy(be,je.Constants.ENDHDR),be.copy(Q,G),t=Q,l=!1,A(Q)}};J(Array.from(this.entries))}catch(R){C(R)}}}}});var of=oe((f2,sf)=>{var ye=sr(),_e=le("path"),Hg=Pa(),jg=nf(),Tn=(...t)=>ye.findLast(t,e=>typeof e=="boolean"),rf=(...t)=>ye.findLast(t,e=>typeof e=="string"),Wg=(...t)=>ye.findLast(t,e=>typeof e=="function"),Kg={noSort:!1,readEntries:!1,method:ye.Constants.NONE,fs:null};sf.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Kg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=ye.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ye(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ye.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ye.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw ye.Errors.INVALID_FILENAME();let c=new jg(r,i),{canonical:l,sanitize:f,zipnamefix:x}=ye;function h(b){if(b&&c){var v;if(typeof b=="string"&&(v=c.getEntry(_e.posix.normalize(b))),typeof b=="object"&&typeof b.entryName<"u"&&typeof b.header<"u"&&(v=c.getEntry(b.entryName)),v)return v}return null}function _(b){let{join:v,normalize:I,sep:A}=_e.posix;return v(_e.isAbsolute(b)?"/":".",I(A+b.split("\\").join(A)+A))}function w(b){return b instanceof RegExp?(function(v){return function(I){return v.test(I)}})(b):typeof b!="function"?()=>!0:b}let S=(b,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",_e.relative(b,v)+I};return{readFile:function(b,v){var I=h(b);return I&&I.getData(v)||null},childCount:function(b){let v=h(b);if(v)return c.getChildCount(v)},readFileAsync:function(b,v){var I=h(b);I?I.getDataAsync(v):v(null,"getEntry failed for:"+b)},readAsText:function(b,v){var I=h(b);if(I){var A=I.getData();if(A&&A.length)return A.toString(v||"utf8")}return""},readAsTextAsync:function(b,v,I){var A=h(b);A?A.getDataAsync(function(C,P){if(P){v(C,P);return}C&&C.length?v(C.toString(I||"utf8")):v("")}):v("")},deleteFile:function(b,v=!0){var I=h(b);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(b){var v=h(b);v&&c.deleteEntry(v.entryName)},addZipComment:function(b){c.comment=b},getZipComment:function(){return c.comment||""},addZipEntryComment:function(b,v){var I=h(b);I&&(I.comment=v)},getZipEntryComment:function(b){var v=h(b);return v&&v.comment||""},updateFile:function(b,v){var I=h(b);I&&I.setData(v)},addLocalFile:function(b,v,I,A){if(o.fs.existsSync(b)){v=v?_(v):"";let C=_e.win32.basename(_e.win32.normalize(b));v+=I||C;let P=o.fs.statSync(b),y=P.isFile()?o.fs.readFileSync(b):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,y,A,P)}else throw ye.Errors.FILE_NOT_FOUND(b)},addLocalFileAsync:function(b,v){b=typeof b=="object"?b:{localPath:b};let I=_e.resolve(b.localPath),{comment:A}=b,{zipPath:C,zipName:P}=b,y=this;o.fs.stat(I,function(R,D){if(R)return v(R,!1);C=C?_(C):"";let B=_e.win32.basename(_e.win32.normalize(I));if(C+=P||B,D.isFile())o.fs.readFile(I,function(G,Y){return G?v(G,!1):(y.addFile(C,Y,A,D),setImmediate(v,void 0,!0))});else if(D.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),A,D),setImmediate(v,void 0,!0)})},addLocalFolder:function(b,v,I){if(I=w(I),v=v?_(v):"",b=_e.normalize(b),o.fs.existsSync(b)){let A=o.findFiles(b),C=this;if(A.length)for(let P of A){let y=_e.join(v,S(b,P));I(y)&&C.addLocalFile(P,_e.dirname(y))}}else throw ye.Errors.FILE_NOT_FOUND(b)},addLocalFolderAsync:function(b,v,I,A){A=w(A),I=I?_(I):"",b=_e.normalize(b);var C=this;o.fs.open(b,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,ye.Errors.FILE_NOT_FOUND(b));else if(P)v(void 0,P);else{var y=o.findFiles(b),R=-1,D=function(){if(R+=1,R<y.length){var B=y[R],G=S(b,B).split("\\").join("/");G=G.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(G)?o.fs.stat(B,function(Y,J){Y&&v(void 0,Y),J.isFile()?o.fs.readFile(B,function(te,Q){te?v(void 0,te):(C.addFile(I+G,Q,"",J),D())}):(C.addFile(I+G+"/",Buffer.alloc(0),"",J),D())}):process.nextTick(()=>{D()})}else v(!0,void 0)};D()}})},addLocalFolderAsync2:function(b,v){let I=this;b=typeof b=="object"?b:{localPath:b},localPath=_e.resolve(_(b.localPath));let{zipPath:A,filter:C,namefix:P}=b;C instanceof RegExp?C=(function(D){return function(B){return D.test(B)}})(C):typeof C!="function"&&(C=function(){return!0}),A=A?_(A):"",P=="latin1"&&(P=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=D=>D);let y=D=>_e.join(A,P(S(localPath,D))),R=D=>_e.win32.basename(_e.win32.normalize(P(D)));o.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?v(void 0,ye.Errors.FILE_NOT_FOUND(localPath)):D?v(void 0,D):o.findFilesAsync(localPath,function(B,G){if(B)return v(B);G=G.filter(Y=>C(y(Y))),G.length||v(void 0,!1),setImmediate(G.reverse().reduce(function(Y,J){return function(te,Q){if(te||Q===!1)return setImmediate(Y,te,!1);I.addLocalFileAsync({localPath:J,zipPath:_e.dirname(y(J)),zipName:R(J)},Y)}},v))})})},addLocalFolderPromise:function(b,v){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:b},v),(C,P)=>{C&&A(C),P&&I(this)})})},addFile:function(b,v,I,A){b=x(b);let C=h(b),P=C!=null;P||(C=new Hg(i),C.entryName=b),C.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(C.header.time=A.mtime);var R=C.isDirectory?16:0;let D=C.isDirectory?16384:32768;return y?D|=4095&A.mode:typeof A=="number"?D|=4095&A:D|=C.isDirectory?493:420,R=(R|D<<16)>>>0,C.attr=R,C.setData(v),P||c.setEntry(C),C},getEntries:function(b){return c.password=b,c?c.entries:[]},getEntry:function(b){return h(b)},getEntryCount:function(){return c.getEntryCount()},forEach:function(b){return c.forEach(b)},extractEntryTo:function(b,v,I,A,C,P){A=Tn(!1,A),C=Tn(!1,C),I=Tn(!0,I),P=rf(C,P);var y=h(b);if(!y)throw ye.Errors.NO_ENTRY();var R=l(y.entryName),D=f(v,P&&!y.isDirectory?P:I?R:_e.basename(R));if(y.isDirectory){var B=c.getEntryChildren(y);return B.forEach(function(J){if(J.isDirectory)return;var te=J.getData();if(!te)throw ye.Errors.CANT_EXTRACT_FILE();var Q=l(J.entryName),be=f(v,I?Q:_e.basename(Q));let he=C?J.header.fileAttr:void 0;o.writeFileTo(be,te,A,he)}),!0}var G=y.getData(c.password);if(!G)throw ye.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(D)&&!A)throw ye.Errors.CANT_OVERRIDE();let Y=C?b.header.fileAttr:void 0;return o.writeFileTo(D,G,A,Y),!0},test:function(b){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(b);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(b,v,I,A){if(I=Tn(!1,I),A=rf(I,A),v=Tn(!1,v),!c)throw ye.Errors.NO_ZIP();c.entries.forEach(function(C){var P=f(b,l(C.entryName));if(C.isDirectory){o.makeDir(P);return}var y=C.getData(A);if(!y)throw ye.Errors.CANT_EXTRACT_FILE();let R=I?C.header.fileAttr:void 0;o.writeFileTo(P,y,v,R);try{o.fs.utimesSync(P,C.header.time,C.header.time)}catch{throw ye.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(b,v,I,A){if(A=Wg(v,I,A),I=Tn(!1,I),v=Tn(!1,v),!A)return new Promise((D,B)=>{this.extractAllToAsync(b,v,I,function(G){G?B(G):D(this)})});if(!c){A(ye.Errors.NO_ZIP());return}b=_e.resolve(b);let C=D=>f(b,_e.normalize(l(D.entryName))),P=(D,B)=>new Error(D+': "'+B+'"'),y=[],R=[];c.entries.forEach(D=>{D.isDirectory?y.push(D):R.push(D)});for(let D of y){let B=C(D),G=I?D.header.fileAttr:void 0;try{o.makeDir(B),G&&o.fs.chmodSync(B,G),o.fs.utimesSync(B,D.header.time,D.header.time)}catch{A(P("Unable to create folder",B))}}R.reverse().reduce(function(D,B){return function(G){if(G)D(G);else{let Y=_e.normalize(l(B.entryName)),J=f(b,Y);B.getDataAsync(function(te,Q){if(Q)D(Q);else if(!te)D(ye.Errors.CANT_EXTRACT_FILE());else{let be=I?B.header.fileAttr:void 0;o.writeFileToAsync(J,te,v,be,function(he){he||D(P("Unable to write file",J)),o.fs.utimes(J,B.header.time,B.header.time,function(O){O?D(P("Unable to set times",J)):D()})})}})}}},A)()},writeZip:function(b,v){if(arguments.length===1&&typeof b=="function"&&(v=b,b=""),!b&&i.filename&&(b=i.filename),!!b){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(b,I,!0);typeof v=="function"&&v(A?null:new Error("failed"),"")}}},writeZipPromise:function(b,v){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},v);return new Promise((C,P)=>{!b&&i.filename&&(b=i.filename),b||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let R=D=>D?C(D):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(b,y,I,A,R)},P)})},toBufferPromise:function(){return new Promise((b,v)=>{c.toAsyncBuffer(b,v)})},toBuffer:function(b,v,I,A){return typeof b=="function"?(c.toAsyncBuffer(b,v,I,A),null):c.compressToBuffer()}}}});import{execFile as M_,spawn as B_,spawnSync as SI}from"node:child_process";import{promisify as F_}from"node:util";function U_(t){if(process.platform!=="win32")return!1;if(eu.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(eu,"").toLowerCase();return z_.has(r)}function tu(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return U_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function dt(t,e=[],r={}){return B_(t,e,tu(t,r))}function nu(t,e=[],r={}){return G_(t,e,tu(t,r))}var z_,eu,G_,yn=Ye(()=>{"use strict";z_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),eu=/\.(cmd|bat|ps1)$/i;G_=F_(M_)});var rx=oe(Le=>{"use strict";function U(t,e){t=t-372;let r=ko(),i=r[t];if(U.mFjAnp===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",w="";for(let S=0,b,v,I=0;v=x.charAt(I++);~v&&(b=S%4?b*64+v:v,S++%4)?_+=String.fromCharCode(255&b>>(-2*S&6)):0)v=h.indexOf(v);for(let S=0,b=_.length;S<b;S++)w+="%"+("00"+_.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};U.OhGtth=o,U.sUydiK={},U.mFjAnp=!0}let c=r[0],l=t+c,f=U.sUydiK[l];return f?i=f:(i=U.OhGtth(i),U.sUydiK[l]=i),i}var M=U;(function(t,e){let r=U,i=t();for(;;)try{if(-parseInt(r(803))/1*(parseInt(r(770))/2)+parseInt(r(998))/3*(-parseInt(r(958))/4)+-parseInt(r(922))/5*(-parseInt(r(1842))/6)+parseInt(r(1570))/7*(parseInt(r(579))/8)+parseInt(r(1227))/9+parseInt(r(1514))/10+-parseInt(r(651))/11*(parseInt(r(409))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(ko,387093);var kb=Object[M(1243)+M(1814)],Ob=Object[M(1391)+M(1520)+"mes"],Xu=(t,e)=>function(){return t&&(e=(0,t[{XVqgJ:function(c,l){return c(l)}}[M(411)](Ob,t)[0]])(t=0)),e},Pb=(t,e)=>{let r={wvemE:function(o,c,l,f){return o(c,l,f)}};for(var i in e)r.wvemE(kb,t,i,{get:e[i],enumerable:!0})};function Nb(){return $u||($u=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Lb(){let t=M;return Vu||(Vu=[IDBCursor[t(1135)+"e"][t(677)],IDBCursor[t(1135)+"e"][t(708)],IDBCursor[t(1135)+"e"][t(708)+t(899)+"ey"]])}function Mb(t){let e=M,r={wyLbv:e(945),MBegR:"error",huYJT:function(o,c,l){return o(c,l)},exIUB:function(o,c){return o===c},FKrSX:e(675),Gqoiz:function(o){return o()},OlsuO:function(o,c){return o(c)},lCgnq:function(o,c){return o instanceof c},YRWzJ:function(o,c){return o!==c}},i=new Promise((o,c)=>{let l=e,f={irmYm:r[l(1512)],iWVyY:r[l(1699)],mwmQW:function(w,S,b){return r[l(1256)](w,S,b)},RtgET:function(w,S){return r.exIUB(w,S)},KHuaQ:r.FKrSX,qerKh:function(w,S){return w(S)},DDyLb:function(w){return r.Gqoiz(w)},vXqpQ:function(w,S){return r[l(432)](w,S)}},x=()=>{let w=l;t[w(1827)+w(457)+w(1004)](f.irmYm,h),t[w(1827)+w(457)+w(1004)](f[w(1714)],_)},h=()=>{let w=l;f[w(685)](f[w(1438)],"ixAfr")?(f.qerKh(o,Lt(t[w(915)])),f[w(1285)](x)):(_0x3775db(_0x1a671b,10),f[w(1064)](_0x4c7455,_0x21af2a,_0x39e3b4))},_=()=>{let w=l;f.vXqpQ(c,t.error),f[w(1285)](x)};t[l(888)+l(1477)](l(945),h),t[l(888)+l(1477)](r[l(1699)],_)});return i.then(o=>{let c=e;if(r.lCgnq(o,IDBCursor))if(r[c(1871)](c(1376),"vZTue"))od[c(1705)](o,t);else return!!this._qosDB}).catch(()=>{}),Ro.set(i,t),i}function Bb(t){let e=M,r={HCzAG:function(o,c){return o!==c},BKoPx:"RhUDq",mtsBL:e(631),eUUAA:function(o){return o()},cLesx:function(o,c){return o||c},iVqgR:function(o,c){return o(c)},wNORi:function(o){return o()},rpkVk:e(1290),lgtld:e(1382)};if(Co.has(t))return;let i=new Promise((o,c)=>{let l=e,f={zuYlz:function(w,S){return r[U(486)](w,S)},samGN:function(w,S){return r.iVqgR(w,S)},UgYEB:l(943)+"or",RBvDX:function(w){return r.wNORi(w)}},x=()=>{let w=l;if(r.HCzAG(r[w(687)],w(1831))){let S=this[w(1259)][w(518)+w(563)+"nc"](this[w(1022)]),b=_0x3f8cc5[w(1030)](f[w(829)](S,"{}"));return _0x39b1a1[w(1809)](b)}else t[w(1827)+w(457)+"ner"](r[w(1288)],h),t["removeEv"+w(457)+w(1004)](w(1290),_),t[w(1827)+"entListe"+w(1004)](w(1382),_)},h=()=>{r.eUUAA(o),x()},_=()=>{let w=l;f[w(576)](c,t[w(1290)]||new DOMException(f[w(1494)],w(943)+"or")),f[w(754)](x)};t[l(888)+l(1477)](r[l(1288)],h),t[l(888)+"Listener"](r.rpkVk,_),t[l(888)+l(1477)](r[l(878)],_)});Co[e(1705)](t,i)}function Fb(t){Do=t(Do)}function zb(t){let e=M,r={WFWPd:function(i,o){return i(o)},vXBDl:function(i,o){return i!==o},tzKkm:e(584),cgAfX:function(i,o){return i(o)},vlMSs:function(i,o,c){return i(o,c)},hGHYr:e(1290),nJMaK:"00000000"+e(1219)+e(1219)+e(1219),Rjiko:function(i,o){return i===o},Daxkp:e(1044),VCLiQ:function(i,o){return i(o)},dfGnX:function(i,o){return i===o},ugcuX:function(i,o){return i in o},hEdTb:e(1267)+e(665),EAkaQ:function(i){return i()},CfJgt:"Mdydh"};if(r[e(1296)](t,IDBDatabase[e(1135)+"e"][e(1673)+e(1334)])&&!r[e(877)](r[e(597)],IDBTransaction[e(1135)+"e"]))return function(i,...o){let c=e,l=t[c(461)](r.WFWPd(Gi,this),i,...o);return sd.set(l,i[c(455)]?i[c(455)]():[i]),Lt(l)};if(r[e(559)](Lb)[e(658)](t)){if(r[e(845)](r.CfJgt,e(1450)))return function(...i){let o=e,c={vAUnC:function(l,f,x){return l(f,x)},Hvbfe:o(1290)};if(r[o(845)](r[o(581)],o(584))){let l=o(1622)+_0x5e9dca+(o(1753)+o(882)+o(412)+"ed");this["_dispatc"+o(1563)+o(1464)](c[o(1888)](_0x34b6e3,c.Hvbfe,{message:l,code:_0x3f978d[o(692)+o(1657)+"R"],error:_0x5353ab}));return}else return t.apply(r[o(995)](Gi,this),i),Lt(od[o(1309)](this))};this[e(714)]("error",r.vlMSs(_0xfb1b75,r[e(1087)],{..._0x1c987a,message:_0x2af033[e(1752)]||""}))}return function(...i){let o=e,c={UsikT:function(l,f){return l(f)},rxDoe:r.nJMaK};if(r.Rjiko("qHjVU",r[o(591)])){let l=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(_0x41434a),f=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[o(1605)](_0x2df013);return l?_0x1e90cf(_0x4a1fe8):f?c[o(863)](_0xcc555b,_0x3c1ddc):c[o(1442)]}else return r[o(995)](Lt,t[o(1110)](r[o(1482)](Gi,this),i))}}function Ub(t){let e=M,r={qDOao:function(i,o){return i===o},PCWch:e(1518),SmObk:function(i,o){return i(o)},BfJLX:function(i,o){return i instanceof o},svvEZ:function(i,o,c){return i(o,c)},UGFWH:function(i){return i()}};return r.qDOao(typeof t,r[e(1348)])?r[e(1273)](zb,t):(r[e(1161)](t,IDBTransaction)&&r[e(1273)](Bb,t),r[e(645)](Qu,t,r[e(1138)](Nb))?new Proxy(t,Do):t)}function Lt(t){let e=M,r={jHxtE:function(o,c){return o(c)},TOmIz:function(o,c){return o!==c}};if(t instanceof IDBRequest)return r.jHxtE(Mb,t);if(Io.has(t))return Io.get(t);let i=r[e(884)](Ub,t);return r[e(686)](i,t)&&(Io.set(t,i),Ro.set(i,t)),i}var Qu,$u,Vu,od,Co,sd,Io,Ro,Do,Gi,Yu=Xu({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={MaelP:function(r,i,o,c){return r(i,o,c)},cYCYu:t(1388),MwSYw:function(r,i){return r instanceof i},cKdLd:function(r,i){return r===i},rRQHV:t(893),GuuCT:function(r,i){return r===i},pTVhS:t(1267)+t(665),rZbVh:function(r,i){return r===i},tLvuZ:t(1695),rjRYR:function(r,i){return r(i)},LDUAX:function(r,i){return r>=i},nHEon:t(788),MXotQ:function(r,i){return r in i}};Qu=(r,i)=>i[t(1863)](o=>r instanceof o),od=new WeakMap,Co=new WeakMap,sd=new WeakMap,Io=new WeakMap,Ro=new WeakMap,Do={get(r,i,o){let c=t;if(e.cYCYu==="KnXNC")e[c(678)](_0x3a824e,this,_0x96a6c,[_0x2a6025,_0x1503a3,_0x4344ea,_0x150410,_0x2279cc,_0x1264c6]);else{if(e.MwSYw(r,IDBTransaction)){if(e[c(1662)](i,e.rRQHV))return Co[c(1309)](r);if(e.GuuCT(i,e[c(484)]))return r[c(1267)+c(665)]||sd[c(1309)](r);if(e[c(861)](i,e[c(1284)]))return o[c(1267)+c(665)][1]?void 0:o[c(1267)+c(799)](o["objectSt"+c(665)][0])}return e[c(1199)](Lt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t,c={nYLLw:function(l,f){return e[U(1669)](l,f)},XjdhD:function(l,f){return e[U(1123)](l,f)}};return e[o(861)](o(788),e[o(1765)])?r instanceof IDBTransaction&&(e.GuuCT(i,o(893))||i===e[o(1284)])?!0:e[o(937)](i,r):!!(c.nYLLw(this[o(864)+"ndex"],this[o(793)+"s"].length)||c[o(1631)](this[o(864)+"ndex"],this.endpoints[o(614)]-1)&&c.XjdhD(this[o(533)+o(926)+"riesCount"],this[o(660)+"es"]))}},Gi=r=>Ro[t(1309)](r)}}),ex={};Pb(ex,{deleteDB:()=>qb,openDB:()=>Gb,unwrap:()=>Gi,wrap:()=>Lt});function ko(){let t=["wenisfu","s3DPuhu","DgTbBwS","y29UC3rYDwm","rwLKEMq","rMvUs1O","B2fYDKW","BfrPBwvVDxq","zw5JB2rLrNi","DefyywG","ywnR","Bw5KsuG","x21LC3nHz2u","AhDTCM0","r3bbDxa","C2vYDMLJzq","weHLBMS","ALv0zge","EwL2D1q","BgLUzq","AgvHzgvYCW","t2PZz2i","sgHSy1q","rgjhtvO","y3vZDg9Tshq","n3WWFdn8mNW","wKrWzLe","Aw9Ul2PZB24","y29Uy2f0","s0H1yve","ywXSq3vYC28","y1PRDu0","DNL5yxq","CNHeB2u","ru5hy2e","AvnguuS","A1DYDxy","DNrMtgS","mNWWFdm","x19LC01Vzhu","q291BNq","AeLfDfO","yNL0zu9MzNm","DgLTzw91DcW","zeT2vNO","sfvHDLm","DKjdr00","BeHAqwq","yKjOz1i","txn3uMi","wLDnqwm","wvnLtgO","wNHer0u","zv90Aw1LB3u","rNrXtxG","zw50","vKzUENC","wgrJvLy","rvLsEgm","Aw5PDcbrB1m","A3nrrLy","vxL6rKy","ywrK","x29UugfNzu4","Dw5PBey","B3jpBMXPBMu","ihn1y2nLC3m","zfn0twS","tgLZDgvUzxi","Cwznqui","shL3DKe","wePvwxm","ug1Avhu","vKnmAve","CYbWyxjHBxm","EeLpDMK","B2nRzxq","Axr0vxi","sNHQCMS","sgvpDhe","x2jPBMfYEvq","CM92AwrLigi","shnfuNe","t2LfreG","x3nVy2TLDa","vwDzrui","z1zHu08","zMLSzw5HBwu","DwTMu08","uvfLrKu","EuXwwfy","v2vIu29JA2u","BunVzNi","qKjJsfC","B25nzxnZywC","ihjLy29UBMu","uxvLDwu","vNf4zMi","A21qAvO","tgLMsgC","sNfrtLq","zeHuEMS","svvTA3u","D3LmyNy","ywXSB2nvBNm","ndm5nti1mhHtuMfWDq","t2jLyw0","wuXRyKq","r29bzfa","zNvUy3rPB24","B3nLza","B3bLCNr5tMe","BMnVzgLUzW","CMvZzxrfBMq","qNneEMW","DKLVzvm","ug9myLu","vhvLDhe","l3DZl3yY","y2HnyxHuCMK","CMvTB3zLq2G","s2TyAeC","Ew5Ztg0","nhWWFdj8m3W","zgzVEw0","y2HHCKnVzgu","BxnN","ExbL","yw5ZzM9YBvq","tgPSuuK","s1DwCfq","CgjICdi","Aw47y2HHCNm","x3bPBMDmB3m","Egjwz2S","CNjVCK1LC3m","Ahr0Chm6","Dg9tDhjPBMC","C3rYAw5NAwy","uMvJB25Uzwm","B3rKyuS","yM5Jtxq","y1LrExi","y2XVC2veqG","rezHtMO","yw55ru8","CMfTugfYyw0","B3rUywW","vKPPr0e","wgTtvLe","yu5TDNm","AvfJBeW","s0DcB1a","yurOrMS","AevYCM9Yrxy","qNjwyKy","CNnWq00","Dvz3Cxq","ve9NDe8","rhrvB2i","CgvYC2LZDgu","ntaXowTsC0HUsq","zxjFDhrS","EgLqr1a","rwz5ue8","tfLzBNm","uLjpuG","De1rCuS","C2nYAxb0","zMvY","C2v0sxrLBq","BvfQsge","y29UBMvJDeu","BwvZC2fNztO","ihzHBgLKigq","x2LUAxrhBg8","ChjVDg9JB2W","sMX2zNG","DxrMofDYAxq","A1LzAgm","z1vWr2C","AxzuBgO","A3PPwMW","rLztsMK","CM92AwrLige","zfziqNy","Cw5fu2W","C2vYDMvYvgK","x2HHBMrSzvi","rxvTqu4","Dxrjza","q1vzEeu","uMrSvMG","zw5HyMXLuw8","DvfsrhO","DLLArgC","DgvZDa","pxv0zI04","BxztBum","AgfZ","B2zMBgLUzq","C2XPy2u","D3jPDgu","yu5Kreu","CLzHBhvLCW","Dg9cExrLCW","DgLUzYbZzxi","zefTChu","q0rZr2O","rLHNqvm","EuzUq1a","B3nLrxzLBNq","Ee9uAxi","y29UBMvJDca","x3vYBa","wgr0reW","BKrxt3K","zgv5q1K","yw51Ce1LC3m","vxfHwgK","EeXAzLe","x2n1CNnVCKy","wgPKAeq","AxrpDMm","B25szwnLAxy","x2LZv29YA2u","Axnby2TdBgu","x3bPBMC","CMvHzg9UBhK","z25yzhm","x21PBMLoyxy","Ag5Rrei","Bgzjvwm","zKPtvKu","r1PzD1G","AxnmB25N","zMX1C2HfEha","zgvSzxrL","y3PmtLi","ANbSCuG","DhbizwfKzxi","wKLQqKC","rLvYvLa","q21JvNm","EeLjDhi","CMvHzhLtDge","y2XVC2u","uuPfBKi","suvtx0vsuK8","DurlC3u","s2fqq20","zNjVBu51Bwi","wM1kthu","y0TKtgq","DfzPuLG","su1oq2O","B0vAt3u","tgr1r2e","s0TZswC","D0f5wfq","tervqvG","rLzoweC","yxDbzeW","AefJA01LC3m","DhjHBNnHy3q","C2vtyMm","x2LZtwLUAvC","ihrPBwvZ","twDzveW","Aw5KzxHpzG","CMvUDevUzha","AKz3swC","ANDpyu4","rLjptLrjrvi","y3vYC29Yx2y","AgP0Aui","uhH3Awq","ENrcywK","C3nHz2vfDMu","DKPrywC","nhWYFdb8mxW","y01Yzwe","BwvZC2fNzv8","x194x21Zz18","D2LSBfjLy28","x2DLBMvYyxq","C3rVCMu","vhrvrhm","rvLqswO","ywf2Exu","tujLz1i","ELbXse4","yxbWzw5Kq2G","Bwu6ia","zMjdthi","s3zkv0u","C2v0","u3DUq3m","A09TtKC","y2TjDMu","ANDwAwi","z2v0q3vYCMu","t3rPqNq","Bg9Nsurhzw4","CMvHzhDYAxq","AvDwEvK","tLv0vwG","yM1VueO","sgnAD2y","DvPSzuG","zw1LBNq","qxHnA0m","Dgrmy0i","r29Vy0O","yMLUyxj5vhK","BwvY","B0LWCw4","Dw9Kqum","CMvXDwLYzwq","C3rVCcbPBw0","r0fkwfG","BK5Xt1e","AuHRv2K","tunpzNe","AxnFywnR","y2XTqMu","zv9ZDwnJzxm","B25mAw5L","z2XMue8","y1PJDvy","u1PjAgG","Bg9N","CeXhugy","v3nLyxm","ywXSzwqGBxu","DgfIyxnL","uhHWy1m","B0DjBNO","yNH2reS","y3vYC29Yx24","ihrPBwvVDxq","rxzLBNq","shHVruG","zxjYtxnN","igzHAwWSig0","EwvWwwK","Dg9VigXHCMC","BKHUu1y","ywnRx2nVzgu","Dg9hzw5LCMe","CLrAzLK","BwvZC2fNzq","tfnXwhq","C3bSAwnL","zev0r2y","CMLLC0nVDw4","BKHfB24","tw1swwO","m3WXFdb8mNW","u09SvNi","DhDVCMTdAge","AKTmsMK","rfjHuve","yNPivxy","EvjLy29UBMu","sgHXuLe","wK1HtNa","ufnAquS","y29UBMvJDfm","BvzXCfu","Dxnju2q","tfDHAgC","zw5JB2rPBMC","CgLUz0XVC3m","ywDLsgLKzq","v3f3Dgy","Bu9OELm","z1jjy3a","wxbMzKy","ugrTBKS","C050yva","Bu9UBhq","AxnQyLO","y0XJD3G","vwHUD3a","AufPDgi","ufbttw4","AenSB3nLrxy","sfHhu0G","Cg5bsgS","r1PKzNe","Ec1TC2CTCw8","vKTyBeK","s0flzKW","EvDhzKO","vxbKyxrLq28","CwXhAxK","yNvMzMvY","C2fNzq","lcbxzwjtB2m","A2v5CW","BgLUzw5V","CNrbBxu","AuPXuKi","tNb4rLa","B3bLCNr5","C3vIyxjYyxK","x2rLyNvN","AxnAzxjV","s2Hwv2O","DMnlzg4","zKPsEeO","DLPQwhq","zhDNChO","rxbhwvy","wwP0thq","sMr4uuO","Aw9UvgLTzw8","CMvTB3zLrxy","Cgf5Bg9Hza","BgLTAxq","rw1mte4","uMHvrhe","AMvJDfn0B3i","uhPQCLm","EfvZzuvUDG","rgffDw0","tunsqNm","CwffEgS","yxjIAw0","yxKSihrYEsa","swzpExy","AgfUz2u","mJq0mJbbvM52DuG","sLnptLa","s05mree","sMznvLG","q3vZDg9Trxi","zxjFAxnFywm","Dg9mB3DLCKm","DgfNEgi","Chv0","C2vYDMLJzs0","lcbOB3n0BMe","BMnLq2XVC2u","DxHwDeW","AuTtsuG","y3vYC29YlNm","vgfN","wgrMCue","tLLMCMW","C0jf","yw5Hz2vY","zxjFCw9Z","C29Tzq","A1LSyuS","nxW0Fdf8nNW","yuj1z1q","yxPPzfy","CKziAum","BwLZzq","ruLMBMG","wvjxEKO","A01vueK","r2f3sem","zKPNuu8","qLjxv0i","yw55rhq","CgfNzwHPzgu","t0jtuhC","yMfJA3vWigu","BMnqtMy","yM9KEq","Cgf5Bg9Hzeu","zufJAW","DMfSDwu","zgrjrcWGzgu","ywDL","DgvmB2Djre4","DKfvBKm","ChvZAa","r0vjrMy","y3ruAw1LB3u","AgXmEMm","r01sDei","t3frBLq","zxj2AwnL","wu1Nr3y","BxL0ENu","mdaWma","nNWXFdv8na","qvvove8","D2fZq2XLyw4","ywjyt3m","uKPfBKm","A29zq3m","uNPWrMS","BLPpChm","CM92AwrLihy","CMXevwS","CNnVCKzPBgu","uKvIwge","x2HHBMrSzu8","v0jQsKW","zKLPAxy","q2LHthK","yxnJCMLWDa","ywnOzwq","y2HnyxHdB3u","yKPfBNq","uwPQzK8","qLv5uge","ChvpwvC","shbkDhC","t3bLBKv2zw4","D0DwAui","vgLTzw91Da","AhzYrfG","wLzguuq","yxnL","r0r4yLC","mJK5nZCYExPUC3jc","DhvWDKO","wfzXz0O","zxmGCMvHy2G","x3DHAxq","yNHfquq","r1LOAK0","y3jLyxrLt3a","AvH2DNi","EKL5D0i","sMz3tNa","C0nVDw50zxi","y2XLyxi","qwv0BeW","Dgv4Dc9Qyxy","Dgv0yNu","y291BNq","zxDut2y","v2PiDhy","BLLXq1O","ugDiru8","DKn0Cg8","AM9PBG","t2XZDu8","EKDyv0W","Cu1OCMC","AMv0CKS","B1fuAuW","ANLMA1e","BM5Ly3q","qwr6u20","z0rjqMm","zKHnzum","y05OAwO","ENn6DNy","u0H1ufu","yw1Lu3bHy2u","Dvrzr2K","u2vXsuq","seXyu2C","BhrPCgXLihq","CxjQrMm","t1HhA2m","vuPmAhu","vxnlELi","u3z6sMK","C29YDa","CM9YrxzLBNq","zw50tgLZDgu","sMjNqMu","CMvWBgfJzq","BMCGB3iGyw4","y2fSBa","EK1nvhG","r3PAwLK","AxnbCNjHEq","z2v0qwXSs2u","yLPfs3O","B3v0sw50zxi","Eg1cqMS","zw5HyMXLvhi","tNbfC2e","vNrJEKe","z1rPBwvVDxq","Be1ewwe","vLvNvLO","Bg9NsurozxC","wfHwuLq","uffyqM4","ihrYEsbYzwm","y3jLyxrLtwu","C2v0u3rVCMe","x3nLBMrby2S","B25VCgvU","B25ozxr3B3i","CfrwAfm","EwD2zvy","y0XLC3G","z0v6zKC","yNbWsu0","sw9wy2i","AwDQAMW","qNnhuwK","ELfxCfe","AfHjthG","CKrmvfm","A1n0yxr1C0m","DMfS","igzPzwXKoIa","BuLlvwe","D3nZoI8V","zergtge","Bhzyvem","zfzHDLi","CMvJzxzPzwq","y3jLyxrLrxi","D0rcALi","Exnwr3i","CMfTzq","yNL0zuXLBMC","CKnMte8","tKfusvzfx0u","B3jRig9MzMW","BNrLCG","zgf0yq","uvLiq0O","zgvIDwC","su5tvefova","AxnSEgu","z2v0u3rVCMe","wNbnvvO","y0LwA2G","wvngDxu","u2j0rKe","wvPQwKS","wgTgz2m","y21nqw4","BMv4DcGPigm","z2v0s2v5","yujiAMm","D1LtzNi","wejctfq","x3bYB3rVy28","sLz6rM0","y3vYCMvUDeu","DMHpzwS","AxnrB1nnzxm","tMfTzq","DLL3Bfq","B25tDgfYDfi","ugr5Ag4","B3jRzxjhBg8","Bgrfuu0","ExbrqMC","twzmq0q","x2LZtM9Kzq","CM16De8","y2uGBM90igK","zMXTve0","wxj6z0G","yxrHlcbKyxq","zuP0Au4","s1zyzNK","B2zM","Bwf4twvZC2e","x2nSzwfYvgK","ugTjrg8","De1HBMfNzxi","wgrsChy","C2Ptyue","rufRyve","rNjVBNrPzxi","BMnRwwO","u1Peuxm","z2vjBMzVu3K","s1rsBvq","zKXhqNa","ugHXu0K","swfcwfm","EhHMCvK","vLzIDgu","s2vHrwO","wKHJEKq","ywLfyum","rePqDeW","x29WDgLVBNm","BM9Uzv9UB24","C2fTr04","BeHHBMrSzxi","B25LCNjVCG","nta5nLz6B2TyyG","x2n1CNnVCK0","DhPlA20","DhjPzxmGCMu","t2jQzwn0","q3DhvLi","AxjLza","BhvUqvi","vMXQuM4","Dg9oDw1Izxi","zxjTr2i","uvPUqKy","rgf4A3a","qw1VDw50","zwnVBM5Ly3q","y1Hnuem","u3rYyxrLz3K","Be9jCxG","AevKvgi","wvHzquK","Dg9cExrLC0i","t05nEKe","tMP3y08","BgfYzK8","tLLOuMy","Ef9MCM9UDgK","x2LUAxq","BNn1vge","q3HRDNu","y3vYC29Y","t1PMzg0","CvHcEfK","ywnRDxbfBMq","zfDVCMTLCKC","zw9yufu","BgvUz3rO","B0zJBwu","CwjdBNq","AwXK","ENrQvxi","BwLUAvbYB2C","thnZDe0","txn1Dui","AhP5zxa","A2v5","se5XsgK","B2jpuem","BeTVr1u","B3vUDa","uhHpug0","tNHfCuC","DMfSDwvZ","y29TCgXLDgu","AgXzu2W","DxnLCKLW","x3bHDgHlzxK","AhztEfa","AK9QCgq","EgrWr3O","t1bbEu8","yxvNthC","ChjVy2vZCW","ENHTv3i","x2LUAxrqCM8","y3jLyxrLt2i","B0ftBK0","C3z2rvO","DeLK","uMvHzcbWyxm","AgvKtwf4uMu","EvPMAuK","CeDPz3y","mZnKrwrPCuC","rMfUvMy","zMLSDgvY","BKXPBMu","EKH5vLm","u2TPCcbWyxm","D0HvuMm","Aw5JBhvKzxm","ihrVihjLDhi","Bwf4uMv0CMK","DwHOqMe","zgD6rMe","Cw9Zx18","ru51r2u","B3jLtMfTzxm","m3WYFdf8nhW","q3jowxC","BvriCg4","x3bPBMDqB24","zerkq0S","swHnu2W","zxHWB3j0CW","DK9eDMS","CfbTvu8","AxHbzNi","x29UrxjYB3i","ywr2yw5Jzq","twfLBfa","q2nXALC","sePKtfO","rLn2zM4","veLnu0G","DgLLCKPtt04","tMfJtuO","uNrNrvq","ve9TsxO","qKTVuhG","vvDxrvC","te5QDgi","yMXVy2TLza","x2rPC2nVBM4","tufyx1jfvfi","vKnsq0O","Bg9IywXty28","ruPiu1G","uuPAB2W","BhbMvfG","Cg5eDKy","BMrLEa","tuLYzxC","Cw9KEfG","txLWB00","CKDyEKi","y29UBMvJDgK","C3jJ","DwXTCeS","uMPrBeG","y29UDgLUDwu","Bwv0Ag9K","z01SALy","EgHQyNG","vKfYA1a","sgr3tvm","zw1PDa","uvD6wwi","AfPQqMu","x2rItMfTzq","AxnszwfKEq","C2HPzNq","ufPRCuS","mhWZ","yw5Nzq","BMv3vMvYC2K","AMHtvhq","zvvYBa","rNjhywW","C3vIC3rYAw4","vMLIv0G","zw5NDgG","wKz4v04","Dg9cExrLC0W","wNrVvvi","BfvnChG","tg9Nsuq","rwrewLe","D0zIEfO","v0zrwKu","tuzqAxi","uez1DMi","wM1cDM4","z0voCeq","C21Yq0m","zxjFywnRx20","yMLUza","AwXLtMfTzq","r1HjEhC","C0Xf","t2PjA28","y3jLyxrLq2W","x3jLywr5q2W","zgv2AwnLx2K","wu9UwK0","x2HHBMrSzva","uKj2rfG","sfnbCMW","D2jpAwC","q2HoEKW","Cg9PBNrdB24","tK1Wy28","yvHgEwq","zM9Yy2u","se5kzgu","tLjJuu0","CNzls2m","yNvMzMvYzwq","q3zeq24","A3fSBvu","ww5VDfq","s2zOuw4","nte0mZrMq2T2v2y","zgvS","A1rnEuW","ugn2tuu","s3jADey","s2TwDuO","y2f0y2G","vMTmtMG","s0Tsy2m","v0Tjwe4","BeLLrMC","B2zMC2v0","tgz6sKK","x2DLDeLUDgu","v3bkEvy","y1vLCfy","Bg5TBxa","DMP4C3C","uNHMtw4","v2rdrNy","BgHYtxG","DfvgCKy","Bwf4tg9ZC0m","zw5KCg9PBNq","y09Wzw4","zwrhzge","jMPZy2fSBgi","z3DiDNC","v2LqB3e","B3jL","rxjYB3jdB2q","zw5HyMXLqxu","Cgf5Bg9Hzfq","mJn5r0z0vuy","txvrsha","x2n1CNnVCK4","x2nSzwfYugK","x2LZqNjVD3m","tg9JAW","ywnRpwzYB24","yu5dsfm","tMvzyKm","q29Kzq","x2TLEvbHDgG","BNbguNy","ignVzgu6ia","CgjdrNa","A0nJu2y","qNbACxG","s01wve8","Cu9mtMO","x0rctMfTzq","EKXHtNa","wujgsw4","twvZC2fNzuu","sfnvuLy","x2LZtwLUAvq","q21uq1i","revOrui","ENvzBhO","C3rLBMvYCW","r2HjtLy","A0jWy3q","u3PPyNa","q3vZDg9Tq2W","EKjVD1C","EKj1rwq","yKzhEfi","zNjVBunOyxi","ExHpBKS","DhLWzq","BMCGDxjSoIa","ruXvqMu","ywrKq291BNq","zxH0zw5ZAw8","DLHcrgW","EevzsLK","v2LUzg93","zMzmAw5L","x2nYzwf0zvm","vu9uy3K","ywrKt25L","ugfizMu","BgLrshK","shL5vhe","B1jTA3q","x1fVu01HBMe","B25TzxnZywC","z0DfA00","zNjHBwvuExa","y3jLyxrLrwW","CLPIvMG","rNHOs1y","vxnPA1q","y3vYCMvUDeK","zNjVBujPDhm","B3bLBKrc","v3j0rNy","Dg9JD3q","twTeB2C","r0ziB3i","sNfosw4","C1bPqwi","AxvPAgW","BNb1quq","B25tDg9Wsw0","BxDHAgq","DwDJDvG","BgD0Bgq","CgLUz09Uy2u","yMfSrxzLBNq","zw5XDwv1zq","yxGGCMv0CMK","z0D1vgi","AKH4Deu","zw5fDMvUDa","t0Hjt1q","wLfgrLK","ywrKrxzLBNq","Dgv4DfbHEwW","v2zZrNe","DhjHA1i","BMDLza","zg9Uzq","z2vY","BM93","zNDZxZeUmc4","rKrOvey","zuPkzey","uhjPBwfYEuS","Efrurw52","BNruCMLLC0m","yKvNtMi","wfbXyMe","BNzSv2W","id4G","x3DZsw5ZDge","r29yzKu","AgTHsLu","zvvrDwW","wLvvA0O","CgLUz19VBMm","wNnitfi","Dev2zw50","EK9wDNK","CMvZDwX0","ugHbzMW","AwDHDg9Yt24","EhHMtgu","CKjUC1q","reLywuS","z0nRzK8","nJK1sLfqq1Lg","x2fKzfDZtgK","uvvhDgm","DgLTzw91Da","BMrWB2LUDfq","CLL0DKy","zNfjseC","A0HTreu","CfDSzK8","wxLLtNC","sNDPufi","icSG","tu1ZDuu","txnhChy","AwvsuKO","tvHVDfe","CfH2rw4","t3zkzwG","BMDuAw1LCG","lcbTyxGGCMu","t1bftL9fuLi","qwjVCNrfCNi","wuDHALy","C3vJy2vZCW","twLZC2LUzYa","q2foD08","B3LUvMu","ENHOyuG","AwPZrMW","AvLJuLu","CgXLyxnLiha","yw1LoIa","yNvmsLq","y05rD0O","v0PJquW","yxnZAwDU","nZi1nJC2uenfufbb","u3zjAwC","AxzTq0W","wKvbvgi","ChrVCG","CvvWrwy","r3LhuLC","z2POtxe","BfvJzKW","ru9OzKe","BgvY","vunfAvK","tKDFrvjst1i","wLnIqvK","t0HIwvK","AuLnwKW","uujpq3e","CMfNzvn5BMm","tMToue0","t3HnD1a","zxjYtM8","qNjPzgDL","rMzLAfi","B2XKvMvYC2K","zsbHihn0CMK","ELLmALa","AxjzsvG","wfDADxu","ywDLu2HVDW","Axvzyxm","rKLmrv9ot1q","CKvuzg0","sMzhCui","wvzSqKS","q0Xpu0ve","CgLUz0LUDgu","BKvxuLa","y2DbzLG","CgfNzxnOB3C","Cgu6ia","mtjewujItMS","yKzSELu","CMvJB25Uzwm","rfvyD3K","yMvvywm","y29UDgv4Da","BMvY","tLjwy2m","quvgCfi","CenQAhC","qunQBfq","C2v0q3vYC28","z0z6zum","tw9KDwXL","tLPytuO","DxnNteS","r3bMrvq","BLnsD2W","z2v0sxrLBq","yxrLq291BNq","sKTRzxi","txbewwu","svjzt0m","DfHAr2S","x3bYzwzPEa","AgLNAa","DMjHvvC","tNPYr2S","z0jzA0K","zKXlv1q","C3rYAw5N","yMjAC2i","CgfYC2u","ign1CNnVCIa","zfb1seS","BgHhtM0","CMvZzxrdB3u","uNvTENO","Eervrui","x0vysvnu","EuPLt0O","zLHQENm","B3bLBIa","B3HMCgW","y29KEKO","Aw5KzxG","rfrjq0O","z2v0q3vYC28","svnlruO","DhfZqwi","DcbSAw1PDa","x2LZsw5PDa","BNrfBMrWB2K","AwXLx25HBwu","zcbLCNjVCI4","DxbKyxrLq3u","yNLL","C2DPza","r0f2uLu","CfDeq0u","q0Ltuem","uLPzuuy","rNfptNq","uKz1s3O","ELbOtMi","r0LqrKO","BxDTuvC","EfPKAwS","CLnitLi","zMzMzG","D1jXuxu","tg9NsurozxC","x3nLCuLK","Bg93","yxb0EeS","z0v4u0S","uNvyq2u","x2nVBM5Ly3q","wwXoswK","Dw5KzwzPBMu","zwvKzwq","x2zVCM1HDeu","wvLxChi","wNjLqK4","BezSDxnO","A1HrDfe","BIWGAg9ZDg4","uNfvEvC","x2LUDgvYDMe","AeDiwxi","Dw5ZAwDUzwq","z2v0qwXS","CMfUzg9T","Buv1Agu","CNzHBa","tuvtu0fhrv8","wePlEuO","nhW1","Dhj1y3rVCIa","zKnSu2y","sLjrvwK","BwvKAwf0zwW","q29UzMLN","refSsuy","vgPtsxu","DgTlDei","x29Uq2XVC2u","vufIuw4","v2L2Du4","zwreqM0","AgDprui","ugDjsgG","yxbWBhK","CMvHC29U","CNzHBfzHBhu","x2rYB3bhBg8","vuXiEwq","Ec11C2uT","CuzpvvC","D3jPDgvvAw4","B0rjrxe","D3fwCfm","zK9VyLq","vw5PBxbSzw0","u2jXwvy","r3v1q1q","yKzcA04","DND1sM8","x25HDMLNyxq","qu96CKG","y3jLyxrLuMu","uwH6v3i","DMvY","zMXhvg0","B3vNEue","vu1NzuW","vwr3quC","ChjVDg90Exa","r21Qzg8","x3jLBw92zvC","vuDgv0G","quXm","Dg9Y","CNnVCL92ywW","ywDLrxzLBNq","q0Pbvxi","CKL5t3y","wvb4CLi","AgXurey","CM92AwrLihC","sfDYqwO","q0Xpu0LorW","B25SAw5L","AK1cyKm","y2XVC2uSihC","AhP3B0m","AxnrB1nby2S","vu9sD24","svfxA2i","zw50zwqGDhK","wLrVu2C","s3HzwK4","CMvQzwn0","qMzktfG","CuHTq3K","t0njq2C","r29Kvhe","tNHUCge","CLbKB1C","uNPLyKq","B2LUDfjLywm","Avrcu3e","rgjqtxq","werREu0","x3jLy29UBMu","ve9oC0S","yxjYyxLIDwy","DMfbuxu","CgXyAgS","zxjHDg9Y","B0ncwLG","thHmuMq","ENrXBLC","zwn0","CuHZree","ELHRCNO","qMXtzNq","z29PBMCGyxC","y2HLy2Tszwe","qxzfrhe","B2nRzxrtDwm","C2v0zgi","C0ToAKK","v2D5De4","quXcr2y","C3bSAxq","Cg9PBNrbBMq","DxjS","x3DZ","zhncv3i","yxv0BW","CMPswvi","qMzbwMW","uNzIC2S","tKHXrum","BK9kALy","v2vPEgLUsLm","Ae1LC3nHz2u","t0HqtvO","qKf2AfG","B2fK","y29UBMvJDa","DgPiCe8","wgDHzuG","yNL0zxm","qLr2t3q","AxHpAMi","DMvYC2LVBMm","vu9eteS","DMvUDa","D29MuNi","mdaWmdaWmda","sfn1uNu","yMzRCvK","vuPzs2W","z0v5qLm","ywWGy3vYC28","ihzHBgLKihm","uvvyvK4","mJG1ndK3mvfRueTdyq","x29UtwvZC2e","ruDhrNa","zg1dv04","wvLxsNy","C2vUza","swXYy3K","ExnOEKq","rwfOEw4","B2fYCfu","AxjZsxC","x2rPC3bHDgm","CMvJzwL2zwq","zxrxB3jRq2G","CMvZB2X2zq","zMLN","zgvMAw5Luhi","zgvJB2rLzey","q09otKvdveK","z0vvu1a","CNnVCL9Uyw0","igXHCMDLCIa","Aw5N","AwPLvgu","BgLZDgvUtMu","Efbgvui","ywX3yxLZ","rhPtrhO","sgDbwM0","AhvzsLq","EhD3r3G","rLrnBwy","x3fVC0rc","yMLUyxj5","zMzLCG","AgfZt3DUuhi","yMPxAwi","x2XPC3rLBMu","ihbYB3rVy28","q2rdB3O","B2jQzwn0u3q","rxzTEue","Ec1TC2CTy3u","x2vUzhbVAw4","wLP5CeW","sKjfBva","u21pyMS","B3LXs1O","u0jbwKq","v3vfsuW","AhDKwhy","D24GCMvHC28","zeDJBMK","rgToCfi","BK5mEMe","A092quy","Eevltei","DeX2DvO","rer5tgi","qwDzvLC","DfvXChe","BxrZqKW","zNjVBuHHC2G","zxjYB3i","wM1XvwS","uMHsB3y","rvjst1i","rgvKAwnHDgu","txPVAK0","zgzhBLG","zMLUza","AeDpCxO","DcbVzIbYyw4","vLnpyxm","yM54CeC","z3Dlr2W","rg53sxm","sgLiDe0","t1bftG","v2vMBNG","vfr0yK0","C3rHCNq","z2v0","CMvKDwnL","Cuz4y0O","Aw5IBhe","D2vI","Bwjnweu","Be9Ssxm","Ae9Wzw5fDMu","uNbrCu0","CM5tufy","BxnNsuq","yuDAtLK","D056uNC","zxH0ugf5Bg8","CMvWBgfJzui","BNrbBMrvCgq","tgT2z3C","B3bLBG","BMfTzq","BMCGzMfPBgu","C0XPC3rLBMu","mNWXFdr8mhW","C0vNC3i","DgHLBG","tKrtzhG","Aw9U","vMLbAMO","CMvHzfvjBNq","vLHdv2i","yw1L","u2HHCMvKv28","quTNzhi","wuvmz2S","Cg93","q2PPwuS","uwf6su0","rKT5wwS","B25JBg9Zzq","BNvTyMvY","uenxy2G","ANL5DLK","ChbL","CeLrufG","EKj6uwW","mhW0Fdj8m3W","DKDeCNy","uKn3Aha","CgPzAvy","r3rbzey","t3LMDue","x2rLC3rYB3K","z2vtEw5J","swHZvw0","zwrPyxrLBhK","u2LfyMW","x29Ut3bLBG","CenIzvK","ywnRtxnNswq","suXosuK","r1jJEeq","DeLUDgvYy2u","EKDPt3m","CMTLCKDSB2i","rLjUDfe","rMHiqLi","Cw9Z","C3j5Afm","rwLXD3y","AKXHzhq","y1nLD2q","rLDt","r2Tevfm","zNjVBNrPzxi","ywjVCNq","zxvdyMS","wK1oBxC","C2v0y3vYC28","DNDbv2y","BwLUzW","wwXnBK0","zNjVBuj5Dgu","Cxrbueu","z2v0t3DUuhi","B25fCNjVCG","uLfLBNi","rfrNq1C","yNLrCe4","Cg9W","EfHXzfG","A1f5wg0","x29UvgLTzw8","y29Kzq","vuH2qxO","C2vUDa","uKHMr2W","qK1wChi","yvngrwO","BhPOD3e","zcWG","qwX2yxy"];return ko=function(){return t},ko()}function Gb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,f={rkHid:function(_,w){return _(w)},gEUSP:function(_,w){return _(w)},CDsGj:l(1655),cLcwx:function(_,w){return _(w)},cDoig:"upgraden"+l(1078)},x=indexedDB[l(1326)](t,e),h=f[l(1792)](Lt,x);return i&&x[l(888)+"Listener"](f.cDoig,_=>{let w=l;i(f.rkHid(Lt,x[w(915)]),_[w(981)+"on"],_[w(723)+"on"],f[w(1246)](Lt,x[w(1673)+w(1334)]))}),r&&x[l(888)+"Listener"](l(690),()=>r()),h[l(1332)](_=>{let w=l;c&&_[w(888)+"Listener"](f[w(1617)],()=>c()),o&&_[w(888)+w(1477)](w(1215)+w(1841),()=>o())})[l(776)](()=>{}),h}function qb(t,{blocked:e}={}){let r=M,i={fbCLr:r(690)},o=indexedDB["deleteDa"+r(1744)](t);return e&&o[r(888)+r(1477)](i[r(1703)],()=>e()),Lt(o)[r(1332)](()=>{})}function Ju(t,e){let r=M,i={oRmkt:r(1637),lfIUc:function(x,h){return x in h},rBnsT:function(x,h){return x===h},COoPb:r(1028),fJRxJ:function(x,h){return x!==h}};if(!(t instanceof IDBDatabase&&!i[r(1641)](e,t)&&i[r(919)](typeof e,i.COoPb)))return;if(To[r(1309)](e))return To[r(1309)](e);let o=e[r(459)](/FromIndex$/,""),c=i[r(1820)](e,o),l=nx.includes(o);if(!i[r(1641)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(l||tx[r(658)](o)))return;let f=async function(x,...h){let _=r,w=this["transact"+_(1334)](x,l?_(1713)+"e":i[_(855)]),S=w.store;return c&&(S=S[_(1043)](h[_(719)]())),(await Promise.all([S[o](...h),l&&w[_(893)]]))[0]};return To.set(e,f),f}var tx,nx,To,Hb=Xu({"node_modules/idb/build/index.js"(){let t=M,e={DJPtL:"5|2|1|4|"+t(721),UzlYA:t(1309),FrGal:t(527),jyfkQ:t(1089),YSFuu:"getAllKeys",QZnBF:function(o){return o()},lzhwq:function(o,c){return o(c)},tPcqP:t(1471),NYhRf:t(1646),pXvEn:"clear"},r=e[t(573)].split("|"),i=0;for(;;){switch(r[i++]){case"0":To=new Map;continue;case"1":tx=[e.UzlYA,e[t(726)],e[t(437)],e[t(521)],t(425)];continue;case"2":e[t(590)](Yu);continue;case"3":e[t(1406)](Fb,o=>({...o,get:(c,l,f)=>Ju(c,l)||o[t(1309)](c,l,f),has:(c,l)=>!!Ju(c,l)||o[t(1608)](c,l)}));continue;case"4":nx=[t(1850),e.tPcqP,e[t(603)],e[t(938)]];continue;case"5":Yu();continue}break}}}),jb={idb:function(t){let e=M;t[e(672)]=Promise.resolve().then(()=>(Hb(),ex))[e(1332)](function(r){return r})}},Zu={};function Nt(t){let e=M,r={nckYj:e(1353)+"1",KXjpZ:function(f,x){return f!==x}},i=r[e(561)][e(1193)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=Zu[t];continue;case"1":return l[e(672)];case"2":var l=Zu[t]={exports:{}};continue;case"3":jb[t](l,l[e(672)],Nt);continue;case"4":if(r.KXjpZ(void 0,c))return c[e(672)];continue}break}}Nt.d=(t,e)=>{let r=U;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object[r(1243)+"operty"](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Nt.o=(e,r)=>Object[t(1135)+"e"][t(1262)+"operty"][t(461)](e,r)})(),(()=>{let t=M,e={jetrK:function(r,i){return r!=i},edGda:t(1077)+"d",FenKZ:t(1011),hccAi:"__esModule"};Nt.r=r=>{let i=t;e[i(435)](e[i(795)],typeof Symbol)&&Symbol[i(1546)+i(1857)]&&Object[i(1243)+i(1814)](r,Symbol["toString"+i(1857)],{value:e[i(1414)]}),Object[i(1243)+i(1814)](r,e.hccAi,{value:!0})}})();var Ce={};(()=>{let t=M,e={JqQNT:function(a,n){return a(n)},qHsDA:function(a,n){return a+n},FRntQ:function(a,n){return a+n},xIItr:t(1435),BsDzl:t(555),rmztO:function(a,n){return a*n},pPmUO:function(a,n){return a*n},plXhk:function(a,n){return a(n)},NDSdx:function(a,n,s){return a(n,s)},ijsFl:function(a,n){return a+n},UCEiY:function(a,n){return a+n},UHvAz:t(377),VibWH:function(a,n){return a(n)},TSXra:"00000000"+t(1219)+t(1219)+t(1219),crQhO:t(1767)+t(1095),tUqpq:t(692)+t(1657)+"R",mTHpn:t(510)+t(1575),FSvfn:"OPEN_ERROR",FqONt:function(a,n){return a>n},aavyu:function(a,n){return a!==n},dPuHK:function(a,n){return a<n},PFuvb:function(a,n){return a<n},DaEum:function(a,n){return a!==n},xxfLe:function(a,n){return a-n},SZDQs:function(a,n){return a<n},wofRr:function(a,n){return a===n},mEuhe:function(a,n){return a<n},yWGfJ:function(a,n){return a||n},CqVNW:"vcNrA",WgytN:function(a,n){return a!==n},cXMPC:function(a,n){return a(n)},vjxsw:function(a,n){return a>>>n},nYqCZ:function(a,n,s){return a(n,s)},hlYSl:function(a,n,s){return a(n,s)},DtUob:t(946)+t(1727)+t(497)+t(623),RqUyW:t(946)+"required"+t(497)+t(1884),aGZNY:t(874),JdxQJ:function(a){return a()},NxEqG:function(a,n,s){return a(n,s)},CaNwO:t(1748)+"ame",OvWnk:function(a,n,s,d,u){return a(n,s,d,u)},UJYKl:t(1206),tkKtB:function(a,n,s){return a(n,s)},anyDt:function(a,n){return a!==n},qaExk:function(a,n){return a===n},FfehR:t(1838),PmZTu:function(a,n,s){return a(n,s)},cSewd:function(a,n){return a(n)},Szibp:function(a,n){return a!==n},gDIBc:function(a,n,s){return a(n,s)},GzZZY:function(a,n,s){return a(n,s)},vJQag:function(a,n){return a(n)},oarvL:function(a,n,s){return a(n,s)},ijeTe:function(a,n,s){return a(n,s)},AxMkC:function(a,n){return a!==n},eJJdF:function(a,n){return a===n},buLJT:t(1681),ztqnW:function(a,n,s){return a(n,s)},ynsLm:function(a,n,s){return a(n,s)},kTMyL:function(a,n){return a!==n},larfO:function(a,n,s){return a(n,s)},bxEAD:function(a,n){return a!==n},VkLNh:function(a,n){return a!==n},GFHor:t(1836),pLGPf:function(a,n,s,d){return a(n,s,d)},VJiGA:t(789),tocwt:function(a,n,s){return a(n,s)},CvDCn:t(1453),HEXzc:t(489),PdmnK:function(a,n,s){return a(n,s)},cMrea:function(a,n){return a(n)},GRcxD:function(a,n,s){return a(n,s)},UyzFF:function(a,n){return a&n},PxpcS:function(a,n){return a===n},bEgNb:t(946)+t(1727)+t(497)+t(447),dVavR:t(946)+t(1727)+t(497)+t(734),tqsAb:function(a,n){return a===n},ONMzA:t(946)+t(1727)+t(497)+t(1424),XkSVQ:function(a,n){return a===n},KjVCC:t(946)+t(1727)+t(497)+t(709),yxOnK:function(a,n){return a(n)},vcKdn:function(a,n){return a&n},FUrVP:function(a,n,s){return a(n,s)},wDBjR:function(a,n){return a>>n},wHURc:function(a,n){return a>=n},VtczA:function(a,n){return a!==n},nWXey:t(762),EvmyA:t(656)+t(1048),ieRRJ:"send_ack",uDKsu:t(1725),hXILx:t(713),GAJXX:t(647)+t(1048),rETdm:function(a,n){return a===n},hnkDB:"UnyMs",JfMVX:"abxLb",flGTm:function(a,n){return a&n},qnESl:function(a,n){return a+n},zxhaH:function(a,n){return a>>>n},ZIjBG:function(a,n){return a<<n},wYSfr:function(a,n){return a<n},wNzRw:function(a,n){return a===n},oGInz:function(a,n){return a+n},OqQnT:function(a,n){return a!==n},JVzFm:function(a,n){return a&n},puOYW:function(a,n){return a|n},yZfiI:function(a,n){return a<<n},mVqpU:function(a,n){return a<n},cUepV:function(a,n){return a==n},kHmDE:function(a,n){return a>=n},EIfnh:"QRVDX",lOIqx:t(1576),ypQBg:function(a,n){return a<<n},PQXBn:function(a,n){return a|n},KVXfy:function(a,n){return a<<n},codzJ:function(a,n){return a&n},vwuJo:function(a,n){return a&n},EOhfA:function(a,n){return a<=n},OXGkc:function(a,n){return a==n},qFOUW:function(a,n){return a>=n},XlGIy:function(a,n){return a+n},UJLhu:function(a,n){return a+n},YBFIn:function(a,n){return a+n},HiHtM:function(a,n){return a+n},itOvc:function(a,n){return a!==n},HxoEH:function(a,n){return a|n},pCbeY:function(a,n){return a|n},bnxpG:function(a,n){return a<<n},dVHBv:function(a,n){return a<<n},mKwDe:function(a,n){return a<<n},aDhFk:function(a,n){return a&n},smrCC:function(a,n){return a&n},OBSPw:function(a,n){return a+n},dAmpu:function(a,n){return a&n},Obeam:function(a,n){return a!=n},seSbc:t(1077)+"d",xxfqY:t(1468)+"DB failed",jFwIg:function(a,n){return a<n},ougyA:t(519),kMUPI:function(a,n){return a<n},vYwlT:function(a,n){return a+n},WivuN:function(a,n){return a<n},RzpFk:function(a,n){return a<n},WMDTR:function(a,n,s){return a(n,s)},iYcRU:function(a,n){return a>=n},VVbte:function(a,n){return a-n},GpfET:function(a,n){return a<n},mytzu:function(a,n){return a&n},gwKGl:function(a,n){return a|n},sryhS:function(a,n){return a&n},PcvME:function(a,n){return a&n},uxVtL:function(a,n){return a|n},ZQFFY:function(a,n){return a&n},ZMaNp:function(a,n){return a>>n},ittUr:function(a,n){return a|n},kYlaK:function(a,n){return a&n},BUyPa:t(1664),Czscv:"Ydbxp",NpEsa:function(a,n){return a<n},Nxnpa:function(a){return a()},gBYkI:t(886),GawHC:function(a,n){return a(n)},YPxrR:function(a,n){return a&n},FanVf:function(a,n){return a&n},VXCWb:function(a,n){return a(n)},NzUyA:function(a,n){return a<<n},beUac:function(a,n){return a&n},GtAdF:t(1012),PZkqK:function(a,n){return a(n)},lHZAd:function(a,n){return a<n},Wseas:function(a,n){return a&n},EpGYV:function(a,n){return a>=n},cZkuM:function(a,n){return a|n},eoXPU:function(a,n){return a&n},DFaNj:function(a,n,s){return a(n,s)},PSZAK:t(1452)+t(478)+"onnecting",ENuGe:function(a,n){return a<n},gVaSO:function(a,n){return a+n},LduGa:function(a,n){return a|n},bmoPJ:function(a,n){return a>>>n},gTxhG:function(a,n){return a(n)},UORwn:function(a,n){return a&n},zszvv:function(a,n){return a(n)},eJtiN:function(a,n){return a<<n},SBAZD:function(a,n){return a&n},jyyvY:t(1739),aUCDk:function(a,n){return a&n},xEKLB:function(a,n){return a(n)},rspCM:function(a,n){return a&n},wGViB:function(a,n){return a&n},edDBm:function(a,n){return a&n},xIOvi:function(a,n){return a(n)},MzojM:function(a,n){return a<<n},FaaUm:function(a,n){return a&n},zxmWr:function(a,n){return a(n)},zBzQl:function(a,n){return a&n},ZsHLR:function(a,n){return a&n},augLw:function(a,n){return a<<n},mOnlt:function(a,n){return a&n},WpJyV:function(a,n){return a|n},nHnSV:function(a,n){return a<<n},lUcfL:function(a,n){return a>>>n},RHfGl:function(a,n){return a===n},FTMmf:function(a,n){return a<n},lpfTX:function(a,n){return a+n},gExSK:function(a,n){return a>>>n},Rvbsk:function(a,n){return a>>>n},ENGca:function(a,n){return a&n},fJgQO:function(a,n){return a>>>n},unilF:function(a,n){return a&n},gwHvw:function(a,n){return a>>>n},jKLJi:function(a,n){return a!==n},lIeFg:function(a,n){return a|n},lKoGU:function(a,n){return a&n},ggPhB:function(a,n){return a&n},VCRCJ:function(a,n){return a>>>n},UAbQn:function(a,n){return a!==n},ISKEJ:function(a,n){return a|n},pCjhw:function(a,n){return a|n},dDJCK:function(a,n){return a&n},VljRn:function(a,n){return a|n},KkVuJ:function(a,n){return a===n},gjhMq:function(a,n){return a|n},KhVWj:function(a,n){return a|n},GIPFJ:function(a,n){return a<<n},GpAup:function(a,n){return a<<n},hvrDX:function(a,n){return a<<n},HWrAj:function(a,n){return a<<n},REbXa:function(a,n){return a>>>n},dmCWN:function(a,n){return a|n},lUMpx:function(a,n){return a<<n},ZPUnO:function(a,n){return a|n},JqNIn:function(a,n){return a<<n},QQeFE:function(a,n){return a&n},zQWpQ:function(a,n){return a>>>n},ulmpK:function(a,n){return a>>>n},tLnXR:function(a,n){return a>>>n},kWruv:function(a,n){return a>>>n},Lkvgw:t(1559),kmPiZ:t(948),hAFZC:function(a,n){return a(n)},SvIig:function(a,n){return a>=n},yepYi:function(a,n){return a+n},lhGNm:function(a,n){return a%n},hRxYb:function(a,n){return a*n},KwiPu:function(a,n){return a*n},KxYZN:function(a,n,s){return a(n,s)},hwdXv:t(1290),IUmku:t(1207),SClaC:"QSFUz",ChNzL:function(a,n){return a===n},rPdoW:function(a,n){return a>>>n},isjbZ:function(a,n){return a+n},YZjZK:function(a,n){return a<<n},nZOps:function(a,n){return a===n},Vqxfb:function(a,n){return a>>>n},qUpEf:function(a,n){return a===n},EYPIj:function(a,n){return a===n},FVSJi:function(a,n){return a+n},abXOs:function(a,n){return a===n},GoXfE:"AwkGc",vIoeS:t(566),MsGpv:function(a,n){return a&n},rvKKc:function(a,n){return a&n},YELgk:function(a,n){return a>>>n},WbnrG:function(a,n){return a&n},gUpGg:function(a,n){return a>>>n},uZleH:function(a,n){return a>>>n},RjQlH:function(a,n){return a&n},kqlmU:function(a,n){return a>>>n},xZdik:function(a,n){return a&n},Pdyhn:function(a,n){return a&n},iuYas:function(a,n){return a>>>n},cNQwJ:"CONNECTI"+t(970),zXkrz:t(1093)+"ERROR",qRiqm:"kOmNG",qodxX:function(a,n){return a||n},OvJeh:function(a,n){return a!==n},bLKnI:t(393),DUXwy:t(1865)+t(1447),yDjVP:function(a,n){return a(n)},xmBBk:function(a,n){return a<<n},dfoym:function(a,n){return a&n},vwAWf:"jWvCs",TjSIu:t(424),bJEnt:t(1574),xLZfQ:"tqqkN",gEzfG:function(a,n){return a||n},dqOVY:t(1271),eIriI:function(a,n){return a===n},oOtPT:t(1233),gEyBS:t(429),Gmjdo:function(a,n){return a||n},VKXlI:"string",VSOas:"manual r"+t(593)+t(1249),rFHiC:function(a,n){return a===n},nOJjV:"jsWpE",xDUEB:function(a,n){return a===n},islxe:function(a,n){return a===n},RQenr:t(1671),oASnM:"Unhandle"+t(1052),obOPC:function(a,n){return a===n},BMVpr:function(a,n){return a<n},lunAR:function(a,n){return a===n},vCtpo:function(a,n,s){return a(n,s)},MFPir:t(1655),DIXYK:t(1326),AOzrH:t(1156),gMljV:"message",hlLzc:function(a,n){return a!==n},YIQAh:function(a,n,s){return a(n,s)},CdCoz:function(a,n){return a+n},deyCY:function(a,n){return a+n},RpQqM:function(a,n){return a<<n},ZEATb:function(a,n){return a&n},DbGMZ:function(a,n){return a&n},MIrew:function(a,n){return a<n},QDmpC:function(a,n){return a+n},WBoVW:function(a,n){return a+n},kXQtQ:t(689),rGXzB:function(a,n){return a instanceof n},SiEbl:"idb",RqJYe:t(1311),nDWOy:function(a,n){return a||n},GoAdP:function(a,n){return a|n},ZToSg:function(a,n){return a+n},oFcme:"4|1|0|2|5|3",WthrA:function(a,n){return a|n},cNhij:function(a,n){return a+n},hzwoC:function(a,n){return a+n},NUtUh:function(a,n){return a|n},inblq:function(a,n){return a&n},GEIFf:function(a,n){return a|n},vyyat:function(a,n){return a&n},MmLPe:function(a,n){return a>>n},GhINV:function(a,n){return a|n},DWZqM:t(1466),zOVvy:t(1532)+"1",JEwqz:function(a,n){return a||n},MpDYe:function(a,n){return a+n},xhjbx:function(a,n,s){return a(n,s)},JwiPR:function(a,n){return a<n},YhNhq:function(a,n){return a<=n},qrjFc:function(a,n){return a>=n},nsuTa:function(a,n){return a<<n},PNzcg:function(a,n){return a&n},ermGb:function(a,n){return a&n},CISPC:function(a,n){return a&n},TTtbM:function(a,n){return a-n},eUQul:function(a,n){return a<<n},jFeOs:function(a,n){return a&n},fLGBp:function(a,n){return a&n},lhrMx:function(a,n){return a+n},ZreBN:t(1150),eBgJn:t(1390),WFQZE:function(a,n){return a<n},LfzJI:function(a,n){return a>>n},jplqH:function(a,n){return a&n},rCfLO:function(a,n){return a&n},mCofr:function(a,n){return a+n},BfAZl:function(a,n){return a+n},IrDcX:function(a,n){return a<<n},KWVpT:function(a,n){return a&n},PzjrS:function(a,n){return a|n},XPqba:function(a,n){return a>>n},DZxsc:function(a,n){return a|n},rKjSa:function(a,n){return a>>n},BsOxa:function(a,n){return a&n},sOXEJ:function(a,n){return a|n},YIOGD:function(a,n){return a&n},JfGqB:function(a,n){return a|n},bFGxR:function(a,n){return a&n},DBDPv:"applicat"+t(1436),WrtFv:"text/pla"+t(1541)+"et=utf-8",klRlM:t(1350),tjHpO:t(1499),uVwqt:function(a,n){return a(n)},HXGSH:"unknown "+t(1111),tUFrF:function(a,n,s){return a(n,s)},rlDUk:function(a,n){return a!==n},dOSaE:t(488),GDxbW:t(423)+t(394),bxvDK:"http",aXFyd:t(796)+t(809)+t(683)+"P",IfOyv:function(a,n){return a(n)},SOlVr:function(a,n){return a!==n},yIJwB:t(1866),MuQHp:t(490),MsuuB:t(526)+"alled mu"+t(449)+"imes in process",DTgCW:function(a,n){return a===n},ztBai:t(401),skHqH:function(a){return a()},VNEWD:function(a,n){return a===n},ldEQM:t(925),pWDCE:t(911)+t(1462)+"t",tXZGk:function(a,n){return a(n)},GMRtB:t(1849),vtfLk:t(1855),VFnzw:"KSaVO",fVaKr:"KmlZW",QUXVN:t(631),xdpGz:function(a){return a()},LNtvX:function(a,n){return a(n)},OyfuA:"nfGzD",JbgBe:t(1497),LSqXt:function(a,n){return a+n},mBlKJ:function(a,n){return a+n},IRYOC:function(a,n){return a===n},jwVib:t(1039),TtUDs:t(883),AEFpR:"script",GZYwX:t(1551),XJKyJ:function(a,n){return a||n},fLKWT:function(a,n,s){return a(n,s)},ALBGf:function(a,n){return a(n)},UsKzR:t(1164),YnotT:t(679),xbVgk:function(a,n){return a||n},Alqkr:function(a,n){return a||n},DiIDL:function(a,n,s){return a(n,s)},HLXSg:"XeZOR",RFuKz:function(a,n){return a||n},tdLcB:function(a,n){return a||n},BBcHW:function(a,n){return a||n},vNdTn:"message_id",ixOjb:function(a,n,s){return a(n,s)},dwgpz:function(a,n){return a(n)},GyyRW:function(a){return a()},bbZsb:function(a,n){return a===n},Uhnwp:t(1598),Alvav:function(a,n){return a|n},TONsK:function(a,n){return a|n},XqtGU:function(a,n){return a&n},YavIP:function(a,n){return a+n},zPhNb:function(a,n){return a>>n},QWzYb:t(934),ksQFV:"x_fronti"+t(1862),rIyOv:"x_frontier_qos_ack",HSArl:function(a,n,s,d){return a(n,s,d)},NupEv:t(604)+t(1847)+"k",LFtIx:t(604)+t(743)+t(1055),QJEnB:function(a,n,s,d){return a(n,s,d)},cmMAn:function(a,n,s,d){return a(n,s,d)},XdfqA:t(1733),SvzJi:"jpdGr",kQyXm:"LtNey",bzHUv:"ack_id",TOgtO:t(1757),Eidzd:function(a){return a()},zzWtH:t(1239),QazIM:function(a,n){return a(n)},DzSDz:function(a,n){return a(n)},TIMSH:function(a,n){return a instanceof n},tKlRj:"applicat"+t(1436)+";charset"+t(1606),AgYVW:t(575)+"e",qfORZ:t(1260),KrZtF:function(a){return a()},YpffF:function(a,n){return a>n},uTYGi:function(a,n){return a(n)},xmaje:function(a,n){return a(n)},aNCHS:function(a,n){return a&n},bFBkN:function(a,n){return a+n},Wefnx:t(476),IaBXS:function(a,n){return a+n},BRWWB:function(a,n){return a+n},lMDYa:function(a,n){return a+n},BXUrN:"index ou"+t(1299)+"ge: ",mSFSi:"LeEiR",PPSMn:t(1252),ykRba:t(1549),NpxFP:"ckkcI",aptxK:function(a,n){return a+n},xXqdX:function(a,n){return a<<n},dgzFa:"KwQXG",KojAK:function(a,n){return a+n},AetlL:function(a,n,s,d){return a(n,s,d)},zBowW:function(a,n){return a|n},qHmCy:function(a,n){return a<<n},ivmCL:function(a,n){return a|n},zGXWL:function(a,n){return a<<n},oCBZX:function(a,n){return a+n},kCcSf:function(a,n){return a>>>n},ivTlj:function(a,n){return a+n},czLNR:function(a,n){return a&n},WJwIF:function(a,n){return a+n},RCwhp:function(a,n){return a&n},iGnZa:function(a,n){return a+n},xiPGP:function(a,n){return a&n},PhAfl:function(a,n){return a+n},fHMeC:t(1794),YFgSV:"dRKAm",DnwIs:function(a,n){return a<n},UhmKM:function(a,n){return a&n},ZHczD:function(a,n){return a|n},LsstM:function(a,n){return a<<n},NYfrl:function(a,n){return a|n},OCICg:function(a,n){return a&n},HNqHi:function(a,n){return a|n},mwahd:function(a){return a()},zEZyP:function(a,n){return a<n},iHkWi:"ondTX",QRBqj:t(1856)+t(374),PZffk:"header",DRaQQ:t(1327),WlfUk:"curvalue",ztjUr:function(a,n){return a(n)},JCQxQ:function(a,n){return a(n)},iQclL:t(1683)+"ile_name",SbqYV:function(a,n,s){return a(n,s)},koYCs:function(a,n,s,d){return a(n,s,d)},mndIH:t(988)+"_EXIST",bURKq:t(516),WKIXN:"CONTINUE",iuihl:function(a,n,s,d){return a(n,s,d)},FVNXG:function(a,n){return a===n},ZtoUR:t(921),vbaUW:t(1189),xEYJY:function(a,n){return a+n},anyEO:t(1487),HUavS:t(1385)+"r",HhlcT:function(a,n){return a===n},WBjJL:t(1220),HhqRQ:t(1763),oDIEq:t(816),AKgdr:t(690),FKyYk:function(a,n){return a&n},wzVNx:function(a,n){return a>>>n},nNqOQ:function(a,n){return a>>>n},FxhKV:function(a,n){return a&n},otnal:function(a,n){return a>>>n},OPAyO:function(a,n){return a!==n},EGGFp:function(a,n,s){return a(n,s)},Rumzz:function(a,n){return a!==n},UdwAG:function(a,n,s){return a(n,s)},ILNII:function(a,n,s,d){return a(n,s,d)},WMQsA:t(1400),HsERq:function(a,n,s,d){return a(n,s,d)},hjtiB:t(604)+t(1571),rYtvF:t(1800)+"s",OYpLH:t(1269)+t(1247)+"e",IFVRv:function(a,n){return a(n)},pjYiV:function(a,n,s){return a(n,s)},hlTDF:"x-msg-cu"+t(1141)+"ue",yFnCP:function(a){return a()},DEhEB:function(a,n){return a>n},KKsIg:t(1351),hzyep:"OLiLP",DAlIF:function(a){return a()},pWlfO:"gEbqG",vpbri:"bVCZv",YlNIi:function(a){return a()},wAyXT:function(a,n){return a===n},fOobT:t(1867),nEWRP:"eElks",YYWpr:function(a){return a()},qOLNj:function(a){return a()},fOpmW:t(1143),rSHNR:function(a,n){return a===n},hZjBe:function(a,n){return a&&n},wqVpS:function(a){return a()},VwmEj:function(a,n,s){return a(n,s)},LSQkk:function(a){return a()},fYEFL:function(a,n){return a(n)},ZUUkJ:function(a){return a()},GYhjM:function(a,n){return a<n},HJdLZ:function(a,n){return a!==n},ypGHM:t(1586),pnuLo:function(a,n,s){return a(n,s)},cIVkh:function(a,n,s){return a(n,s)},PaHfe:function(a,n){return a|n},Cxkvu:function(a,n){return a|n},vZjXt:function(a,n){return a&n},JKker:function(a,n){return a>n},CUYxE:function(a,n){return a&n},vaAQu:function(a,n,s){return a(n,s)},QhzWr:function(a,n){return a&n},ZFxWN:function(a,n){return a===n},akRaW:function(a,n){return a===n},UqaXi:function(a,n){return a!==n},BpZqx:function(a,n){return a===n},mvSmC:t(858),rtAmu:function(a,n){return a!==n},KeaEj:"ZUZqM",IzeYd:function(a,n,s){return a(n,s)},FDhTF:t(418),WfsFq:t(1054),euCbk:t(1174)+t(1578),aNdDE:t(1540),AdzSm:function(a,n){return a/n},Tuetq:t(1198),jLadt:function(a,n){return a==n},sPiAb:function(a,n){return a===n},jNiem:t(952)+t(386)+"alid url",YYWJv:function(a,n){return a(n)},UMgeL:function(a,n){return a===n},JRQUi:t(769),roQDR:function(a,n){return a&n},Ojsgb:t(1561),qbCnt:t(1728)+t(1362)+t(1504)+"ct",dsBWr:t(1609),QjjfO:"pageshow",PHJke:function(a,n){return a===n},LjlQI:"YLkbD",Pxwid:t(499),SbtFA:"QmPco",cZcuV:t(1488),KkXhG:"pagehide",VArkP:function(a,n){return a!==n},OiEDH:function(a,n){return a==n},fJSVE:"ws://",NMpco:"OPzsB",UODLK:t(1318),yshzD:"bd_did",bncMt:"ttwid",jOjpd:t(952)+t(1490)+t(1885)+"viceID or ttwID",WnXOS:t(1518),glfPO:t(1313),KaPCm:t(896)+"0",IbvCg:function(a,n,s){return a(n,s)},ZMNmw:function(a,n){return a||n},vYZDg:t(1e3)+"t",fqIHG:function(a,n){return a(n)},jMBbC:t(1682)+">",hkaJU:function(a,n){return a*n},GoocJ:function(a,n){return a-n},mIKUa:t(1074),wMyla:function(a,n,s){return a(n,s)},ZmqUk:t(1185)+t(1839)+"reconnec"+t(1615)+t(1130),tViRX:function(a,n){return a&n},sNtaP:function(a,n){return a&n},MgYTL:function(a,n){return a>>>n},tKpjk:function(a,n){return a&n},XCHHU:function(a,n){return a>>>n},bjWib:function(a,n){return a>>>n},qYdYT:function(a,n){return a!==n},qXBxY:t(1038),irsIw:"pBmPX",qfMAB:"3|0|2|1|4",OtiBt:t(601),fClSf:function(a,n,s){return a(n,s)},JfwNp:t(1419),BsGQi:t(746),FtqMx:function(a,n){return a+n},LxLRd:t(1109),irYIX:"rSxWx",ZVFQD:t(1434)+t(378),UGPKD:t(1152)+"s already closed",VDGAb:t(952)+t(1593)+t(1583)+t(549)+"a must b"+t(982)+t(460)+" arraybu"+t(1261),HTnZI:t(1347),cwINr:t(952)+t(1593)+t(1225)+t(374),oEZOu:function(a,n){return a(n)},usISd:t(1402),Wqwtf:function(a,n){return a<n},kYYhc:t(881),NacMJ:function(a,n){return a==n},flmTM:t(1708),sjSaA:"DypFc",ncPNf:t(945),aBHjc:t(911)+t(1735)+"s",kOvAF:"\0\0\0\0\0\0\0\0",BTmln:function(a,n){return a*n},LWahg:function(a,n){return a!=n},HgAZm:t(847),mBDIp:function(a,n){return a===n},ZmJLu:t(583),iXvvr:function(a,n){return a===n},lKhQJ:function(a,n){return a!=n},ygveV:t(1294)+t(612)+t(694)+"pe",YSeLj:function(a,n){return a===n},GDhSc:t(1339)+t(1371)+"alScope",dGcni:"ServiceW"+t(540)+"balScope",nvlWl:function(a,n){return a!=n},ysVGr:function(a,n){return a!=n},FKXUp:function(a,n,s){return a(n,s)},uKqag:t(1692)+t(663)};Nt.r(Ce),Nt.d(Ce,{FWS:()=>Up,CustomErrorEvent:()=>jd,createCloseEvent:()=>xt,ReconnectEvent:()=>Hd,createErrorEvent:()=>ot,decodedFrame:()=>Zt,createOpenEvent:()=>Jd,CustomCloseEvent:()=>Wd,createReconnectEvent:()=>da,FrontierMessageEvent:()=>$d,encodeFrame:()=>Bt,createMessageEvent:()=>Yd,OpenEvent:()=>Vd,ErrorCode:()=>Qt,Event:()=>Yn,MessageEvent:()=>Kd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(895)](),u=r||(r=e[n(1509)](x,a)),p=Math[n(1090)]()[n(1546)](16)[n(1610)](-6);return e[n(1182)](e[n(1372)](s,d)+u,p)}function o(){let a=t;if(e[a(1653)]===e[a(1523)])_0x4afe6d[a(889)+"oad"]="",_0x55dd07[a(1740)](_0x103c84);else return e[a(545)](1e4,Date[a(895)]())+Math.floor(e.pPmUO(1e4,Math[a(1090)]()))}function c(a){let n=t;return e[n(1372)](e.plXhk(Array,8)[n(431)]("0"),e[n(1333)](parseInt,a,10)[n(1546)](2))[n(1610)](-8)}function l(a){let n=t;return e[n(950)](e[n(1509)](Array,4)[n(431)]("0"),e[n(1333)](parseInt,a,2)[n(1546)](16))[n(1610)](-4)}function f(a){let n=t,s=a.split(/\./).map(p=>c(p)),d=[];return d[0]=e[n(1509)](l,e[n(969)](s[0],s[1])),d[1]=e[n(1176)](l,e[n(969)](s[2],s[3])),[n(377),e[n(1401)],n(377),e[n(1401)],n(377),n(1067),d[0],d[1]][n(431)]("")}function x(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(a);return s?e[n(728)](f,a):d?e[n(1509)](h,a):e.TSXra}function h(a){let n=t,s={ViAjj:e.crQhO,UWWEW:e[n(1287)],QYHCJ:n(1093)+"ERROR",wFbxZ:e[n(668)],AvEDq:e[n(681)]},d="",u=[],p=0,m=0,E=!0,g=e[n(1401)];if(e[n(1060)](a[n(1678)]("::"),-1))if(e.aavyu(n(1005),n(1005))){let k=s[n(1335)][n(1193)]("|"),N=0;for(;;){switch(k[N++]){case"0":_0x5211e0[_0x4f7af3[s[n(688)]]=5003]=s[n(688)];continue;case"1":_0x41f9c5[_0x199d53["CONNECTI"+n(970)]=5002]=n(1245)+n(970);continue;case"2":_0x35973c[_0xa32aa1[s[n(514)]]=5004]=s[n(514)];continue;case"3":_0x545c75[_0x76ebcd[s.wFbxZ]=5001]=s[n(736)];continue;case"4":_0x4065b2[_0x50303a[s[n(1187)]]=5005]=s.AvEDq;continue;case"5":return _0x2aeb87}break}}else{let k=a.split("::");for(let z=0;e[n(1032)](z,k[n(614)]);z++){let H=k[z];if(H[n(1678)](":")>0){let L=H[n(1193)](":");E&&(p=L.length),m+=L.length;for(let F=0;e[n(739)](F,L[n(614)]);F++)if(e[n(1835)](4,L[F][n(614)])){let se=g.substring(0,e[n(918)](4,L[F][n(614)])),qe=se[n(1437)](L[F]);u[n(1889)](qe)}else u[n(1889)](L[F]);E=!1}else{if(e[n(1835)](4,H[n(614)])){let L=g[n(727)+"g"](0,e[n(918)](4,H[n(614)])),F=L[n(1437)](H);u[n(1889)](F)}else u[n(1889)](H);E&&(p+=1),m+=1,E=!1}}let N="";for(let z=0;e[n(1032)](z,8-m);z++)N=N[n(1437)](g);for(let z=0;e[n(562)](z,u.length);z++)e[n(1218)](z,p)?(d=d.concat(N),d=d[n(1437)](u[z])):d=d.concat(u[z]);return d}{let k=a[n(1193)](":");for(let N=0;e.mEuhe(N,k.length);N++){let z=k[N];if(e[n(1698)](4,k[N][n(614)])){let H=g[n(727)+"g"](0,e[n(918)](4,k[N][n(614)])),L=H[n(1437)](z);d=d[n(1437)](L)}else d=d.concat(z)}return d}}function _(a,n){let s=t;if(e[s(1698)]("VivBp",e.CqVNW)){let d=a[s(623)];e.WgytN(void 0,d)&&(e[s(1333)](ue,n,10),e[s(1333)](W,n,d));let u=a[s(1884)];e[s(1191)](void 0,u)&&(e.NDSdx(ue,n,18),W(n,u))}else{let d=this[s(1259)][s(1016)](this[s(1022)]),u=_0x2ee41f[s(1030)](e[s(1803)](d,"{}"));return _0x4f6fec[s(630)](u)}}function w(a){let n=t,s={};e:for(;!e.cXMPC(J,a);){let d=e[n(594)](fe,a);switch(e.vjxsw(d,3)){case 0:break e;case 1:s[n(623)]=O(a,e[n(728)](fe,a));break;case 2:s[n(1884)]=e[n(428)](O,a,fe(a));break;default:e[n(632)](C,a,7&d)}}if(e[n(1218)](void 0,s[n(623)]))throw new Error(e[n(1568)]);if(s[n(1884)]===void 0)throw new Error(e[n(1085)]);return s}function S(a){let n=t;if(e[n(1698)](e[n(1320)],e[n(1320)]))_0x115d13.body[n(1529)+n(617)](_0x3534af);else{let s=e.JdxQJ(R);return e.NDSdx(b,a,s),e.cXMPC(G,s)}}function b(a,n){let s=t,d=a[s(447)];d!==void 0&&(e[s(1191)](e[s(1222)],"tzERI")?(e[s(629)](ue,n,8),e[s(1103)](ut,n,d)):(this[s(864)+s(699)]=0,this[s(533)+s(926)+"riesCount"]=0));let u=a[s(734)];e[s(1876)](void 0,u)&&(e.qaExk(s(1838),e[s(980)])?(e[s(1103)](ue,n,16),e.NDSdx(ut,n,u)):(this[s(1639)+s(917)+s(1428)]=_0x1bd535,_0x258b88?this[s(390)+s(654)]():this["_handleO"+s(848)]()));let p=a[s(1424)];e[s(1835)](void 0,p)&&(e.PmZTu(ue,n,24),e[s(1481)](ut,n,e[s(1378)](P,p)));let m=a[s(709)];e[s(833)](void 0,m)&&(e.gDIBc(ue,n,32),e[s(463)](ut,n,e[s(1688)](P,m)));let E=a[s(1429)];if(e[s(1698)](void 0,E))for(let se of E){e[s(1415)](ue,n,42);let qe=e[s(1825)](R);e[s(1250)](_,se,qe),ue(n,qe[s(1829)]),e[s(629)]($,n,qe),e[s(1509)](D,qe)}let g=a[s(1882)+s(1521)];e[s(1720)](void 0,g)&&(e[s(898)](e[s(954)],e[s(954)])?(e.PmZTu(ue,n,50),e[s(1180)](W,n,g)):(this[s(805)+"ameSpace"]=_0x13c17a,this[s(1630)+s(745)]=_0x34863a,this[s(1421)+"Strategy"]=_0x3e6ba6,this._qosDB=e[s(629)](_0x3d1622,this[s(805)+s(445)],e[s(947)])));let k=a[s(802)+"ype"];e[s(1835)](void 0,k)&&(e.gDIBc(ue,n,58),W(n,k));let N=a[s(1828)];if(N!==void 0){if(e[s(898)]("hGnCJ",s(1190)))return this[s(1259)]?.[s(718)];e[s(1333)](ue,n,66),e[s(1531)](ue,n,N.length),e[s(1481)](he,n,N)}let z=a[s(1069)];e[s(772)](void 0,z)&&(e[s(1180)](ue,n,74),e[s(602)](W,n,z));let H=a[s(1596)+s(1387)];e[s(414)](void 0,H)&&(ue(n,82),e[s(1333)](W,n,H));let L=a[s(1319)];e[s(777)](void 0,L)&&(ue(n,90),e.gDIBc(W,n,L));let F=a.frameType;e[s(414)](void 0,F)&&(e[s(898)](e[s(870)],e[s(870)])?(e[s(1333)](ue,n,96),ut(n,P(F))):wZsIRl.OvWnk(_0x5b3cb1,_0x258949(_0x43121b.result),_0x33bbd1.oldVersion,_0x1e6d2e[s(723)+"on"],wZsIRl[s(1509)](_0x4b7015,_0x154286[s(1673)+s(1334)])))}function v(a){let n=t;return e.vJQag(I,e[n(1509)](B,a))}function I(a){let n=t,s={GCkKq:function(u,p,m,E){return e[U(1741)](u,p,m,E)}};if(e[n(1557)]!=="YxaOr"){let u={};e:for(;!e[n(1378)](J,a);){let p=fe(a);switch(e[n(787)](p,3)){case 0:break e;case 1:u[n(447)]=e[n(868)](vt,a,!0);break;case 2:u[n(734)]=e[n(868)](vt,a,!0);break;case 3:u[n(1424)]=e[n(594)](fe,a);break;case 4:u[n(709)]=fe(a);break;case 5:if(e[n(1835)](e[n(766)],e.HEXzc)){let m=e[n(1176)](A,a);(u.headers||(u[n(1429)]=[]))[n(1889)](w(a)),a[n(1829)]=m;break}else this[n(533)+n(926)+n(1764)+"t"]=0;case 6:u[n(1882)+"ncoding"]=e[n(1788)](O,a,e[n(1690)](fe,a));break;case 7:u["payloadT"+n(1536)]=e.nYqCZ(O,a,fe(a));break;case 8:u[n(1828)]=e.PmZTu(be,a,fe(a));break;case 9:u.LogIDNew=e[n(1333)](O,a,e[n(1176)](fe,a));break;case 10:u["serverTi"+n(1387)]=O(a,fe(a));break;case 11:u.msgID=e[n(1368)](O,a,e[n(1176)](fe,a));break;case 12:u[n(859)+"e"]=e[n(1176)](fe,a);break;default:C(a,e[n(1470)](7,p))}}if(e[n(1745)](void 0,u[n(447)]))throw new Error(e[n(902)]);if(u[n(734)]===void 0)throw new Error(e[n(502)]);if(e[n(1047)](void 0,u[n(1424)]))throw new Error(e[n(600)]);if(e[n(1558)](void 0,u[n(709)]))throw new Error(e.KjVCC);return u}else for(var d in _0x485432)OGVHhA.GCkKq(_0x59a760,_0x218196,d,{get:_0x5a1e1b[d],enumerable:!0})}function A(a){let n=t,s=e.yxOnK(fe,a),d=a.limit;return a[n(1829)]=e[n(1372)](a.offset,s),d}function C(a,n){let s=t;switch(n){case 0:for(;e.vcKdn(128,e[s(1690)](ie,a)););break;case 2:e[s(1651)](Y,a,fe(a));break;case 5:Y(a,4);break;case 1:e[s(428)](Y,a,8);break;default:throw new Error(e.ijsFl(s(1121)+s(1157)+s(997),n))}}function P(a){let n=t;return a|=0,{low:a,high:e[n(505)](a,31),unsigned:e[n(657)](a,0)}}let y=[];function R(){let a=t,n=y[a(1396)]();return n?(n.offset=n[a(1829)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function D(a){let n=t;e.VtczA("WNDaH",e.nWXey)?y[n(1889)](a):this.on(_0x18d05d,_0x48f3c0)}function B(a){return{bytes:a,offset:0,limit:a.length}}function G(a){let n=t,s=a[n(1212)],d=a[n(1829)];return e[n(1745)](s[n(614)],d)?s:s[n(1815)](0,d)}function Y(a,n){let s=t;if(e[s(1372)](a[s(781)],n)>a[s(1829)])throw new Error(e[s(1268)]);a.offset+=n}function J(a){let n=t;return a[n(781)]>=a[n(1829)]}function te(a,n){let s=t,d=a[s(1212)],u=a.offset,p=a[s(1829)],m=e[s(950)](u,n);if(e[s(1060)](m,d[s(614)])){let E=new Uint8Array(2*m);E.set(d),a.bytes=E}return a[s(781)]=m,m>p&&(a[s(1829)]=m),u}function Q(a,n){let s=t,d={IhsUm:function(u,p){return e.XkSVQ(u,p)},pqtXw:e[s(936)]};if(e[s(1558)](e[s(1658)],e[s(493)])){let u=_0x3d62ad(_0x408cce);this[s(1196)]&&d[s(1361)](this[s(1196)][s(1654)+"te"],this.OPEN)&&(this._ws&&this[s(1196)][s(1232)](u),this._debug(d.pqtXw,_0x53b560))}else{let u=a[s(781)];if(e.ijsFl(u,n)>a[s(1829)])throw new Error(e[s(1729)]);return a[s(781)]+=n,u}}function be(a,n){let s=t;if(e.rETdm(e[s(1640)],e[s(1845)]))return this._ws?this[s(1196)][s(1723)+"pe"]:this[s(1489)+s(1536)];{let d=e[s(1368)](Q,a,n);return a[s(1212)][s(1815)](d,e[s(1182)](d,n))}}function he(a,n){let s=t,d=te(a,n[s(614)]);a[s(1212)][s(1705)](n,d)}function O(a,n){let s=t,d={aiEaC:function(k,N){return e[U(787)](k,N)},EfyPO:function(k,N){return e.flGTm(k,N)},vGDrv:function(k,N){return e[U(787)](k,N)},XOiZy:function(k,N){return e[U(1595)](k,N)},MswRb:function(k,N){return e[U(949)](k,N)},GAvRU:function(k,N){return k|N},cnJCO:function(k,N){return k<<N},YjtLt:function(k,N){return e[U(1650)](k,N)}},u=e[s(1368)](Q,a,n),p=String[s(838)+s(812)],m=a[s(1212)],E="\uFFFD",g="";for(let k=0;e[s(529)](k,n);k++){let N=m[e[s(950)](k,u)],z,H,L,F;if(e.wofRr(e[s(1131)](128,N),0))g+=p(N);else if(e[s(1321)](e.UyzFF(224,N),192))k+1>=n?g+=E:(z=m[e[s(1746)](e[s(969)](k,u),1)],e[s(373)](e[s(532)](192,z),128)?g+=E:(F=e[s(400)](e[s(649)](e[s(1819)](31,N),6),e[s(1819)](63,z)),e[s(1778)](F,128)?g+=E:(g+=e[s(1690)](p,F),k++)));else if(e[s(785)](240&N,224))if(e[s(929)](e[s(1182)](k,2),n))g+=E;else if(e[s(989)](e[s(1870)],e[s(596)])){_0x215aad[s(1644)](_0x2aea5f)||(_0x47add0=_0x586120[s(1660)+"er"](_0x1e6065));let se=d[s(572)](this[s(1023)],16),qe=65535&this.high,ts=this[s(1071)]>>>16,ns=d.EfyPO(65535,this[s(1071)]),ma=d[s(1354)](_0x29aa98[s(1023)],16),wa=d[s(1573)](65535,_0x3aa5e3[s(1023)]),Wr=d.vGDrv(_0x548c4f[s(1071)],16),_a=65535&_0x13e952.low,tn=0,Ft=0,Kr=0,rs=0;return rs+=ns+_a,Kr+=rs>>>16,rs&=65535,Kr+=ts+Wr,Ft+=Kr>>>16,Kr&=65535,Ft+=d.XOiZy(qe,wa),tn+=d[s(1458)](Ft,16),Ft&=65535,tn+=se+ma,tn&=65535,_0x547c62[s(865)](d[s(1056)](d.cnJCO(Kr,16),rs),d.GAvRU(d[s(1824)](tn,16),Ft),this[s(1088)])}else z=m[k+u+1],H=m[e[s(1182)](e[s(1746)](k,u),2)],e[s(772)](e[s(532)](e[s(400)](z,e.ypQBg(H,8)),49344),32896)?g+=E:(F=e.puOYW(e[s(477)](e[s(551)](e.codzJ(15,N),12),e[s(1125)](63,z)<<6),e[s(1125)](63,H)),e[s(529)](F,2048)||F>=55296&&e[s(967)](F,57343)?g+=E:(g+=e[s(1688)](p,F),k+=2));else e.OXGkc(e[s(1042)](248,N),240)?e[s(1116)](k+3,n)?g+=E:(z=m[e.XlGIy(k,u)+1],H=m[e[s(452)](e[s(823)](k,u),2)],L=m[e[s(1304)](e[s(969)](k,u),3)],e[s(1632)](e[s(1751)](e[s(1365)](z,e[s(1301)](H,8)),e[s(1594)](L,16))&12632256,8421504)?g+=E:(F=e.PQXBn(e[s(400)](e.pCbeY(e.mKwDe(e[s(1562)](7,N),18),e[s(1650)](e[s(532)](63,z),12)),e[s(742)](63,H)<<6),63&L),e[s(1778)](F,65536)||F>1114111?g+=E:(F-=65536,g+=e[s(632)](p,e[s(950)](F>>10,55296),e[s(1878)](e[s(1616)](1023,F),56320)),k+=3))):g+=E}return g}function W(a,n){let s=t,d=n[s(614)],u=0;for(let E=0;e[s(1680)](E,d);E++)if(e[s(1132)]===e[s(1132)]){let g=n[s(1534)+"At"](E);e[s(929)](g,55296)&&g<=56319&&e[s(1872)](e[s(537)](E,1),d)&&(g=e[s(918)](e[s(452)](e[s(1301)](g,10),n[s(1534)+"At"](++E)),56613888)),u+=e[s(1106)](g,128)?1:e[s(384)](g,2048)?2:g<65536?3:4}else{if(e[s(1803)](_0x1e4e8d,_0x473717))return new _0x2fe50b(_0x52472f,_0x1df4bd);if(e[s(1803)](_0x44aadd,_0x625b15)&&e.Obeam(e[s(1674)],typeof _0x1bedd9))return new _0x592605(_0x4c094d,_0x4e15f1);if(e.yWGfJ(_0x31029a,_0x5d118d)&&e.seSbc!=typeof _0x3cf812)return new _0x4776da(_0x47c200,_0x654fe8);throw new _0xf45025(e.xxfqY)}e[s(632)](ue,a,u);let p=e.WMDTR(te,a,u),m=a[s(1212)];for(let E=0;e.RzpFk(E,d);E++){let g=n.charCodeAt(E);e[s(951)](g,55296)&&g<=56319&&e[s(739)](E+1,d)&&(g=e.VVbte(e[s(823)](g<<10,n[s(1534)+"At"](++E)),56613888)),e[s(1014)](g,128)?m[p++]=g:(e.wYSfr(g,2048)?m[p++]=e[s(376)](g>>6,31)|192:(e[s(1872)](g,65536)?m[p++]=e[s(1302)](e[s(1375)](e[s(505)](g,12),15),224):(m[p++]=e.PcvME(e[s(505)](g,18),7)|240,m[p++]=e[s(1302)](e.wDBjR(g,12)&63,128)),m[p++]=e[s(1854)](e[s(887)](e[s(1775)](g,6),63),128)),m[p++]=e[s(1486)](e[s(1864)](63,g),128))}}function $(a,n){let s=t;if(e[s(399)]===e.Czscv)return this[s(1196)]?this[s(1196)][s(844)+"ns"]:"";{let d=e[s(1651)](te,a,n[s(1829)]),u=a[s(1212)],p=n.bytes;for(let m=0,E=n[s(1829)];e[s(470)](m,E);m++)u[e[s(1372)](m,d)]=p[m]}}function ie(a){let n=t;return a[n(1212)][e[n(463)](Q,a,1)]}function Ve(a,n){let s=t;if(e[s(1321)](e[s(1026)],e[s(1026)])){let d=te(a,1);a.bytes[d]=n}else wZsIRl[s(1688)](_0x24ff5d,_0x55a239[s(1290)]),wZsIRl[s(1165)](_0x3c40b0)}function fe(a){let n=t,s={wjIrE:function(d,u){return e[U(1873)](d,u)},YyeNw:function(d,u){return e[U(1145)](d,u)},MKXRW:function(d,u){return e[U(652)](d,u)},fIiiv:function(d,u){return e[U(1337)](d,u)},usgLK:function(d,u){return e.NzUyA(d,u)},oxfpl:function(d,u){return e.beUac(d,u)}};if(n(1012)===e[n(1357)]){let d=0,u=0,p;do p=e[n(720)](ie,a),e[n(1456)](d,32)&&(u|=e[n(649)](e.Wseas(127,p),d)),d+=7;while(e[n(532)](128,p));return u}else _0x39a2ec=s.wjIrE(_0x4e4022,_0x34226b),_0x3cd338=s[n(931)](127,_0x4888ef),s.MKXRW(128,_0x3264ff)&&(_0x2ad7e2=s[n(392)](_0x2af7a1,_0x439f2e),_0x5afb99|=s[n(1013)](s[n(1041)](127,_0x251acb),7))}function ue(a,n){let s=t;for(n>>>=0;e[s(1823)](n,128);)Ve(a,e.cZkuM(e[s(613)](127,n),128)),n>>>=7;e[s(1553)](Ve,a,n)}function vt(a,n){let s=t,d=0,u=0,p=0,m;if(m=e.gTxhG(ie,a),d=e[s(1155)](127,m),e[s(773)](128,m)&&(m=e[s(443)](ie,a),d|=e[s(542)](127&m,7),128&m))if(e.VtczA(s(1638),s(1830))){if(m=e[s(1509)](ie,a),d|=e[s(550)](e[s(613)](127,m),14),e[s(613)](128,m)&&(m=e[s(443)](ie,a),d|=e.yZfiI(127&m,21),e.SBAZD(128,m)))if(e[s(1349)]!==e[s(1349)]){let E=this[s(1270)+s(556)]?.getCurrentEndpoint();this[s(1816)]("connect "+E+s(1749)),this[s(691)+s(1181)](1001,e[s(1776)],!0)}else m=ie(a),u=e.aUCDk(127,m),e.sryhS(128,m)&&(m=e.xEKLB(ie,a),u|=e[s(550)](e[s(1565)](127,m),7),e[s(403)](128,m)&&(m=ie(a),u|=e[s(1650)](e[s(1375)](127,m),14),e[s(1107)](128,m)&&(m=e[s(1484)](ie,a),u|=e[s(1295)](e.FaaUm(127,m),21),e[s(1275)](128,m)&&(m=e[s(641)](ie,a),p=e[s(1352)](127,m),e.ZsHLR(128,m)&&(m=e.PZkqK(ie,a),p|=e[s(639)](e[s(1790)](127,m),7))))))}else{let E={CmcVs:function(H,L){return e.ENuGe(H,L)},zMMTx:function(H,L){return H>L},RJEnC:function(H,L){return e[s(1873)](H,L)},XdRpv:function(H,L){return e[s(1495)](H,L)},iTBSq:function(H,L){return e.GawHC(H,L)},XkFgc:function(H,L){return e[s(1666)](H,L)}},g=e[s(1803)](_0x5a377e,8192),k=e.bmoPJ(g,1),N=null,z=g;return function(H){let L=s;if(E[L(1652)](H,1)||E[L(462)](H,k))return E[L(382)](_0x3657ef,H);E[L(462)](E[L(557)](z,H),g)&&(N=E[L(1169)](_0x4cf1b9,g),z=0);let F=_0x3e8213[L(461)](N,z,z+=H);return 7&z&&(z=E[L(524)](7,z)+1),F}}return{low:e[s(784)](d,e.yZfiI(u,28)),high:e.ittUr(e[s(1716)](u,4),e.nHnSV(p,24)),unsigned:n}}function ut(a,n){let s=t,d=e[s(1716)](n[s(1071)],0),u=e[s(966)](e.zxhaH(n.low,28)|e[s(1650)](n[s(1023)],4),0),p=n[s(1023)]>>>24,m=p===0?e[s(1403)](0,u)?e[s(1258)](d,16384)?d<128?1:2:e[s(1032)](d,2097152)?3:4:e[s(529)](u,16384)?e.jFwIg(u,128)?5:6:u<2097152?7:8:e.mEuhe(p,128)?9:10,E=e[s(428)](te,a,m),g=a[s(1212)];switch(m){case 10:g[e[s(697)](E,9)]=e[s(1155)](e.gExSK(p,7),1);case 9:g[e[s(823)](E,8)]=m!==9?e[s(1302)](128,p):e[s(912)](127,p);case 8:g[E+7]=e[s(471)](8,m)?e[s(1201)](u,21)|128:e[s(1443)](e[s(1874)](u,21),127);case 7:g[e.gVaSO(E,6)]=e.VkLNh(7,m)?e[s(1201)](u,14)|128:e.unilF(u>>>14,127);case 6:g[E+5]=m!==6?e[s(797)](u,7)|128:e[s(966)](u,7)&127;case 5:g[E+4]=e[s(1770)](5,m)?e[s(780)](128,u):e[s(626)](127,u);case 4:g[E+3]=e.WgytN(4,m)?e.vjxsw(d,21)|128:e.ggPhB(e[s(693)](d,21),127);case 3:g[E+2]=e[s(1105)](3,m)?d>>>14|128:e[s(797)](d,14)&127;case 2:g[E+1]=e[s(1835)](2,m)?e[s(1046)](d>>>7,128):e[s(652)](e[s(1201)](d,7),127);case 1:g[E]=e[s(777)](1,m)?e[s(1007)](128,d):e.dDJCK(127,d)}}function Zt(a){return v(a)}function Bt(a){return e.PZkqK(S,a)}let Xt=65536,qr=e[t(1282)],me=e.BTmln(Xt,Xt),Ae=e[t(674)](me,me),Vn=e.AdzSm(Ae,2),De=String[t(1135)+"e"][t(1534)+"At"];class de{constructor(n,s,d){let u=t;this[u(1644)]=!0,this[u(1071)]=e[u(587)](0,n),this.high=e[u(1751)](0,s),this.unsigned=!!d}static[t(1644)](n){let s=t;return n&&e[s(775)](!0,n[s(1644)])}static fromBits(n,s,d){return new de(n,s,d)}static[t(1389)+"s"](n,s,d){let u=t;return d?de[u(1389)+u(747)](n,s):de[u(1389)+"sBE"](n,s)}static[t(1389)+t(747)](n,s){let d=t;return new de(e[d(965)](e.KhVWj(n[0],n[1]<<8),n[2]<<16)|n[3]<<24,e[d(1302)](e.puOYW(n[4]|n[5]<<8,e.GIPFJ(n[6],16)),e[d(542)](n[7],24)),s)}static[t(1389)+t(1860)](n,s){let d=t;return new de(e.WpJyV(e[d(1818)](e[d(1756)](n[4],24),e[d(1295)](n[5],16)),e[d(1423)](n[6],8))|n[7],e[d(1046)](e[d(1854)](e[d(1046)](e[d(405)](n[0],24),e[d(1148)](n[1],16)),e.MzojM(n[2],8)),n[3]),s)}static[t(1289)](n){let s=t;return e[s(1837)](n,qr)?qd:new de(e[s(389)](e[s(780)](e[s(1230)](e.gwKGl(De.call(n,0),e[s(733)](De.call(n,1),8)),e[s(1063)](De[s(461)](n,2),16)),e[s(1295)](De[s(461)](n,3),24)),0),e[s(949)](e[s(400)](e.ZPUnO(e.ZPUnO(De[s(461)](n,4),e[s(1063)](De[s(461)](n,5),8)),e.NzUyA(De.call(n,6),16)),e[s(871)](De[s(461)](n,7),24)),0),!0)}toHash(){let n=t;return String[n(838)+"Code"](e[n(1498)](255,this[n(1071)]),e[n(1125)](this[n(1071)]>>>8,255),e.zQWpQ(this[n(1071)],16)&255,this.low>>>24,255&this[n(1023)],e[n(1443)](e.ulmpK(this[n(1023)],8),255),e.tLnXR(this[n(1023)],16)&255,e[n(1445)](this[n(1023)],24))}static fromNumber(n,s=!0){let d=t,u={iGJmC:function(p,m,E){return e[U(440)](p,m,E)}};if(e[d(898)](e[d(1325)],e[d(1507)]))return _0xc57398[d(1212)][YWFtNb.iGJmC(_0xba346d,_0x1199e8,1)];if(e.hAFZC(isNaN,n))return s?Xh:qd;if(s){if(n>=Ae)return ep}else{if(e.EOhfA(n,-Vn))return tp;if(e[d(959)](e[d(1754)](n,1),Vn))return Qh}return de[d(865)](e[d(1033)](n,me)|0,e[d(780)](n/me,0),s)}[t(588)](){let n=t;return this[n(1088)]?e.qnESl(e.hRxYb(this.high>>>0,me),this[n(1071)]>>>0):e[n(1182)](e[n(1410)](this.high,me),this[n(1071)]>>>0)}[t(1817)](){let n=t,s={YXYAI:function(d,u,p){return e[U(1159)](d,u,p)},byQpN:e[n(1277)],dStMk:function(d,u){return e[n(1558)](d,u)}};if(e[n(775)](e[n(1511)],e.SClaC)){let d=this["_endpoin"+n(556)]?.["checkRea"+n(1528)+"es"](),u=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoint"]();if(d&&!_0x484138[n(1760)]){let p=n(1622)+u+(" fail, m"+n(882)+"es reached");this["_dispatc"+n(1563)+n(1464)](s[n(598)](_0x50e51b,s[n(1395)],{message:p,code:_0x50791a[n(692)+n(1657)+"R"],error:_0x11223}));return}this._ws&&s[n(1476)](this[n(1196)][n(1654)+"te"],this.OPEN)&&this[n(691)+n(1181)](),this["_dispatchErrorEv"+n(1464)](_0x53c6fd(s[n(1395)],{message:_0x36c2fb[n(1760)],code:_0x3fb926["NATIVE_E"+n(1575)],error:_0xa335aa}))}else return this.high===0&&e[n(757)](0,this[n(1071)])}[t(1471)](n){let s=t;de[s(1644)](n)||(n=de.fromNumber(n));let d=this[s(1023)]>>>16,u=65535&this.high,p=e[s(1166)](this[s(1071)],16),m=e[s(1042)](65535,this[s(1071)]),E=n[s(1023)]>>>16,g=65535&n.high,k=e[s(389)](n[s(1071)],16),N=65535&n.low,z=0,H=0,L=0,F=0;return F+=m+N,L+=e[s(1201)](F,16),F&=65535,L+=p+k,H+=L>>>16,L&=65535,H+=e[s(1791)](u,g),z+=e[s(706)](H,16),H&=65535,z+=e[s(1754)](d,E),z&=65535,de.fromBits(L<<16|F,e[s(1666)](e[s(523)](z,16),H),this[s(1088)])}equals(n){let s=t;return de[s(1644)](n)||(n=de.fromNumber(n)),e[s(1698)](this[s(1088)],n[s(1088)])&&e.KkVuJ(this[s(1023)]>>>31,1)&&e.nZOps(e[s(1506)](n[s(1023)],31),1)?!1:this[s(1023)]===n.high&&e[s(963)](this.low,n[s(1071)])}[t(851)](){let n=t;return e.qUpEf(-1,this[n(1071)])&&e[n(1697)](-1,this[n(1023)])?de.fromBits(0,0,this.unsigned):e[n(757)](-1,this.low)?de.fromBits(0,e[n(1592)](this[n(1023)],1),this[n(1088)]):de.fromBits(e[n(452)](this[n(1071)],1),this[n(1023)],this[n(1088)])}[t(1614)](n){let s=t;return n?this[s(731)+"E"]():this[s(599)+"E"]()}[t(731)+"E"](){let n=t,s={FXgAS:function(d,u,p){return d(u,p)},KTRmT:e[n(1277)]};if(e[n(381)](e[n(907)],e[n(1524)])){let d=s[n(1618)](_0x346478,s[n(564)],{message:_0x1a2ca3[n(1760)],code:_0x21c16f[n(942)+"OR"],error:_0x34a873});this[n(1238)+n(1563)+n(1464)](d)}else{let d=this.high,u=this.low;return[e[n(935)](255,u),e.UyzFF(e[n(1073)](u,8),255),e[n(1742)](e[n(1874)](u,16),255),e.tLnXR(u,24),e[n(764)](255,d),e.lKoGU(e[n(1341)](d,8),255),e.WbnrG(e[n(1341)](d,16),255),e[n(1589)](d,24)]}}[t(599)+"E"](){let n=t,s=this.high,d=this[n(1071)];return[s>>>24,e[n(1498)](e[n(1718)](s,16),255),e.RjQlH(e[n(767)](s,8),255),e[n(1065)](255,s),d>>>24,e[n(539)](e[n(987)](d,16),255),e[n(1473)](d>>>8,255),e.lKoGU(255,d)]}}let qd=new de(0,0,!1),Xh=new de(0,0,!0),Qh=de[t(865)](-1,2147483647,!1),ep=de[t(865)](-1,-1,!0),tp=de[t(865)](0,-2147483648,!1);var Qt=(function(a){let n=t,s=(n(666)+"0|5").split("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(681)]]=5005]=e[n(681)];continue;case"1":a[a[e[n(1287)]]=5003]=e[n(1287)];continue;case"2":a[a[e[n(955)]]=5002]=e[n(955)];continue;case"3":a[a[n(510)+"RROR"]=5001]=n(510)+n(1575);continue;case"4":a[a[e[n(1183)]]=5004]=n(1093)+n(1293);continue;case"5":return a}break}})({});class Yn{constructor(n){let s=t,d={wbOig:function(u,p){return e[U(1688)](u,p)}};e[s(414)](e.qRiqm,s(1707))?(d[s(756)](_0x37add6,this[s(669)+"gTimeoutId"]),d[s(756)](_0xaee4e4,this[s(1172)+s(1891)+s(646)]),this._pingPongTimeoutId=null,this["_reconnectTimeou"+s(646)]=null):(this[s(840)]=n,this.target=null)}}class Hd extends Yn{constructor(n,s){let d=t;if(e.OvJeh(e.bLKnI,"CiaLy")){if(_0x57b4b6)return new _0x11088a(_0x4ff0c2.url,_0xa70973.protocol);if(e.qodxX(_0x9b3656,_0x7dbc00))return new _0x3c60ce(_0x4bc263.url,_0x3b86bf[d(1585)],_0x26ca40.headers);if(e[d(1803)](_0x358243,_0x376358)&&e.Obeam(d(1077)+"d",typeof _0x12c9c3)&&_0x366426)return new _0x1e3da5(_0x1516de[d(1195)],_0x58bf0a[d(1585)+"s"])}else super(n),this[d(1760)]=s&&s[d(1760)]||null}}class jd extends Yn{constructor(n,s){let d=t,u=e[d(1001)].split("|"),p=0;for(;;){switch(u[p++]){case"0":this.message=s&&s[d(1760)]||"";continue;case"1":this.colno=s&&s.colno||0;continue;case"2":this.lineno=s&&s[d(1810)]||0;continue;case"3":this[d(1400)]=s&&s[d(1400)]||5001;continue;case"4":this[d(1290)]=s&&s[d(1290)]||null;continue;case"5":super(n);continue;case"6":this[d(1496)]=s&&s[d(1496)]||"";continue}break}}}class Wd extends Yn{constructor(n,s){let d=t;super(n),this.code=s&&s.code||0,this[d(1111)]=s&&s.reason||"",this.wasClean=s&&s[d(380)]||!1,this["willReco"+d(438)]=s&&s[d(1693)+"nnect"]||!1}}class Kd extends Yn{constructor(n,s){let d=t;super(n),this.data=s&&s[d(513)]||null}}class $d extends Kd{constructor(n,s){let d=t;super(n),this[d(513)]=s&&s[d(513)]||null,this[d(1760)]=s&&s[d(1760)]||null}}class Vd extends Yn{constructor(n,s){let d=t;super(n),this[d(513)]=s&&s[d(513)]||null}}function ot(a,{message:n,code:s,error:d}){return new jd(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new Wd(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function Yd(a,{data:n,message:s}){return new $d(a,{data:n,message:s})}function Jd(a,{data:n}){return new Vd(a,{data:n})}function da(a,{message:n}){return new Hd(a,{message:n})}class Zd{constructor(n,s){let d=t,u={yxmcu:function(p,m){return e.yDjVP(p,m)},BTvOt:function(p,m){return e[U(468)](p,m)},uodAC:function(p,m){return e[U(1533)](p,m)}};e[d(1218)](e[d(1386)],e[d(1102)])?(_0x2f2a4a=nCGrfE.yxmcu(_0x5d5262,_0x56cf56),_0x2d58a9|=nCGrfE[d(1213)](nCGrfE[d(1726)](127,_0x27e3d5),7)):(this.endpoints=n,this[d(660)+"es"]=s,this[d(864)+d(699)]=0,this[d(533)+d(926)+d(1764)+"t"]=0)}[t(1522)+t(758)+t(1242)](){let n=t;if(e[n(471)](e[n(397)],e[n(1629)]))this[n(864)+n(699)]=0,this[n(533)+n(926)+n(1764)+"t"]=0;else for(var s in _0x37ff32)_0x394917.o(_0x11e693,s)&&!_0x3b6b97.o(_0x29c17e,s)&&_0xf905a9[n(1243)+n(1814)](_0x1df17b,s,{enumerable:!0,get:_0x3f31d3[s]})}resetTries(){let n=t,s={tupvJ:function(d,u){return e[U(487)](d,u)}};if(n(1455)===e.dqOVY){let d=this[n(1259)].getStorageSync(this[n(1022)]),u=_0x1762a2[n(1030)](s[n(410)](d,"{}"));return u[_0x14ad88||_0x4c86a7[this[n(634)]]]=_0x9ed9fa,this._qosDB[n(480)+"geSync"](this[n(1022)],_0x320964[n(1547)+"y"](u)),_0x4500cd||_0x2dcb6f[this[n(634)]]}else this["currentE"+n(926)+"riesCount"]=0}[t(1710)+t(1050)+"nt"](){let n=t;return this[n(793)+"s"][this[n(864)+n(699)]]}[t(1710)+t(1050)+t(901)+"ount"](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]}[t(1186)+t(1528)+"es"](){let n=t,s={ewTOf:function(d){return e.Nxnpa(d)}};if(e.eIriI(e.oOtPT,e[n(1223)]))IhoSLz[n(426)](_0x1a9918),_0x27fc65();else return!!(e[n(1116)](this[n(864)+"ndex"],this[n(793)+"s"][n(614)])||this[n(864)+n(699)]===this[n(793)+"s"][n(614)]-1&&e.rETdm(this["currentE"+n(926)+n(1764)+"t"],this[n(660)+"es"]))}["checkCur"+t(1679)+"ointReac"+t(648)+"tries"](){let n=t;if(e[n(1868)](e[n(1203)],e[n(1203)]))return e[n(451)](this[n(864)+n(699)],this[n(793)+"s"].length)?!0:e[n(1060)](this[n(533)+"ndpointT"+n(1764)+"t"],this.maxRetries);{let{url:s}=e[n(1136)](_0x33d559,{}),d=_0x45bb24.isArray(s)?s:e[n(451)](e[n(1801)],typeof s)?[s]:[];_0x2f75c5&&_0x2ccb62[n(957)](this[n(574)],_0x3ae301),d&&d.length?this[n(1270)+n(556)]=new _0x2e2e94(d,this[n(574)].maxRetries):this[n(1270)+"tManager"]?.["resetEnd"+n(758)+n(1242)](),this[n(1542)+n(420)]?.[n(1034)+n(512)](this[n(574)][n(1782)+n(1449)]),this[n(750)+n(1519)]=!1,this[n(1196)]&&e[n(772)](this._ws[n(1654)+"te"],this[n(992)])?this[n(691)+n(1181)](1e3,e.VSOas,!0):(this[n(1049)]=!0,this._connect())}}[t(1323)+t(611)+"pointAnd"+t(1804)+"unt"](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]=1,this[n(864)+n(699)]++,this[n(793)+"s"][this[n(864)+n(699)]]}["getCurre"+t(1050)+"ntAndUpd"+t(1017)](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]++,this[n(1710)+n(1050)+"nt"]()}}let Jn=(e[t(1780)](e[t(1674)],typeof globalThis)&&e.HgAZm===globalThis[t(1412)+t(1140)].name||e[t(1780)]("undefined",typeof window)&&e.mBDIp(e[t(1255)],window["construc"+t(1140)][t(1327)]))&&e[t(1674)]!=typeof document,An=e[t(1780)](e[t(1674)],typeof globalThis)&&(e.ZmJLu===globalThis[t(1412)+t(1140)][t(1327)]||e[t(417)](t(1294)+"dWorkerGlobalScope",globalThis[t(1412)+"tor"][t(1327)]))&&e.seSbc!=typeof tt,Hr=(e[t(1780)](e[t(1674)],typeof globalThis)&&e[t(898)](t(583),globalThis["construc"+t(1140)].name)||e.NacMJ(e[t(1674)],typeof globalThis)||e[t(1674)]!=typeof globalThis&&!!globalThis[t(1204)+t(979)])&&e[t(1515)](e.seSbc,typeof wx),jr=e.lKhQJ(e.seSbc,typeof globalThis)&&(e[t(1431)](e[t(485)],globalThis[t(1412)+"tor"][t(1327)])||e[t(1460)](e.GDhSc,globalThis[t(1412)+t(1140)][t(1327)])||e[t(517)](e[t(1279)],globalThis[t(1412)+t(1140)][t(1327)]))&&e.LWahg(e.seSbc,typeof self),np=e[t(1674)]!=typeof globalThis&&e[t(1661)]===globalThis[t(1412)+"tor"].name&&e[t(904)](e[t(1674)],typeof global)&&e[t(1460)](t(583),global[t(1412)+"tor"].name)&&t(1077)+"d"!=typeof process&&!!process.version;class la{constructor(){this._listeners={}}[t(714)](n,...s){let d=t,u=this[d(1264)+"rs"][n];if(u)u[d(1610)]().forEach(p=>p.fn[d(1110)](p.ctx,s));else if(e[d(1036)](d(1290),n)&&!this[d(578)])if(e[d(517)](e[d(1393)],e[d(1393)])){let p=s.length&&s[0];if(p instanceof Error)throw p;let m=new Error(e[d(1495)](e[d(644)],p?" ("+p[d(1760)]+")":""));throw m[d(1003)]=p,p}else e[d(463)](_0x5d2c9b,_0x123d79,18),e[d(1103)](_0x54432b,_0x122288,_0x5d3f03);return this}[t(552)](n,s){let d=t;if(e[d(625)](void 0,n))this[d(1264)+"rs"]={};else if(e[d(1745)](void 0,s))this._listeners[n]=null;else{let u=this._listeners[n];if(u)for(let p=0;e[d(1404)](p,u[d(614)]);)e[d(586)](u[p].fn,s)?u[d(1762)](p,1):++p}return this}on(n,s,d){let u=t;return(this[u(1264)+"rs"][n]||(this._listeners[n]=[]))[u(1889)]({fn:s,ctx:d||this}),this}}class rp extends la{[t(1079)+t(1544)+t(1886)](n){let s=t;return n[s(1752)]||n[s(978)]?(s(1582)+" "+(n[s(1752)]||"")+s(815)+(n[s(978)]||"")).trim():JSON[s(1547)+"y"](n)}constructor(n,s,d){let u=t;super(),this._socket=null,Hr&&wx[u(1777)+"ocket"]&&(this[u(1493)]=wx[u(1777)+u(1485)]({url:n,protocols:s,header:d,fail:this[u(849)+"ocketFai"+u(577)][u(744)](this),success:this[u(849)+u(1188)+"cessHand"+u(968)][u(744)](this)})),An&&tt["connectS"+u(1485)]&&(this._socket=tt[u(1777)+u(1485)]({url:n,protocols:s,header:d,fail:this["_createSocketFai"+u(577)][u(744)](this),success:this[u(849)+u(1188)+"cessHand"+u(968)][u(744)](this)}))}[t(849)+t(1188)+"cessHand"+t(968)](){let n=t;Promise[n(1241)]()[n(1332)](()=>{this[n(923)+"steners"]()})}[t(849)+"ocketFai"+t(577)](n){let s=t,d={MmRYj:function(u,p,m){return e[U(1788)](u,p,m)},MypoM:"error",PxOPm:function(u,p,m){return e[U(430)](u,p,m)},OxMwP:e[s(738)]};Promise.resolve()[s(1332)](()=>{let u=s,p=d[u(1766)](ot,d[u(702)],{message:this["_formatE"+u(1544)+u(1886)](n)});this[u(714)](d.MypoM,p);let m=d[u(628)](xt,"close",{reason:this["_formatE"+u(1544)+u(1886)](n)});this.emit(d[u(977)],m)})}["_addWsLi"+t(830)](){let n=t,s={rDLTS:function(d,u){return e[U(1892)](d,u)},Eahyn:function(d,u){return e.xxfLe(d,u)},CrNYw:e[n(1277)]};this._socket.onOpen(d=>{let u=n;this.emit(e.DIXYK,Jd(e.DIXYK,{...d,data:d[u(1752)]||""}))}),this[n(1493)].onClose(d=>{let u=n;this.emit(e[u(738)],xt(e.MFPir,{...d}))}),this[n(1493)][n(1503)+"e"](d=>{let u=n;if(e.obOPC(e[u(1127)],e.AOzrH))this[u(714)](e[u(710)],Yd(u(1760),{...d}));else{if(wQiLKs[u(494)](4,_0xd53629[u(614)])){let p=_0x2f3eee.substring(0,wQiLKs[u(1235)](4,_0x2e7a57.length)),m=p[u(1437)](_0x1fd81d);_0x49acce.push(m)}else _0x8dd642[u(1889)](_0x580190);_0x1d75e2&&(_0x10362f+=1),_0x2e7b92+=1,_0x5d535b=!1}}),this[n(1493)][n(1392)](d=>{let u=n;this[u(714)]("error",ot(s[u(667)],{...d,message:d[u(1752)]||""}))})}[t(1232)](n){let s=t,d={AUNTO:function(u,p){return e[U(1266)](u,p)},rTZfY:function(u,p){return e[U(1626)](u,p)},Eopxp:function(u,p){return u!==p},HcZwf:function(u,p){return e[U(1864)](u,p)},WJcAL:function(u,p){return e[U(784)](u,p)},KMVTO:function(u,p){return e[U(1317)](u,p)},OHbYY:function(u,p){return u|p},uQRDz:function(u,p){return e.ZEATb(u,p)},CjwZw:function(u,p){return e[U(1432)](u,p)},kziZl:function(u,p){return u<<p},yivwT:function(u,p){return u&p},zPqHN:function(u,p){return u&p},NRcQM:function(u,p){return e[U(700)](u,p)},XdtDL:function(u,p){return e.QDmpC(u,p)},tAXah:function(u,p){return e.WBoVW(u,p)},iIMZL:function(u,p){return e[U(1036)](u,p)},SwnCs:e[s(1083)],mbMXE:e.hwdXv};if(e[s(703)](n,Uint8Array)){let u=n[s(1806)][s(1610)](n[s(1451)+"et"],e[s(1791)](n[s(508)+"th"],n.byteOffset));this[s(1493)]&&this[s(1493)][s(1232)]({data:u,fail:p=>{let m=s;this[m(714)](m(1290),e.YIQAh(ot,e[m(1277)],{message:this[m(1079)+"rrorMess"+m(1886)](p)}))}})}else this[s(1493)]&&this[s(1493)].send({data:n,fail:u=>{let p=s;d[p(973)](d[p(1706)],d.SwnCs)?this[p(714)](d[p(1314)],ot(d[p(1314)],{message:this[p(1079)+"rrorMess"+p(1886)](u)})):(_0xaef953=_0x5bc895[ZMfjhm[p(379)](ZMfjhm[p(379)](_0x597ea4,_0x15df0c),1)],_0x553598=_0x33a60c[ZMfjhm[p(1759)](_0x28df30,_0x3b363c)+2],_0x24b7f4=_0x4524b7[ZMfjhm[p(1759)](_0x4e4f6a,_0x50a96d)+3],ZMfjhm.Eopxp(ZMfjhm[p(1717)](ZMfjhm[p(956)](ZMfjhm[p(956)](_0x5d442a,_0x309bc3<<8),ZMfjhm[p(819)](_0x5738bf,16)),12632256),8421504)?_0x1c2bbf+=_0x6a2c7c:(_0x55e1ab=ZMfjhm[p(956)](ZMfjhm[p(972)](ZMfjhm[p(956)](ZMfjhm[p(819)](ZMfjhm[p(1603)](7,_0xa73ae0),18),ZMfjhm.KMVTO(ZMfjhm.CjwZw(63,_0x46413a),12)),ZMfjhm[p(1591)](ZMfjhm[p(1427)](63,_0x1e9cea),6)),ZMfjhm[p(1700)](63,_0x292500)),ZMfjhm[p(763)](_0x56a844,65536)||_0x7cf82c>1114111?_0x449846+=_0x29f58f:(_0xc21555-=65536,_0x466b06+=_0x277227(ZMfjhm[p(1624)](_0x59f6f3>>10,55296),ZMfjhm[p(1418)](1023&_0x2039c0,56320)),_0x16c5fc+=3)))}})}[t(1655)](n,s){this[t(1493)]&&this._socket.close({code:n,reason:s})}[t(888)+t(1477)](n,s){this.on(n,s)}[t(1827)+"entListe"+t(1004)](n,s){this[t(552)](n,s)}get[t(1654)+"te"](){let n=t;return this._socket[n(1654)+"te"]}get[t(1723)+"pe"](){return this._socket.binaryType}set[t(1723)+"pe"](n){}get[t(1195)](){let n=t;return this[n(1493)][n(1195)]}get protocol(){return this._socket.protocol}get[t(844)+"ns"](){let n=t;return this[n(1493)][n(844)+"ns"]}get[t(765)+t(592)](){let n=t,s={XIdxB:e[n(1363)]};return e.UAbQn(e.RqJYe,"XYLXc")?0:(_0x39425f||(_0x1e18c9=_0x41c49f[n(1241)]()[n(1332)](_0x19db38.bind(_0x1cacd6,s.XIdxB))),_0x3239da)}}function ip(a,n){let s=t;if(n)return new n(a.url,a[s(1585)]);if(e.nDWOy(Hr,An))return new rp(a[s(1195)],a[s(1585)],a[s(1429)]);if(e[s(701)](Jn,jr)&&e.Obeam(e[s(1674)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(1195)],a[s(1585)+"s"])}function sp(a){let n=t;if(e[n(772)](e.DWZqM,"cjGxJ")){let s=e[n(914)][n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(Hr&&wx["connectS"+n(1485)])return!0;continue;case"1":return!1;case"2":if(An&&tt[n(1777)+n(1485)])return!0;continue;case"3":if(e.JEwqz(Jn,jr)&&e[n(1515)](e[n(1674)],typeof WebSocket)&&WebSocket)return!0;continue;case"4":if(a)return!0;continue}break}}else if(_0x5ad4e9=_0x1bee44[n(1534)+"At"](_0x550ca2),_0x45a443<128)_0x3a9829[_0x2f348d++]=_0x2ad173;else if(_0x1e8273<2048)_0x5e6ba1[_0x864a0++]=e[n(1517)](_0x3a1518>>6,192),_0x53e372[_0x1ca38a++]=e[n(539)](63,_0x288e53)|128;else if((64512&_0x38b053)===55296&&e[n(385)](e[n(707)](64512,_0x4645d6=_0x2c8f8b[n(1534)+"At"](e[n(1158)](_0x358b27,1))),56320)){let s=e[n(615)][n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":_0x112876[_0x5ea576++]=e.ZMaNp(_0x369ae1,18)|240;continue;case"1":++_0x9ce67;continue;case"2":_0xdd6901[_0x4e9813++]=e.WthrA(e[n(1775)](_0x4157ed,12)&63,128);continue;case"3":_0x50e5bc[_0x531e31++]=e[n(1854)](e[n(376)](63,_0x3cb488),128);continue;case"4":_0x523a0e=e[n(442)](e[n(1153)](65536,e.dfoym(1023,_0x33c1e9)<<10),1023&_0x365951);continue;case"5":_0x28e3c2[_0xc9cec3++]=e[n(1715)](e[n(1312)](_0x472edf>>6,63),128);continue}break}}else _0x3a40f3[_0x5aac01++]=_0x2942c1>>12|224,_0x1b541b[_0x188237++]=e[n(1890)](e[n(1441)](e.MmLPe(_0x483cf6,6),63),128),_0x9ade4f[_0x18666b++]=e[n(831)](63&_0xe0f268,128)}function Xd(a,n,s){let d=t,u={FhHBR:function(E,g){return e.EOhfA(E,g)},YhfOR:d(526)+d(1743)+d(449)+"imes in "+d(640),EYRxc:function(E,g){return e[d(1321)](E,g)}},p=-1;async function m(E){let g=d;return u[g(1373)](E,p)?Promise[g(1160)](new Error(u.YhfOR)):(p=E,u[g(1467)](E,s[g(614)])?Promise.resolve():s[E][g(744)](a)(n,m[g(744)](null,E+1)))}m(0)}function Qd(a){let n=t,s={Jpzfp:function(d,u){return e[U(1019)](d,u)},PoLbU:function(d,u){return e[U(839)](d,u)},bBhgR:function(d,u,p){return e[U(711)](d,u,p)}};if(e[n(1835)](n(543),n(543)))return jpuVxC.Jpzfp(jpuVxC[n(1525)](_0x5a5f67,4).join("0"),jpuVxC[n(1457)](_0x3d62e0,_0x4a6cd4,2).toString(16))[n(1610)](-4);{let d=0,u=0;for(let p=0;e[n(1456)](p,a[n(614)]);++p)u=a[n(1534)+"At"](p),e.JwiPR(u,128)?d+=1:u<2048?d+=2:e[n(1047)](e[n(961)](64512,u),55296)&&e[n(532)](64512,a.charCodeAt(e[n(1595)](p,1)))===56320?(++p,d+=4):d+=3;return d}}function el(a,n,s){let d=t;if(e[d(932)](e[d(569)](s,n),1))return"";let u="";for(let p=n;e[d(1091)](p,s);){let m=a[p++];if(e.YhNhq(m,127))u+=String["fromChar"+d(812)](m);else if(e[d(450)](m,192)&&e[d(562)](m,224))u+=String[d(838)+d(812)](e[d(606)](e.PNzcg(31,m),6)|e[d(589)](63,a[p++]));else if(e[d(951)](m,224)&&e.GpfET(m,240))u+=String["fromChar"+d(812)](e[d(1715)](e[d(965)](e[d(1058)](15,m)<<12,e[d(1063)](e[d(613)](63,a[p++]),6)),e[d(887)](63,a[p++])));else if(e.wHURc(m,240)){let E=e[d(1307)](e[d(1486)](e[d(1365)](e[d(477)](e[d(909)](e.jFeOs(7,m),18),(63&a[p++])<<12),e[d(639)](e.fLGBp(63,a[p++]),6)),e[d(376)](63,a[p++])),65536);u+=String["fromChar"+d(812)](e.lhrMx(55296,E>>10)),u+=String["fromChar"+d(812)](56320+(1023&E))}}return u}function fa(a,n,s){let d=t,u={fJHkA:function(p,m){return e[U(1835)](p,m)},iJqRB:e[d(1081)],zBuEd:d(1609)};if(e.eBgJn!==d(1704)){let p=s,m,E;for(let g=0;g<a[d(614)];++g)m=a[d(1534)+"At"](g),m<128?n[s++]=m:e[d(737)](m,2048)?(n[s++]=e[d(782)](m,6)|192,n[s++]=e[d(1007)](e[d(1648)](63,m),128)):e[d(509)](64512,m)===55296&&e[d(898)](64512&(E=a[d(1534)+"At"](e[d(1501)](g,1))),56320)?(m=e[d(1200)](65536,e.IrDcX(1023&m,10))+e.KWVpT(1023,E),++g,n[s++]=e[d(1833)](e[d(903)](m,18),240),n[s++]=e[d(400)](e.WbnrG(e[d(505)](m,12),63),128),n[s++]=e.DZxsc(e[d(1441)](e.rKjSa(m,6),63),128),n[s++]=e[d(1890)](e.BsOxa(63,m),128)):(n[s++]=e.sOXEJ(m>>12,224),n[s++]=e.YIOGD(e[d(1775)](m,6),63)|128,n[s++]=e[d(990)](e[d(837)](63,m),128));return s-p}else _0x2e5e49[d(1569)+"d"]&&(this[d(1126)+d(1474)]()&&(!this[d(1196)]||this[d(1196)][d(1654)+"te"]!==this[d(1305)]||u.fJHkA(this._ws[d(1654)+"te"],this[d(1245)+"NG"]))&&this["_handleO"+d(654)](),this[d(807)+"er"]&&_0x5efdb6[d(888)+d(1477)](u[d(1812)],this["_handleO"+d(654)]),this[d(807)+"er"]&&_0x15c9ef[d(888)+d(1477)](u[d(836)],this[d(390)+d(848)]))}async function tl(a){let n=t;if(e[n(1801)]==typeof a){let s=new Uint8Array(Qd(a));return e.pLGPf(fa,a,s,0),s}return e[n(703)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1806)],a[n(1451)+"et"],a.byteLength)}function op(a){let n=t;try{return e[n(1515)](e.VKXlI,typeof a)&&(e.rGXzB(a,ArrayBuffer)||a[n(1806)]&&e[n(703)](a[n(1806)],ArrayBuffer))||e.VKXlI!=typeof a?"":(JSON[n(1030)](a),e.DBDPv)}catch{return n(1028)==typeof a?e[n(867)]:""}}let ap=(a,n)=>{let s=t;switch(a){case"boe":case e.klRlM:return{[s(1115)+a]:1,"x-tt-env":n};default:return{}}};class cp{constructor(n){let s=t;this[s(792)+"ount"]=n,this[s(425)]=0}[t(843)](){let n=t;this[n(425)]++}["checkRea"+t(396)+"nt"](){let n=t;return e.aavyu(e[n(1210)],n(1499))?"frontier_"+this._DBName:e.qrjFc(this[n(425)],this[n(792)+n(627)])}["resetCou"+t(512)](n=0){let s=t;this[s(792)+"ount"]=n,this[s(425)]=0}}async function dp(a){let n=t,s={KAKfL:function(d,u){return e[U(1566)](d,u)},XgaeH:e[n(1797)],WuEIL:function(d,u,p){return d(u,p)},uhhBa:function(d,u,p){return e[n(791)](d,u,p)},bfkqY:function(d,u){return e[n(387)](d,u)},oarpU:e.dOSaE,liQHy:n(1577),oyqKZ:e[n(408)],NTKfO:e.bxvDK,KVBRi:e[n(760)],zYLjP:function(d,u){return e[n(1840)](d,u)}};return new Promise(d=>{let u=n,p={lvXTC:function(m,E,g){return s[U(1276)](m,E,g)},EcNOy:function(m,E,g){return s[U(661)](m,E,g)}};if(s[u(1221)](u(444),s[u(1236)])){if(!Jn)return s.KAKfL(d,s.XgaeH);try{let m=document["createEl"+u(1719)](s[u(853)]);window[u(1381)+u(1843)]=E=>{let g=u;document[g(1881)][g(1529)+"ild"](m),window[g(1381)+g(1843)]=void 0,s[g(1802)](d,E&&E[g(1535)]||s.XgaeH)},m[u(840)]=s[u(1274)],m[u(705)]=a.replace(/^ws/,s.NTKfO)+s.KVBRi;try{document[u(1881)]["appendCh"+u(617)](m)}catch{document[u(1881)][u(1529)+u(617)](m)}}catch{window[u(1381)+u(1843)]=void 0,s[u(983)](d,s[u(1211)])}}else gIwURW[u(501)](_0x22630c,_0x5bfc4f,74),gIwURW.EcNOy(_0x541221,_0x42efea,_0x541b09)})}function en(a,n,s){let d=t;return e[d(1768)](e.yIJwB,e[d(804)])?!!a?.find(u=>u[d(623)]===n&&u[d(1884)]===s):(this[d(533)+"ndpointT"+d(1764)+"t"]=1,this["currentI"+d(699)]++,this[d(793)+"s"][this["currentI"+d(699)]])}function Zn(a,n){let s=t;return a?.[s(1297)](d=>d[s(623)]===n)?.[s(1884)]}let ua=null;async function lp(){return ua||(ua=Promise[t(1241)]().then(Nt.bind(Nt,e.SiEbl))),ua}class fp extends la{constructor(n,s){let d=t;super(),this[d(717)]=n,this[d(813)]=s,this[d(1259)]=void 0,this[d(642)+d(1869)]=null}async openDB(){let n=t,s={VXjlU:function(d,u){return e.YhNhq(d,u)},xOTir:e[n(621)],YVlBK:function(d,u){return e[n(1394)](d,u)},UOTcy:function(d,u){return e.lhrMx(d,u)}};if(e[n(1697)](e[n(1686)],e[n(1686)]))await this[n(605)]();else return yfsYRu.VXjlU(_0x4d91d4,_0x484ca0)?_0x1a8ec8[n(1160)](new _0xb2438d(yfsYRu[n(1621)])):(_0x130797=_0x27613e,yfsYRu[n(991)](_0x5104c1,_0x5b954d[n(614)])?_0x305489[n(1241)]():_0x4765e5[_0x3b489f][n(744)](_0x1de131)(_0x5a061f,_0x39df39[n(744)](null,yfsYRu[n(850)](_0x336b8b,1))))}async[t(605)](){let n=t,s={IhMSl:function(d,u){return e.VNEWD(d,u)},PCZnB:n(944),gRIcp:function(d,u){return d(u)},OZfdm:e[n(541)],MCOfq:n(911)+n(1735)+"s",clmBe:e[n(1057)],oJYlx:function(d,u){return e[n(1021)](d,u)},dDFLa:function(d,u,p){return e[n(629)](d,u,p)}};if(e.obOPC(e.GMRtB,e[n(372)])){if(this[n(1259)])return;if(this[n(642)+n(1869)])return this[n(642)+n(1869)];try{let d=this[n(717)],u=this[n(813)];this[n(642)+n(1869)]=(async()=>{let p=n,{openDB:m}=await e.skHqH(lp);this._qosDB=await m(p(1381)+"_"+d,1,{upgrade(E){let g=p;if(s[g(671)](g(944),s.PCZnB))E[g(643)+g(1832)+"e"](d,{keyPath:u});else{let{type:k}=_0x845cea;this[g(714)](k,_0x268f1a)}}})})(),await this[n(642)+n(1869)]}catch(d){e[n(387)](e[n(1446)],e[n(1446)])?this[n(642)+n(1869)]=null:console[n(1740)](d)}finally{this["_initPro"+n(1869)]=null}}else{let d={zLaNp:function(m,E){return s.oJYlx(m,E)},qMhrg:n(945),npFRv:s[n(1732)],iSFQK:s[n(1734)]};this[n(806)+n(940)](),this[n(669)+n(472)+"Id"]=s[n(500)](_0x283b08,this[n(1636)][n(744)](this),this[n(574)][n(993)+n(1092)]);let u=()=>{let m=n;d[m(822)](_0x258279,d[m(434)]),this[m(552)](d[m(814)],u),this.off(d[m(1444)],p)},p=()=>{let m=n;s[m(1786)](_0x67cbf3,s[m(609)]),this[m(552)](s[m(1732)],u),this[m(552)](s[m(1734)],p)};this.on(s.MCOfq,u),this.on("ping_onc"+n(1462)+"t",p),this._ping()}}async get(n){let s=t;try{if(e[s(1465)]===e.fVaKr){let d=_0x5c1da1[s(1760)][s(1828)];d&&_0x560181.setCursors(d)}else return await this._init(),this[s(1259)]?.[s(1309)](this._dbName,n)}catch(d){console[s(1740)](d)}}async[t(1705)](n,s){let d=t;return await this[d(605)](),this[d(1259)]?.put(this[d(717)],n)}async[t(771)](n){let s=t;try{return await this._init(),this._qosDB?.[s(1646)](this[s(717)],n)}catch(d){console[s(1740)](d)}}async[t(421)](){let n=t,s={ULHyd:e[n(1226)],hLgpS:e.hwdXv,GyGRW:n(1382),pMojm:function(d){return e[n(637)](d)},CjiYK:function(d,u){return e.LNtvX(d,u)},QJZol:n(943)+"or",pGigv:function(d){return e[n(1165)](d)}};try{return await this._init(),this[n(1259)]?.[n(421)](this._dbName)}catch(d){if(e[n(1403)](e[n(1358)],e[n(458)])){let u=()=>{let E=n;_0x390f1e["removeEv"+E(457)+E(1004)](dQxxJQ[E(1114)],p),_0x59087c[E(1827)+"entListe"+E(1004)](dQxxJQ.hLgpS,m),_0x2f1803[E(1827)+E(457)+"ner"](dQxxJQ[E(964)],m)},p=()=>{_0x15c6e1(),dQxxJQ.pMojm(u)},m=()=>{let E=n;dQxxJQ[E(1343)](_0x26bed9,_0x2bf9e9[E(1290)]||new _0x1ef303(dQxxJQ[E(696)],dQxxJQ.QJZol)),dQxxJQ[E(650)](u)};_0x4018f5["addEvent"+n(1477)](n(631),p),_0xe9f975[n(888)+n(1477)](n(1290),m),_0x1bb93a["addEvent"+n(1477)](n(1382),m)}else console.log(d)}}async[t(1809)](){let n=t;return await this[n(605)](),this[n(1259)]?.[n(465)+"ys"](this[n(717)])}async[t(1089)](){let n=t;if(e[n(1020)](e[n(1709)],n(1039)))return await this[n(605)](),this[n(1259)]?.[n(1089)](this[n(717)]);{let s=_0x4c7f7f[n(614)]&&_0x2fdd0f[0];if(e[n(703)](s,_0x564a11))throw s;let d=new _0x1d3088(e[n(1761)](e[n(644)],s?e[n(1746)](e.mBlKJ(" (",s[n(1760)]),")"):""));throw d.context=s,s}}async closeDB(){let n=t;try{if(e[n(1696)]!==e[n(1696)])return _0x49349d||(_0x50ce97=[_0x8769b,_0x5baf70,_0x3b1911,_0x1bdc4f,_0x16eebd]);this[n(1259)]?.[n(1655)](),this[n(1259)]=void 0}catch(s){console.log(s)}}get[t(718)](){let n=t;try{return!!this[n(1259)]}catch(s){return console[n(1740)](s),!1}}}class up{constructor(n,s){let d=t;this[d(821)]=n,this[d(634)]=s,this[d(1259)]=localStorage}async openDB(){}get[t(1022)](){let n=t;return n(1381)+"_"+this[n(821)]}async get(n){let s=t,d=this[s(1259)].getItem(this[s(1022)]);return JSON[s(1030)](d||"{}")[n]}async set(n,s){let d=t,u=this[d(1259)][d(1016)](this[d(1022)]),p=JSON.parse(u||"{}");return p[s||n[this[d(634)]]]=n,this[d(1259)][d(1579)](this[d(1022)],JSON.stringify(p)),s||n[this._pathKey]}async[t(771)](n){let s=t,d={vMeni:function(u,p){return e[U(1021)](u,p)},ICYpq:e[s(1797)],WjHtv:e[s(1006)],ZWMAc:s(423)+s(394),GkDTS:function(u,p){return u+p},zKwjK:e[s(1747)],RzebD:e.aXFyd};if(e.abXOs(e.GZYwX,e[s(1643)])){let u=this[s(1259)][s(1016)](this._prefix),p=JSON.parse(u||"{}");return p[n]=void 0,this[s(1259)][s(1579)](this[s(1022)],JSON[s(1547)+"y"](p))}else{let u=_0xa5c877[s(860)+s(1719)](oNfrrG[s(427)]);_0x4ac798[s(1381)+"JSONP"]=p=>{let m=s;_0x4ef266[m(1881)]["removeCh"+m(617)](u),_0x56bdc4[m(1381)+m(1843)]=void 0,oNfrrG.vMeni(_0x88f085,p&&p.msg||oNfrrG.ICYpq)},u[s(840)]=oNfrrG[s(1459)],u[s(705)]=oNfrrG[s(1380)](_0x4e5307[s(459)](/^ws/,oNfrrG.zKwjK),oNfrrG[s(1167)]);try{_0x19f031[s(1881)][s(1701)+s(617)](u)}catch{_0x462142[s(1881)][s(1529)+s(617)](u)}}}async clear(){let n=t;return this[n(1259)][n(421)]()}async[t(1809)](){let n=t,s=this._qosDB[n(1016)](this._prefix),d=JSON[n(1030)](e.JEwqz(s,"{}"));return Object[n(1809)](d)}async[t(1089)](){let n=t,s=this[n(1259)][n(1016)](this[n(1022)]),d=JSON[n(1030)](e[n(1094)](s,"{}"));return Object[n(630)](d)}closeDB(){return Promise.resolve()}get[t(718)](){return!!this[t(1259)]}}class xp{constructor(n,s){let d=t;this[d(821)]=n,this._pathKey=s,this[d(1259)]=An?tt:Hr?wx:null}async[t(866)](){}get[t(1022)](){let n=t,s={HSURV:function(d,u,p){return e[U(1027)](d,u,p)},sPmHT:function(d,u){return e[U(1192)](d,u)}};if(e[n(453)]!==e[n(768)])return"frontier_"+this._DBName;nEfbNZ[n(825)](_0xe7eaa4,_0x56cb02,96),nEfbNZ.HSURV(_0x35a841,_0x3fd633,nEfbNZ.sPmHT(_0x5f4055,_0x54f986))}async[t(1309)](n){let s=t,d=this[s(1259)]["getStora"+s(1360)](this[s(1022)]);return JSON.parse(e[s(701)](d,"{}"))[n]}async[t(1705)](n,s){let d=t,u=this[d(1259)].getStorageSync(this[d(1022)]),p=JSON.parse(e[d(1543)](u,"{}"));return p[s||n[this._pathKey]]=n,this._qosDB[d(480)+"geSync"](this[d(1022)],JSON.stringify(p)),s||n[this[d(634)]]}async[t(771)](n){let s=t,d=this[s(1259)].getStorageSync(this[s(1022)]),u=JSON[s(1030)](e.Alqkr(d,"{}"));return u[n]=void 0,this._qosDB[s(480)+s(1360)](this[s(1022)],JSON[s(1547)+"y"](u))}async[t(421)](){let n=t;return this[n(1259)]["clearSto"+n(975)]()}async[t(1809)](){let n=t,s={EdDZQ:function(d,u,p){return e.DiIDL(d,u,p)}};if(e[n(1837)](e[n(448)],e.HLXSg)){let d=this._qosDB[n(518)+n(563)+"nc"](this[n(1022)]),u=JSON[n(1030)](e[n(1061)](d,"{}"));return Object[n(1809)](u)}else s[n(735)](_0xaf388,_0x59121e,this[n(783)+"rvalValue"](_0x255cb8))}async getAll(){let n=t,s=this[n(1259)][n(518)+n(563)+"nc"](this[n(1022)]),d=JSON.parse(e.tdLcB(s,"{}"));return Object.values(d)}[t(1552)](){return Promise.resolve()}get[t(718)](){return!!this[t(1259)]}}function nl(a,n){let s=t;if(e[s(1721)](An,An))return new xp(a,n);if(e[s(1625)](Jn,jr)&&e.Obeam(e[s(1674)],typeof indexedDB))return new fp(a,n);if(e[s(1502)](Jn,jr)&&e[s(1674)]!=typeof localStorage)return new up(a,n);throw new Error(e[s(568)])}class hp{constructor(){let n=t;this[n(1086)+n(1416)+"Id"]=null,this._interval=36e5,this[n(1259)]=e[n(1250)](nl,n(1374),e.vNdTn)}async[t(1086)+t(1082)](){let n=t;e.IfOyv(clearInterval,this[n(1086)+"lTimeoutId"]),this[n(1086)+n(1416)+"Id"]=e[n(1214)](setInterval,()=>{let s=n;this[s(1645)+s(585)]()},this[n(1086)+"l"])}async[t(866)](){let n=t;await this[n(1259)][n(866)]()[n(1332)](()=>{this["_interva"+n(1082)]()})}async[t(1645)+t(585)](){let n=t;e[n(1029)](n(1598),e[n(1793)])?(await this._qosDB?.[n(1089)]()||[])[n(653)](({timestamp:u})=>u<Date[n(895)]()).forEach(u=>{let p=n;this[p(1259)]?.[p(771)](u[p(1691)+"id"])}):(this[n(1049)]=!1,e[n(1822)](_0x33a32f,this[n(1075)+n(1826)+n(1599)]),e.GyyRW(_0x11a96a))}async[t(771)](n){let s=t;return this._qosDB?.[s(771)](n)}async[t(1705)](n,s){let d=t;if(e[d(715)]===d(934))return this._qosDB?.[d(1705)]({message_id:n,timestamp:s});{let u=e[d(918)](e[d(1408)](e[d(831)](e[d(1173)]((7&_0x5c1798)<<18,e.XqtGU(63,_0x5a0b81[_0x399781++])<<12),e[d(1148)](63&_0x4ec611[_0xa88f60++],6)),63&_0x26a56f[_0x3d93bb++]),65536);_0x3e8a7a+=_0x3880f0[d(838)+d(812)](e.YavIP(55296,e[d(1062)](u,10))),_0xdbcd7+=_0x552aca["fromChar"+d(812)](e[d(1182)](56320,e.ENGca(1023,u)))}}async[t(1309)](n){let s=t;return this[s(1259)]?.[s(1309)](n)}async closeDB(){let n=t;clearInterval(this[n(1086)+n(1416)+"Id"]),await this[n(1259)]?.[n(1552)]()}get[t(718)](){let n=t;return this[n(1259)]?.[n(718)]}}function xa(a){let n=t,s=!!this[n(574)][n(1602)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1741)](en,a.message[n(1429)],e[n(1469)],"2"),u=d&&en(a[n(1760)][n(1429)],e[n(1144)],"1"),p=d&&e[n(755)](en,a.message.headers,e.NupEv,"1"),m=p?Zn(a[n(1760)][n(1429)],e.LFtIx)?.[n(1193)](",").filter(Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:m}}async function rl(){let a=t;return this["_QoSMana"+a(894)]||(this[a(856)+a(894)]=new hp),this[a(856)+"ger"][a(718)]||await this[a(856)+"ger"][a(866)](),this[a(856)+a(894)]}async function pp(a,n){let s=t,d={nSRwl:function(g,k){return g(k)}},{enableAutoAck:u}=this[s(574)],p=e[s(1656)](en,a[s(1760)].headers,"need_ack","1"),m=e[s(525)](en,a[s(1760)][s(1429)],e[s(1858)],"1"),E=xa[s(461)](this,a);if(u&&p)if(e.IRYOC(e[s(454)],e[s(1398)]))_0x47c533+=WipwvE[s(1015)](_0x5da921,_0x1f3d72),_0x19f88a+=2;else{let{SeqID:g,LogID:k,service:N,LogIDNew:z,method:H}=a[s(1760)];this._sendAck({SeqID:g,LogID:k,LogIDNew:z,service:N,method:H,headers:[{key:e[s(1858)],value:"1"},{key:e[s(1772)],value:z||""},{key:e[s(1567)],value:"0"}]})}m&&!E[s(1154)]&&this._dispatchAckMessageEvent(a),e[s(1413)](n)}async function gp(a,n){let s=t;this._debug(e.zzWtH,a[s(1760)]),n()}async function mp(a,n){let s=t,d=e[s(1344)](Zt,await e[s(1254)](tl,a.data));try{if(e[s(682)](d[s(1828)],Uint8Array)){let u=e[s(703)](this[s(574)][s(1882)+s(1521)],Object)?{force:!!this[s(574)][s(1882)+s(1521)].force,encoding:this[s(574)][s(1882)+s(1521)][s(1781)]?this[s(574)][s(1882)+"ncoding"][s(1781)].replace(/\s/g,"")[s(1848)+"ase"]():""}:{force:!1,encoding:this._options[s(1882)+"ncoding"]?this._options[s(1882)+s(1521)].replace(/\s/g,"")[s(1848)+"ase"]():""},p=d[s(1882)+"ncoding"]?d["payloadE"+s(1521)][s(459)](/\s/g,"")[s(1848)+s(407)]():"",m=this._options[s(802)+s(1536)]instanceof Object?{force:!!this[s(574)].payloadType[s(761)],type:this[s(574)]["payloadT"+s(1536)][s(840)]?this[s(574)][s(802)+"ype"][s(840)].replace(/\s/g,"")[s(1848)+"ase"]():""}:{force:!1,type:this[s(574)]["payloadT"+s(1536)]?this[s(574)][s(802)+s(1536)][s(459)](/\s/g,"")[s(1848)+s(407)]():""},E=d[s(802)+s(1536)]?d[s(802)+s(1536)][s(459)](/\s/g,"")[s(1848)+"ase"]():"",g=m.force?m[s(840)]:E||m[s(840)],k=u[s(761)]?u[s(1781)]:p||u.encoding,N=[e[s(867)],e.DBDPv,e.tKlRj,e[s(1801)]],z=[e[s(1286)],e.qfORZ];this[s(574)][s(469)+s(1537)+s(1322)+"ad"]&&N.includes(g)&&(!k||z[s(658)](k))?d[s(889)+s(1208)]=e[s(755)](el,d.payload,0,d[s(1828)][s(508)+"th"]):d["textPayl"+s(1208)]=""}else d[s(889)+s(1208)]=""}catch(u){d[s(889)+s(1208)]="",console.log(u)}a[s(1760)]=d,e[s(774)](n)}function wp(a,n,s){let d=t;if(e[d(1306)]!=="aYNcc"){let u=e.nDWOy(s,8192),p=u>>>1,m=null,E=u;return function(g){let k=d;if(g<1||e[k(1787)](g,p))return e[k(446)](a,g);e[k(1787)](e[k(1626)](E,g),u)&&(m=e.xmaje(a,u),E=0);let N=n[k(461)](m,E,E+=g);return e[k(810)](7,E)&&(E=e[k(1124)](e[k(477)](7,E),1)),N}}else{let u=_0x338375[d(727)+"g"](0,4-_0xb7f837[d(614)]),p=u.concat(_0x311454);_0x1bbea3[d(1889)](p)}}let _p=4294967295;function yp(a,n,s){let d=t;return e[d(1378)](RangeError,e[d(567)](e[d(1875)](e.CdCoz(e[d(473)](e.BXUrN,a),d(933))+e.tdLcB(n,1),d(905)),s))}function bp(a,n,s){let d=t,u={RSrdR:function(p,m){return p>m},bZEKz:e[d(1268)]};if(e.OqQnT(e.mSFSi,e[d(1795)])){if(e[d(1060)](s,_p))throw new Error("integer "+d(1755)+"e");let p=3;for(;p>=0;)if(e[d(1876)](e.ykRba,e[d(1813)])){let m=e[d(1002)](255,s);e[d(755)](pa,m,a,e[d(442)](n,p)),s>>>=8,p--}else return _0x4db209[d(1740)](_0x3e81ff),!1;return e[d(1072)](n,4)}else{if(xNaruv.RSrdR(_0x514fbd[d(781)]+_0x1292e6,_0x2a9a47.limit))throw new _0x4ae5e1(xNaruv[d(466)]);_0x3acf56[d(781)]+=_0x11b817}}function Ep(a,n){let s=t,d=0,u=n,p=e.deyCY(n,4);for(;u<p;){let{value:m,offset:E}=e[s(440)](ha,a,u);u=E,d=e[s(797)](e[s(1397)](d,8),0),d+=m}return{value:d,offset:p}}function vp(a,n,s){let d=t;if(d(924)!==e[d(662)]){let u=(d(1689)+"3")[d(1193)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(n[d(1587)+"e"])return e[d(1595)](n[d(1587)+"e"](a,s),s);continue;case"1":if(n[d(1611)])return e[d(1153)](n[d(1611)](a,s),s);continue;case"2":if(e[d(664)](a[d(614)],40))return fa(a,n,s)+s;continue;case"3":return e.KojAK(e[d(422)](fa,a,n,s),s);case"4":if(!a)return s;continue}break}}else{if(!this[d(1196)])return;this[d(1359)+d(1500)+"t"](_0x5c32ec,_0x48f99f,_0x532cad)}}function Sp(a,n){let s=t,d=new de(e[s(835)](e.KVXfy(a[n+4],24),e[s(1162)](a[n+5],16))|e[s(542)](a[n+6],8)|a[n+7],e[s(1715)](e[s(960)](a[n+0]<<24,e[s(1162)](a[e.FRntQ(n,1)],16))|e[s(433)](a[e[s(1178)](n,2)],8),a[e.BRWWB(n,3)]),!0);return n+=8,{value:d,offset:e[s(1878)](n,8)}}function Ap(a,n,s){let d=t,u=a[d(1071)],p=a[d(1023)];return n[s]=e[d(817)](p,24),n[e[d(1590)](s,1)]=e[d(1647)](e[d(1589)](p,16),255),n[e.WJwIF(s,2)]=e[d(1355)](p>>>8,255),n[s+3]=e.CISPC(255,p),n[e.iGnZa(s,4)]=e[d(492)](u,24),n[e[d(1592)](s,5)]=u>>>16&255,n[e[d(473)](s,6)]=e[d(539)](e[d(966)](u,8),255),n[s+7]=e[d(1572)](255,u),s+=8,s}function ha(a,n){let s=t;return a[s(1336)+"8"]?{value:a[s(1336)+"8"](n),offset:n+1}:{value:255&a[n],offset:e[s(916)](n,1)}}function pa(a,n,s){let d=t,u={zNWSe:e[d(1277)],ZmBvn:function(p,m,E){return e[d(1214)](p,m,E)}};if(e[d(471)](e[d(441)],e.YFgSV))return n[d(1117)+"t8"]?n.writeUint8(a,s):n[s]=e[d(565)](255,a),e[d(1595)](s,1);this[d(714)](VOJWmk.zNWSe,VOJWmk[d(740)](_0x195dfa,VOJWmk.zNWSe,{message:this[d(1079)+d(1544)+d(1886)](_0xb68291)}))}let Ip=function(a){return new Uint8Array(a)},Tp=e[t(506)](e[t(1674)],typeof Buffer)?Buffer[t(1513)+"afe"]:e.FKXUp(wp,Ip,Uint8Array[t(1135)+"e"].subarray);(()=>{let a=t,n={MVsrQ:function(d,u){return d<=u},lOlIs:function(d,u){return d<u},iKYIG:function(d,u){return e[U(1307)](d,u)},hGOqz:function(d,u){return e[U(1106)](d,u)},tkAmk:function(d,u){return d&u},mQOyR:function(d,u){return e[U(1303)](d,u)},BlSft:function(d,u){return e[U(831)](d,u)},qlGiy:function(d,u){return e[U(903)](d,u)},RhRov:function(d,u){return d>>u},lnmmp:function(d,u){return e[U(1440)](d,u)},OjIko:function(d,u){return e.UhmKM(d,u)},WiPoq:function(d,u){return e[U(1302)](d,u)},txyPd:function(d,u){return d&u},jUtda:function(d,u){return e[U(571)](d,u)},EyjPc:function(d,u){return e[U(1432)](d,u)},hwmrm:function(d,u){return e[U(587)](d,u)},XHenk:function(d,u){return e[U(492)](d,u)},Hzhfh:function(d,u){return d|u},aSFEj:function(d,u){return e[U(620)](d,u)},XJUYs:function(d,u){return e[U(1517)](d,u)},pnAHk:function(d,u){return e[U(693)](d,u)},rmtxi:function(d,u){return d<u},CTnfz:function(d,u){return e[U(1517)](d,u)},zGiOs:function(d,u){return e[U(670)](d,u)},XBBLT:function(d,u){return e[U(1859)](d,u)},IFYug:function(d,u){return d|u},ACjlT:function(d,u){return d<<u},LifHg:function(d,u){return e[U(1163)](d,u)},mQjHa:function(d,u){return e[U(1060)](d,u)},XWZuu:function(d,u){return d===u},kyJTX:a(1799),mOhzS:function(d,u){return e[a(624)](d,u)}},s=4294967295;return function(d,u,p=!0){let m=a;if(s=n.EyjPc(127,d[u])>>>0,n[m(1315)](d[u++],128))return{value:p?s:n[m(1422)](0,s),offset:u};if(s=n[m(1425)](n.Hzhfh(s,n[m(1405)](n[m(1411)](127,d[u]),7)),0),d[u++]<128)return{value:p?s:n[m(1480)](0,s),offset:u};if(s=n[m(1798)](n.lnmmp(s,(127&d[u])<<14),0),n.rmtxi(d[u++],128))return{value:p?s:n.CTnfz(0,s),offset:u};if(s=n[m(1425)](n[m(1422)](s,n[m(1370)](127,d[u])<<21),0),n.hGOqz(d[u++],128))return{value:p?s:n[m(530)](0,s),offset:u};if(s=n[m(1425)](n.IFYug(s,n[m(1008)](n[m(1508)](15,d[u]),28)),0),n.hGOqz(d[u++],128))return{value:p?s:n[m(786)](0,s),offset:u};if(n[m(1580)](u+=5,d[m(614)])){if(n[m(985)](n.kyJTX,"GZdfq"))throw u=d[m(614)],yp(u,10,d[m(614)]);{let E=_0x2bd553[m(1534)+"At"](_0x4bcc0b);E>=55296&&cpmlQB.MVsrQ(E,56319)&&cpmlQB[m(1315)](_0x16ec16+1,_0x1b9508)&&(E=cpmlQB.iKYIG((E<<10)+_0x2cac11[m(1534)+"At"](++_0xfa3729),56613888)),cpmlQB[m(1298)](E,128)?_0x568ee0[_0x20f3a7++]=E:(cpmlQB[m(1315)](E,2048)?_0xcbfcd[_0x47c301++]=cpmlQB[m(1411)](E>>6,31)|192:(cpmlQB.mQOyR(E,65536)?_0x9c3718[_0xfe5743++]=cpmlQB[m(1184)](cpmlQB.tkAmk(cpmlQB[m(1805)](E,12),15),224):(_0x3fd2cd[_0x3cce89++]=cpmlQB[m(1184)](cpmlQB[m(1411)](cpmlQB[m(1292)](E,18),7),240),_0x395586[_0xd292d1++]=cpmlQB[m(786)](cpmlQB[m(748)](E>>12,63),128)),_0x309a15[_0x33cc6f++]=cpmlQB[m(798)](cpmlQB.txyPd(cpmlQB.RhRov(E,6),63),128)),_0x559f32[_0x550227++]=cpmlQB[m(1426)](cpmlQB[m(748)](63,E),128))}}return{value:p?s:n[m(1785)](0,s),offset:u}}})();let Cp=16,ga=32;function Rp(a){let n=t,s={CmTCR:function(p){return e[U(876)](p)}},d=0,u={};for(let p=0;e.zEZyP(p,a[n(614)]);p++)if(e[n(757)]("vfWuM",e[n(1731)])){let m=this[n(1270)+n(556)]?.[n(1710)+n(1050)+"nt"]();this[n(1816)](n(1040)+m),s[n(827)](_0x1d1725)}else u[a[p][n(1748)+n(1338)]]=Qd(a[p][n(1748)+n(1338)]),d+=e.vYwlT(14,u[a[p]["cursor_n"+n(1338)]]);return[d,u]}function il(a,n,s){let d=t,u={DbPMt:e.QRBqj,YrzgH:function(k,N,z,H){return k(N,z,H)},AQSOH:e.PZffk,phMMy:d(1851)+"name",KKRcc:e[d(1771)],YMgGv:function(k,N,z,H){return e[d(755)](k,N,z,H)},jhSTt:e.WlfUk},[p,m]=e[d(618)](Rp,a),E=e.JCQxQ(Tp,p),g=0;return a.forEach(k=>{let N=d;console[N(1740)](u[N(1170)],k,k[N(1424)]),g=u.YrzgH(pa,0,E,g),console[N(1740)](u.AQSOH,g),g=bp(E,g,k[N(1424)]||0),console[N(1740)](N(1424),g),g=u[N(548)](pa,m[k[N(1748)+N(1338)]],E,g),console[N(1740)](u.phMMy,g),g=u[N(548)](vp,k[N(1748)+N(1338)],E,g),console[N(1740)](u[N(778)],g),g=u[N(375)](Ap,de[N(1660)+"er"](k[N(608)]||n),E,g),console.log(u[N(724)],g)}),{frameType:ga,headers:[{key:e[d(1560)],value:s}],payload:E}}function Dp(a){let n=t,s=0,d=[];for(;e[n(1032)](s,a[n(508)+"th"]);){let{offset:u}=e[n(1553)](ha,a,s);s=u;let p={cursor_name:"",cursor:0,service:0},{value:m,offset:E}=Ep(a,s);p[n(1424)]=m,s=E;let{value:g,offset:k}=e[n(1122)](ha,a,s);s=k,p[n(1748)+"ame"]=e[n(383)](el,a,s,e[n(790)](s,g)),s+=g;let{value:N,offset:z}=Sp(a,s);p[n(608)]=N[n(588)](),s=z,d[n(1889)](p)}return d}function kp(){let a=t;return{frameType:ga,headers:[{key:e.iQclL,value:e[a(1420)]}],payload:void 0}}class Op{constructor(n,s,d){let u=t;this["_cursorN"+u(445)]=n,this[u(1630)+u(745)]=s,this[u(1421)+u(595)]=d,this[u(1259)]=nl(this[u(805)+"ameSpace"],e.CaNwO)}async[t(866)](){let n=t;await this[n(1259)][n(866)]()}async[t(1045)+"rs"](){let n=t;if(!this[n(1259)][n(718)])return;let s=this[n(1421)+n(595)],d=await this._qosDB[n(1089)]();switch(console[n(1740)](n(1439)+n(1613),d),s){case n(1139):return d&&d[n(614)]?e[n(1656)](il,d,0,this[n(1630)+"ileName"]):void 0;case e.bURKq:return;case e.WKIXN:return d&&d[n(614)]?e[n(873)](il,d,0,this[n(1630)+n(745)]):kp()}}async[t(1705)](n,s,d){let u=t;return e[u(1670)](u(921),e[u(732)])?(console[u(1740)](e[u(1024)],n,s,d),this[u(1259)].set({cursor_name:n,cursor:s,service:d})):this[u(1421)+"Queue"][u(1310)]((m,E)=>(m+=E&&E[u(508)+"th"]||0,m),0)+(this[u(1196)]?this._ws[u(765)+u(592)]:0)}async[t(1009)+"rs"](n){let s=t,d={kBpct:function(p,m){return e[U(505)](p,m)},trakR:function(p,m){return e[U(846)](p,m)},hgOEB:function(p,m){return e.MsGpv(p,m)}},u=e[s(594)](Dp,n);for(let p of u)e.hlLzc(e[s(1554)],e[s(1554)])?(_0x4941de-=65536,_0x33f6f9+=_0x3bad7b(XplnYR[s(832)](_0x3fd3a9,10)+55296,XplnYR[s(891)](XplnYR[s(1108)](1023,_0xa9495b),56320)),_0xc155c4+=3):(console.log(e[s(1454)],u),await this._qosDB[s(1705)](p))}async[t(1309)](n){let s=t;return e[s(1431)](e[s(391)],e[s(1774)])?null:(await this[s(1259)].get(n))?.[s(608)]}async[t(1552)](){let n=t;if(e[n(1118)]===e[n(1118)])await this[n(1259)][n(1552)]();else return new _0x3ee06c(_0x3e28b8,{code:_0x5d13f2,reason:_0x45ad2a,wasClean:_0x296dd9,willReconnect:_0x368e7d})}["updateCu"+t(388)+"Name"](n){let s=t;this[s(1630)+s(745)]=n}get[t(718)](){let n=t;return this[n(1259)][n(718)]}}let Pp=e.uKqag;async function sl(a){let n=t;if(!this[n(574)][n(1602)+"S"])return null;let{aID:s,fpID:d,messageStrategy:u}=this[n(574)],p=e.XJKyJ(a,Pp);try{return this[n(580)+n(1861)]?a&&this["_cursorM"+n(1861)][n(1053)+n(388)+n(536)](a):this["_cursorM"+n(1861)]=new Op(d+"_"+s+"_"+p,p,u),this[n(580)+n(1861)][n(718)]||await this[n(580)+n(1861)].openDB(),this[n(580)+n(1861)]}catch{return null}}async function Np(a,n){let s=t,d={bFlzU:function(L,F){return e[U(965)](L,F)},wRqQu:function(L,F){return L<<F},HDXWi:function(L,F){return e[U(1859)](L,F)},boyxn:function(L,F){return L<<F},IRKGf:function(L,F){return L<<F},xwwGx:function(L,F){return e[U(638)](L,F)},NkNPM:function(L,F,se){return e[U(1229)](L,F,se)},NHqEC:function(L,F){return e[U(1035)](L,F)},NeYbC:function(L,F,se){return e.UdwAG(L,F,se)},JBEmP:function(L,F,se){return e[U(602)](L,F,se)}},u=e[s(1367)](en,a.message[s(1429)],e.WMQsA,"-1"),p=e[s(1491)](en,a[s(1760)][s(1429)],s(1733),"1"),m=e[s(632)](Zn,a[s(1760)].headers,s(604)+"er_msgid"),E=e[s(1509)](Number,e[s(1103)](Zn,a[s(1760)][s(1429)],e[s(1684)]))||0,g=xa[s(461)](this,a),k=e.HsERq(en,a.message[s(1429)],e[s(927)],"2"),N=Zn(a[s(1760)][s(1429)],e.OYpLH),z=e.IFVRv(Number,e[s(1356)](Zn,a.message.headers,e[s(1146)]));if(g[s(1154)])return e[s(1619)](n);let H=g[s(535)+s(1807)]?await rl[s(461)](this):null;if(e[s(828)](a.message[s(1424)],0)&&p&&!u||e[s(1060)](a[s(1760)][s(1424)],0))if(e[s(1394)](s(1280),e[s(1667)])){let L=_0xc930ca["deleteDa"+s(1744)](_0x4a70ec);return _0x5115e4&&L["addEvent"+s(1477)](wZsIRl[s(1340)],()=>_0x5836ad()),_0x171e1f(L)[s(1332)](()=>{})}else{if(m&&g[s(535)+s(1807)]&&H){if(!!!await H.get(m))if(e[s(622)]===e[s(622)])this[s(1238)+"hMessage"+s(1750)](a),await H[s(1705)](m,e.WBoVW(Date[s(895)](),E));else{let F=this[s(1023)],se=this.low;return[F>>>24,e[s(1470)](e[s(1874)](F,16),255),e[s(1345)](e.wzVNx(F,8),255),e[s(1002)](255,F),e[s(706)](se,24),e[s(961)](e[s(1730)](se,16),255),e[s(862)](e[s(1556)](se,8),255),e.sryhS(255,se)]}return e[s(1101)](n)}if(k){if(e[s(757)](e[s(930)],e.vpbri))return new _0x2c91f7(FmStYk[s(999)](FmStYk[s(999)](_0x1763e3[0]|FmStYk[s(1068)](_0x3208e6[1],8),_0x2828da[2]<<16),FmStYk[s(1068)](_0x29a23b[3],24)),FmStYk.HDXWi(_0x203e09[4]|FmStYk.boyxn(_0x3c9fb8[5],8)|_0x3edd33[6]<<16,FmStYk.IRKGf(_0x562eb1[7],24)),_0x1c5cc6);{let L=await sl.call(this);if(!L)return this[s(1238)+s(1205)+s(1750)](a),e[s(1076)](n);let F=await L[s(1309)](N)??-1;if(e[s(1680)](F,z))if(e[s(1668)](e[s(1120)],e[s(994)])){let se=_0x3abcfa[s(623)];FmStYk[s(1257)](void 0,se)&&(_0x3118d6(_0x1273d3,10),FmStYk[s(976)](_0x171412,_0x41429b,se));let qe=_0x1b21b1[s(1884)];FmStYk[s(1202)](void 0,qe)&&(FmStYk[s(811)](_0x5b7a92,_0x1533c8,18),FmStYk[s(1272)](_0xfc13e8,_0x3e977e,qe))}else this[s(1238)+"hMessageEvent"](a),L[s(1705)](N,z,a[s(1760)].service);else throw new Error(s(503)+" message"+s(1031)+z+(s(1248)+"than loc"+s(1224)+"r ")+F);return e[s(1080)](n)}}return this[s(1238)+s(1205)+s(1750)](a),e[s(1076)](n)}}async function Lp(a,n){let s=t,d=xa[s(461)](this,a);if(!d[s(535)+"sage"])return e[s(820)](n);let u=await rl[s(461)](this);if(d[s(1635)+s(1627)+s(1886)]&&d[s(1366)+"s"][s(614)])for(let p of d[s(1366)+"s"])await u[s(771)](p);n()}async function Mp(a,n){let s=t;if(e.fOpmW!==s(1143))this._DBName=_0x370918,this[s(634)]=_0x520da9,this._qosDB=_0x49c734?_0x8fbf8:_0x2c3c45?_0x2d81b3:null;else{let d=e[s(1066)](a[s(1760)][s(859)+"e"],Cp),u=a[s(1760)][s(859)+"e"]===ga;if(e[s(716)](!d,!u))return e[s(1119)](n);let p=e.VwmEj(Zn,a.message[s(1429)],e[s(1560)]);if(!p)return e[s(1076)](n);let m=await sl[s(461)](this,p);if(!m)return e.LSQkk(n);if(d){let E=await m[s(1045)+"rs"](),g={frameType:E?.["frameType"],SeqID:de[s(1660)+"er"](this._seqId++),LogID:de[s(1660)+"er"](this._options["logIDGen"+s(1177)]()),service:9e3,method:5,headers:E?.[s(1429)],payload:E?.[s(1828)]},k=e.fYEFL(S,g);this[s(1196)]&&this._ws.readyState&&this._ws[s(1232)](k)}if(u){let E=a[s(1760)][s(1828)];E&&m[s(1009)+"rs"](E)}}}let Bp=async function(a,n){let s=t,d={pnDvF:s(1683)+s(1051),QXKma:"FILE_NOT"+s(1037)};if(s(854)!==s(854))return{frameType:_0x4eee2e,headers:[{key:qlEVlQ[s(698)],value:qlEVlQ.QXKma}],payload:void 0};this[s(1049)]=!1,clearTimeout(this[s(1075)+s(1826)+s(1599)]),e[s(910)](n)},Fp=async function(a,n){let s=t;if(!this[s(1196)]||e[s(1632)](this[s(1196)].readyState,this[s(1305)]))return n();let{pingInterval:d}=this[s(574)];this[s(1270)+s(556)]?.[s(1522)+s(758)+s(1242)]();for(let p=0;e[s(415)](p,this[s(1421)+s(1505)][s(614)]);p++){let m=this[s(1421)+s(1505)][p];if(e[s(757)](this._ws[s(1654)+"te"],this[s(1305)])&&e.aavyu(null,m))this[s(1196)]&&this[s(1196)][s(1232)](m),this[s(1421)+s(1505)][p]=null;else break}this["_message"+s(1505)]=this[s(1421)+"Queue"][s(653)](p=>!!p),this["_pingPon"+s(472)+"Id"]=e[s(1229)](setTimeout,()=>this[s(1636)](),d),this[s(1238)+s(1316)+"nt"](a),this._isBrowser&&this[s(1196)]&&(this[s(1196)][s(1723)+"pe"]=this["_binaryT"+s(1536)]);let u=this._endpointManager?.["getCurre"+s(1050)+"nt"]();this[s(1816)]("open "+u+s(1475)),n()},zp=async function(a,n){let s=t;if(e[s(680)](e.ypGHM,e.ypGHM))_0x418911[s(1881)][s(1701)+"ild"](_0x3b81b4);else{let d=this[s(1270)+s(556)]?.[s(1710)+s(1050)+"nt"]();this._debug(s(1040)+d),e[s(637)](n)}};class Up extends la{constructor(n){let s=t,d={MkDog:function(E,g){return e[U(1200)](E,g)},vODvk:function(E,g,k){return e[U(1175)](E,g,k)},nNLza:function(E,g){return e[U(1129)](E,g)},RdlVh:s(1290),mSZqG:function(E,g){return e[s(730)](E,g)},hvSxP:s(1253),gFzeC:function(E,g){return e.akRaW(E,g)},NzrGk:function(E,g){return e[s(1628)](E,g)},gENpD:s(1461),QBOCq:"mBugs",HywvA:function(E,g){return e[s(818)](E,g)},ELUBe:e[s(1607)],zHyVS:function(E,g,k,N){return E(g,k,N)},YKiaA:function(E,g){return e[s(1811)](E,g)},OFnIS:e[s(570)],ZYUCv:function(E,g,k){return e.IzeYd(E,g,k)},RZYQF:e[s(897)],dHTzk:e[s(738)],BrVbF:e[s(890)],EJHSX:function(E,g){return e.tXZGk(E,g)},KNLDA:function(E,g,k){return E(g,k)}};super(),this[s(1639)+s(917)+s(1428)]=!0,this[s(807)+"er"]=Jn,this[s(544)]=np,this[s(826)+"T"]=An,this[s(1675)+"X"]=Hr,this[s(1634)+"r"]=jr,this[s(1421)+s(1505)]=[],this[s(1270)+s(556)]=null,this[s(750)+"osed"]=!1,this[s(1489)+s(1536)]=e[s(1383)],this[s(1075)+s(808)]=!1,this[s(1075)+"ionTimeoutId"]=null,this[s(1172)+"ctTimeou"+s(646)]=null,this["_pingPon"+s(472)+"Id"]=null,this[s(1070)]=0,this[s(1049)]=!1,this[s(1623)]="",this["_QoSMana"+s(894)]=null,this[s(580)+s(1861)]=null,this[s(1542)+s(420)]=null,this._protocols=e[s(1612)],this[s(992)]=3,this.CONNECTING=0,this[s(1305)]=1,this[s(1149)]=2,this._onOpen=E=>{let g=s;try{e[g(873)](Xd,this,E,[Bp,Fp,zp])}catch(k){let N=e[g(1553)](ot,g(1290),{message:k[g(1760)],code:Qt.OPEN_ERROR,error:k});this[g(1238)+"hErrorEvent"](N)}},this._onMessage=async E=>{let g=s,k={YOnZM:function(H,L,F){return H(L,F)},AvfVy:d[g(1601)]},{pingInterval:N,pingFrequency:z}=this[g(574)];if((E.data==="hi"&&d.mSZqG(d[g(635)],z)||d[g(1010)]("auto",z))&&(d[g(1025)](d[g(741)],d[g(974)])?(this[g(806)+"ngTimer"](),this[g(714)](g(911)+"e_success",g(945)),this[g(669)+"gTimeoutId"]=setTimeout(this[g(1636)][g(744)](this),N)):_0x4d5943.d=(H,L)=>{for(var F in L)_0x3ddc93.o(L,F)&&!_0x4f20a1.o(H,F)&&_0x185abf.defineProperty(H,F,{enumerable:!0,get:L[F]})}),!d[g(1479)]("hi",E.data))try{if(d[g(842)]!==g(858)){let H=_0x34de8d[g(1806)].slice(_0x3d1cbd.byteOffset,pqDlRn[g(869)](_0xacf7e2[g(508)+"th"],_0x41581e.byteOffset));this[g(1493)]&&this[g(1493)][g(1232)]({data:H,fail:L=>{let F=g;this[F(714)](F(1290),jMUpDd[F(752)](_0x1299d9,jMUpDd.AvfVy,{message:this["_formatE"+F(1544)+F(1886)](L)}))}})}else d[g(655)](Xd,this,E,[mp,pp,Lp,Mp,Np,gp])}catch(H){if(d.YKiaA(d.OFnIS,d.OFnIS)){for(_0x2758cc>>>=0;_0x344f09>=128;)pqDlRn.vODvk(_0x263944,_0x201352,pqDlRn[g(1281)](127,_0x4ff3c7)|128),_0x411bc6>>>=7;_0x2f21db(_0x1d9ef0,_0x316982)}else{let L=d.ZYUCv(ot,d[g(1601)],{message:H[g(1760)],code:Qt[g(1093)+g(1293)],error:H});this["_dispatc"+g(1563)+g(1464)](L)}}},this._onError=E=>{let g=s,k=this["_endpoin"+g(556)]?.["checkRea"+g(1528)+"es"](),N=this["_endpoin"+g(556)]?.getCurrentEndpoint();if(k&&!E[g(1760)]){let z=g(1622)+N+(g(1753)+"ax retri"+g(412)+"ed");this[g(1238)+"hErrorEv"+g(1464)](e.pnuLo(ot,e[g(1277)],{message:z,code:Qt[g(692)+"IES_ERROR"],error:E}));return}this._ws&&e[g(1403)](this._ws[g(1654)+"te"],this[g(1305)])&&this[g(691)+g(1181)](),this["_dispatc"+g(1563)+g(1464)](e[g(520)](ot,"error",{message:E.message,code:Qt[g(510)+g(1575)],error:E}))},this[s(1104)]=async E=>{let g=s;if(d.RZYQF!==d[g(1059)])return this[g(1259)]?.[g(1309)](_0x436f8c);{this["_clearTi"+g(1724)](),this[g(806)+"ngTimer"](),this[g(1137)+"sListeners"](),this[g(1196)]=null,this[g(1075)+"Lock"]=!1;let k=this[g(1270)+g(556)]?.[g(1186)+g(1528)+"es"]();if(!k&&this[g(1126)+g(1474)]()&&!this[g(750)+g(1519)]){let N=this[g(1270)+g(556)]?.getCurrentEndpoint(),z=this._options["reconnec"+g(1369)+g(962)](E[g(1400)],E[g(1111)]);this[g(1238)+"hCloseEv"+g(1464)](d[g(673)](xt,d[g(1510)],{code:1006,reason:E[g(1111)]||g(704)+g(1328)+"d, unknown reaso"+g(1084)+g(953)+N,willReconnect:z})),z&&this[g(1075)]();return}if(d.YKiaA(1e3,E[g(1400)])&&this[g(750)+g(1519)]){this[g(1238)+"hCloseEv"+g(1464)](d.vODvk(xt,d[g(1510)],{code:1e3,reason:d[g(1564)]})),this[g(1270)+"tManager"]?.[g(1522)+g(758)+g(1242)](),this[g(1542)+g(420)]?.[g(1034)+g(512)]();return}if(E[g(1400)]!==1e3&&k){let N=this[g(1270)+"tManager"]?.[g(1710)+"ntEndpoint"](),z=E[g(1111)];z||(z=await d[g(695)](dp,this[g(1623)])),z=g(704)+g(1328)+g(1407)+z+(g(1852)+g(1702))+N+(g(941)+g(582)+"ached"),this["_dispatchCloseEv"+g(1464)](d[g(1844)](xt,g(1655),{code:E[g(1400)],reason:z}));let H=g(1622)+N+(g(1753)+g(882)+g(412)+"ed");this[g(1238)+g(1563)+"ent"](ot(d.RdlVh,{message:H,code:Qt[g(692)+g(1657)+"R"]})),this[g(1270)+g(556)]?.["resetEnd"+g(758)+g(1242)](),this._pingLossCounter?.[g(1034)+g(512)]();return}if(E[g(1400)]!==1e3&&!E[g(1111)]){let N=this[g(1270)+g(556)]?.[g(1710)+"ntEndpoint"]();this["_dispatc"+g(1796)+"ent"](xt("close",{code:E[g(1400)],reason:"connecti"+g(1328)+"d, unkno"+g(1278)+g(1084)+g(953)+N})),this["_endpoin"+g(556)]?.[g(1522)+"pointCon"+g(1242)](),this[g(1542)+g(420)]?.[g(1034)+g(512)]();return}this[g(1238)+g(1796)+g(1464)](E),this[g(1270)+g(556)]?.[g(1522)+g(758)+g(1242)](),this[g(1542)+g(420)]?.["resetCou"+g(512)]()}},this.onclose=null,this[s(578)]=null,this[s(857)+"e"]=null,this.onopen=null,this[s(538)+"econnect"]=null,this[s(1633)+s(1883)]=null,this["onStopImmediatel"+s(1773)+"ct"]=null,this[s(390)+s(654)]=this._handleOnLine[s(744)](this),this[s(390)+s(848)]=this["_handleO"+s(848)].bind(this),this[s(753)+"ageHide"]=this[s(753)+s(1783)].bind(this),this[s(753)+s(986)]=this["_handleP"+s(986)][s(744)](this),this[s(574)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(439)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[s(1526)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(779)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,m=Array[s(464)](u)?u:e.jLadt(e[s(1801)],typeof u)?[u]:[];if(!m||e[s(872)](0,m[s(614)]))throw new Error(e.jNiem);if(!e[s(1231)](sp,p))throw new Error("please p"+s(1147)+s(1483)+s(1808)+"ket cons"+s(1096)+"is undefined");Object[s(957)](this[s(574)],n),this[s(1270)+s(556)]=new Zd(m,this[s(574)][s(660)+"es"]),this[s(1542)+s(420)]=new cp(this[s(574)]["pingLoss"+s(1449)]),this[s(574)]["automati"+s(794)]&&(e[s(1133)](e[s(1098)],s(1171))?(_0x36f29b=e.GoAdP(e[s(852)](e[s(607)](e[s(1301)](e[s(1821)](7,_0x330b97),18),e.vwuJo(63,_0x25bac3)<<12),e[s(1539)](63,_0x240b00)<<6),63&_0x375a13),e.dPuHK(_0x33cda7,65536)||e[s(1018)](_0x6e0fe5,1114111)?_0x18a6ba+=_0x57c35e:(_0x579177-=65536,_0x45924f+=_0x248c9b(e[s(1266)](_0x54f905>>10,55296),e[s(790)](e[s(1600)](1023,_0x1770f1),56320)),_0x5ca3d7+=3)):(this[s(1049)]=!0,this[s(1075)]())),this[s(574)][s(1251)+s(1769)+s(892)]&&(this[s(826)+"T"]||this[s(1675)+"X"]?this[s(1472)+s(1240)+s(722)]():this[s(807)+"er"]&&this["_initGlo"+s(880)+s(1477)]())}[t(390)+t(654)](){let n=t;if(e[n(1035)](e[n(1430)],n(1561)))_0x542d0c=e[n(1650)](e.roQDR(31,_0x13812f),6)|63&_0x424a1d,_0xff54e4<128?_0x4684dc+=_0x4a6d18:(_0x39cdf4+=e[n(1484)](_0x2002ed,_0x500cdb),_0x2fb522++);else{if(this[n(574)].disableAutoReconnect||this[n(750)+n(1519)])return;this[n(1597)+"econnect"]()}}["_handleO"+t(848)](){let n=t;this[n(1359)+n(1500)+"t"]();let s=e[n(632)](da,n(1e3)+"t",{message:e[n(616)]});this[n(875)+"mediatelyReconnect"]&&this[n(875)+n(1099)+n(1773)+"ct"](s)}["_initGlo"+t(880)+t(1477)](){let n=t;this[n(807)+"er"]&&window[n(888)+n(1477)](e[n(1081)],this[n(390)+n(654)]),this[n(807)+"er"]&&window[n(888)+n(1477)](e[n(1197)],this[n(390)+n(848)]),this[n(807)+"er"]&&window[n(888)+"Listener"]("pagehide",this._handlePageHide),this._isBrowser&&window[n(888)+n(1477)](e[n(398)],this[n(753)+n(986)])}["_dropGlo"+t(880)+t(1477)](){let n=t;if(e.PHJke(e[n(1538)],n(1516)))this._isBrowser&&window[n(1827)+n(457)+n(1004)]("online",this[n(390)+n(654)]),this[n(807)+"er"]&&window[n(1827)+n(457)+n(1004)](n(1609),this._handleOffLine),this[n(807)+"er"]&&window[n(1827)+n(457)+"ner"](n(1877),this[n(753)+n(1783)]),this[n(807)+"er"]&&window[n(1827)+n(457)+n(1004)](n(996),this[n(753)+n(986)]);else return this[n(1259)][n(421)]()}[t(753)+"ageHide"](n){let s=t;!n.persisted&&(e[s(939)](e[s(522)],e[s(1738)])?(this._isBrowser&&window[s(1827)+s(457)+"ner"](e[s(1530)],this["_handleP"+s(1783)]),this._isBrowser&&window[s(1827)+s(457)+"ner"](s(996),this[s(753)+s(986)]),this[s(1655)]()):(_0x5e620b=e[s(1685)],_0x48c12c=_0x365ff5.replace(/(^http)((?:[s]*:\/\/))/,""),_0x5ae2c7=/(^ws)((?:[s]*:\/\/))/[s(1605)](_0x197d4a)?_0x185e07:""+_0x456f06+_0x5f1539)),this[s(807)+"er"]&&window[s(1827)+s(457)+s(1004)](s(1150),this[s(390)+s(654)]),this._isBrowser&&window[s(1827)+s(457)+"ner"](s(1609),this["_handleO"+s(848)])}[t(753)+t(986)](n){let s=t;n.persisted&&(this["_navigat"+s(1474)]()&&(!this._ws||e[s(712)](this[s(1196)][s(1654)+"te"],this[s(1305)])||e[s(1191)](this._ws[s(1654)+"te"],this.CONNECTING))&&this["_handleO"+s(654)](),this[s(807)+"er"]&&window[s(888)+s(1477)](s(1150),this[s(390)+s(654)]),this[s(807)+"er"]&&window[s(888)+"Listener"](e.dsBWr,this[s(390)+"ffLine"]))}async[t(1694)+t(725)](n){let s=t,{fpID:d,deviceID:u,bddID:p,ttwID:m,accessKey:E,aID:g,customParams:k={},enableAutoAck:N,enableQoS:z,QoSLevel:H,env:L}=this._options,F,se,qe;this[s(807)+"er"]||this._isMiniWX||this[s(826)+"T"]?(F=location&&e[s(1492)](s(1545),location.protocol)?e[s(1685)]:e[s(1642)],se=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),qe=/^wss(.*:\/\/)/[s(1605)](n)?n:""+F+se):e[s(759)]===e[s(1216)]?(_0x573eb5=_0xfefac6[s(1437)](_0x8de639),_0x340f31=_0x59a896.concat(_0x427476[_0x3c0e2e])):(F=s(499),se=n[s(459)](/(^http)((?:[s]*:\/\/))/,""),qe=/(^ws)((?:[s]*:\/\/))/[s(1605)](se)?se:""+F+se);let ts=p?e[s(1234)]:m?e[s(1550)]:s(751)+"d",ns=p||m||u;if(!ns||!ts)throw new Error(e[s(636)]);let ma=e[s(451)](e.WnXOS,typeof k)?await k():k,wa=L?ap(L[s(1834)],L[s(900)]):{},Wr=Object[s(957)]({device_platform:e[s(1737)],version_code:e[s(1659)],access_key:E,fpid:d,aid:g,[ts]:ns,xsack:N?1:0,xaack:N?1:0,xsqos:z?1:0,qos_level:z?H:void 0,qos_sdk_version:2,...wa},ma),_a=Object[s(1809)](Wr)[s(1310)]((tn,Ft)=>Wr[Ft]!==void 0?""+tn+(tn?"&":"?")+Ft+"="+Wr[Ft]:tn,"");return qe+s(1527)+_a}async[t(1075)](){let n=t;if(!(this[n(1075)+n(808)]||this[n(750)+n(1519)])){this[n(1075)+n(808)]=!0;try{let s=this[n(1270)+n(556)]?.["checkCur"+n(1679)+n(1168)+"hedMaxRetries"](),{timeoutInterval:d}=this[n(574)];if(s){let p=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoint"](),m=this[n(1270)+n(556)]?.["replaceB"+n(611)+n(1194)+n(1804)+"unt"](),E=this[n(1270)+"tManager"]?.["getCurre"+n(1050)+n(901)+"ount"]();if(m){let g=n(1622)+p+(" timeout, max re"+n(582)+"ached, will use "+n(1879)+"ndpoint ")+m+(n(659)+"y"),k=e.GzZZY(ot,n(1290),{message:g,code:Qt[n(692)+"IES_ERROR"]});this[n(1816)](g),this[n(1238)+"hErrorEvent"](k),this._url=await this["_generat"+n(725)](m),this[n(1816)](n(1622)+m+" "+E+n(1676)),this[n(1137)+n(1329)+"rs"]()}else{let g=n(1622)+p+(n(1749)+", max re"+n(582)+n(395));this._debug(g),this[n(1238)+n(1563)+n(1464)](e.IbvCg(ot,n(1290),{message:g,code:Qt[n(692)+n(1657)+"R"]}));return}}else{let p=this[n(1270)+n(556)]?.[n(1710)+n(1050)+n(1324)+n(1017)](),m=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoi"+n(901)+"ount"]();this._url=await this[n(1694)+n(725)](e[n(1384)](p,"")),this[n(1816)](n(1622)+p+" "+m+n(1676)),this[n(1137)+"sListeners"]()}if(this[n(1049)])this._isInit=!1;else{let p=e[n(711)](da,e[n(1604)],{message:n(1308)});this[n(538)+"econnect"]&&this[n(538)+"econnect"](p)}let u=this._endpointManager?.[n(1710)+"ntEndpointTriesC"+n(627)]()||0;e[n(1018)](u,1)&&await this._wait(e[n(569)](u,1)),this[n(1816)](n(704)+n(841)+this._url+(n(1265)+"ls: ")+this[n(531)+"ls"]),this[n(1196)]=e[n(1134)](ip,{url:this[n(1623)],protocols:[this[n(531)+"ls"]],headers:this[n(574)][n(619)+n(1555)+"s"][n(1433)+n(1649)]},this[n(574)].ws),(this[n(807)+"er"]||this[n(1634)+"r"])&&this[n(1196)]&&(this[n(1196)].binaryType=this["_binaryT"+n(1536)]),this[n(923)+n(830)](),this[n(1075)+n(1826)+"utId"]=setTimeout(this[n(1399)+"ut"][n(744)](this),d)}catch(s){throw this[n(1075)+n(808)]=!1,s}}}[t(554)+"mer"](){let n=t;e[n(928)](clearTimeout,this[n(1075)+n(1826)+n(1599)]),this[n(1075)+n(1826)+n(1599)]=null}[t(806)+"ngTimer"](){let n=t;clearTimeout(this["_pingPon"+n(472)+"Id"]),clearTimeout(this[n(1172)+n(1891)+n(646)]),this[n(669)+n(472)+"Id"]=null,this[n(1172)+n(1891)+n(646)]=null}[t(1816)](...n){let s=t;this[s(574)][s(515)]&&console[s(1740)][s(1110)](console,[e[s(1151)],...n])}[t(783)+"rvalValue"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[s(574)],m=e[s(908)](d,Math[s(1342)](p,e[s(1722)](n,1)));return m>u?u:m}_ping(){let n=t,s={ZSbAY:e[n(1797)]};if(this._ws&&this[n(1196)][n(1654)+"te"]===this.CONNECTING)if(e.aavyu("RuXCe",e[n(498)]))_0x8bc7b[n(1881)]["removeCh"+n(617)](_0x5bef62),_0x4a3cdc[n(1381)+"JSONP"]=void 0,_0x7d62b3(_0x343ee0&&_0x38d3f2[n(1535)]||NejjPF[n(971)]);else{this[n(806)+n(940)](),this[n(669)+n(472)+"Id"]=e.wMyla(setTimeout,this._ping[n(744)](this),this[n(574)]["pingInte"+n(1092)]);return}if(!this[n(1196)]||this._ws.readyState!==this.OPEN)return void this["_handleR"+n(593)]();this._ws&&this[n(1196)][n(1232)]("hi"),this[n(1172)+"ctTimeoutId"]=e[n(602)](setTimeout,this[n(1597)+"econnect"+n(404)][n(744)](this),this[n(574)]["pingTime"+n(467)+n(496)])}[t(1597)+t(593)+"Timeout"](){let n=t;this[n(1542)+"sCounter"]?.addCount(),this[n(714)](e.pWDCE,n(925)),this[n(1542)+n(420)]?.["checkRea"+n(396)+"nt"]()?this._handleReconnect():this[n(1636)]()}[t(1126)+"orOnline"](){let n=t;return this[n(826)+"T"]||this[n(1675)+"X"]?this[n(1639)+"igatorOn"+n(1428)]:(this[n(807)+"er"]||this._isWorker)&&this[n(574)][n(1251)+"tworkCha"+n(892)]?navigator[n(1736)]:!0}[t(1597)+"econnect"](){let n=t;!this[n(1126)+"orOnline"]()||this[n(750)+"osed"]||(this[n(1270)+n(556)]?.[n(1522)+n(758)+n(1242)](),this["_pingLos"+n(420)]?.[n(1034)+n(512)](),this._ws?this["_disconn"+n(1181)](1001,e[n(1291)],!0):this._connect())}["_onPageN"+t(1240)+t(722)](){let n=t;this._isMiniTT?tt[n(483)+n(495)+n(1841)](({isConnected:s})=>{let d=n;this[d(1639)+"igatorOn"+d(1428)]=s,s?this[d(390)+"nLine"]():this[d(390)+d(848)]()}):this._isMiniWX&&wx["onNetwor"+n(495)+n(1841)](({isConnected:s})=>{let d=n;this[d(1639)+d(917)+d(1428)]=s,s?this[d(390)+"nLine"]():this[d(390)+d(848)]()})}[t(413)](n){let s={bbymH:function(d,u,p){return e.fLKWT(d,u,p)}};return new Promise(d=>{let u=U;s.bbymH(setTimeout,d,this[u(783)+u(1112)+"e"](n))})}["_disconn"+t(1181)](n=1e3,s="",d=!1){let u=t;this[u(1196)]&&this[u(1359)+u(1500)+"t"](n,s,d)}[t(1399)+"ut"](){let n=t,s=this["_endpoin"+n(556)]?.[n(1710)+"ntEndpoint"]();this[n(1816)]("connect "+s+n(1749)),this[n(691)+n(1181)](1001,e[n(1776)],!0)}[t(481)](n){let s=t,d=e[s(1283)](Bt,n);this[s(1196)]&&this[s(1196)][s(1654)+"te"]===this[s(1305)]&&(this[s(1196)]&&this[s(1196)][s(1232)](d),this[s(1816)](e[s(936)],n))}[t(1137)+t(1329)+"rs"](){let n=t;this[n(1196)]&&(this[n(1196)]["removeEv"+n(457)+n(1004)](e[n(920)],this._onOpen),this[n(1196)][n(1827)+n(457)+n(1004)]("close",this[n(1104)]),this[n(1196)]["removeEv"+n(457)+n(1004)](e.gMljV,this[n(1228)+"ge"]),this[n(1196)][n(1827)+n(457)+n(1004)](e.hwdXv,this[n(676)]))}_addWsListeners(){let n=t;if(e.qYdYT(e[n(610)],e[n(1237)])){let s=e[n(1478)].split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1196)][n(888)+n(1477)](n(1326),this[n(1364)]);continue;case"1":this._ws[n(888)+n(1477)](e[n(710)],this[n(1228)+"ge"]);continue;case"2":this[n(1196)][n(888)+n(1477)](n(1655),this[n(1104)]);continue;case"3":if(!this[n(1196)])return;continue;case"4":this[n(1196)][n(888)+n(1477)](e[n(1277)],this[n(676)]);continue}break}}else return _0x3759aa["fromChar"+n(812)](e[n(1663)](255,this.low),e[n(1789)](e[n(1677)](this[n(1071)],8),255),e.tKpjk(e[n(1409)](this[n(1071)],16),255),e.wzVNx(this.low,24),255&this[n(1023)],e[n(1263)](this[n(1023)],8)&255,e[n(1125)](e[n(1073)](this[n(1023)],16),255),e[n(1556)](this[n(1023)],24))}[t(906)+"nceClose"](n=1e3,s=""){let d=t;try{if(e[d(1632)]("NjwcO",e[d(1711)]))return{bytes:_0xb0623,offset:0,limit:_0x23121c[d(614)]};this[d(1196)]&&this._ws[d(1655)](n,s)}catch{}}["_destroy"+t(1500)+"t"](n=1e3,s="",d=!1){let u=t;if(this[u(806)+u(940)](),this._clearTimer(),this[u(1137)+u(1329)+"rs"](),this[u(906)+u(1853)](1e3,s),this[u(1075)+u(808)]=!1,d&&this[u(1126)+u(1474)]()&&!this[u(750)+"osed"]){if(this[u(1270)+"tManager"]?.[u(1186)+u(1528)+"es"]()){let m=this[u(1270)+"tManager"]?.[u(1710)+u(1050)+"nt"]();this[u(1238)+u(1796)+u(1464)](xt(e.MFPir,{code:1006,reason:u(1622)+m+(u(1749)+u(941)+u(582)+u(395)),wasClean:!0}))}else{let m=this[u(574)][u(1e3)+u(1369)+u(962)](n,s);this[u(1238)+"hCloseEvent"](xt(e.MFPir,{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[u(1075)]()}return}this[u(1126)+u(1474)]()||this["_readyCl"+u(1519)]?this["_dispatc"+u(1796)+u(1464)](xt(u(1655),{code:n,reason:e[u(890)]})):this[u(1238)+u(1796)+u(1464)](e[u(1097)](xt,e.MFPir,{code:1006,reason:u(1185)+"ay, netw"+u(511)+"ine"})),this[u(1196)]=null,this[u(1270)+u(556)]?.["resetEnd"+u(758)+u(1242)](),this["_pingLos"+u(420)]?.[u(1034)+u(512)]()}[t(1238)+t(1316)+"nt"](n){let s=t;this[s(714)](e[s(920)],n),this.onopen&&this[s(482)](n)}["_dispatchMessage"+t(1750)](n){this[t(714)](e.gMljV,n),this.onmessage&&this.onmessage(n)}[t(1238)+t(1672)+t(1142)](n){let s=t;this[s(714)](e[s(419)],n),this[s(1633)+"eAck"]&&this[s(1633)+s(1883)](n)}[t(1238)+t(1563)+t(1464)](n){let s=t;this[s(714)](e[s(1277)],n),this.onerror&&this[s(578)](n)}[t(1238)+t(1796)+t(1464)](n){let s=t;this.emit(s(1655),n),this.onclose&&this[s(1346)](n)}get[t(1723)+"pe"](){let n=t;return this[n(1196)]?this[n(1196)][n(1723)+"pe"]:this[n(1489)+n(1536)]}set[t(1723)+"pe"](n){let s=t;this["_binaryT"+s(1536)]=n,this._ws&&(this[s(1196)][s(1723)+"pe"]=n)}get retryCount(){let n=t;return this[n(1270)+n(556)]?.["getCurre"+n(1050)+"ntTriesCount"]()||0}get[t(765)+t(592)](){let n=t;if(e[n(491)]!==n(746))this[n(826)+"T"]||this._isMiniWX?this[n(1472)+n(1240)+"ange"]():this[n(807)+"er"]&&this[n(1584)+n(880)+"Listener"]();else{let s=this["_message"+n(1505)].reduce((d,u)=>(d+=u&&u[n(508)+"th"]||0,d),0);return e[n(1463)](s,this[n(1196)]?this[n(1196)][n(765)+n(592)]:0)}}get[t(844)+"ns"](){let n=t;return this[n(1196)]?this[n(1196)][n(844)+"ns"]:""}get[t(1585)](){let n=t;return this[n(1196)]?this[n(1196)].protocol:""}get[t(1654)+"te"](){let n=t;return this[n(1196)]?this[n(1196)][n(1654)+"te"]:this[n(574)]["automati"+n(794)]?this[n(1245)+"NG"]:this[n(992)]}get[t(1195)](){let n=t,s={QPDGl:function(d,u){return e[U(470)](d,u)}};if(e[n(1179)]===e[n(984)]){let d=0,u={};for(let p=0;rkYkrG.QPDGl(p,_0x3918d3.length);p++)u[_0x500a74[p]["cursor_n"+n(1338)]]=_0x48e0fe(_0x486da3[p]["cursor_n"+n(1338)]),d+=14+u[_0x2b68d4[p][n(1748)+n(1338)]];return[d,u]}else return this[n(1196)]?this[n(1196)].url:this[n(1623)]}[t(1655)](n=1e3,s){let d=t,u=e[d(406)][d(1193)]("|"),p=0;for(;;){switch(u[p++]){case"0":this[d(554)+d(1724)]();continue;case"1":if(!this[d(1196)])return void this[d(1816)](d(1152)+"s instan"+d(546)+"nitialized");continue;case"2":this[d(1113)+d(880)+d(1477)]();continue;case"3":this[d(806)+d(940)]();continue;case"4":this[d(1359)+"WebSocket"](n,s);continue;case"5":if(e.tqsAb(this[d(1196)].readyState,this[d(992)])||e[d(1697)](this[d(1196)][d(1654)+"te"],this.CLOSING))return void this[d(1816)](e.UGPKD);continue;case"6":this[d(856)+d(894)]?.[d(1552)]();continue;case"7":this[d(750)+d(1519)]=!0;continue}break}}async[t(1232)](n,s){let d=t;if(e[d(451)](null,n))throw new Error(e.VDGAb);e[d(1377)](e.HTnZI,typeof n)&&(n=JSON[d(1547)+"y"](n)),e[d(1515)](e[d(1801)],typeof n)&&!e[d(682)](n,ArrayBuffer)&&!(n.buffer&&e[d(703)](n[d(1806)],ArrayBuffer))&&(n=JSON.stringify(n));let u=await tl(n),p=op(n),{method:m=0,service:E=this[d(574)][d(1424)],logID:g=this[d(574)][d(1712)+d(1177)](),headers:k=this[d(574)][d(1429)],payloadEncoding:N=this[d(574)][d(1882)+"ncoding"],payloadType:z=this._options[d(802)+d(1536)],logIDNew:H=this[d(574)][d(475)+d(1100)][d(801)+d(1758)+d(1887)+"ew"]?i(this[d(574)]["logIDNew"+d(1100)][d(633)]):""}=e.yWGfJ(s,{});if(!E)throw new Error(e.cwINr);let L={SeqID:de.fromNumber(this[d(1070)]++),LogID:de[d(1660)+"er"](g),service:E,method:m,headers:k,payloadEncoding:e[d(682)](N,Object)?N[d(1781)]?N[d(1781)]:"":N,payloadType:z instanceof Object?z.type?z[d(840)]:p:z||p,payload:u,LogIDNew:H},F=e[d(1665)](Bt,L);return this._ws&&this[d(1196)][d(1654)+"te"]===this[d(1305)]?(this._ws&&this[d(1196)][d(1232)](F),this[d(1816)](e[d(1779)],L)):e[d(1784)](this[d(1421)+d(1505)][d(614)],this[d(574)][d(553)+"geQueueL"+d(729)])?(this["_message"+d(1505)].push(F),this[d(1816)](e[d(1588)],L)):(this[d(1421)+"Queue"][d(719)](),this[d(1421)+d(1505)][d(1889)](F)),{seqID:this[d(1070)],logID:g,logIDNew:H}}async[t(1e3)+"t"](n){let s=t,{url:d}=n||{},u=Array[s(464)](d)?d:e[s(684)](s(1028),typeof d)?[d]:[];n&&Object[s(957)](this[s(574)],n),u&&u[s(614)]?this[s(1270)+s(556)]=new Zd(u,this[s(574)][s(660)+"es"]):this[s(1270)+s(556)]?.[s(1522)+s(758)+s(1242)](),this[s(1542)+s(420)]?.[s(1034)+s(512)](this._options[s(1782)+s(1449)]),this[s(750)+s(1519)]=!1,this._ws&&e.itOvc(this[s(1196)][s(1654)+"te"],this[s(992)])?this[s(691)+s(1181)](1e3,e[s(1300)],!0):(this[s(1049)]=!0,this._connect())}async[t(1209)](){let n=t;if(!this[n(1075)+n(808)]){let s=(n(1330)+"3")[n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1049)]=!0;continue;case"1":this[n(1542)+n(420)]?.resetCounter();continue;case"2":this[n(1270)+n(556)]?.[n(1522)+"pointCon"+n(1242)]();continue;case"3":this[n(1075)]();continue;case"4":this._readyClosed=!1;continue}break}}}[t(888)+"Listener"](n,s){this.on(n,s)}dispatchEvent(n){let{type:s}=n;this.emit(s,n)}["removeEv"+t(457)+t(1004)](n,s){let d=t;if(e[d(1020)](e[d(547)],e[d(558)]))return this[d(1259)]?.set({message_id:_0x4fac01,timestamp:_0x1ac25a});this[d(552)](n,s)}[t(879)](){return new Promise((n,s)=>{let d=U,u={sEgsr:function(E,g){return E(g)},oQTiL:e[d(1880)],vhOek:e[d(528)],VUgVZ:e[d(1057)]};this[d(806)+"ngTimer"](),this[d(669)+"gTimeoutId"]=e[d(1159)](setTimeout,this[d(1636)].bind(this),this[d(574)][d(993)+d(1092)]);let p=()=>{let E=d;u[E(1331)](n,u[E(436)]),this[E(552)](u[E(534)],p),this[E(552)](u[E(474)],m)},m=()=>{let E=d;u[E(1331)](s,E(925)),this.off(u[E(534)],p),this.off(u[E(474)],m)};this.on(e[d(528)],p),this.on(e[d(1057)],m),this._ping()})}}})(),Le[M(834)+M(1620)]=Ce[M(834)+M(1620)],Le[M(1846)+M(456)]=Ce.CustomErrorEvent,Le[M(800)+"e"]=Ce[M(800)+"e"],Le[M(1750)]=Ce[M(1750)],Le[M(1379)]=Ce[M(1379)],Le[M(560)+"MessageE"+M(1217)]=Ce["Frontier"+M(824)+M(1217)],Le[M(824)+M(1217)]=Ce[M(824)+"vent"],Le[M(402)+"t"]=Ce[M(402)+"t"],Le[M(1548)+"tEvent"]=Ce[M(1548)+M(913)],Le[M(749)+M(1620)]=Ce[M(749)+M(1620)],Le.createErrorEvent=Ce[M(504)+M(456)],Le[M(479)+M(1687)+"nt"]=Ce[M(479)+M(1687)+"nt"],Le[M(416)+M(885)]=Ce["createOp"+M(885)],Le["createRe"+M(1581)+M(1217)]=Ce[M(1128)+M(1581)+M(1217)],Le[M(1244)+M(507)]=Ce["decodedF"+M(507)],Le[M(1417)+"ame"]=Ce["encodeFr"+M(1338)];for(Ao in Ce)[M(834)+"oseEvent",M(1846)+M(456),"ErrorCode",M(1750),"FWS",M(560)+"MessageEvent",M(824)+M(1217),M(402)+"t",M(1548)+M(913),M(749)+M(1620),M(504)+M(456),M(479)+"ssageEvent",M(416)+M(885),"createRe"+M(1581)+M(1217),"decodedFrame",M(1417)+M(1338)][M(1678)](Ao)===-1&&(Le[Ao]=Ce[Ao]);var Ao;Object.defineProperty(Le,M(1448)+"le",{value:!0})});var Kt=oe((tC,ox)=>{"use strict";var ix=["nodebuffer","arraybuffer","fragments"],sx=typeof Blob<"u";sx&&ix.push("blob");ox.exports={BINARY_TYPES:ix,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var qi=oe((nC,Oo)=>{"use strict";var{EMPTY_BUFFER:Wb}=Kt(),ad=Buffer[Symbol.species];function Kb(t,e){if(t.length===0)return Wb;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new ad(r.buffer,r.byteOffset,i):r}function ax(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function cx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function $b(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function cd(t){if(cd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new ad(t):ArrayBuffer.isView(t)?e=new ad(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),cd.readOnly=!1),e}Oo.exports={concat:Kb,mask:ax,toArrayBuffer:$b,toBuffer:cd,unmask:cx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");Oo.exports.mask=function(e,r,i,o,c){c<48?ax(e,r,i,o,c):t.mask(e,r,i,o,c)},Oo.exports.unmask=function(e,r){e.length<32?cx(e,r):t.unmask(e,r)}}catch{}});var fx=oe((rC,lx)=>{"use strict";var dx=Symbol("kDone"),dd=Symbol("kRun"),ld=class{constructor(e){this[dx]=()=>{this.pending--,this[dd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[dd]()}[dd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[dx])}}};lx.exports=ld});var kr=oe((iC,px)=>{"use strict";var Hi=le("zlib"),ux=qi(),Vb=fx(),{kStatusCode:xx}=Kt(),Yb=Buffer[Symbol.species],Jb=Buffer.from([0,0,255,255]),No=Symbol("permessage-deflate"),$t=Symbol("total-length"),Rr=Symbol("callback"),En=Symbol("buffers"),Dr=Symbol("error"),Po,fd=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Po){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Po=new Vb(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Rr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Po.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Po.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Hi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Hi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[No]=this,this._inflate[$t]=0,this._inflate[En]=[],this._inflate.on("error",Xb),this._inflate.on("data",hx)}this._inflate[Rr]=i,this._inflate.write(e),r&&this._inflate.write(Jb),this._inflate.flush(()=>{let c=this._inflate[Dr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=ux.concat(this._inflate[En],this._inflate[$t]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$t]=0,this._inflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Hi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Hi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[$t]=0,this._deflate[En]=[],this._deflate.on("data",Zb)}this._deflate[Rr]=i,this._deflate.write(e),this._deflate.flush(Hi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=ux.concat(this._deflate[En],this._deflate[$t]);r&&(c=new Yb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Rr]=null,this._deflate[$t]=0,this._deflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};px.exports=fd;function Zb(t){this[En].push(t),this[$t]+=t.length}function hx(t){if(this[$t]+=t.length,this[No]._maxPayload<1||this[$t]<=this[No]._maxPayload){this[En].push(t);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][xx]=1009,this.removeListener("data",hx),this.reset()}function Xb(t){if(this[No]._inflate=null,this[Dr]){this[Rr](this[Dr]);return}t[xx]=1007,this[Rr](t)}});var Or=oe((sC,Lo)=>{"use strict";var{isUtf8:gx}=le("buffer"),{hasBlob:Qb}=Kt(),eE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function tE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ud(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function nE(t){return Qb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Lo.exports={isBlob:nE,isValidStatusCode:tE,isValidUTF8:ud,tokenChars:eE};if(gx)Lo.exports.isValidUTF8=function(t){return t.length<24?ud(t):gx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Lo.exports.isValidUTF8=function(e){return e.length<32?ud(e):t(e)}}catch{}});var md=oe((oC,Sx)=>{"use strict";var{Writable:rE}=le("stream"),mx=kr(),{BINARY_TYPES:iE,EMPTY_BUFFER:_x,kStatusCode:sE,kWebSocket:oE}=Kt(),{concat:xd,toArrayBuffer:aE,unmask:cE}=qi(),{isValidStatusCode:dE,isValidUTF8:yx}=Or(),Mo=Buffer[Symbol.species],lt=0,bx=1,Ex=2,vx=3,hd=4,pd=5,Bo=6,gd=class extends rE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||iE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[oE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Mo(i.buffer,i.byteOffset+e,i.length-e),new Mo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Mo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case lt:this.getInfo(e);break;case bx:this.getPayloadLength16(e);break;case Ex:this.getPayloadLength64(e);break;case vx:this.getMask();break;case hd:this.getData(e);break;case pd:case Bo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[mx.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=bx:this._payloadLength===127?this._state=Ex:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=vx:this._state=hd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=hd}getData(e){let r=_x;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&cE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=pd,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[mx.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=xd(i,r):this._binaryType==="arraybuffer"?o=aE(xd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=xd(i,r);if(!this._skipUTF8Validation&&!yx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===pd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit("message",o,!1),this._state=lt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,_x),this.end();else{let i=e.readUInt16BE(0);if(!dE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Mo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!yx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=lt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=lt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[sE]=o,l}};Sx.exports=gd});var yd=oe((cC,Tx)=>{"use strict";var{Duplex:aC}=le("stream"),{randomFillSync:lE}=le("crypto"),Ax=kr(),{EMPTY_BUFFER:fE,kWebSocket:uE,NOOP:xE}=Kt(),{isBlob:Pr,isValidStatusCode:hE}=Or(),{mask:Ix,toBuffer:qn}=qi(),ft=Symbol("kByteLength"),pE=Buffer.alloc(4),Fo=8*1024,Hn,Nr=Fo,Et=0,gE=1,mE=2,wd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Et,this.onerror=xE,this[uE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||pE,r.generateMask?r.generateMask(i):(Nr===Fo&&(Hn===void 0&&(Hn=Buffer.alloc(Fo)),lE(Hn,0,Fo),Nr=0),i[0]=Hn[Nr++],i[1]=Hn[Nr++],i[2]=Hn[Nr++],i[3]=Hn[Nr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||l)&&r[ft]!==void 0?f=r[ft]:(e=Buffer.from(e),f=e.length):(f=e.length,o=r.mask&&r.readOnly&&!l);let x=f;f>=65536?(c+=8,x=127):f>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(o?f+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(f,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(f,4,6)),r.mask?(h[1]|=128,h[c-4]=i[0],h[c-3]=i[1],h[c-2]=i[2],h[c-1]=i[3],l?[h,e]:o?(Ix(e,i,h,c,f),[h]):(Ix(e,i,e,0,f),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=fE;else{if(typeof e!="number"||!hE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+f),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ft]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Et?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Ax.extensionName],c=r.binary?2:1,l=r.compress,f,x;typeof e=="string"?(f=Buffer.byteLength(e),x=!1):Pr(e)?(f=e.size,x=!1):(e=qn(e),f=e.length,x=qn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=f>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[ft]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==Et?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ft],this._state=mE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(_d,this,f,o);return}this._bufferedBytes-=i[ft];let l=qn(c);r?this.dispatch(l,r,i,o):(this._state=Et,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(wE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ax.extensionName];this._bufferedBytes+=i[ft],this._state=gE,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");_d(this,x,o);return}this._bufferedBytes-=i[ft],this._state=Et,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===Et&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ft],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ft],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Tx.exports=wd;function _d(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function wE(t,e,r){_d(t,e,r),t.onerror(e)}});var Mx=oe((dC,Lx)=>{"use strict";var{kForOnEventAttribute:ji,kListener:bd}=Kt(),Cx=Symbol("kCode"),Rx=Symbol("kData"),Dx=Symbol("kError"),kx=Symbol("kMessage"),Ox=Symbol("kReason"),Lr=Symbol("kTarget"),Px=Symbol("kType"),Nx=Symbol("kWasClean"),Vt=class{constructor(e){this[Lr]=null,this[Px]=e}get target(){return this[Lr]}get type(){return this[Px]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var jn=class extends Vt{constructor(e,r={}){super(e),this[Cx]=r.code===void 0?0:r.code,this[Ox]=r.reason===void 0?"":r.reason,this[Nx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Cx]}get reason(){return this[Ox]}get wasClean(){return this[Nx]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Mr=class extends Vt{constructor(e,r={}){super(e),this[Dx]=r.error===void 0?null:r.error,this[kx]=r.message===void 0?"":r.message}get error(){return this[Dx]}get message(){return this[kx]}};Object.defineProperty(Mr.prototype,"error",{enumerable:!0});Object.defineProperty(Mr.prototype,"message",{enumerable:!0});var Wi=class extends Vt{constructor(e,r={}){super(e),this[Rx]=r.data===void 0?null:r.data}get data(){return this[Rx]}};Object.defineProperty(Wi.prototype,"data",{enumerable:!0});var _E={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[ji]&&o[bd]===e&&!o[ji])return;let i;if(t==="message")i=function(c,l){let f=new Wi("message",{data:l?c:c.toString()});f[Lr]=this,zo(e,this,f)};else if(t==="close")i=function(c,l){let f=new jn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Lr]=this,zo(e,this,f)};else if(t==="error")i=function(c){let l=new Mr("error",{error:c,message:c.message});l[Lr]=this,zo(e,this,l)};else if(t==="open")i=function(){let c=new Vt("open");c[Lr]=this,zo(e,this,c)};else return;i[ji]=!!r[ji],i[bd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[bd]===e&&!r[ji]){this.removeListener(t,r);break}}};Lx.exports={CloseEvent:jn,ErrorEvent:Mr,Event:Vt,EventTarget:_E,MessageEvent:Wi};function zo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Uo=oe((lC,Bx)=>{"use strict";var{tokenChars:Ki}=Or();function Mt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function yE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,f,x=-1,h=-1,_=-1,w=0;for(;w<t.length;w++)if(h=t.charCodeAt(w),l===void 0)if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(w!==0&&(h===32||h===9))_===-1&&x!==-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);h===44?(Mt(e,b,r),r=Object.create(null)):l=b,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(f===void 0)if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(h===32||h===9)_===-1&&x!==-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w),Mt(r,t.slice(x,_),!0),h===44&&(Mt(e,l,r),r=Object.create(null),l=void 0),x=_=-1}else if(h===61&&x!==-1&&_===-1)f=t.slice(x,w),x=_=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(o){if(Ki[h]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);x===-1?x=w:i||(i=!0),o=!1}else if(c)if(Ki[h]===1)x===-1&&(x=w);else if(h===34&&x!==-1)c=!1,_=w;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===34&&t.charCodeAt(w-1)===61)c=!0;else if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(x!==-1&&(h===32||h===9))_===-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);i&&(b=b.replace(/\\/g,""),i=!1),Mt(r,f,b),h===44&&(Mt(e,l,r),r=Object.create(null),l=void 0),f=void 0,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=w);let S=t.slice(x,_);return l===void 0?Mt(e,S,r):(f===void 0?Mt(r,S,!0):i?Mt(r,f,S.replace(/\\/g,"")):Mt(r,f,S),Mt(e,l,r)),e}function bE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Bx.exports={format:bE,parse:yE}});var jo=oe((xC,Yx)=>{"use strict";var EE=le("events"),vE=le("https"),SE=le("http"),Ux=le("net"),AE=le("tls"),{randomBytes:IE,createHash:TE}=le("crypto"),{Duplex:fC,Readable:uC}=le("stream"),{URL:Ed}=le("url"),vn=kr(),CE=md(),RE=yd(),{isBlob:DE}=Or(),{BINARY_TYPES:Fx,CLOSE_TIMEOUT:kE,EMPTY_BUFFER:Go,GUID:OE,kForOnEventAttribute:vd,kListener:PE,kStatusCode:NE,kWebSocket:Ue,NOOP:Gx}=Kt(),{EventTarget:{addEventListener:LE,removeEventListener:ME}}=Mx(),{format:BE,parse:FE}=Uo(),{toBuffer:zE}=qi(),qx=Symbol("kAborted"),Sd=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],UE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends EE{constructor(e,r,i){super(),this._binaryType=Fx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Go,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Hx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fx.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new CE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new RE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ue]=this,c[Ue]=this,e[Ue]=this,o.on("conclude",HE),o.on("drain",jE),o.on("error",WE),o.on("message",KE),o.on("ping",$E),o.on("pong",VE),c.onerror=YE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Kx),e.on("data",Ho),e.on("end",$x),e.on("error",Vx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[vn.extensionName]&&this._extensions[vn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Wx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Go,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Go,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Go,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ge,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(ge.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(ge,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(ge.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(ge,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(ge.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(ge,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(ge.prototype,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ge.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ge.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[vd])return e[PE];return null},set(e){for(let r of this.listeners(t))if(r[vd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[vd]:!0})}})});ge.prototype.addEventListener=LE;ge.prototype.removeEventListener=ME;Yx.exports=ge;function Hx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:kE,protocolVersion:Sd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Sd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Sd.join(", ")})`);let c;if(e instanceof Ed)c=e;else try{c=new Ed(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",f=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!l&&!f?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;qo(t,I);return}let h=l?443:80,_=IE(16).toString("base64"),w=l?vE.request:SE.request,S=new Set,b;if(o.createConnection=o.createConnection||(l?qE:GE),o.defaultPort=o.defaultPort||h,o.port=c.port||h,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(b=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=BE({[vn.extensionName]:b.offer()})),r.length){for(let I of r){if(typeof I!="string"||!UE.test(I)||S.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),f){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=l,t._originalHostOrSocketPath=f?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,C]of Object.entries(I))i.headers[A.toLowerCase()]=C}else if(t.listenerCount("redirect")===0){let I=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=w(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=w(o);o.timeout&&v.on("timeout",()=>{st(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[qx]||(v=t._req=null,qo(t,I))}),v.on("response",I=>{let A=I.headers.location,C=I.statusCode;if(A&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){st(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new Ed(A,e)}catch{let R=new SyntaxError(`Invalid URL: ${A}`);qo(t,R);return}Hx(t,P,r,i)}else t.emit("unexpected-response",v,I)||st(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,A,C)=>{if(t.emit("upgrade",I),t.readyState!==ge.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){st(t,A,"Invalid Upgrade header");return}let y=TE("sha1").update(_+OE).digest("base64");if(I.headers["sec-websocket-accept"]!==y){st(t,A,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],D;if(R!==void 0?S.size?S.has(R)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":S.size&&(D="Server sent no subprotocol"),D){st(t,A,D);return}R&&(t._protocol=R);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!b){st(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let G;try{G=FE(B)}catch{st(t,A,"Invalid Sec-WebSocket-Extensions header");return}let Y=Object.keys(G);if(Y.length!==1||Y[0]!==vn.extensionName){st(t,A,"Server indicated an extension that was not requested");return}try{b.accept(G[vn.extensionName])}catch{st(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=b}t.setSocket(A,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function qo(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function GE(t){return t.path=t.socketPath,Ux.connect(t)}function qE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ux.isIP(t.host)?"":t.host),AE.connect(t)}function st(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,st),e.setHeader?(e[qx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(qo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ad(t,e,r){if(e){let i=DE(e)?e.size:zE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Yt[t.readyState]})`);process.nextTick(r,i)}}function HE(t,e){let r=this[Ue];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ue]!==void 0&&(r._socket.removeListener("data",Ho),process.nextTick(jx,r._socket),t===1005?r.close():r.close(t,e))}function jE(){let t=this[Ue];t.isPaused||t._socket.resume()}function WE(t){let e=this[Ue];e._socket[Ue]!==void 0&&(e._socket.removeListener("data",Ho),process.nextTick(jx,e._socket),e.close(t[NE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function zx(){this[Ue].emitClose()}function KE(t,e){this[Ue].emit("message",t,e)}function $E(t){let e=this[Ue];e._autoPong&&e.pong(t,!this._isServer,Gx),e.emit("ping",t)}function VE(t){this[Ue].emit("pong",t)}function jx(t){t.resume()}function YE(t){let e=this[Ue];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Wx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Wx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Kx(){let t=this[Ue];if(this.removeListener("close",Kx),this.removeListener("data",Ho),this.removeListener("end",$x),t._readyState=ge.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Ue]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",zx),t._receiver.on("finish",zx))}function Ho(t){this[Ue]._receiver.write(t)||this.pause()}function $x(){let t=this[Ue];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function Vx(){let t=this[Ue];this.removeListener("error",Vx),this.on("error",Gx),t&&(t._readyState=ge.CLOSING,this.destroy())}});var Qx=oe((pC,Xx)=>{"use strict";var hC=jo(),{Duplex:JE}=le("stream");function Jx(t){t.emit("close")}function ZE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Zx(t){this.removeListener("error",Zx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function XE(t,e){let r=!0,i=new JE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let f=!l&&i._readableState.objectMode?c.toString():c;i.push(f)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Jx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Jx,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",ZE),i.on("error",Zx),i}Xx.exports=XE});var Id=oe((gC,eh)=>{"use strict";var{tokenChars:QE}=Or();function ev(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&QE[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let f=t.slice(r,i);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}eh.exports={parse:ev}});var ah=oe((wC,oh)=>{"use strict";var tv=le("events"),Wo=le("http"),{Duplex:mC}=le("stream"),{createHash:nv}=le("crypto"),th=Uo(),Wn=kr(),rv=Id(),iv=jo(),{CLOSE_TIMEOUT:sv,GUID:ov,kWebSocket:av}=Kt(),cv=/^[+/0-9A-Za-z]{22}==$/,nh=0,rh=1,sh=2,Td=class extends tv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:sv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:iv,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Wo.createServer((i,o)=>{let c=Wo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=dv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=nh}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===sh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick($i,this);return}if(e&&this.once("close",e),this._state!==rh)if(this._state=rh,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick($i,this):process.nextTick($i,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{$i(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",ih);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!cv.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Vi(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=rv.parse(x)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&_!==void 0){let S=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let b=th.parse(_);b[Wn.extensionName]&&(S.accept(b[Wn.extensionName]),w[Wn.extensionName]=S)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(b,v,I,A)=>{if(!b)return Vi(r,v||401,I,A);this.completeUpgrade(w,c,h,e,r,i,o)});return}if(!this.options.verifyClient(S))return Vi(r,401)}this.completeUpgrade(w,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[av])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>nh)return Vi(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${nv("sha1").update(r+ov).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(i.size){let w=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;w&&(h.push(`Sec-WebSocket-Protocol: ${w}`),_._protocol=w)}if(e[Wn.extensionName]){let w=e[Wn.extensionName].params,S=th.format({[Wn.extensionName]:[w]});h.push(`Sec-WebSocket-Extensions: ${S}`),_._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",ih),_.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick($i,this)})),f(_,o)}};oh.exports=Td;function dv(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function $i(t){t._state=sh,t.emit("close")}function ih(){this.destroy()}function Vi(t,e,r,i){r=r||Wo.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} ${Wo.STATUS_CODES[e]}\r
|
|
17
17
|
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let
|
|
21
|
-
<string>${
|
|
20
|
+
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else Vi(r,i,o,c)}});import{existsSync as Pv,openSync as Nv}from"node:fs";import{mkdir as Lv}from"node:fs/promises";import{dirname as Mv}from"node:path";import{fileURLToPath as Bv}from"node:url";function zv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function kd(t=X()){return Pv(t.libEntry)?t.libEntry:Bv(new URL("../index.ts",import.meta.url))}async function bh(t={}){let e=t.paths??X(),r=t.entryOverride??kd(e),i=zv(e,process.env.COZE_BRIDGE_LOG_MODE);await Lv(Mv(i),{recursive:!0});let o=Nv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=dt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Zi]:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return Fv.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var Fv,Zi,Jo=Ye(()=>{"use strict";yn();ne();ke();Fv=j("spawn-daemon"),Zi="COZE_BRIDGE_DAEMON"});import{spawn as TS}from"node:child_process";import{mkdir as CS,unlink as RS,writeFile as DS}from"node:fs/promises";import{dirname as kS,join as OS}from"node:path";function Ur(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function PS(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Ur(r)}</key>
|
|
21
|
+
<string>${Ur(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function NS(t,e){return new Promise((r,i)=>{let o=TS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var zr,Qi,ra,Fd,Fh=Ye(()=>{"use strict";ne();zr=j("supervisor.launchd"),Qi="ai.coze.bridge",ra=NS,Fd={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>${Qi}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Ur(t.nodeBin)}</string>
|
|
35
|
+
<string>${Ur(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>${Ur(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Ur(t.logFile)}</string>${PS(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return OS(t.homeDir,"Library","LaunchAgents",`${Qi}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await CS(kS(i),{recursive:!0}),await DS(i,this.renderConfig(t),"utf8"),zr.info("plist written",{plistPath:i,activate:r}),!r)return;await ra("launchctl",["unload","-w",i]).catch(c=>zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ra("launchctl",["load","-w",i]),zr.info("launchd job loaded",{label:Qi});let o=process.getuid?.()??0;await ra("launchctl",["kickstart","-k",`gui/${o}/${Qi}`]),zr.info("launchd job kickstarted",{label:Qi,uid:o})},async uninstall(t){let e=this.configPath(t);await ra("launchctl",["unload","-w",e]).catch(r=>zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await RS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),zr.info("launchd job removed",{plistPath:e})}}});import{spawn as LS}from"node:child_process";import{mkdir as MS,unlink as BS,writeFile as FS}from"node:fs/promises";import{dirname as zS,join as zh}from"node:path";function sa(t,e){return t.isRoot?e:["--user",...e]}function GS(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function oa(t,e){return new Promise((r,i)=>{let o=LS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var ia,Gr,US,zd,Uh=Ye(()=>{"use strict";ne();ia=j("supervisor.systemd"),Gr="coze-bridge.service",US="/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
|
+
${GS(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?zh(US,Gr):zh(t.homeDir,".config","systemd","user",Gr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await MS(zS(i),{recursive:!0}),await FS(i,this.renderConfig(t),"utf8"),ia.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await oa("systemctl",sa(t,["daemon-reload"])),await oa("systemctl",sa(t,r?["enable","--now",Gr]:["enable",Gr])),ia.info("systemd unit enabled",{unitName:Gr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await oa("systemctl",sa(t,["disable","--now",Gr])).catch(r=>ia.warn("systemctl disable failed (ignored)",{err:String(r)})),await BS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await oa("systemctl",sa(t,["daemon-reload"])).catch(()=>{}),ia.info("systemd unit removed",{unitPath:e})}}});import{spawn as qS}from"node:child_process";import{join as HS}from"node:path";function Gh(t,e){return new Promise((r,i)=>{let o=qS(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Ud,aa,Gd,qh=Ye(()=>{"use strict";ne();Ud=j("supervisor.taskscheduler"),aa="CozeBridge",Gd={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,44 +86,43 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return H1(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Mh("schtasks",["/Create","/SC","ONLOGON","/TN",sa,"/TR",r,"/RU",t.userName,"/F"]),zd.info("task scheduler entry created",{task:sa,logFile:t.logFile})},async uninstall(t){await Mh("schtasks",["/Delete","/TN",sa,"/F"]).catch(e=>zd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),zd.info("task scheduler entry removed",{task:sa})}}});var Fh={};_a(Fh,{buildContext:()=>$1,getSupervisor:()=>G1,launchdSupervisor:()=>Bd,systemdSupervisor:()=>Fd,taskSchedulerSupervisor:()=>Ud});import{homedir as q1,userInfo as j1}from"node:os";function G1(t=process.platform){switch(t){case"darwin":return Bd;case"linux":return Fd;case"win32":return Ud;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function W1(){let t={};for(let e of K1){let r=process.env[e];r&&(t[e]=r)}return t}function $1(){let t=X();return{nodeBin:process.execPath,entry:Rd(t),logFile:t.logFile,homeDir:q1(),userName:j1().username,isRoot:process.getuid?.()===0,env:W1()}}var K1,zh=Ye(()=>{"use strict";Oe();Vo();Nh();Lh();Bh();K1=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();tn();var g0=H("acp-installer-warmup"),cg=["claude-code","codex"];async function m0(t={}){let e=t.ensure??nr,i=(await Promise.allSettled(cg.map(async o=>{let c=await e(o);g0.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&g0.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))})}nn();ne();import{readdir as yg}from"node:fs/promises";import{mkdir as v0,writeFile as S0}from"node:fs/promises";import{join as Aa}from"node:path";var _g={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function sr(t,e,r){await v0(t,{recursive:!0});let i=_g[e],o=Aa(t,i);return await S0(o,r??"","utf8"),o}async function I0(t){let e=Aa(t,".claude");await v0(e,{recursive:!0});let r=Aa(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await S0(r,i,"utf8"),r}var et=H("agent-detail-sync"),bg=6e4,Eg=5*6e4,ls=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await yg(r)}catch(o){et.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}et.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await je(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){et.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(u){et.warn("detail sync failed for agent, skipping",{agentId:o,err:String(u)})}}})),et.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){et.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){et.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await je(e,this.opts.paths);if(!i){et.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){et.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,Eg):bg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){et.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,u=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,u=!0),o.deployType&&et.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){et.debug("detail sync: no diff",{agentId:e});return}await Ze(i,this.opts.paths),et.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:i.agentName}),u&&(await sr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Hl=St(iu(),1);import{lstat as Hc,mkdir as qc,readFile as Bl,readdir as Jw,rm as Yw,stat as Zw,writeFile as jc}from"node:fs/promises";import{dirname as Xw,join as kt,normalize as Qw,relative as Wc,resolve as Gc,sep as Fl}from"node:path";import{Readable as zl}from"node:stream";import{pipeline as Ul}from"node:stream/promises";import Gg from"events";import Xe from"fs";import{EventEmitter as Ic}from"node:events";import zu from"node:stream";import{StringDecoder as Kg}from"node:string_decoder";import qu from"node:path";import mr from"node:fs";import{dirname as im,parse as sm}from"path";import{EventEmitter as xm}from"events";import oc from"assert";import{Buffer as Mn}from"buffer";import*as du from"zlib";import hm from"zlib";import{posix as ur}from"node:path";import{basename as Hm}from"node:path";import js from"fs";import Ct from"fs";import gu from"path";import{win32 as Xm}from"node:path";import vu from"path";import rl from"node:fs";import pw from"node:assert";import{randomBytes as il}from"node:crypto";import re from"node:fs";import Pe from"node:path";import sl from"fs";import Xs from"node:fs";import _i from"node:path";import it from"node:fs";import Ew from"node:fs/promises";import Ws from"node:path";import{join as gl}from"node:path";import rt from"node:fs";import _l from"node:path";var qg=Object.defineProperty,jg=(t,e)=>{for(var r in e)qg(t,r,{get:e[r],enumerable:!0})},su=typeof process=="object"&&process?process:{stdout:null,stderr:null},Wg=t=>!!t&&typeof t=="object"&&(t instanceof zn||t instanceof zu||$g(t)||Vg(t)),$g=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.pipe=="function"&&t.pipe!==zu.Writable.prototype.pipe,Vg=t=>!!t&&typeof t=="object"&&t instanceof Ic&&typeof t.write=="function"&&typeof t.end=="function",zt=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),sn=Symbol("emittedEnd"),gs=Symbol("emittingEnd"),ni=Symbol("emittedError"),ms=Symbol("closed"),ou=Symbol("read"),ws=Symbol("flush"),au=Symbol("flushChunk"),ht=Symbol("encoding"),dr=Symbol("decoder"),Be=Symbol("flowing"),ri=Symbol("paused"),hr=Symbol("resume"),Fe=Symbol("buffer"),Ve=Symbol("pipes"),ze=Symbol("bufferLength"),Oa=Symbol("bufferPush"),_s=Symbol("bufferShift"),Ke=Symbol("objectMode"),Ie=Symbol("destroyed"),Na=Symbol("error"),Pa=Symbol("emitData"),cu=Symbol("emitEnd"),La=Symbol("emitEnd2"),It=Symbol("async"),Ma=Symbol("abort"),ys=Symbol("aborted"),ii=Symbol("signal"),Tn=Symbol("dataListeners"),nt=Symbol("discarded"),si=t=>Promise.resolve().then(t),Jg=t=>t(),Yg=t=>t==="end"||t==="finish"||t==="prefinish",Zg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Xg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Uu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[hr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Qg=class extends Uu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},em=t=>!!t.objectMode,tm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",zn=class extends Ic{[Be]=!1;[ri]=!1;[Ve]=[];[Fe]=[];[Ke];[ht];[It];[dr];[zt]=!1;[sn]=!1;[gs]=!1;[ms]=!1;[ni]=null;[ze]=0;[Ie]=!1;[ii];[ys]=!1;[Tn]=0;[nt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");em(e)?(this[Ke]=!0,this[ht]=null):tm(e)?(this[ht]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[ht]=null),this[It]=!!e.async,this[dr]=this[ht]?new Kg(this[ht]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Fe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ve]});let{signal:r}=e;r&&(this[ii]=r,r.aborted?this[Ma]():r.addEventListener("abort",()=>this[Ma]()))}get bufferLength(){return this[ze]}get encoding(){return this[ht]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[It]}set async(t){this[It]=this[It]||!!t}[Ma](){this[ys]=!0,this.emit("abort",this[ii]?.reason),this.destroy(this[ii]?.reason)}get aborted(){return this[ys]}set aborted(t){}write(t,e,r){if(this[ys])return!1;if(this[zt])throw new Error("write after end");if(this[Ie])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[It]?si:Jg;if(!this[Ke]&&!Buffer.isBuffer(t)){if(Xg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Zg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ke]?(this[Be]&&this[ze]!==0&&this[ws](!0),this[Be]?this.emit("data",t):this[Oa](t),this[ze]!==0&&this.emit("readable"),r&&i(r),this[Be]):t.length?(typeof t=="string"&&!(e===this[ht]&&!this[dr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ht]&&(t=this[dr].write(t)),this[Be]&&this[ze]!==0&&this[ws](!0),this[Be]?this.emit("data",t):this[Oa](t),this[ze]!==0&&this.emit("readable"),r&&i(r),this[Be]):(this[ze]!==0&&this.emit("readable"),r&&i(r),this[Be])}read(t){if(this[Ie])return null;if(this[nt]=!1,this[ze]===0||t===0||t&&t>this[ze])return this[Ut](),null;this[Ke]&&(t=null),this[Fe].length>1&&!this[Ke]&&(this[Fe]=[this[ht]?this[Fe].join(""):Buffer.concat(this[Fe],this[ze])]);let e=this[ou](t||null,this[Fe][0]);return this[Ut](),e}[ou](t,e){if(this[Ke])this[_s]();else{let r=e;t===r.length||t===null?this[_s]():typeof r=="string"?(this[Fe][0]=r.slice(t),e=r.slice(0,t),this[ze]-=t):(this[Fe][0]=r.subarray(t),e=r.subarray(0,t),this[ze]-=t)}return this.emit("data",e),!this[Fe].length&&!this[zt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[zt]=!0,this.writable=!1,(this[Be]||!this[ri])&&this[Ut](),this}[hr](){this[Ie]||(!this[Tn]&&!this[Ve].length&&(this[nt]=!0),this[ri]=!1,this[Be]=!0,this.emit("resume"),this[Fe].length?this[ws]():this[zt]?this[Ut]():this.emit("drain"))}resume(){return this[hr]()}pause(){this[Be]=!1,this[ri]=!0,this[nt]=!1}get destroyed(){return this[Ie]}get flowing(){return this[Be]}get paused(){return this[ri]}[Oa](t){this[Ke]?this[ze]+=1:this[ze]+=t.length,this[Fe].push(t)}[_s](){return this[Ke]?this[ze]-=1:this[ze]-=this[Fe][0].length,this[Fe].shift()}[ws](t=!1){do;while(this[au](this[_s]())&&this[Fe].length);!t&&!this[Fe].length&&!this[zt]&&this.emit("drain")}[au](t){return this.emit("data",t),this[Be]}pipe(t,e){if(this[Ie])return t;this[nt]=!1;let r=this[sn];return e=e||{},t===su.stdout||t===su.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ve].push(e.proxyErrors?new Qg(this,t,e):new Uu(this,t,e)),this[It]?si(()=>this[hr]()):this[hr]()),t}unpipe(t){let e=this[Ve].find(r=>r.dest===t);e&&(this[Ve].length===1?(this[Be]&&this[Tn]===0&&(this[Be]=!1),this[Ve]=[]):this[Ve].splice(this[Ve].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[nt]=!1,this[Tn]++,!this[Ve].length&&!this[Be]&&this[hr]();else if(t==="readable"&&this[ze]!==0)super.emit("readable");else if(Yg(t)&&this[sn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ni]){let i=e;this[It]?si(()=>i.call(this,this[ni])):i.call(this,this[ni])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Tn]=this.listeners("data").length,this[Tn]===0&&!this[nt]&&!this[Ve].length&&(this[Be]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Tn]=0,!this[nt]&&!this[Ve].length&&(this[Be]=!1)),e}get emittedEnd(){return this[sn]}[Ut](){!this[gs]&&!this[sn]&&!this[Ie]&&this[Fe].length===0&&this[zt]&&(this[gs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ms]&&this.emit("close"),this[gs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ie&&this[Ie])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[It]?(si(()=>this[Pa](r)),!0):this[Pa](r);if(t==="end")return this[cu]();if(t==="close"){if(this[ms]=!0,!this[sn]&&!this[Ie])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ni]=r,super.emit(Na,r);let o=!this[ii]||this.listeners("error").length?super.emit("error",r):!1;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Ut](),i}[Pa](t){for(let r of this[Ve])r.dest.write(t)===!1&&this.pause();let e=this[nt]?!1:super.emit("data",t);return this[Ut](),e}[cu](){return this[sn]?!1:(this[sn]=!0,this.readable=!1,this[It]?(si(()=>this[La]()),!0):this[La]())}[La](){if(this[dr]){let e=this[dr].end();if(e){for(let r of this[Ve])r.dest.write(e);this[nt]||super.emit("data",e)}}for(let e of this[Ve])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ke]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ke]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ke])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ht]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ie,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[nt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[zt])return e();let i,o,c=p=>{this.off("data",u),this.off("end",f),this.off(Ie,x),e(),o(p)},u=p=>{this.off("error",c),this.off("end",f),this.off(Ie,x),this.pause(),i({value:p,done:!!this[zt]})},f=()=>{this.off("error",c),this.off("data",u),this.off(Ie,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,b)=>{o=b,i=p,this.once(Ie,x),this.once("error",c),this.once("end",f),this.once("data",u)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[nt]=!1;let t=!1,e=()=>(this.pause(),this.off(Na,e),this.off(Ie,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Na,e),this.once(Ie,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ie])return t?this.emit("error",t):this.emit(Ie),this;this[Ie]=!0,this[nt]=!0,this[Fe].length=0,this[ze]=0;let e=this;return typeof e.close=="function"&&!this[ms]&&e.close(),t?this.emit("error",t):this.emit(Ie),this}static get isStream(){return Wg}},nm=Xe.writev,pn=Symbol("_autoClose"),wt=Symbol("_close"),oi=Symbol("_ended"),ae=Symbol("_fd"),Ba=Symbol("_finished"),Gt=Symbol("_flags"),Fa=Symbol("_flush"),ic=Symbol("_handleChunk"),sc=Symbol("_makeBuf"),mi=Symbol("_mode"),bs=Symbol("_needDrain"),_r=Symbol("_onerror"),yr=Symbol("_onopen"),za=Symbol("_onread"),pr=Symbol("_onwrite"),gn=Symbol("_open"),mt=Symbol("_path"),un=Symbol("_pos"),At=Symbol("_queue"),gr=Symbol("_read"),Ua=Symbol("_readSize"),jt=Symbol("_reading"),ai=Symbol("_remain"),Ha=Symbol("_size"),ks=Symbol("_write"),Cn=Symbol("_writing"),Os=Symbol("_defaultFlag"),Ln=Symbol("_errored"),Ac=class extends zn{[Ln]=!1;[ae];[mt];[Ua];[jt]=!1;[Ha];[ai];[pn];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[Ln]=!1,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[Ua]=e.readSize||16*1024*1024,this[jt]=!1,this[Ha]=typeof e.size=="number"?e.size:1/0,this[ai]=this[Ha],this[pn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ae]=="number"?this[gr]():this[gn]()}get fd(){return this[ae]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[gn](){Xe.open(this[mt],"r",(t,e)=>this[yr](t,e))}[yr](t,e){t?this[_r](t):(this[ae]=e,this.emit("open",e),this[gr]())}[sc](){return Buffer.allocUnsafe(Math.min(this[Ua],this[ai]))}[gr](){if(!this[jt]){this[jt]=!0;let t=this[sc]();if(t.length===0)return process.nextTick(()=>this[za](null,0,t));Xe.read(this[ae],t,0,t.length,null,(e,r,i)=>this[za](e,r,i))}}[za](t,e,r){this[jt]=!1,t?this[_r](t):this[ic](e,r)&&this[gr]()}[wt](){if(this[pn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[_r](t){this[jt]=!0,this[wt](),this.emit("error",t)}[ic](t,e){let r=!1;return this[ai]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ai]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ae]=="number"&&this[gr](),!1;case"error":return this[Ln]?!1:(this[Ln]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},rm=class extends Ac{[gn](){let t=!0;try{this[yr](null,Xe.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[gr](){let t=!0;try{if(!this[jt]){this[jt]=!0;do{let e=this[sc](),r=e.length===0?0:Xe.readSync(this[ae],e,0,e.length,null);if(!this[ic](r,e))break}while(!0);this[jt]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[pn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}},$s=class extends Gg{readable=!1;writable=!0;[Ln]=!1;[Cn]=!1;[oi]=!1;[At]=[];[bs]=!1;[mt];[mi];[pn];[ae];[Os];[Gt];[Ba]=!1;[un];constructor(t,e){e=e||{},super(e),this[mt]=t,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[mi]=e.mode===void 0?438:e.mode,this[un]=typeof e.start=="number"?e.start:void 0,this[pn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[un]!==void 0?"r+":"w";this[Os]=e.flags===void 0,this[Gt]=e.flags===void 0?r:e.flags,this[ae]===void 0&&this[gn]()}emit(t,...e){if(t==="error"){if(this[Ln])return!1;this[Ln]=!0}return super.emit(t,...e)}get fd(){return this[ae]}get path(){return this[mt]}[_r](t){this[wt](),this[Cn]=!0,this.emit("error",t)}[gn](){Xe.open(this[mt],this[Gt],this[mi],(t,e)=>this[yr](t,e))}[yr](t,e){this[Os]&&this[Gt]==="r+"&&t&&t.code==="ENOENT"?(this[Gt]="w",this[gn]()):t?this[_r](t):(this[ae]=e,this.emit("open",e),this[Cn]||this[Fa]())}end(t,e){return t&&this.write(t,e),this[oi]=!0,!this[Cn]&&!this[At].length&&typeof this[ae]=="number"&&this[pr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[oi]?(this.emit("error",new Error("write() after end()")),!1):this[ae]===void 0||this[Cn]||this[At].length?(this[At].push(t),this[bs]=!0,!1):(this[Cn]=!0,this[ks](t),!0)}[ks](t){Xe.write(this[ae],t,0,t.length,this[un],(e,r)=>this[pr](e,r))}[pr](t,e){t?this[_r](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[At].length?this[Fa]():(this[Cn]=!1,this[oi]&&!this[Ba]?(this[Ba]=!0,this[wt](),this.emit("finish")):this[bs]&&(this[bs]=!1,this.emit("drain"))))}[Fa](){if(this[At].length===0)this[oi]&&this[pr](null,0);else if(this[At].length===1)this[ks](this[At].pop());else{let t=this[At];this[At]=[],nm(this[ae],t,this[un],(e,r)=>this[pr](e,r))}}[wt](){if(this[pn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Hu=class extends $s{[gn](){let t;if(this[Os]&&this[Gt]==="r+")try{t=Xe.openSync(this[mt],this[Gt],this[mi])}catch(e){if(e?.code==="ENOENT")return this[Gt]="w",this[gn]();throw e}else t=Xe.openSync(this[mt],this[Gt],this[mi]);this[yr](null,t)}[wt](){if(this[pn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}[ks](t){let e=!0;try{this[pr](null,Xe.writeSync(this[ae],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[wt]()}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"]]),am=t=>!!t.sync&&!!t.file,cm=t=>!t.sync&&!!t.file,dm=t=>!!t.sync&&!t.file,um=t=>!t.sync&&!t.file,lm=t=>!!t.file,fm=t=>om.get(t)||t,Tc=(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},Ai=(t,e,r,i,o)=>Object.assign((c=[],u,f)=>{Array.isArray(c)&&(u=c,c={}),typeof u=="function"&&(f=u,u=void 0),u=u?Array.from(u):[];let x=Tc(c);if(o?.(x,u),am(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,u)}else if(cm(x)){let p=e(x,u);return f?p.then(()=>f(),f):p}else if(dm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,u)}else if(um(x)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(x,u)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),pm=hm.constants||{ZLIB_VERNUM:4736},Rt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},pm)),gm=Mn.concat,uu=Object.getOwnPropertyDescriptor(Mn,"concat"),mm=t=>t,qa=uu?.writable===!0||uu?.set!==void 0?t=>{Mn.concat=t?mm:gm}:t=>{},Bn=Symbol("_superWrite"),Es=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ja=Symbol("flushFlag"),Cc=class extends zn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof du[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new du[e](t)}catch(r){throw new Es(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new Es(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return oc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Mn.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}[Bn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Mn.from(t,e)),this.#e)return;oc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},qa(!0);let u;try{let x=typeof t[ja]=="number"?t[ja]:this.#r;u=this.#t._processChunk(t,x),qa(!1)}catch(x){qa(!1),this.#o(new Es(x,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new Es(x,this.write)));let f;if(u)if(Array.isArray(u)&&u.length>0){let x=u[0];f=this[Bn](Mn.from(x));for(let p=1;p<u.length;p++)f=this[Bn](u[p])}else f=this[Bn](Mn.from(u));return r&&r(),f}},ju=class extends Cc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Rt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Rt.Z_FINISH,t.fullFlushFlag=Rt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Rt.Z_SYNC_FLUSH),oc(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 ju{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Bn](t){return this.#e?(this.#e=!1,t[9]=255,super[Bn](t)):super[Bn](t)}},_m=class extends ju{constructor(t){super(t,"Unzip")}},Gu=class extends Cc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Rt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Rt.BROTLI_OPERATION_FLUSH,super(t,e)}},ym=class extends Gu{constructor(t){super(t,"BrotliCompress")}},bm=class extends Gu{constructor(t){super(t,"BrotliDecompress")}},Ku=class extends Cc{constructor(t,e){t=t||{},t.flush=t.flush||Rt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Rt.ZSTD_e_end,t.fullFlushFlag=Rt.ZSTD_e_flush,super(t,e)}},Em=class extends Ku{constructor(t){super(t,"ZstdCompress")}},vm=class extends Ku{constructor(t){super(t,"ZstdDecompress")}},Sm=(t,e)=>{if(Number.isSafeInteger(t))t<0?Am(t,e):Im(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Im=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Am=(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]=Wu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=$u(o))}},Tm=t=>{let e=t[0],r=e===128?Dm(t.subarray(1,t.length)):e===255?Cm(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},Cm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),u;i?u=Wu(c):c===0?u=c:(i=!0,u=$u(c)),u!==0&&(r-=u*Math.pow(256,e-o-1))}return r},Dm=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},Wu=t=>(255^t)&255,$u=t=>(255^t)+1&255,Rm={};jg(Rm,{code:()=>Dc,isCode:()=>Ns,isName:()=>km,name:()=>Vs});var Ns=t=>Vs.has(t),km=t=>Dc.has(t),Vs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Dc=new Map(Array.from(Vs).map(t=>[t[1],t[0]])),Fn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??ln(t,e+100,8),this.uid=r?.uid??i?.uid??ln(t,e+108,8),this.gid=r?.gid??i?.gid??ln(t,e+116,8),this.size=r?.size??i?.size??ln(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ga(t,e+136,12),this.cksum=ln(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(Ns(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??ln(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??ln(t,e+337,8)??0,t[e+475]!==0){let u=Dn(t,e+345,155);this.path=u+"/"+this.path}else{let u=Dn(t,e+345,130);u&&(this.path=u+"/"+this.path),this.atime=r?.atime??i?.atime??Ga(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Ga(t,e+488,12)}let c=256;for(let u=e;u<e+148;u++)c+=t[u];for(let u=e+156;u<e+512;u++)c+=t[u];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Om(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Rn(t,e,100,o)||this.needPax,this.needPax=fn(t,e+100,8,this.mode)||this.needPax,this.needPax=fn(t,e+108,8,this.uid)||this.needPax,this.needPax=fn(t,e+116,8,this.gid)||this.needPax,this.needPax=fn(t,e+124,12,this.size)||this.needPax,this.needPax=Ka(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Rn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Rn(t,e+265,32,this.uname)||this.needPax,this.needPax=Rn(t,e+297,32,this.gname)||this.needPax,this.needPax=fn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=fn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Rn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Rn(t,e+345,155,c)||this.needPax:(this.needPax=Rn(t,e+345,130,c)||this.needPax,this.needPax=Ka(t,e+476,12,this.atime)||this.needPax,this.needPax=Ka(t,e+488,12,this.ctime)||this.needPax);let u=256;for(let f=e;f<e+148;f++)u+=t[f];for(let f=e+156;f<e+512;f++)u+=t[f];return this.cksum=u,fn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Vs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Dc.get(t));if(Ns(e)||e==="Unsupported")this.#e=e;else if(Ns(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Om=(t,e)=>{let r=t,i="",o,c=ur.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=ur.dirname(r),r=ur.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=ur.join(ur.basename(i),r),i=ur.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Dn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ga=(t,e,r)=>Nm(ln(t,e,r)),Nm=t=>t===void 0?void 0:new Date(t*1e3),ln=(t,e,r)=>Number(t[e])&128?Tm(t.subarray(e,e+r)):Lm(t,e,r),Pm=t=>isNaN(t)?void 0:t,Lm=(t,e,r)=>Pm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Mm={12:8589934591,8:2097151},fn=(t,e,r,i)=>i===void 0?!1:i>Mm[r]||i<0?(Sm(i,t.subarray(e,e+r)),!0):(Bm(t,e,r,i),!1),Bm=(t,e,r,i)=>t.write(Fm(i,r),e,r,"ascii"),Fm=(t,e)=>zm(Math.floor(t).toString(8),e),zm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ka=(t,e,r,i)=>i===void 0?!1:fn(t,e,r,i.getTime()/1e3),Um=new Array(156).join("\0"),Rn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Um,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),qs=class Vu{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Fn({path:("PaxHeader/"+Hm(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(Gm,Object.create(null)),Gm=(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"),u=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(u)*1e3):/^[0-9]+$/.test(u)?+u:u,t},Km=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Km!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ju=class extends zn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Js=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Wm=1024*1024,ac=Buffer.from([31,139]),cc=Buffer.from([40,181,47,253]),$m=Math.max(ac.length,cc.length),at=Symbol("state"),kn=Symbol("writeEntry"),Ht=Symbol("readEntry"),Wa=Symbol("nextEntry"),lu=Symbol("processEntry"),Tt=Symbol("extendedHeader"),ci=Symbol("globalExtendedHeader"),on=Symbol("meta"),fu=Symbol("emitMeta"),xe=Symbol("buffer"),qt=Symbol("queue"),an=Symbol("ended"),$a=Symbol("emittedEnd"),On=Symbol("emit"),Ce=Symbol("unzip"),vs=Symbol("consumeChunk"),Ss=Symbol("consumeChunkSub"),Va=Symbol("consumeBody"),xu=Symbol("consumeMeta"),hu=Symbol("consumeHeader"),di=Symbol("consuming"),Ja=Symbol("bufferConcat"),Is=Symbol("maybeEnd"),lr=Symbol("writing"),cn=Symbol("aborted"),As=Symbol("onDone"),Nn=Symbol("sawValidEntry"),Ts=Symbol("sawNullBlock"),Cs=Symbol("sawEOF"),pu=Symbol("closeStream"),Vm=()=>!0,Ii=class extends xm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[qt]=[];[xe];[Ht];[kn];[at]="begin";[on]="";[Tt];[ci];[an]=!1;[Ce];[cn]=!1;[Nn];[Ts]=!1;[Cs]=!1;[lr]=!1;[di]=!1;[$a]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(As,()=>{(this[at]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(As,t.ondone):this.on(As,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Wm,this.filter=typeof t.filter=="function"?t.filter:Vm;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[pu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Js(this,t,e,r)}[hu](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new Fn(t,e,this[Tt],this[ci])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ts]?(this[Cs]=!0,this[at]==="begin"&&(this[at]="header"),this[On]("eof")):(this[Ts]=!0,this[On]("nullBlock"));else if(this[Ts]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[kn]=new Ju(r,this[Tt],this[ci]);if(!this[Nn])if(o.remain){let c=()=>{o.invalid||(this[Nn]=!0)};o.on("end",c)}else this[Nn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[On]("ignoredEntry",o),this[at]="ignore",o.resume()):o.size>0&&(this[on]="",o.on("data",c=>this[on]+=c),this[at]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[On]("ignoredEntry",o),this[at]=o.remain?"ignore":"header",o.resume()):(o.remain?this[at]="body":(this[at]="header",o.end()),this[Ht]?this[qt].push(o):(this[qt].push(o),this[Wa]())))}}}[pu](){queueMicrotask(()=>this.emit("close"))}[lu](t){let e=!0;if(!t)this[Ht]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ht]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Wa]()),e=!1);return e}[Wa](){do;while(this[lu](this[qt].shift()));if(this[qt].length===0){let t=this[Ht];!t||t.flowing||t.size===t.remain?this[lr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Va](t,e){let r=this[kn];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[at]="header",this[kn]=void 0,r.end()),o.length}[xu](t,e){let r=this[kn],i=this[Va](t,e);return!this[kn]&&r&&this[fu](r),i}[On](t,e,r){this[qt].length===0&&!this[Ht]?this.emit(t,e,r):this[qt].push([t,e,r])}[fu](t){switch(this[On]("meta",this[on]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=qs.parse(this[on],this[Tt],!1);break;case"GlobalExtendedHeader":this[ci]=qs.parse(this[on],this[ci],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Tt]??Object.create(null);this[Tt]=e,e.path=this[on].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Tt]||Object.create(null);this[Tt]=e,e.linkpath=this[on].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[cn]=!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[cn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<$m)return this[xe]=t,r?.(),!0;for(let u=0;this[Ce]===void 0&&u<ac.length;u++)t[u]!==ac[u]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let u=0;u<cc.length;u++)if(t[u]!==cc[u]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[an])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new Fn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let u=this[an];this[an]=!1,this[Ce]=this[Ce]===void 0?new _m({}):o?new vm({}):new bm({}),this[Ce].on("data",x=>this[vs](x)),this[Ce].on("error",x=>this.abort(x)),this[Ce].on("end",()=>{this[an]=!0,this[vs]()}),this[lr]=!0;let f=!!this[Ce][u?"end":"write"](t);return this[lr]=!1,r?.(),f}}this[lr]=!0,this[Ce]?this[Ce].write(t):this[vs](t),this[lr]=!1;let i=this[qt].length>0?!1:this[Ht]?this[Ht].flowing:!0;return!i&&this[qt].length===0&&this[Ht]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ja](t){t&&!this[cn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[Is](){if(this[an]&&!this[$a]&&!this[cn]&&!this[di]){this[$a]=!0;let t=this[kn];if(t&&t.blockRemain){let e=this[xe]?this[xe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[xe]&&t.write(this[xe]),t.end()}this[On](As)}}[vs](t){if(this[di]&&t)this[Ja](t);else if(!t&&!this[xe])this[Is]();else if(t){if(this[di]=!0,this[xe]){this[Ja](t);let e=this[xe];this[xe]=void 0,this[Ss](e)}else this[Ss](t);for(;this[xe]&&this[xe]?.length>=512&&!this[cn]&&!this[Cs];){let e=this[xe];this[xe]=void 0,this[Ss](e)}this[di]=!1}(!this[xe]||this[an])&&this[Is]()}[Ss](t){let e=0,r=t.length;for(;e+512<=r&&!this[cn]&&!this[Cs];)switch(this[at]){case"begin":case"header":this[hu](t,e),e+=512;break;case"ignore":case"body":e+=this[Va](t,e);break;case"meta":e+=this[xu](t,e);break;default:throw new Error("invalid state: "+this[at])}e<r&&(this[xe]=this[xe]?Buffer.concat([t.subarray(e),this[xe]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[cn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[an]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Is]())),this}},wi=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},Jm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Yu=(t,e)=>{let r=new Map(e.map(c=>[wi(c),!0])),i=t.filter,o=(c,u="")=>{let f=u||sm(c).root||".",x;if(c===f)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(im(c),f)}return r.set(c,x),x};t.filter=i?(c,u)=>i(c,u)&&o(wi(c)):c=>o(wi(c))},Ym=t=>{let e=new Ii(t),r=t.file,i;try{i=mr.openSync(r,"r");let o=mr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let u=Buffer.allocUnsafe(o.size),f=mr.readSync(i,u,0,o.size,0);e.end(f===u.byteLength?u:u.subarray(0,f))}else{let u=0,f=Buffer.allocUnsafe(c);for(;u<o.size;){let x=mr.readSync(i,f,0,c,u);if(x===0)break;u+=x,e.write(f.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{mr.closeSync(i)}catch{}}},Zm=(t,e)=>{let r=new Ii(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,u)=>{r.on("error",u),r.on("end",c),mr.stat(o,(f,x)=>{if(f)u(f);else{let p=new Ac(o,{readSize:i,size:x.size});p.on("error",u),p.pipe(r)}})})},br=Ai(Ym,Zm,t=>new Ii(t),t=>new Ii(t),(t,e)=>{e?.length&&Yu(t,e),t.noResume||Jm(t)}),Zu=(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:Qm,parse:mu}=Xm,Rc=t=>{let e="",r=mu(t);for(;Qm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=mu(t)}return[e,t]},Ys=["|","<",">","?",":"],kc=Ys.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),ew=new Map(Ys.map((t,e)=>[t,kc[e]])),tw=new Map(kc.map((t,e)=>[t,Ys[e]])),wu=t=>Ys.reduce((e,r)=>e.split(r).join(ew.get(r)),t),nw=t=>kc.reduce((e,r)=>e.split(r).join(tw.get(r)),t),Xu=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),wi(e)+"/"+t):Z(t),rw=16*1024*1024,_u=Symbol("process"),yu=Symbol("file"),bu=Symbol("directory"),dc=Symbol("symlink"),Eu=Symbol("hardlink"),ui=Symbol("header"),Ps=Symbol("read"),uc=Symbol("lstat"),Ls=Symbol("onlstat"),lc=Symbol("onread"),fc=Symbol("onreadlink"),xc=Symbol("openfile"),hc=Symbol("onopenfile"),xn=Symbol("close"),Gs=Symbol("mode"),pc=Symbol("awaitDrain"),Ya=Symbol("ondrain"),Dt=Symbol("prefix"),Qu=class extends zn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Tc(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||rw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,u]=Rc(this.path);c&&typeof u=="string"&&(this.path=u,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=nw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||gu.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[Ls](o):this[uc]()}warn(t,e,r={}){return Js(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[uc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ls](e)})}[Ls](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ow(t),this.emit("stat",t),this[_u]()}[_u](){switch(this.type){case"File":return this[yu]();case"Directory":return this[bu]();case"SymbolicLink":return this[dc]();default:return this.end()}}[Gs](t){return Zu(t,this.type==="Directory",this.portable)}[Dt](t){return Xu(t,this.prefix)}[ui](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Fn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this[Gs](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new qs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[bu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ui](),this.end()}[dc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[fc](e)})}[fc](t){this.linkpath=Z(t),this[ui](),this.end()}[Eu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(gu.relative(this.cwd,t)),this.stat.size=0,this[ui](),this.end()}[yu](){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[Eu](e);this.linkCache.set(t,this.absolute)}if(this[ui](),this.stat.size===0)return this.end();this[xc]()}[xc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[hc](e)})}[hc](t){if(this.fd=t,this.#e)return this[xn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ps]()}[Ps](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,u)=>{if(c)return this[xn](()=>this.emit("error",c));this[lc](u)})}[xn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[lc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Ya]():this[pc](()=>this[Ya]())}[pc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ya](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[xn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ps]()}},iw=class extends Qu{sync=!0;[uc](){this[Ls](Ct.lstatSync(this.absolute))}[dc](){this[fc](Ct.readlinkSync(this.absolute))}[xc](){this[hc](Ct.openSync(this.absolute,"r"))}[Ps](){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 u=Ct.readSync(e,r,i,o,c);this[lc](u),t=!1}finally{if(t)try{this[xn](()=>{})}catch{}}}[pc](t){t()}[xn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},sw=class extends zn{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Js(this,t,e,r)}constructor(t,e={}){let r=Tc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Gs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[u,f]=Rc(this.path);u&&typeof f=="string"&&(this.path=f,o=u)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Fn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new qs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Dt](t){return Xu(t,this.prefix)}[Gs](t){return Zu(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}},ow=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",aw=class wr{tail;head;length=0;static create(e=[]){return new wr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)dw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)uw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new wr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new wr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new wr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new wr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let u=0;o&&u<e;u++)o=o.next;let c=[];for(let u=0;o&&u<r;u++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let u of i)o=cw(this,o,u);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 cw(t,e,r){let i=e,o=e?e.next:t.head,c=new Oc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function dw(t,e){t.tail=new Oc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function uw(t,e){t.head=new Oc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Oc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Su=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Iu=Buffer.alloc(1024),Ms=Symbol("onStat"),li=Symbol("ended"),pt=Symbol("queue"),fi=Symbol("queue"),dn=Symbol("current"),Pn=Symbol("process"),xi=Symbol("processing"),Ds=Symbol("processJob"),gt=Symbol("jobs"),Za=Symbol("jobDone"),Bs=Symbol("addFSEntry"),Au=Symbol("addTarEntry"),gc=Symbol("stat"),mc=Symbol("readdir"),Fs=Symbol("onreaddir"),zs=Symbol("pipe"),Tu=Symbol("entry"),Xa=Symbol("entryOpt"),Us=Symbol("writeEntryClass"),el=Symbol("write"),Qa=Symbol("ondrain"),Zs=class extends zn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Us];onWriteEntry;[pt];[fi]=new Map;[gt]=0;[xi]=!1;[li]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Us]=Qu,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 ym(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Em(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[Qa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Qa]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[pt]=new aw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[xi]=!1,this[li]=!1}[el](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[li]=!0,this[Pn](),r&&r(),this}write(t){if(this[li])throw new Error("write after end");return t instanceof Ju?this[Au](t):this[Bs](t),this.flowing}[Au](t){let e=Z(vu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Su(t.path,e);r.entry=new sw(t,this[Xa](r)),r.entry.on("end",()=>this[Za](r)),this[gt]+=1,this[pt].push(r)}this[Pn]()}[Bs](t){let e=Z(vu.resolve(this.cwd,t));this[pt].push(new Su(t,e)),this[Pn]()}[gc](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";js[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Ms](t,i)})}[Ms](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[dn])this[Ds](t);else{let r=`${e.dev}:${e.ino}`,i=this[fi].get(r);i?i.push(t):this[fi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Pn]()}[mc](t){t.pending=!0,this[gt]+=1,js.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Fs](t,r)})}[Fs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Pn]()}[Pn](){if(!this[xi]){this[xi]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[Ds](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[xi]=!1,this[li]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(Iu):(super.write(Iu),super.end()))}}get[dn](){return this[pt]&&this[pt].head&&this[pt].head.value}[Za](t){this[pt].shift(),this[gt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[fi].get(r);if(i){this[fi].delete(r);for(let o of i)o.pending=!1,this[Ds](o)}}this[Pn]()}[Ds](t){if(t.pending&&t.pendingLink&&t===this[dn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[dn]&&!t.piped&&this[zs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ms](t,e):this[gc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Fs](t,e):this[mc](t),!t.readdir)return}if(t.entry=this[Tu](t),!t.entry){t.ignore=!0;return}t===this[dn]&&!t.piped&&this[zs](t)}}}[Xa](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}}[Tu](t){this[gt]+=1;try{return new this[Us](t.path,this[Xa](t)).on("end",()=>this[Za](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Qa](){this[dn]&&this[dn].entry&&this[dn].entry.resume()}[zs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Js(this,t,e,r)}},Nc=class extends Zs{sync=!0;constructor(t){super(t),this[Us]=iw}pause(){}resume(){}[gc](t){let e=this.follow?"statSync":"lstatSync";this[Ms](t,js[e](t.absolute))}[mc](t){this[Fs](t,js.readdirSync(t.absolute))}[zs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[el](i)})}},lw=(t,e)=>{let r=new Nc(t),i=new Hu(t.file,{mode:t.mode||438});r.pipe(i),tl(r,e)},fw=(t,e)=>{let r=new Zs(t),i=new $s(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,u)=>{i.on("error",u),i.on("close",c),r.on("error",u)});return nl(r,e).catch(c=>r.emit("error",c)),o},tl=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?br({file:qu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},nl=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await br({file:qu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},xw=(t,e)=>{let r=new Nc(t);return tl(r,e),r},hw=(t,e)=>{let r=new Zs(t);return nl(r,e).catch(i=>r.emit("error",i)),r},D2=Ai(lw,fw,xw,hw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),gw=process.env.__FAKE_PLATFORM__||process.platform,ol=gw==="win32",{O_CREAT:al,O_NOFOLLOW:Cu,O_TRUNC:cl,O_WRONLY:dl}=sl.constants,ul=Number(process.env.__FAKE_FS_O_FILENAME__)||sl.constants.UV_FS_O_FILEMAP||0,mw=ol&&!!ul,ww=512*1024,_w=ul|cl|al|dl,Du=!ol&&typeof Cu=="number"?Cu|cl|al|dl:null,ll=Du!==null?()=>Du:mw?t=>t<ww?_w:"w":()=>"w",wc=(t,e,r)=>{try{return Xs.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Ks=(t,e,r,i)=>{Xs.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},yw=(t,e,r,i,o)=>{if(e.isDirectory())fl(_i.resolve(t,e.name),r,i,c=>{if(c)return o(c);let u=_i.resolve(t,e.name);Ks(u,r,i,o)});else{let c=_i.resolve(t,e.name);Ks(c,r,i,o)}},fl=(t,e,r,i)=>{Xs.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return Ks(t,e,r,i);let u=c.length,f=null,x=p=>{if(!f){if(p)return i(f=p);if(--u===0)return Ks(t,e,r,i)}};for(let p of c)yw(t,p,e,r,x)})},bw=(t,e,r,i)=>{e.isDirectory()&&xl(_i.resolve(t,e.name),r,i),wc(_i.resolve(t,e.name),r,i)},xl=(t,e,r)=>{let i;try{i=Xs.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return wc(t,e,r);throw c}for(let o of i)bw(t,o,e,r);return wc(t,e,r)},hl=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Qs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},vw=(t,e)=>{it.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new hl(t,r?.code||"ENOTDIR")),e(r)})},Sw=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,u=e.uid,f=e.gid,x=typeof u=="number"&&typeof f=="number"&&(u!==e.processUid||f!==e.processGid),p=e.preserve,b=e.unlink,E=Z(e.cwd),T=(v,I)=>{v?r(v):I&&x?fl(I,u,f,S=>T(S)):c?it.chmod(t,o,r):r()};if(t===E)return vw(t,T);if(p)return Ew.mkdir(t,{mode:o,recursive:!0}).then(v=>T(null,v??void 0),T);let y=Z(Ws.relative(E,t)).split("/");_c(E,y,o,b,E,void 0,T)},_c=(t,e,r,i,o,c,u)=>{if(e.length===0)return u(null,c);let f=e.shift(),x=Z(Ws.resolve(t+"/"+f));it.mkdir(x,r,pl(x,e,r,i,o,c,u))},pl=(t,e,r,i,o,c,u)=>f=>{f?it.lstat(t,(x,p)=>{if(x)x.path=x.path&&Z(x.path),u(x);else if(p.isDirectory())_c(t,e,r,i,o,c,u);else if(i)it.unlink(t,b=>{if(b)return u(b);it.mkdir(t,r,pl(t,e,r,i,o,c,u))});else{if(p.isSymbolicLink())return u(new Qs(t,t+"/"+e.join("/")));u(f)}}):(c=c||t,_c(t,e,r,i,o,c,u))},Iw=t=>{let e=!1,r;try{e=it.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new hl(t,r??"ENOTDIR")}},Aw=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,u=e.gid,f=typeof c=="number"&&typeof u=="number"&&(c!==e.processUid||u!==e.processGid),x=e.preserve,p=e.unlink,b=Z(e.cwd),E=v=>{v&&f&&xl(v,c,u),o&&it.chmodSync(t,i)};if(t===b)return Iw(b),E();if(x)return E(it.mkdirSync(t,{mode:i,recursive:!0})??void 0);let T=Z(Ws.relative(b,t)).split("/"),y;for(let v=T.shift(),I=b;v&&(I+="/"+v);v=T.shift()){I=Z(Ws.resolve(I));try{it.mkdirSync(I,i),y=y||I}catch{let S=it.lstatSync(I);if(S.isDirectory())continue;if(p){it.unlinkSync(I),it.mkdirSync(I,i),y=y||I;continue}else if(S.isSymbolicLink())return new Qs(I,I+"/"+T.join("/"))}}return E(y)},ec=Object.create(null),Ru=1e4,fr=new Set,Tw=t=>{fr.has(t)?fr.delete(t):ec[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),fr.add(t);let e=ec[t],r=fr.size-Ru;if(r>Ru/10){for(let i of fr)if(fr.delete(i),delete ec[i],--r<=0)break}return e},Cw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Dw=Cw==="win32",Rw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=gl(i,r)),e.push(r||"/"),e},[]),kw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Dw?["win32 parallelization disabled"]:t.map(i=>wi(gl(Tw(i))));let r=new Set(t.map(i=>Rw(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 u=this.#e.get(c);if(!u||u?.[0]!==t)continue;let f=u[1];if(!f){this.#e.delete(c);continue}if(u.shift(),typeof f=="function")o.add(f);else for(let x of f)o.add(x)}for(let c of i){let u=this.#e.get(c),f=u?.[0];if(!(!u||!(f instanceof Set)))if(f.size===1&&u.length===1){this.#e.delete(c);continue}else if(f.size===1){u.shift();let x=u[0];typeof x=="function"&&o.add(x)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Ow=()=>process.umask(),ku=Symbol("onEntry"),yc=Symbol("checkFs"),Ou=Symbol("checkFs2"),bc=Symbol("isReusable"),ct=Symbol("makeFs"),Ec=Symbol("file"),vc=Symbol("directory"),Hs=Symbol("link"),Nu=Symbol("symlink"),Pu=Symbol("hardlink"),gi=Symbol("ensureNoSymlink"),Lu=Symbol("unsupported"),Mu=Symbol("checkPath"),tc=Symbol("stripAbsolutePath"),hn=Symbol("mkdir"),Ue=Symbol("onError"),Rs=Symbol("pending"),Bu=Symbol("pend"),xr=Symbol("unpend"),nc=Symbol("ended"),rc=Symbol("maybeClose"),Sc=Symbol("skip"),yi=Symbol("doChown"),bi=Symbol("uid"),Ei=Symbol("gid"),vi=Symbol("checkedCwd"),Nw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Si=Nw==="win32",Pw=1024,Lw=(t,e)=>{if(!Si)return re.unlink(t,e);let r=t+".DELETE."+il(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Mw=t=>{if(!Si)return re.unlinkSync(t);let e=t+".DELETE."+il(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},Fu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Pc=class extends Ii{[nc]=!1;[vi]=!1;[Rs]=0;reservations=new kw;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[nc]=!0,this[rc]()},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:Pw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Si,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Pe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Ow():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[ku](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[rc](){this[nc]&&this[Rs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[tc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Rc(r),u=c.replaceAll(/\\/g,"/").split("/");if(u.includes("..")||Si&&/^[a-z]:\.\.$/i.test(u[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let f=Pe.posix.dirname(t.path),x=Pe.posix.normalize(Pe.posix.join(f,u.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}[Mu](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[tc](t,"path")||!this[tc](t,"linkpath"))return!1;if(t.absolute=Pe.isAbsolute(t.path)?Z(Pe.resolve(t.path)):Z(Pe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Pe.win32.parse(String(t.absolute));t.absolute=i+wu(String(t.absolute).slice(i.length));let{root:o}=Pe.win32.parse(t.path);t.path=o+wu(t.path.slice(o.length))}return!0}[ku](t){if(!this[Mu](t))return t.resume();switch(pw.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[yc](t);default:return this[Lu](t)}}[Ue](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[xr](),e.resume())}[hn](t,e,r){Sw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[yi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[bi](t){return Fu(this.uid,t.uid,this.processUid)}[Ei](t){return Fu(this.gid,t.gid,this.processGid)}[Ec](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new $s(String(t.absolute),{flags:ll(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[Ue](f,t),e()});let o=1,c=f=>{if(f){i.fd&&re.close(i.fd,()=>{}),this[Ue](f,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[Ue](x,t):this[xr](),e()})};i.on("finish",()=>{let f=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,b=t.mtime;re.futimes(x,p,b,E=>E?re.utimes(f,p,b,T=>c(T&&E)):c())}if(typeof x=="number"&&this[yi](t)){o++;let p=this[bi](t),b=this[Ei](t);typeof p=="number"&&typeof b=="number"&&re.fchown(x,p,b,E=>E?re.chown(f,p,b,T=>c(T&&E)):c())}c()});let u=this.transform&&this.transform(t)||t;u!==t&&(u.on("error",f=>{this[Ue](f,t),e()}),t.pipe(u)),u.pipe(i)}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[hn](String(t.absolute),r,i=>{if(i){this[Ue](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[xr](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[yi](t)&&(o++,re.chown(String(t.absolute),Number(this[bi](t)),Number(this[Ei](t)),c)),c()})}[Lu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Nu](t,e){let r=Z(Pe.relative(this.cwd,Pe.resolve(Pe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[gi](t,this.cwd,r,()=>this[Hs](t,String(t.linkpath),"symlink",e),i=>{this[Ue](i,t),e()})}[Pu](t,e){let r=Z(Pe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[gi](t,this.cwd,i,()=>this[Hs](t,r,"link",e),o=>{this[Ue](o,t),e()})}[gi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let u=Pe.resolve(e,c);re.lstat(u,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new Qs(u,Pe.resolve(u,r.join("/"))));this[gi](t,u,r,i,o)})}[Bu](){this[Rs]++}[xr](){this[Rs]--,this[rc]()}[Sc](t){this[xr](),t.resume()}[bc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Si}[yc](t){this[Bu]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Ou](t,r))}[Ou](t,e){let r=u=>{e(u)},i=()=>{this[hn](this.cwd,this.dmode,u=>{if(u){this[Ue](u,t),r();return}this[vi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let u=Z(Pe.dirname(String(t.absolute)));if(u!==this.cwd)return this[hn](u,this.dmode,f=>{if(f){this[Ue](f,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(u,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[Sc](t),r();return}if(u||this[bc](t,f))return this[ct](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,p=b=>this[ct](b??null,t,r);return x?re.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),x=>this[ct](x??null,t,r))}if(t.absolute===this.cwd)return this[ct](null,t,r);Lw(String(t.absolute),x=>this[ct](x??null,t,r))})};this[vi]?o():i()}[ct](t,e,r){if(t){this[Ue](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ec](e,r);case"Link":return this[Pu](e,r);case"SymbolicLink":return this[Nu](e,r);case"Directory":case"GNUDumpDir":return this[vc](e,r)}}[Hs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[Ue](o,t):(this[xr](),t.resume()),i()})}},hi=t=>{try{return[null,t()]}catch(e){return[e,null]}},ml=class extends Pc{sync=!0;[ct](t,e){return super[ct](t,e,()=>{})}[yc](t){if(!this[vi]){let o=this[hn](this.cwd,this.dmode);if(o)return this[Ue](o,t);this[vi]=!0}if(t.absolute!==this.cwd){let o=Z(Pe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[hn](o,this.dmode);if(c)return this[Ue](c,t)}}let[e,r]=hi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Sc](t);if(e||this[bc](t,r))return this[ct](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[u]=c?hi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ct](u,t)}let[o]=hi(()=>re.rmdirSync(String(t.absolute)));this[ct](o,t)}let[i]=t.absolute===this.cwd?[]:hi(()=>Mw(String(t.absolute)));this[ct](i,t)}[Ec](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=u=>{let f;try{re.closeSync(o)}catch(x){f=x}(u||f)&&this[Ue](u||f,t),e()},o;try{o=re.openSync(String(t.absolute),ll(t.size),r)}catch(u){return i(u)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",u=>this[Ue](u,t)),t.pipe(c)),c.on("data",u=>{try{re.writeSync(o,u,0,u.length)}catch(f){i(f)}}),c.on("end",()=>{let u=null;if(t.mtime&&!this.noMtime){let f=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,f,x)}catch(p){try{re.utimesSync(String(t.absolute),f,x)}catch{u=p}}}if(this[yi](t)){let f=this[bi](t),x=this[Ei](t);try{re.fchownSync(o,Number(f),Number(x))}catch(p){try{re.chownSync(String(t.absolute),Number(f),Number(x))}catch{u=u||p}}}i(u)})}[vc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[hn](String(t.absolute),r);if(i){this[Ue](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[yi](t))try{re.chownSync(String(t.absolute),Number(this[bi](t)),Number(this[Ei](t)))}catch{}e(),t.resume()}[hn](t,e){try{return Aw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[gi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let u of r){c=Pe.resolve(c,u);let[f,x]=hi(()=>re.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new Qs(c,Pe.resolve(e,r.join("/"))))}i()}[Hs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Ue](c,t)}}},Bw=t=>{let e=new ml(t),r=t.file,i=rl.statSync(r),o=t.maxReadSize||16*1024*1024;new rm(r,{readSize:o,size:i.size}).pipe(e)},Fw=(t,e)=>{let r=new Pc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,u)=>{r.on("error",u),r.on("close",c),rl.stat(o,(f,x)=>{if(f)u(f);else{let p=new Ac(o,{readSize:i,size:x.size});p.on("error",u),p.pipe(r)}})})},wl=Ai(Bw,Fw,t=>new ml(t),t=>new Pc(t),(t,e)=>{e?.length&&Yu(t,e)}),zw=(t,e)=>{let r=new Nc(t),i=!0,o,c;try{try{o=rt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=rt.openSync(t.file,"w+");else throw x}let u=rt.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<u.size;c+=512){for(let b=0,E=0;b<512;b+=E){if(E=rt.readSync(o,f,b,f.length-b,c+b),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new Fn(f);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>u.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Uw(t,r,c,o,e)}finally{if(i)try{rt.closeSync(o)}catch{}}},Uw=(t,e,r,i,o)=>{let c=new Hu(t.file,{fd:i,start:r});e.pipe(c),qw(e,o)},Hw=(t,e)=>{e=Array.from(e);let r=new Zs(t),i=(o,c,u)=>{let f=(T,y)=>{T?rt.close(o,v=>u(T)):u(null,y)},x=0;if(c===0)return f(null,0);let p=0,b=Buffer.alloc(512),E=(T,y)=>{if(T||y===void 0)return f(T);if(p+=y,p<512&&y)return rt.read(o,b,p,b.length-p,x+p,E);if(x===0&&b[0]===31&&b[1]===139)return f(new Error("cannot append to compressed archives"));if(p<512)return f(null,x);let v=new Fn(b);if(!v.cksumValid)return f(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return f(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,rt.read(o,b,0,512,x,E)};rt.read(o,b,0,512,x,E)};return new Promise((o,c)=>{r.on("error",c);let u="r+",f=(x,p)=>{if(x&&x.code==="ENOENT"&&u==="r+")return u="w+",rt.open(t.file,u,f);if(x||!p)return c(x);rt.fstat(p,(b,E)=>{if(b)return rt.close(p,()=>c(b));i(p,E.size,(T,y)=>{if(T)return c(T);let v=new $s(t.file,{fd:p,start:y});r.pipe(v),v.on("error",c),v.on("close",o),jw(r,e)})})};rt.open(t.file,u,f)})},qw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?br({file:_l.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},jw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await br({file:_l.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},pi=Ai(zw,Hw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!lm(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")}),G2=Ai(pi.syncFile,pi.asyncFile,pi.syncNoFile,pi.asyncNoFile,(t,e=[])=>{pi.validate?.(t,e),Gw(t)}),Gw=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))};nn();var _t={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Ti(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function yl(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Lc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function bl(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Er(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}We();ne();Oe();We();function Kt(t,e){if(Ti(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function eo(t){return t.startsWith("http://")||t.startsWith("https://")}function to(t){return t.endsWith("/")?t.slice(0,-1):t}We();ne();var no="1008033",El="1289";var vl="pbbp2",Sl="https://www.coze.cn",Il="/api/coze_claw/resource/get_frontier_key",Ww="https://www.coze.cn",$w="wss://frontier.coze.cn";function ro(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Ww}function Al(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??$w}function vr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Di(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ci=H("handshake");async function Mc(t){let e=ro(t.endpoint),r=t.timeoutMs??1e4,i=`${to(e)}${Il}?aid=${encodeURIComponent(no)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...vr(t.ppeOverride)},c=new AbortController,u=setTimeout(()=>c.abort(),r);Ci.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let v=await f.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${v.slice(0,200)}`)}let b=await f.json();if(b.code!==void 0&&b.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${b.code} msg=${b.msg??"-"} logid=${x}`);let E=b.data??{},T=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,y=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!T||!y){let v=JSON.stringify(b).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ci.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:p}),{accessKey:T,deviceId:y}}catch(f){if(f instanceof C)throw Ci.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw Ci.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:f});let x=f.cause;throw Ci.error("handshake error",{base:e,message:f instanceof Error?f.message:String(f),errno:x?.code,syscall:x?.syscall,cause:String(f).slice(0,300)}),new C("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(u)}}var Bc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",Tl=2e5;function Cl(t){return{model:Fc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Dl(t){return!t||t===yt}var Vw=new Set(["auto","\u81EA\u52A8"]);function Fc(t){let e=t?.trim();if(e)return Vw.has(e.toLowerCase())?yt:e}function Rl(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Bc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||yt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Dl(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function kl(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):Dl(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Bc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Tl;e.push("-c",`model_context_window=${r}`)}return e}function Ol(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function zc(t,e){let{ttEnv:r,usePpe:i}=Di(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Nl(t,e,r){if(!t.modelToken)return{};let i=zc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,u])=>`${c}:${u}`).join(`
|
|
92
|
-
`)}}function Uc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Pl(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=zc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let u={baseUrl:`${Bc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Tl,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(u.headers=o),u}function Ll(t,e,r){if(!t.modelToken)return[];let i=zc(e,r),o=[];for(let[c,u]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${u}"`);return o}var Le=H("agent-handlers"),Ml=5*1024*1024,e_=1,t_=6,n_=new Set(["node_modules",".git",".coze","dist","build",".next"]),io=class{constructor(e){this.opts=e}opts;async listSkills(e){Kt(e._meta,"_agent/listSkills");let r=Er(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??$e(r).workspace,c=i?.skills??[],u=[];for(let f of c){let x=kt(o,f.relPath,"SKILL.md");await Zw(x).then(b=>b.isFile()).catch(()=>!1)&&u.push(a_(f))}return{skills:u}}async addSkills(e){Kt(e._meta,"_agent/addSkills");let r=Er(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],u=new Map(c.map((x,p)=>[x.skillId,p])),f=[];for(let x of o){let p=await $c({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Vc(c,u,p),f.push(x)}return await ds(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Kt(e._meta,"_agent/removeSkills");let r=Er(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],u=[];for(let f of c){if(!o.has(f.skillId)){u.push(f);continue}let x=kt(i.workspace,f.relPath);await Yw(x,{recursive:!0,force:!0}),Le.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await ds(r,u),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 u=c.acpSessionId;if(u&&i.activeTriggers.has(u)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Le.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:u});continue}let x=c.downstream;c.downstream=void 0,Le.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:u}),x.stop(r).catch(p=>Le.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Le.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await je(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Le.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await sr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Le.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ze(i),Le.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await je(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ze(i),Le.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}):(Le.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Kt(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Fc(e.model)??yt,i=await je(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ze(i),Le.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Le.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(u=>Le.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let c=[];for(let[u,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let x=o.sessions.get(u);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Le.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Kt(e._meta,_t.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,_t.RESET),await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Le.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,u]of i.sessions)o.set(c,{modelToken:u.modelToken,tokenGeneratedAt:u.tokenGeneratedAt});await ei(e,o)}async clearPersistedAcpSessionIds(e){let r=await je(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Ze(r)}async repairAgent(e){if(Kt(e._meta,_t.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${_t.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Le.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,_t.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Le.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Le.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Kt(e._meta,"_agent/getFileTree");let r=e._meta,i=Er(r),o=await this.resolveWorkspace(i),c=e.filePath??"",u=this.safeJoin(o,c),f=await Hc(u).catch(()=>null);if(!f)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(f.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Qr(u,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=w_(e.depth);return f.isDirectory()?{tree:await m_(o,u,c,x)}:{tree:[{name:__(c),path:jl(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Kt(e._meta,"_agent/getFileContent");let r=Er(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Hc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Qr(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Ml)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Ml})`);let u=await Bl(o);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:c.size}:{content:u.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await je(e).catch(()=>null))?.workspace??$e(e).workspace}safeJoin(e,r){let i=Gc(e,r||"."),o=Wc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Fl}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return je(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function r_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function i_(t){return t==="claude-code"?kt(".claude","skills"):kt(".agents","skills")}var s_=3e4,o_=50*1024*1024,Sr=3e4;async function $c(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,u=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!u)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=r_(o.skillName),x=i_(i),p=kt(x,f),b=kt(r,p);if(await qc(b,{recursive:!0}),c){let T=Buffer.from(o.content,"utf8");Ri(T.length),await jc(kt(b,"SKILL.md"),T,"utf8")}else{let T=await c_(o.downloadUrl);u_(T)?await h_(T,b):l_(T)?await f_(T,b):await jc(kt(b,"SKILL.md"),T.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Le.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),E}function Vc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function a_(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 c_(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ri(e);let r=d_(t);return Ri(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Bl(e);return Ri(r.length),r}if(eo(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),s_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ri(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ri(t){if(t>o_)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function d_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function u_(t){return t.length>=2&&t[0]===31&&t[1]===139}function l_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function Kc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function f_(t,e){let r,i;try{r=new Hl.default(t),i=r.getEntries()}catch(u){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${u.message}`,{cause:u})}for(let u of i){let f=u.entryName;if(!f||Kc(f))continue;if(f.startsWith("/")||/^[A-Za-z]:[\\/]/.test(f))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${f}`);if(f.split(/[/\\]/).some(p=>p===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${f}`);let x=u.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${f}`)}let o=x_(i),c=Gc(e);for(let u of i){if(Kc(u.entryName))continue;let f=u.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=Gc(e,f),p=Wc(c,x);if(p.startsWith("..")||p==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(u.isDirectory){await qc(x,{recursive:!0});continue}await qc(Xw(x),{recursive:!0});let b;try{b=u.getData()}catch(E){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${u.entryName}): ${E.message}`,{cause:E})}await jc(x,b)}}function x_(t){let e;for(let r of t){let i=r.entryName;if(!i||Kc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function h_(t,e){await p_(t);let r=wl({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${Sr}ms)`))},Sr);try{await Ul(zl.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${Sr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function p_(t){let e=[],r=br({onReadEntry:c=>{let u=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${u.slice(0,100)}`);return}if(u.startsWith("/")||u.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(u)){e.push(`tar entry absolute path: ${u}`);return}u.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${u}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${Sr}ms)`))},Sr);try{await Ul(zl.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${Sr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var g_=5e3;async function m_(t,e,r,i){return ql(t,e,r,i,{count:0})}async function ql(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Jw(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of c){if(n_.has(f.name)||f.isSymbolicLink())continue;if(o.count>=g_){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=kt(e,f.name),p=Qw(kt(r,f.name)),b=null;try{b=await Hc(x)}catch{continue}if(b.isSymbolicLink())continue;o.count++;let E={name:f.name,path:jl(Wc(t,x)),isDir:b.isDirectory(),size:b.size,modifiedAt:Math.floor(b.mtimeMs)};b.isDirectory()&&i>1&&(E.children=await ql(t,x,p,i-1,o)),u.push(E)}return u.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),u}function w_(t){return!t||t<=0?e_:Math.min(t,t_)}function __(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function jl(t){return t.split(Fl).join("/")}ne();import{readFileSync as eA}from"node:fs";import{dirname as nA,join as rA}from"node:path";import{fileURLToPath as sA}from"node:url";var Ir="0.1.99-alpha.1";var mn=H("agent-health-reporter"),y_=1e4,ki=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??y_}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()}),mn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),mn.info("heartbeat stopped"))}async tick(){if(this.inFlight){mn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){mn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let u of this.opts.core.agents.values()){let f=b_(u);if(!f)continue;let x={agentId:u.agentId,status:f};u.patToken&&(x.patToken=u.patToken),u.accountId&&(x.accountId=u.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:Ir,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(u){mn.warn("heartbeat batch send failed",{count:r.length,err:String(u)})}let c=o?.authFailures;if(c&&c.length>0&&(mn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(u=>u.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(u){mn.warn("onAuthFailures callback failed (ignored)",{err:String(u)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){mn.warn("onTickEnd hook failed",{err:String(r)})}}};function b_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}nn();import{chmod as yy,mkdir as po,rm as by,stat as Ey,writeFile as vy}from"node:fs/promises";import{homedir as Sy}from"node:os";import{join as Qc}from"node:path";tn();import{spawnSync as F_}from"node:child_process";import{existsSync as z_}from"node:fs";import{release as U_}from"node:os";import{basename as H_,isAbsolute as q_}from"node:path";function Oi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Ar(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Tr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function wn(t,e){return{jsonrpc:"2.0",id:t,error:e}}We();var so=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ee={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function Gl(t){return"method"in t&&"id"in t&&t.id!==void 0}function Kl(t){return"method"in t&&!("id"in t)}function oo(t){return!("method"in t)&&"id"in t}var E_={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ee.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ee.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ee.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ee.AGENT_ENV_NOT_READY};function v_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ni(t.message)}:typeof t=="string"?Ni(t):typeof t=="object"?I_(t):t}var S_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Ni(t){let e=t;for(let[r,i]of S_)e=e.replace(r,i);return e}function I_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ni(i):e[r]=i;return e}function Pi(t){if(t instanceof C){let e=v_(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:E_[t.code]??ee.INTERNAL_ERROR,message:Ni(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:Ni(t instanceof Error?t.message:String(t))}}function Wl(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:u,...f}=e;c=f}return new C(r,o,{retriable:e?.retriable??!1,cause:c})}function Vl(t){return`${JSON.stringify(t)}
|
|
93
|
-
`}var
|
|
94
|
-
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(u){this.onError?.({line:c,error:u})}}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 Yl={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},gA=Object.fromEntries(Object.entries(Yl).map(([t,e])=>[e,t])),A_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Cr=class{seq=0;next(e,r){this.seq+=1;let i=Yl[e]??T_(e),o=A_[i]??[],c=[i,String(this.seq)];if(o.length>0){let u=o.map(x=>Jl(r?.[x]??"")),f=C_(u).join(":");f&&c.push(f)}else r&&Object.values(r).some(u=>u)&&c.push(Object.values(r).filter(Boolean).map(u=>Jl(String(u))).join(":"));return c.join("_")}reset(){this.seq=0}};function T_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Jl(t){return t.replace(/[:_\s]+/g,"-")}function C_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Xr();import{readFileSync as D_}from"node:fs";var R_=384;async function Jc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await ir(t.agentEnvFile,r,{mode:R_})}function Yc(t){try{let e=JSON.parse(D_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Zl(t,e,r={},i=o=>o){return{...i({...t,...Yc(e)}),...r}}_n();es();We();ne();Oe();var B_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function tf(t,e){if(!e)return null;for(let r of B_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var j_=Ft("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),G_=200,K_=40,W_=Ft("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),$_=Ft("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),V_=Ft("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),nf=500;function J_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=nf?t:`${e.slice(0,nf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function rf(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),F_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function sf(t){try{return z_(t)}catch{return}}function Y_(t,e){return{platform:process.platform,osRelease:U_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:q_(e.command)?sf(e.command):void 0,cwd:e.cwd,cwdExists:sf(e.cwd),envKeys:e.envKeys}}function Z_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${H_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Ot=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new ao({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Cr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Zl(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=dt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>G_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(this.buildExitError(o,c));for(let f of this.exitHandlers)f(o,c)}),i.on("error",o=>{let c=o,u=Y_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:u}),this.failAllPending(new C("AGENT_SPAWN_FAILED",Z_(c,u),{cause:u}))}),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()));rf(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||rf(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=W_,i=$_,o=V_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Ar("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Tr(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(wn(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=j_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let u=this.idAllocator.next(e),f=Oi(u,e,r),x=(()=>{if(typeof r!="object"||r===null)return;let E=r.sessionId;return typeof E=="string"?E:void 0})(),p=i>0&&Number.isFinite(i),b=o>0&&Number.isFinite(o);return new Promise((E,T)=>{let y={resolve:E,reject:T,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(p){let S=()=>{y.timer=setTimeout(()=>{let D=Date.now()-v;if(this.inflightAgentRequests.size>0&&D<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:u,method:e,elapsed:D,approvalMaxMs:c,...x?{sessionId:x}:{}}),S();return}this.pending.delete(u),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer);let P=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:u,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:P,...x?{sessionId:x}:{}}),T(P?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=b?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:u,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),I?.();return}y.timer&&clearTimeout(y.timer),this.pending.delete(u),this.log.warn("first session/update timeout, rejecting pending call",{id:u,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),T(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;y.onFirstUpdate=b?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=null,y.onFirstUpdate=null}:null,this.pending.set(u,y),I?.();try{this.writeFrame(f)}catch(S){y.timer&&clearTimeout(y.timer),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),this.pending.delete(u),T(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Vl(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(oo(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(Wl(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:J_(e.result)}),r.resolve(e.result));return}if(Kl(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Gl(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(wn(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(wn(e.id,Pi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(K_).join(`
|
|
95
|
-
`),o=tf(this.framework,i);return o?new C(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function X_(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 co=class extends Ot{framework="claude-code";constructor(e){let{command:r,args:i}=Zr("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 X_(e)}};tn();import{spawn as Q_}from"node:child_process";import{existsSync as af,mkdirSync as ey,mkdtempSync as ty,readFileSync as ny,readdirSync as ry,rmSync as iy,statSync as sy}from"node:fs";import{tmpdir as oy}from"node:os";import{join as uo}from"node:path";var cf=9e4;function ay(t){let e=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t):Number.NaN;return!Number.isFinite(e)||e<=0?cf:Math.max(1,Math.floor(e*1e3))}function of(t){if(typeof t=="string"&&t.trim())return{command:t,timeoutMs:cf};if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(e.type&&e.type!=="command")return;let r=typeof e.command=="string"?e.command.trim():"";if(r)return{command:r,timeoutMs:ay(e.timeout)}}function Zc(t){if(Array.isArray(t))return t.flatMap(i=>Zc(i));if(!t||typeof t!="object"){let i=of(t);return i?[i]:[]}let e=t;if(e.hooks)return Zc(e.hooks);let r=of(e);return r?[r]:[]}function cy(t){let e=uo(t,"hooks.json");if(!af(e))return[];let r=JSON.parse(ny(e,"utf8")),o=r.hooks&&typeof r.hooks=="object"?r.hooks:r;return Zc(o.Stop??o.stop)}function dy(t){let e=uo(t,"sessions");if(!af(e))return;let r=[],i=c=>{let u;try{u=ry(c,{withFileTypes:!0})}catch{return}for(let f of u){let x=uo(c,f.name);f.isDirectory()?i(x):f.isFile()&&f.name.endsWith(".jsonl")&&r.push(x)}};i(e);let o;for(let c of r)try{let u=sy(c).mtimeMs;(!o||u>o.mtimeMs)&&(o={path:c,mtimeMs:u})}catch{}return o?.path}var lo=class extends Ot{framework="codex";authMethodId;codexHomeDir;cleanupCodexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Zr("codex",e.command,i),u=e.isolateCodexHome?e.codexHomeDir??e.env?.CODEX_HOME??ty(uo(oy(),"coze-bridge-codex-home-")):void 0,f=!!u&&!e.codexHomeDir&&e.env?.CODEX_HOME!==u;u&&!f&&ey(u,{recursive:!0});let x=u?{...e.env??{},CODEX_HOME:u}:e.env,p={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...x?{env:x}:{}};super(p),this.authMethodId=e.authMethodId,this.codexHomeDir=u,this.cleanupCodexHomeDir=f}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async sessionPrompt(e){let r=await super.sessionPrompt(e);return this.runStopHooksBestEffort(e.sessionId).catch(i=>{this.log.warn("codex stop hook unexpected failure",{err:String(i)})}),r}async runStopHooksBestEffort(e){let r=this.codexHomeDir??this.opts.env?.CODEX_HOME;if(!r)return;let i;try{i=cy(r)}catch(u){this.log.warn("codex stop hook load failed",{codexHomeDir:r,err:String(u)});return}if(i.length===0)return;let o=dy(r),c=JSON.stringify({hook_event_name:"Stop",session_id:e,...o?{transcript_path:o}:{},trigger:"coze-bridge"});for(let u of i)try{await this.runHookCommand(u,c)}catch(f){this.log.warn("codex stop hook failed",{codexHomeDir:r,command:u.command.slice(0,200),err:String(f)})}}runHookCommand(e,r){return new Promise((i,o)=>{let c=Q_(e.command,{cwd:this.opts.cwd,env:{...process.env,...this.opts.env??{}},shell:!0,stdio:["pipe","ignore","pipe"]}),u="",f=setTimeout(()=>{c.kill("SIGTERM"),o(new Error(`hook timed out after ${e.timeoutMs}ms`))},e.timeoutMs);c.stderr?.setEncoding("utf8"),c.stderr?.on("data",x=>{u+=x,u.length>4e3&&(u=u.slice(-4e3))}),c.on("error",x=>{clearTimeout(f),o(x)}),c.on("close",(x,p)=>{if(clearTimeout(f),x===0){i();return}o(new Error(`hook exited code=${x} signal=${p} stderr=${u.slice(-1e3)}`))}),c.stdin.end(`${r}
|
|
96
|
-
`)})}async stop(e){if(await super.stop(e),this.codexHomeDir&&this.cleanupCodexHomeDir)try{iy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var uy=3e4,Dr=class extends Ot{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},uy))}get acpSessionName(){return this.sessionName}};We();ne();Oe();function Xc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}tn();var yn=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var fo=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new yn,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Li(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Li(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}_n();ne();import{constants as df}from"node:fs";import{access as ly}from"node:fs/promises";import{delimiter as fy,join as xy}from"node:path";var bt=H("framework-detector"),uf={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},hy=[".exe",".cmd",".bat",".ps1"],Un=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??dt,access:e.access??ly}}async detect(e){let r=uf[e],i=await this.which(r);if(!i)return bt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,u]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(uf).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(fy).filter(Boolean),i=this.env.platform==="win32"?["",...hy]:[""];for(let o of r)for(let c of i){let u=xy(o,e+c);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?df.F_OK:df.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return bt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return bt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return bt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return bt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(u=>u?.isDefault===!0);return c?!c.id||!c.workspace?(bt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(bt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return bt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return bt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||bt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let u=JSON.parse(c[0]);typeof u.gateway?.port=="number"&&(o.port=u.gateway.port),typeof u.service?.runtime?.status=="string"&&(o.runtime=u.service.runtime.status),!i&&typeof u.rpc?.error=="string"&&(o.detail=u.rpc.error)}catch(u){bt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(u)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(gy(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,u,f=x=>{c||(c=!0,u&&clearTimeout(u),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{x.kill("SIGKILL"),f(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",p=>f({code:p,stdout:o}))}catch{f(null)}})}},py=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function gy(t){return t.replace(py,"")}import{homedir as my}from"node:os";import{join as wy}from"node:path";_n();We();Xr();ne();async function xf(){let t=wy(my(),".openclaw/openclaw.json");return(await rr(t))?.gateway?.auth?.token??""}var lf=H("openclaw.config"),_y=[0,5e3,5e3],ff="models.providers.",xo="agents.defaults.models",ho=class{command;env;retryDelaysMs;queue=new yn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??_y}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(u=>setTimeout(u,c));try{return await r()}catch(u){i=u,lf.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(u)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=dt(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",u=>{c+=u.toString("utf8")}),o.on("error",i),o.on("close",u=>{u===0?r():i(new Error(`exit ${u}: ${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){lf.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",`${ff}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ff}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${xo}[${e}]`,()=>this.runCli(["config","set",xo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${xo}[${e}]`,`${xo}.${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 ge=H("agent-manager"),Iy=(t,e,r,i,o,c,u,f,x,p)=>{switch(t){case"claude-code":{let b={...o?{...Rl(o),...Nl(o,u,f)}:{},...x??{},IS_SANDBOX:"1"};return new co({cwd:r,env:b,agentId:i})}case"codex":{let E=[...o?[...kl(o),...Ll(o,u,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],T=!!o,y={...o?Ol(o):{},...x??{},...T?{COZE_CODEX_BYPASS_HOOK_TRUST:"1"}:{}};return new lo({cwd:r,agentId:i,...E.length>0?{extraArgs:E}:{},...Object.keys(y).length>0?{env:y}:{},...T?{authMethodId:"openai-api-key",isolateCodexHome:!0,codexHomeDir:p}:{}})}case"openclaw":return new Dr({command:e,cwd:r,agentId:i,...c?{sessionName:Xc(c)}:{}})}};function ed(t){return t==="claude-code"||t==="codex"}function Ay(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(Ty(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return HS(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Gh("schtasks",["/Create","/SC","ONLOGON","/TN",aa,"/TR",r,"/RU",t.userName,"/F"]),Ud.info("task scheduler entry created",{task:aa,logFile:t.logFile})},async uninstall(t){await Gh("schtasks",["/Delete","/TN",aa,"/F"]).catch(e=>Ud.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ud.info("task scheduler entry removed",{task:aa})}}});var Hh={};ba(Hh,{buildContext:()=>YS,getSupervisor:()=>KS,launchdSupervisor:()=>Fd,systemdSupervisor:()=>zd,taskSchedulerSupervisor:()=>Gd});import{homedir as jS,userInfo as WS}from"node:os";function KS(t=process.platform){switch(t){case"darwin":return Fd;case"linux":return zd;case"win32":return Gd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function VS(){let t={};for(let e of $S){let r=process.env[e];r&&(t[e]=r)}return t}function YS(){let t=X();return{nodeBin:process.execPath,entry:kd(t),logFile:t.logFile,homeDir:jS(),userName:WS().username,isRoot:process.getuid?.()===0,env:VS()}}var $S,jh=Ye(()=>{"use strict";ke();Jo();Fh();Uh();qh();$S=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();nn();var ml=j("acp-installer-warmup"),xg=["claude-code","codex"];async function wl(t={}){let e=t.ensure??er,i=(await Promise.allSettled(xg.map(async o=>{let c=await e(o);ml.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&ml.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();ne();import{readdir as Ag}from"node:fs/promises";import{mkdir as Sl,writeFile as Al}from"node:fs/promises";import{join as Ca}from"node:path";var Sg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await Sl(t,{recursive:!0});let i=Sg[e],o=Ca(t,i);return await Al(o,r??"","utf8"),o}async function Il(t,e){let r=Ca(t,".claude");await Sl(r,{recursive:!0});let i=Ca(r,"settings.local.json"),o={permissions:{defaultMode:"bypassPermissions"}};e==="cloud"&&(o.autoCompactWindow=15e4);let c=JSON.stringify(o,null,2);return await Al(i,c,"utf8"),i}var et=j("agent-detail-sync"),Ig=6e4,Tg=5*6e4,xs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Ag(r)}catch(o){et.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}et.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){et.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){et.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),et.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){et.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){et.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){et.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){et.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Tg):Ig;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(o.agentId&&o.agentId!==e){et.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&et.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){et.debug("detail sync: no diff",{agentId:e});return}await Xe(i,this.opts.paths),et.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var H0=St(of(),1);import{lstat as Hc,mkdir as jc,readFile as z0,readdir as e_,rm as t_,stat as n_,writeFile as Wc}from"node:fs/promises";import{dirname as r_,join as kt,normalize as i_,relative as Vc,resolve as Kc,sep as U0}from"node:path";import{Readable as G0}from"node:stream";import{pipeline as q0}from"node:stream/promises";import Yg from"events";import Qe from"fs";import{EventEmitter as Tc}from"node:events";import Gf from"node:stream";import{StringDecoder as Jg}from"node:string_decoder";import jf from"node:path";import pr from"node:fs";import{dirname as dm,parse as lm}from"path";import{EventEmitter as wm}from"events";import cc from"assert";import{Buffer as Bn}from"buffer";import*as ff from"zlib";import _m from"zlib";import{posix as cr}from"node:path";import{basename as Km}from"node:path";import Ws from"fs";import Ct from"fs";import wf from"path";import{win32 as rw}from"node:path";import Af from"path";import s0 from"node:fs";import yw from"node:assert";import{randomBytes as o0}from"node:crypto";import re from"node:fs";import Pe from"node:path";import a0 from"fs";import eo from"node:fs";import yi from"node:path";import it from"node:fs";import Tw from"node:fs/promises";import Vs from"node:path";import{join as w0}from"node:path";import rt from"node:fs";import b0 from"node:path";var $g=Object.defineProperty,Vg=(t,e)=>{for(var r in e)$g(t,r,{get:e[r],enumerable:!0})},af=typeof process=="object"&&process?process:{stdout:null,stderr:null},Zg=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Gf||Xg(t)||Qg(t)),Xg=t=>!!t&&typeof t=="object"&&t instanceof Tc&&typeof t.pipe=="function"&&t.pipe!==Gf.Writable.prototype.pipe,Qg=t=>!!t&&typeof t=="object"&&t instanceof Tc&&typeof t.write=="function"&&typeof t.end=="function",zt=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),ws=Symbol("emittingEnd"),ri=Symbol("emittedError"),_s=Symbol("closed"),cf=Symbol("read"),ys=Symbol("flush"),df=Symbol("flushChunk"),ht=Symbol("encoding"),ar=Symbol("decoder"),Me=Symbol("flowing"),ii=Symbol("paused"),ur=Symbol("resume"),Be=Symbol("buffer"),$e=Symbol("pipes"),Fe=Symbol("bufferLength"),Na=Symbol("bufferPush"),bs=Symbol("bufferShift"),We=Symbol("objectMode"),Se=Symbol("destroyed"),La=Symbol("error"),Ma=Symbol("emitData"),lf=Symbol("emitEnd"),Ba=Symbol("emitEnd2"),At=Symbol("async"),Fa=Symbol("abort"),Es=Symbol("aborted"),si=Symbol("signal"),Cn=Symbol("dataListeners"),nt=Symbol("discarded"),oi=t=>Promise.resolve().then(t),em=t=>t(),tm=t=>t==="end"||t==="finish"||t==="prefinish",nm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,rm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),qf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ur](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},im=class extends qf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},sm=t=>!!t.objectMode,om=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends Tc{[Me]=!1;[ii]=!1;[$e]=[];[Be]=[];[We];[ht];[At];[ar];[zt]=!1;[on]=!1;[ws]=!1;[_s]=!1;[ri]=null;[Fe]=0;[Se]=!1;[si];[Es]=!1;[Cn]=0;[nt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");sm(e)?(this[We]=!0,this[ht]=null):om(e)?(this[ht]=e.encoding,this[We]=!1):(this[We]=!1,this[ht]=null),this[At]=!!e.async,this[ar]=this[ht]?new Jg(this[ht]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Be]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$e]});let{signal:r}=e;r&&(this[si]=r,r.aborted?this[Fa]():r.addEventListener("abort",()=>this[Fa]()))}get bufferLength(){return this[Fe]}get encoding(){return this[ht]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[We]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[At]}set async(t){this[At]=this[At]||!!t}[Fa](){this[Es]=!0,this.emit("abort",this[si]?.reason),this.destroy(this[si]?.reason)}get aborted(){return this[Es]}set aborted(t){}write(t,e,r){if(this[Es])return!1;if(this[zt])throw new Error("write after end");if(this[Se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[At]?oi:em;if(!this[We]&&!Buffer.isBuffer(t)){if(rm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(nm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[We]?(this[Me]&&this[Fe]!==0&&this[ys](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):t.length?(typeof t=="string"&&!(e===this[ht]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ht]&&(t=this[ar].write(t)),this[Me]&&this[Fe]!==0&&this[ys](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):(this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me])}read(t){if(this[Se])return null;if(this[nt]=!1,this[Fe]===0||t===0||t&&t>this[Fe])return this[Ut](),null;this[We]&&(t=null),this[Be].length>1&&!this[We]&&(this[Be]=[this[ht]?this[Be].join(""):Buffer.concat(this[Be],this[Fe])]);let e=this[cf](t||null,this[Be][0]);return this[Ut](),e}[cf](t,e){if(this[We])this[bs]();else{let r=e;t===r.length||t===null?this[bs]():typeof r=="string"?(this[Be][0]=r.slice(t),e=r.slice(0,t),this[Fe]-=t):(this[Be][0]=r.subarray(t),e=r.subarray(0,t),this[Fe]-=t)}return this.emit("data",e),!this[Be].length&&!this[zt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[zt]=!0,this.writable=!1,(this[Me]||!this[ii])&&this[Ut](),this}[ur](){this[Se]||(!this[Cn]&&!this[$e].length&&(this[nt]=!0),this[ii]=!1,this[Me]=!0,this.emit("resume"),this[Be].length?this[ys]():this[zt]?this[Ut]():this.emit("drain"))}resume(){return this[ur]()}pause(){this[Me]=!1,this[ii]=!0,this[nt]=!1}get destroyed(){return this[Se]}get flowing(){return this[Me]}get paused(){return this[ii]}[Na](t){this[We]?this[Fe]+=1:this[Fe]+=t.length,this[Be].push(t)}[bs](){return this[We]?this[Fe]-=1:this[Fe]-=this[Be][0].length,this[Be].shift()}[ys](t=!1){do;while(this[df](this[bs]())&&this[Be].length);!t&&!this[Be].length&&!this[zt]&&this.emit("drain")}[df](t){return this.emit("data",t),this[Me]}pipe(t,e){if(this[Se])return t;this[nt]=!1;let r=this[on];return e=e||{},t===af.stdout||t===af.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[$e].push(e.proxyErrors?new im(this,t,e):new qf(this,t,e)),this[At]?oi(()=>this[ur]()):this[ur]()),t}unpipe(t){let e=this[$e].find(r=>r.dest===t);e&&(this[$e].length===1?(this[Me]&&this[Cn]===0&&(this[Me]=!1),this[$e]=[]):this[$e].splice(this[$e].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[nt]=!1,this[Cn]++,!this[$e].length&&!this[Me]&&this[ur]();else if(t==="readable"&&this[Fe]!==0)super.emit("readable");else if(tm(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ri]){let i=e;this[At]?oi(()=>i.call(this,this[ri])):i.call(this,this[ri])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Cn]=this.listeners("data").length,this[Cn]===0&&!this[nt]&&!this[$e].length&&(this[Me]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[nt]&&!this[$e].length&&(this[Me]=!1)),e}get emittedEnd(){return this[on]}[Ut](){!this[ws]&&!this[on]&&!this[Se]&&this[Be].length===0&&this[zt]&&(this[ws]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[_s]&&this.emit("close"),this[ws]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Se&&this[Se])return!1;if(t==="data")return!this[We]&&!r?!1:this[At]?(oi(()=>this[Ma](r)),!0):this[Ma](r);if(t==="end")return this[lf]();if(t==="close"){if(this[_s]=!0,!this[on]&&!this[Se])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ri]=r,super.emit(La,r);let o=!this[si]||this.listeners("error").length?super.emit("error",r):!1;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Ut](),i}[Ma](t){for(let r of this[$e])r.dest.write(t)===!1&&this.pause();let e=this[nt]?!1:super.emit("data",t);return this[Ut](),e}[lf](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(oi(()=>this[Ba]()),!0):this[Ba]())}[Ba](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[$e])r.dest.write(e);this[nt]||super.emit("data",e)}}for(let e of this[$e])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[We]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[We]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[We])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ht]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Se,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[nt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[zt])return e();let i,o,c=h=>{this.off("data",l),this.off("end",f),this.off(Se,x),e(),o(h)},l=h=>{this.off("error",c),this.off("end",f),this.off(Se,x),this.pause(),i({value:h,done:!!this[zt]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Se,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,_)=>{o=_,i=h,this.once(Se,x),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[nt]=!1;let t=!1,e=()=>(this.pause(),this.off(La,e),this.off(Se,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(La,e),this.once(Se,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Se])return t?this.emit("error",t):this.emit(Se),this;this[Se]=!0,this[nt]=!0,this[Be].length=0,this[Fe]=0;let e=this;return typeof e.close=="function"&&!this[_s]&&e.close(),t?this.emit("error",t):this.emit(Se),this}static get isStream(){return Zg}},am=Qe.writev,gn=Symbol("_autoClose"),wt=Symbol("_close"),ai=Symbol("_ended"),ce=Symbol("_fd"),za=Symbol("_finished"),jt=Symbol("_flags"),Ua=Symbol("_flush"),oc=Symbol("_handleChunk"),ac=Symbol("_makeBuf"),wi=Symbol("_mode"),vs=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Ga=Symbol("_onread"),xr=Symbol("_onwrite"),mn=Symbol("_open"),mt=Symbol("_path"),fn=Symbol("_pos"),It=Symbol("_queue"),hr=Symbol("_read"),qa=Symbol("_readSize"),Ht=Symbol("_reading"),ci=Symbol("_remain"),Ha=Symbol("_size"),Ps=Symbol("_write"),Rn=Symbol("_writing"),Ns=Symbol("_defaultFlag"),Mn=Symbol("_errored"),Cc=class extends Un{[Mn]=!1;[ce];[mt];[qa];[Ht]=!1;[Ha];[ci];[gn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Mn]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[qa]=e.readSize||16*1024*1024,this[Ht]=!1,this[Ha]=typeof e.size=="number"?e.size:1/0,this[ci]=this[Ha],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[hr]():this[mn]()}get fd(){return this[ce]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){Qe.open(this[mt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[ce]=e,this.emit("open",e),this[hr]())}[ac](){return Buffer.allocUnsafe(Math.min(this[qa],this[ci]))}[hr](){if(!this[Ht]){this[Ht]=!0;let t=this[ac]();if(t.length===0)return process.nextTick(()=>this[Ga](null,0,t));Qe.read(this[ce],t,0,t.length,null,(e,r,i)=>this[Ga](e,r,i))}}[Ga](t,e,r){this[Ht]=!1,t?this[mr](t):this[oc](e,r)&&this[hr]()}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[Ht]=!0,this[wt](),this.emit("error",t)}[oc](t,e){let r=!1;return this[ci]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ci]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[hr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},cm=class extends Cc{[mn](){let t=!0;try{this[wr](null,Qe.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[hr](){let t=!0;try{if(!this[Ht]){this[Ht]=!0;do{let e=this[ac](),r=e.length===0?0:Qe.readSync(this[ce],e,0,e.length,null);if(!this[oc](r,e))break}while(!0);this[Ht]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.closeSync(t),this.emit("close")}}},Ys=class extends Yg{readable=!1;writable=!0;[Mn]=!1;[Rn]=!1;[ai]=!1;[It]=[];[vs]=!1;[mt];[wi];[gn];[ce];[Ns];[jt];[za]=!1;[fn];constructor(t,e){e=e||{},super(e),this[mt]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[wi]=e.mode===void 0?438:e.mode,this[fn]=typeof e.start=="number"?e.start:void 0,this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[fn]!==void 0?"r+":"w";this[Ns]=e.flags===void 0,this[jt]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[mt]}[mr](t){this[wt](),this[Rn]=!0,this.emit("error",t)}[mn](){Qe.open(this[mt],this[jt],this[wi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Ns]&&this[jt]==="r+"&&t&&t.code==="ENOENT"?(this[jt]="w",this[mn]()):t?this[mr](t):(this[ce]=e,this.emit("open",e),this[Rn]||this[Ua]())}end(t,e){return t&&this.write(t,e),this[ai]=!0,!this[Rn]&&!this[It].length&&typeof this[ce]=="number"&&this[xr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ai]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[Rn]||this[It].length?(this[It].push(t),this[vs]=!0,!1):(this[Rn]=!0,this[Ps](t),!0)}[Ps](t){Qe.write(this[ce],t,0,t.length,this[fn],(e,r)=>this[xr](e,r))}[xr](t,e){t?this[mr](t):(this[fn]!==void 0&&typeof e=="number"&&(this[fn]+=e),this[It].length?this[Ua]():(this[Rn]=!1,this[ai]&&!this[za]?(this[za]=!0,this[wt](),this.emit("finish")):this[vs]&&(this[vs]=!1,this.emit("drain"))))}[Ua](){if(this[It].length===0)this[ai]&&this[xr](null,0);else if(this[It].length===1)this[Ps](this[It].pop());else{let t=this[It];this[It]=[],am(this[ce],t,this[fn],(e,r)=>this[xr](e,r))}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Hf=class extends Ys{[mn](){let t;if(this[Ns]&&this[jt]==="r+")try{t=Qe.openSync(this[mt],this[jt],this[wi])}catch(e){if(e?.code==="ENOENT")return this[jt]="w",this[mn]();throw e}else t=Qe.openSync(this[mt],this[jt],this[wi]);this[wr](null,t)}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.closeSync(t),this.emit("close")}}[Ps](t){let e=!0;try{this[xr](null,Qe.writeSync(this[ce],t,0,t.length,this[fn])),e=!1}finally{if(e)try{this[wt]()}catch{}}}},fm=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),um=t=>!!t.sync&&!!t.file,xm=t=>!t.sync&&!!t.file,hm=t=>!!t.sync&&!t.file,pm=t=>!t.sync&&!t.file,gm=t=>!!t.file,mm=t=>fm.get(t)||t,Rc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=mm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ti=(t,e,r,i,o)=>Object.assign((c=[],l,f)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(f=l,l=void 0),l=l?Array.from(l):[];let x=Rc(c);if(o?.(x,l),um(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(xm(x)){let h=e(x,l);return f?h.then(()=>f(),f):h}else if(hm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(pm(x)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),ym=_m.constants||{ZLIB_VERNUM:4736},Dt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},ym)),bm=Bn.concat,uf=Object.getOwnPropertyDescriptor(Bn,"concat"),Em=t=>t,ja=uf?.writable===!0||uf?.set!==void 0?t=>{Bn.concat=t?Em:bm}:t=>{},Fn=Symbol("_superWrite"),Ss=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},Wa=Symbol("flushFlag"),Dc=class extends Un{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof ff[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new ff[e](t)}catch(r){throw new Ss(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new Ss(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return cc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[Wa]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Fn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;cc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ja(!0);let l;try{let x=typeof t[Wa]=="number"?t[Wa]:this.#r;l=this.#t._processChunk(t,x),ja(!1)}catch(x){ja(!1),this.#o(new Ss(x,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new Ss(x,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];f=this[Fn](Bn.from(x));for(let h=1;h<l.length;h++)f=this[Fn](l[h])}else f=this[Fn](Bn.from(l));return r&&r(),f}},Wf=class extends Dc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Dt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Dt.Z_FINISH,t.fullFlushFlag=Dt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Dt.Z_SYNC_FLUSH),cc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},vm=class extends Wf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Fn](t){return this.#e?(this.#e=!1,t[9]=255,super[Fn](t)):super[Fn](t)}},Sm=class extends Wf{constructor(t){super(t,"Unzip")}},Kf=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Dt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Dt.BROTLI_OPERATION_FLUSH,super(t,e)}},Am=class extends Kf{constructor(t){super(t,"BrotliCompress")}},Im=class extends Kf{constructor(t){super(t,"BrotliDecompress")}},$f=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Dt.ZSTD_e_end,t.fullFlushFlag=Dt.ZSTD_e_flush,super(t,e)}},Tm=class extends $f{constructor(t){super(t,"ZstdCompress")}},Cm=class extends $f{constructor(t){super(t,"ZstdDecompress")}},Rm=(t,e)=>{if(Number.isSafeInteger(t))t<0?km(t,e):Dm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Dm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},km=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Vf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Yf(o))}},Om=t=>{let e=t[0],r=e===128?Nm(t.subarray(1,t.length)):e===255?Pm(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},Pm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Vf(c):c===0?l=c:(i=!0,l=Yf(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Nm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Vf=t=>(255^t)&255,Yf=t=>(255^t)+1&255,Lm={};Vg(Lm,{code:()=>kc,isCode:()=>Ls,isName:()=>Mm,name:()=>Js});var Ls=t=>Js.has(t),Mm=t=>kc.has(t),Js=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),kc=new Map(Array.from(Js).map(t=>[t[1],t[0]])),zn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??un(t,e+100,8),this.uid=r?.uid??i?.uid??un(t,e+108,8),this.gid=r?.gid??i?.gid??un(t,e+116,8),this.size=r?.size??i?.size??un(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ka(t,e+136,12),this.cksum=un(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(Ls(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??un(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??un(t,e+337,8)??0,t[e+475]!==0){let l=Dn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Dn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Ka(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Ka(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Bm(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=xn(t,e+100,8,this.mode)||this.needPax,this.needPax=xn(t,e+108,8,this.uid)||this.needPax,this.needPax=xn(t,e+116,8,this.gid)||this.needPax,this.needPax=xn(t,e+124,12,this.size)||this.needPax,this.needPax=$a(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=xn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=xn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(t,e+345,130,c)||this.needPax,this.needPax=$a(t,e+476,12,this.atime)||this.needPax,this.needPax=$a(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let f=e;f<e+148;f++)l+=t[f];for(let f=e+156;f<e+512;f++)l+=t[f];return this.cksum=l,xn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Js.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(kc.get(t));if(Ls(e)||e==="Unsupported")this.#e=e;else if(Ls(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Bm=(t,e)=>{let r=t,i="",o,c=cr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=cr.dirname(r),r=cr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=cr.join(cr.basename(i),r),i=cr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Dn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ka=(t,e,r)=>Fm(un(t,e,r)),Fm=t=>t===void 0?void 0:new Date(t*1e3),un=(t,e,r)=>Number(t[e])&128?Om(t.subarray(e,e+r)):Um(t,e,r),zm=t=>isNaN(t)?void 0:t,Um=(t,e,r)=>zm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Gm={12:8589934591,8:2097151},xn=(t,e,r,i)=>i===void 0?!1:i>Gm[r]||i<0?(Rm(i,t.subarray(e,e+r)),!0):(qm(t,e,r,i),!1),qm=(t,e,r,i)=>t.write(Hm(i,r),e,r,"ascii"),Hm=(t,e)=>jm(Math.floor(t).toString(8),e),jm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",$a=(t,e,r,i)=>i===void 0?!1:xn(t,e,r,i.getTime()/1e3),Wm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Wm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),js=class Jf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new zn({path:("PaxHeader/"+Km(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new Jf($m(Vm(e),r),i)}},$m=(t,e)=>e?Object.assign({},e,t):t,Vm=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(Ym,Object.create(null)),Ym=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Jm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Zf=class extends Un{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Zs=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Zm=1024*1024,dc=Buffer.from([31,139]),lc=Buffer.from([40,181,47,253]),Xm=Math.max(dc.length,lc.length),at=Symbol("state"),On=Symbol("writeEntry"),Gt=Symbol("readEntry"),Va=Symbol("nextEntry"),xf=Symbol("processEntry"),Tt=Symbol("extendedHeader"),di=Symbol("globalExtendedHeader"),an=Symbol("meta"),hf=Symbol("emitMeta"),xe=Symbol("buffer"),qt=Symbol("queue"),cn=Symbol("ended"),Ya=Symbol("emittedEnd"),Pn=Symbol("emit"),Te=Symbol("unzip"),As=Symbol("consumeChunk"),Is=Symbol("consumeChunkSub"),Ja=Symbol("consumeBody"),pf=Symbol("consumeMeta"),gf=Symbol("consumeHeader"),li=Symbol("consuming"),Za=Symbol("bufferConcat"),Ts=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),Cs=Symbol("onDone"),Nn=Symbol("sawValidEntry"),Rs=Symbol("sawNullBlock"),Ds=Symbol("sawEOF"),mf=Symbol("closeStream"),Qm=()=>!0,Ii=class extends wm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[qt]=[];[xe];[Gt];[On];[at]="begin";[an]="";[Tt];[di];[cn]=!1;[Te];[dn]=!1;[Nn];[Rs]=!1;[Ds]=!1;[dr]=!1;[li]=!1;[Ya]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Cs,()=>{(this[at]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Cs,t.ondone):this.on(Cs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Zm,this.filter=typeof t.filter=="function"?t.filter:Qm;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[mf]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Zs(this,t,e,r)}[gf](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new zn(t,e,this[Tt],this[di])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Rs]?(this[Ds]=!0,this[at]==="begin"&&(this[at]="header"),this[Pn]("eof")):(this[Rs]=!0,this[Pn]("nullBlock"));else if(this[Rs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[On]=new Zf(r,this[Tt],this[di]);if(!this[Nn])if(o.remain){let c=()=>{o.invalid||(this[Nn]=!0)};o.on("end",c)}else this[Nn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Pn]("ignoredEntry",o),this[at]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[at]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Pn]("ignoredEntry",o),this[at]=o.remain?"ignore":"header",o.resume()):(o.remain?this[at]="body":(this[at]="header",o.end()),this[Gt]?this[qt].push(o):(this[qt].push(o),this[Va]())))}}}[mf](){queueMicrotask(()=>this.emit("close"))}[xf](t){let e=!0;if(!t)this[Gt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Gt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Va]()),e=!1);return e}[Va](){do;while(this[xf](this[qt].shift()));if(this[qt].length===0){let t=this[Gt];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ja](t,e){let r=this[On];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[at]="header",this[On]=void 0,r.end()),o.length}[pf](t,e){let r=this[On],i=this[Ja](t,e);return!this[On]&&r&&this[hf](r),i}[Pn](t,e,r){this[qt].length===0&&!this[Gt]?this.emit(t,e,r):this[qt].push([t,e,r])}[hf](t){switch(this[Pn]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=js.parse(this[an],this[Tt],!1);break;case"GlobalExtendedHeader":this[di]=js.parse(this[an],this[di],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Tt]??Object.create(null);this[Tt]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Tt]||Object.create(null);this[Tt]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Te]===void 0||this.brotli===void 0&&this[Te]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<Xm)return this[xe]=t,r?.(),!0;for(let l=0;this[Te]===void 0&&l<dc.length;l++)t[l]!==dc[l]&&(this[Te]=!1);let o=!1;if(this[Te]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<lc.length;l++)if(t[l]!==lc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Te]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new zn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Te]===void 0||this[Te]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Te]=this[Te]===void 0?new Sm({}):o?new Cm({}):new Im({}),this[Te].on("data",x=>this[As](x)),this[Te].on("error",x=>this.abort(x)),this[Te].on("end",()=>{this[cn]=!0,this[As]()}),this[dr]=!0;let f=!!this[Te][l?"end":"write"](t);return this[dr]=!1,r?.(),f}}this[dr]=!0,this[Te]?this[Te].write(t):this[As](t),this[dr]=!1;let i=this[qt].length>0?!1:this[Gt]?this[Gt].flowing:!0;return!i&&this[qt].length===0&&this[Gt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Za](t){t&&!this[dn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[Ts](){if(this[cn]&&!this[Ya]&&!this[dn]&&!this[li]){this[Ya]=!0;let t=this[On];if(t&&t.blockRemain){let e=this[xe]?this[xe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[xe]&&t.write(this[xe]),t.end()}this[Pn](Cs)}}[As](t){if(this[li]&&t)this[Za](t);else if(!t&&!this[xe])this[Ts]();else if(t){if(this[li]=!0,this[xe]){this[Za](t);let e=this[xe];this[xe]=void 0,this[Is](e)}else this[Is](t);for(;this[xe]&&this[xe]?.length>=512&&!this[dn]&&!this[Ds];){let e=this[xe];this[xe]=void 0,this[Is](e)}this[li]=!1}(!this[xe]||this[cn])&&this[Ts]()}[Is](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ds];)switch(this[at]){case"begin":case"header":this[gf](t,e),e+=512;break;case"ignore":case"body":e+=this[Ja](t,e);break;case"meta":e+=this[pf](t,e);break;default:throw new Error("invalid state: "+this[at])}e<r&&(this[xe]=this[xe]?Buffer.concat([t.subarray(e),this[xe]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[dn]||(this[Te]?(t&&this[Te].write(t),this[Te].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ts]())),this}},_i=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},ew=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Xf=(t,e)=>{let r=new Map(e.map(c=>[_i(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||lm(c).root||".",x;if(c===f)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(dm(c),f)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(_i(c)):c=>o(_i(c))},tw=t=>{let e=new Ii(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),f=pr.readSync(i,l,0,o.size,0);e.end(f===l.byteLength?l:l.subarray(0,f))}else{let l=0,f=Buffer.allocUnsafe(c);for(;l<o.size;){let x=pr.readSync(i,f,0,c,l);if(x===0)break;l+=x,e.write(f.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},nw=(t,e)=>{let r=new Ii(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(f,x)=>{if(f)l(f);else{let h=new Cc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},_r=Ti(tw,nw,t=>new Ii(t),t=>new Ii(t),(t,e)=>{e?.length&&Xf(t,e),t.noResume||ew(t)}),Qf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:iw,parse:_f}=rw,Oc=t=>{let e="",r=_f(t);for(;iw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=_f(t)}return[e,t]},Xs=["|","<",">","?",":"],Pc=Xs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),sw=new Map(Xs.map((t,e)=>[t,Pc[e]])),ow=new Map(Pc.map((t,e)=>[t,Xs[e]])),yf=t=>Xs.reduce((e,r)=>e.split(r).join(sw.get(r)),t),aw=t=>Pc.reduce((e,r)=>e.split(r).join(ow.get(r)),t),e0=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),_i(e)+"/"+t):Z(t),cw=16*1024*1024,bf=Symbol("process"),Ef=Symbol("file"),vf=Symbol("directory"),fc=Symbol("symlink"),Sf=Symbol("hardlink"),fi=Symbol("header"),Ms=Symbol("read"),uc=Symbol("lstat"),Bs=Symbol("onlstat"),xc=Symbol("onread"),hc=Symbol("onreadlink"),pc=Symbol("openfile"),gc=Symbol("onopenfile"),hn=Symbol("close"),Ks=Symbol("mode"),mc=Symbol("awaitDrain"),Xa=Symbol("ondrain"),Rt=Symbol("prefix"),t0=class extends Un{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Rc(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||cw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Oc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=aw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||wf.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Bs](o):this[uc]()}warn(t,e,r={}){return Zs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[uc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Bs](e)})}[Bs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=fw(t),this.emit("stat",t),this[bf]()}[bf](){switch(this.type){case"File":return this[Ef]();case"Directory":return this[vf]();case"SymbolicLink":return this[fc]();default:return this.end()}}[Ks](t){return Qf(t,this.type==="Directory",this.portable)}[Rt](t){return e0(t,this.prefix)}[fi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new zn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this[Ks](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new js({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[vf](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[fi](),this.end()}[fc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hc](e)})}[hc](t){this.linkpath=Z(t),this[fi](),this.end()}[Sf](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(wf.relative(this.cwd,t)),this.stat.size=0,this[fi](),this.end()}[Ef](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Sf](e);this.linkCache.set(t,this.absolute)}if(this[fi](),this.stat.size===0)return this.end();this[pc]()}[pc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[gc](e)})}[gc](t){if(this.fd=t,this.#e)return this[hn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ms]()}[Ms](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,l)=>{if(c)return this[hn](()=>this.emit("error",c));this[xc](l)})}[hn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[xc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[hn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[hn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Xa]():this[mc](()=>this[Xa]())}[mc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Xa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[hn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ms]()}},dw=class extends t0{sync=!0;[uc](){this[Bs](Ct.lstatSync(this.absolute))}[fc](){this[hc](Ct.readlinkSync(this.absolute))}[pc](){this[gc](Ct.openSync(this.absolute,"r"))}[Ms](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Ct.readSync(e,r,i,o,c);this[xc](l),t=!1}finally{if(t)try{this[hn](()=>{})}catch{}}}[mc](t){t()}[hn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},lw=class extends Un{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Zs(this,t,e,r)}constructor(t,e={}){let r=Rc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ks](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=Oc(this.path);l&&typeof f=="string"&&(this.path=f,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new zn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new js({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Rt](t){return e0(t,this.prefix)}[Ks](t){return Qf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},fw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",uw=class gr{tail;head;length=0;static create(e=[]){return new gr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)hw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)pw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new gr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new gr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=xw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function xw(t,e,r){let i=e,o=e?e.next:t.head,c=new Nc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function hw(t,e){t.tail=new Nc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function pw(t,e){t.head=new Nc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Nc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},If=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Tf=Buffer.alloc(1024),Fs=Symbol("onStat"),ui=Symbol("ended"),pt=Symbol("queue"),xi=Symbol("queue"),ln=Symbol("current"),Ln=Symbol("process"),hi=Symbol("processing"),ks=Symbol("processJob"),gt=Symbol("jobs"),Qa=Symbol("jobDone"),zs=Symbol("addFSEntry"),Cf=Symbol("addTarEntry"),wc=Symbol("stat"),_c=Symbol("readdir"),Us=Symbol("onreaddir"),Gs=Symbol("pipe"),Rf=Symbol("entry"),ec=Symbol("entryOpt"),qs=Symbol("writeEntryClass"),n0=Symbol("write"),tc=Symbol("ondrain"),Qs=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[qs];onWriteEntry;[pt];[xi]=new Map;[gt]=0;[hi]=!1;[ui]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[qs]=t0,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new vm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Am(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Tm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[tc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[tc]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[pt]=new uw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[hi]=!1,this[ui]=!1}[n0](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[ui]=!0,this[Ln](),r&&r(),this}write(t){if(this[ui])throw new Error("write after end");return t instanceof Zf?this[Cf](t):this[zs](t),this.flowing}[Cf](t){let e=Z(Af.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new If(t.path,e);r.entry=new lw(t,this[ec](r)),r.entry.on("end",()=>this[Qa](r)),this[gt]+=1,this[pt].push(r)}this[Ln]()}[zs](t){let e=Z(Af.resolve(this.cwd,t));this[pt].push(new If(t,e)),this[Ln]()}[wc](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";Ws[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Fs](t,i)})}[Fs](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[ks](t);else{let r=`${e.dev}:${e.ino}`,i=this[xi].get(r);i?i.push(t):this[xi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[_c](t){t.pending=!0,this[gt]+=1,Ws.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Us](t,r)})}[Us](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[hi]){this[hi]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[ks](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[hi]=!1,this[ui]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(Tf):(super.write(Tf),super.end()))}}get[ln](){return this[pt]&&this[pt].head&&this[pt].head.value}[Qa](t){this[pt].shift(),this[gt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[xi].get(r);if(i){this[xi].delete(r);for(let o of i)o.pending=!1,this[ks](o)}}this[Ln]()}[ks](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[Gs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Fs](t,e):this[wc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Us](t,e):this[_c](t),!t.readdir)return}if(t.entry=this[Rf](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Gs](t)}}}[ec](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Rf](t){this[gt]+=1;try{return new this[qs](t.path,this[ec](t)).on("end",()=>this[Qa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[tc](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Gs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[zs](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Zs(this,t,e,r)}},Lc=class extends Qs{sync=!0;constructor(t){super(t),this[qs]=dw}pause(){}resume(){}[wc](t){let e=this.follow?"statSync":"lstatSync";this[Fs](t,Ws[e](t.absolute))}[_c](t){this[Us](t,Ws.readdirSync(t.absolute))}[Gs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[zs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[n0](i)})}},gw=(t,e)=>{let r=new Lc(t),i=new Hf(t.file,{mode:t.mode||438});r.pipe(i),r0(r,e)},mw=(t,e)=>{let r=new Qs(t),i=new Ys(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return i0(r,e).catch(c=>r.emit("error",c)),o},r0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:jf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},i0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:jf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},ww=(t,e)=>{let r=new Lc(t);return r0(r,e),r},_w=(t,e)=>{let r=new Qs(t);return i0(r,e).catch(i=>r.emit("error",i)),r},k2=Ti(gw,mw,ww,_w,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),bw=process.env.__FAKE_PLATFORM__||process.platform,c0=bw==="win32",{O_CREAT:d0,O_NOFOLLOW:Df,O_TRUNC:l0,O_WRONLY:f0}=a0.constants,u0=Number(process.env.__FAKE_FS_O_FILENAME__)||a0.constants.UV_FS_O_FILEMAP||0,Ew=c0&&!!u0,vw=512*1024,Sw=u0|l0|d0|f0,kf=!c0&&typeof Df=="number"?Df|l0|d0|f0:null,x0=kf!==null?()=>kf:Ew?t=>t<vw?Sw:"w":()=>"w",yc=(t,e,r)=>{try{return eo.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},$s=(t,e,r,i)=>{eo.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Aw=(t,e,r,i,o)=>{if(e.isDirectory())h0(yi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=yi.resolve(t,e.name);$s(l,r,i,o)});else{let c=yi.resolve(t,e.name);$s(c,r,i,o)}},h0=(t,e,r,i)=>{eo.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return $s(t,e,r,i);let l=c.length,f=null,x=h=>{if(!f){if(h)return i(f=h);if(--l===0)return $s(t,e,r,i)}};for(let h of c)Aw(t,h,e,r,x)})},Iw=(t,e,r,i)=>{e.isDirectory()&&p0(yi.resolve(t,e.name),r,i),yc(yi.resolve(t,e.name),r,i)},p0=(t,e,r)=>{let i;try{i=eo.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return yc(t,e,r);throw c}for(let o of i)Iw(t,o,e,r);return yc(t,e,r)},g0=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},to=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Cw=(t,e)=>{it.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new g0(t,r?.code||"ENOTDIR")),e(r)})},Rw=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,f=e.gid,x=typeof l=="number"&&typeof f=="number"&&(l!==e.processUid||f!==e.processGid),h=e.preserve,_=e.unlink,w=Z(e.cwd),S=(v,I)=>{v?r(v):I&&x?h0(I,l,f,A=>S(A)):c?it.chmod(t,o,r):r()};if(t===w)return Cw(t,S);if(h)return Tw.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let b=Z(Vs.relative(w,t)).split("/");bc(w,b,o,_,w,void 0,S)},bc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),x=Z(Vs.resolve(t+"/"+f));it.mkdir(x,r,m0(x,e,r,i,o,c,l))},m0=(t,e,r,i,o,c,l)=>f=>{f?it.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),l(x);else if(h.isDirectory())bc(t,e,r,i,o,c,l);else if(i)it.unlink(t,_=>{if(_)return l(_);it.mkdir(t,r,m0(t,e,r,i,o,c,l))});else{if(h.isSymbolicLink())return l(new to(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,bc(t,e,r,i,o,c,l))},Dw=t=>{let e=!1,r;try{e=it.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new g0(t,r??"ENOTDIR")}},kw=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,f=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),x=e.preserve,h=e.unlink,_=Z(e.cwd),w=v=>{v&&f&&p0(v,c,l),o&&it.chmodSync(t,i)};if(t===_)return Dw(_),w();if(x)return w(it.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Z(Vs.relative(_,t)).split("/"),b;for(let v=S.shift(),I=_;v&&(I+="/"+v);v=S.shift()){I=Z(Vs.resolve(I));try{it.mkdirSync(I,i),b=b||I}catch{let A=it.lstatSync(I);if(A.isDirectory())continue;if(h){it.unlinkSync(I),it.mkdirSync(I,i),b=b||I;continue}else if(A.isSymbolicLink())return new to(I,I+"/"+S.join("/"))}}return w(b)},nc=Object.create(null),Of=1e4,lr=new Set,Ow=t=>{lr.has(t)?lr.delete(t):nc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=nc[t],r=lr.size-Of;if(r>Of/10){for(let i of lr)if(lr.delete(i),delete nc[i],--r<=0)break}return e},Pw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Nw=Pw==="win32",Lw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=w0(i,r)),e.push(r||"/"),e},[]),Mw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Nw?["win32 parallelization disabled"]:t.map(i=>_i(w0(Ow(i))));let r=new Set(t.map(i=>Lw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let f=l[1];if(!f){this.#e.delete(c);continue}if(l.shift(),typeof f=="function")o.add(f);else for(let x of f)o.add(x)}for(let c of i){let l=this.#e.get(c),f=l?.[0];if(!(!l||!(f instanceof Set)))if(f.size===1&&l.length===1){this.#e.delete(c);continue}else if(f.size===1){l.shift();let x=l[0];typeof x=="function"&&o.add(x)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Bw=()=>process.umask(),Pf=Symbol("onEntry"),Ec=Symbol("checkFs"),Nf=Symbol("checkFs2"),vc=Symbol("isReusable"),ct=Symbol("makeFs"),Sc=Symbol("file"),Ac=Symbol("directory"),Hs=Symbol("link"),Lf=Symbol("symlink"),Mf=Symbol("hardlink"),mi=Symbol("ensureNoSymlink"),Bf=Symbol("unsupported"),Ff=Symbol("checkPath"),rc=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),ze=Symbol("onError"),Os=Symbol("pending"),zf=Symbol("pend"),fr=Symbol("unpend"),ic=Symbol("ended"),sc=Symbol("maybeClose"),Ic=Symbol("skip"),bi=Symbol("doChown"),Ei=Symbol("uid"),vi=Symbol("gid"),Si=Symbol("checkedCwd"),Fw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ai=Fw==="win32",zw=1024,Uw=(t,e)=>{if(!Ai)return re.unlink(t,e);let r=t+".DELETE."+o0(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Gw=t=>{if(!Ai)return re.unlinkSync(t);let e=t+".DELETE."+o0(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},Uf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Mc=class extends Ii{[ic]=!1;[Si]=!1;[Os]=0;reservations=new Mw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[ic]=!0,this[sc]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:zw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ai,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Pe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Bw():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Pf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[sc](){this[ic]&&this[Os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[rc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Oc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ai&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let f=Pe.posix.dirname(t.path),x=Pe.posix.normalize(Pe.posix.join(f,l.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Ff](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[rc](t,"path")||!this[rc](t,"linkpath"))return!1;if(t.absolute=Pe.isAbsolute(t.path)?Z(Pe.resolve(t.path)):Z(Pe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Pe.win32.parse(String(t.absolute));t.absolute=i+yf(String(t.absolute).slice(i.length));let{root:o}=Pe.win32.parse(t.path);t.path=o+yf(t.path.slice(o.length))}return!0}[Pf](t){if(!this[Ff](t))return t.resume();switch(yw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ec](t);default:return this[Bf](t)}}[ze](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[fr](),e.resume())}[pn](t,e,r){Rw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[bi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ei](t){return Uf(this.uid,t.uid,this.processUid)}[vi](t){return Uf(this.gid,t.gid,this.processGid)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ys(String(t.absolute),{flags:x0(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[ze](f,t),e()});let o=1,c=f=>{if(f){i.fd&&re.close(i.fd,()=>{}),this[ze](f,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[ze](x,t):this[fr](),e()})};i.on("finish",()=>{let f=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let h=t.atime||new Date,_=t.mtime;re.futimes(x,h,_,w=>w?re.utimes(f,h,_,S=>c(S&&w)):c())}if(typeof x=="number"&&this[bi](t)){o++;let h=this[Ei](t),_=this[vi](t);typeof h=="number"&&typeof _=="number"&&re.fchown(x,h,_,w=>w?re.chown(f,h,_,S=>c(S&&w)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[ze](f,t),e()}),t.pipe(l)),l.pipe(i)}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[ze](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[fr](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[bi](t)&&(o++,re.chown(String(t.absolute),Number(this[Ei](t)),Number(this[vi](t)),c)),c()})}[Bf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Lf](t,e){let r=Z(Pe.relative(this.cwd,Pe.resolve(Pe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[mi](t,this.cwd,r,()=>this[Hs](t,String(t.linkpath),"symlink",e),i=>{this[ze](i,t),e()})}[Mf](t,e){let r=Z(Pe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[mi](t,this.cwd,i,()=>this[Hs](t,r,"link",e),o=>{this[ze](o,t),e()})}[mi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Pe.resolve(e,c);re.lstat(l,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new to(l,Pe.resolve(l,r.join("/"))));this[mi](t,l,r,i,o)})}[zf](){this[Os]++}[fr](){this[Os]--,this[sc]()}[Ic](t){this[fr](),t.resume()}[vc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ai}[Ec](t){this[zf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Nf](t,r))}[Nf](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[ze](l,t),r();return}this[Si]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Pe.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,f=>{if(f){this[ze](f,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[Ic](t),r();return}if(l||this[vc](t,f))return this[ct](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,h=_=>this[ct](_??null,t,r);return x?re.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),x=>this[ct](x??null,t,r))}if(t.absolute===this.cwd)return this[ct](null,t,r);Uw(String(t.absolute),x=>this[ct](x??null,t,r))})};this[Si]?o():i()}[ct](t,e,r){if(t){this[ze](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Sc](e,r);case"Link":return this[Mf](e,r);case"SymbolicLink":return this[Lf](e,r);case"Directory":case"GNUDumpDir":return this[Ac](e,r)}}[Hs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[ze](o,t):(this[fr](),t.resume()),i()})}},pi=t=>{try{return[null,t()]}catch(e){return[e,null]}},_0=class extends Mc{sync=!0;[ct](t,e){return super[ct](t,e,()=>{})}[Ec](t){if(!this[Si]){let o=this[pn](this.cwd,this.dmode);if(o)return this[ze](o,t);this[Si]=!0}if(t.absolute!==this.cwd){let o=Z(Pe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[ze](c,t)}}let[e,r]=pi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ic](t);if(e||this[vc](t,r))return this[ct](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?pi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ct](l,t)}let[o]=pi(()=>re.rmdirSync(String(t.absolute)));this[ct](o,t)}let[i]=t.absolute===this.cwd?[]:pi(()=>Gw(String(t.absolute)));this[ct](i,t)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{re.closeSync(o)}catch(x){f=x}(l||f)&&this[ze](l||f,t),e()},o;try{o=re.openSync(String(t.absolute),x0(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[ze](l,t)),t.pipe(c)),c.on("data",l=>{try{re.writeSync(o,l,0,l.length)}catch(f){i(f)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let f=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,f,x)}catch(h){try{re.utimesSync(String(t.absolute),f,x)}catch{l=h}}}if(this[bi](t)){let f=this[Ei](t),x=this[vi](t);try{re.fchownSync(o,Number(f),Number(x))}catch(h){try{re.chownSync(String(t.absolute),Number(f),Number(x))}catch{l=l||h}}}i(l)})}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[ze](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[bi](t))try{re.chownSync(String(t.absolute),Number(this[Ei](t)),Number(this[vi](t)))}catch{}e(),t.resume()}[pn](t,e){try{return kw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[mi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Pe.resolve(c,l);let[f,x]=pi(()=>re.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new to(c,Pe.resolve(e,r.join("/"))))}i()}[Hs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ze](c,t)}}},qw=t=>{let e=new _0(t),r=t.file,i=s0.statSync(r),o=t.maxReadSize||16*1024*1024;new cm(r,{readSize:o,size:i.size}).pipe(e)},Hw=(t,e)=>{let r=new Mc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),s0.stat(o,(f,x)=>{if(f)l(f);else{let h=new Cc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},y0=Ti(qw,Hw,t=>new _0(t),t=>new Mc(t),(t,e)=>{e?.length&&Xf(t,e)}),jw=(t,e)=>{let r=new Lc(t),i=!0,o,c;try{try{o=rt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=rt.openSync(t.file,"w+");else throw x}let l=rt.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let _=0,w=0;_<512;_+=w){if(w=rt.readSync(o,f,_,f.length-_,c+_),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!w)break e}let x=new zn(f);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>l.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Ww(t,r,c,o,e)}finally{if(i)try{rt.closeSync(o)}catch{}}},Ww=(t,e,r,i,o)=>{let c=new Hf(t.file,{fd:i,start:r});e.pipe(c),$w(e,o)},Kw=(t,e)=>{e=Array.from(e);let r=new Qs(t),i=(o,c,l)=>{let f=(S,b)=>{S?rt.close(o,v=>l(S)):l(null,b)},x=0;if(c===0)return f(null,0);let h=0,_=Buffer.alloc(512),w=(S,b)=>{if(S||b===void 0)return f(S);if(h+=b,h<512&&b)return rt.read(o,_,h,_.length-h,x+h,w);if(x===0&&_[0]===31&&_[1]===139)return f(new Error("cannot append to compressed archives"));if(h<512)return f(null,x);let v=new zn(_);if(!v.cksumValid)return f(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return f(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),h=0,rt.read(o,_,0,512,x,w)};rt.read(o,_,0,512,x,w)};return new Promise((o,c)=>{r.on("error",c);let l="r+",f=(x,h)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",rt.open(t.file,l,f);if(x||!h)return c(x);rt.fstat(h,(_,w)=>{if(_)return rt.close(h,()=>c(_));i(h,w.size,(S,b)=>{if(S)return c(S);let v=new Ys(t.file,{fd:h,start:b});r.pipe(v),v.on("error",c),v.on("close",o),Vw(r,e)})})};rt.open(t.file,l,f)})},$w=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:b0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Vw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:b0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},gi=Ti(jw,Kw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!gm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),K2=Ti(gi.syncFile,gi.asyncFile,gi.syncNoFile,gi.asyncNoFile,(t,e=[])=>{gi.validate?.(t,e),Yw(t)}),Yw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var _t={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Ci(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function E0(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Bc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function v0(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function yr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ke();ne();ke();Ke();function Wt(t,e){if(Ci(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function no(t){return t.startsWith("http://")||t.startsWith("https://")}function ro(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();ne();var io="1008033",S0="1289";var A0="pbbp2",I0="https://www.coze.cn",T0="/api/coze_claw/resource/get_frontier_key",Zw="https://www.coze.cn",Xw="wss://frontier.coze.cn";function so(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Zw}function C0(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Xw}function br(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Di(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ri=j("handshake");async function Fc(t){let e=so(t.endpoint),r=t.timeoutMs??1e4,i=`${ro(e)}${T0}?aid=${encodeURIComponent(io)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...br(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ri.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=f.headers.get("x-tt-logid")??"",h=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let v=await f.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${v.slice(0,200)}`)}let _=await f.json();if(_.code!==void 0&&_.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${x}`);let w=_.data??{},S=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,b=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!S||!b){let v=JSON.stringify(_).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ri.info("handshake ok",{remoteDeviceId:b,logid:x,traceId:h}),{accessKey:S,deviceId:b}}catch(f){if(f instanceof T)throw Ri.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw Ri.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:f});let x=f.cause;throw Ri.error("handshake error",{base:e,message:f instanceof Error?f.message:String(f),errno:x?.code,syscall:x?.syscall,cause:String(f).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(l)}}var zc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",R0=15e4;function D0(t){return{model:Uc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function k0(t){return!t||t===yt}var Qw=new Set(["auto","\u81EA\u52A8"]);function Uc(t){let e=t?.trim();if(e)return Qw.has(e.toLowerCase())?yt:e}function O0(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=zc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||yt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else k0(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function P0(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):k0(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${zc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??R0;e.push("-c",`model_context_window=${r}`)}return e}function N0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Gc(t,e){let{ttEnv:r,usePpe:i}=Di(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function L0(t,e,r){if(!t.modelToken)return{};let i=Gc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function qc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function M0(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=Gc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${zc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??R0,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function B0(t,e,r){if(!t.modelToken)return[];let i=Gc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Ne=j("agent-handlers"),F0=5*1024*1024,s_=1,o_=6,a_=new Set(["node_modules",".git",".coze","dist","build",".next"]),oo=class{constructor(e){this.opts=e}opts;async listSkills(e){Wt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ze(r).workspace,c=i?.skills??[],l=[];for(let f of c){let x=kt(o,f.relPath,"SKILL.md");await n_(x).then(_=>_.isFile()).catch(()=>!1)&&l.push(u_(f))}return{skills:l}}async addSkills(e){Wt(e._meta,"_agent/addSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,h)=>[x.skillId,h])),f=[];for(let x of o){let h=await Yc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Jc(c,l,h),f.push(x)}return await fs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Wt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let f of c){if(!o.has(f.skillId)){l.push(f);continue}let x=kt(i.workspace,f.relPath);await t_(x,{recursive:!0,force:!0}),Ne.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await fs(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ne.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Ne.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(h=>Ne.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Ne.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await He(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ne.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ne.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Xe(i),Ne.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Xe(i),Ne.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Ne.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Wt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Uc(e.model)??yt,i=await He(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Xe(i),Ne.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ne.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Ne.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Ne.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Wt(e._meta,_t.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,_t.RESET),await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ne.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ti(e,o)}async clearPersistedAcpSessionIds(e){let r=await He(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Xe(r)}async repairAgent(e){if(Wt(e._meta,_t.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${_t.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Ne.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,_t.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ne.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ne.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Wt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),f=await Hc(l).catch(()=>null);if(!f)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(f.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ei(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=v_(e.depth);return f.isDirectory()?{tree:await E_(o,l,c,x)}:{tree:[{name:S_(c),path:W0(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Wt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Hc(o).catch(()=>null);if(!c||!c.isFile())throw new T("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ei(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>F0)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${F0})`);let l=await z0(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??Ze(e).workspace}safeJoin(e,r){let i=Kc(e,r||"."),o=Vc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${U0}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return He(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function c_(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function d_(t){return t==="claude-code"?kt(".claude","skills"):kt(".agents","skills")}var l_=3e4,f_=50*1024*1024,Er=3e4;async function Yc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=c_(o.skillName),x=d_(i),h=kt(x,f),_=kt(r,h);if(await jc(_,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");ki(S.length),await Wc(kt(_,"SKILL.md"),S,"utf8")}else{let S=await x_(o.downloadUrl);p_(S)?await __(S,_):g_(S)?await m_(S,_):await Wc(kt(_,"SKILL.md"),S.toString("utf8"),"utf8")}let w={skillId:o.skillId,skillName:o.skillName,relPath:h,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Ne.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:h,source:c?"content":"downloadUrl"}),w}function Jc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function u_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function x_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ki(e);let r=h_(t);return ki(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await z0(e);return ki(r.length),r}if(no(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),l_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return ki(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ki(t){if(t>f_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function h_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function p_(t){return t.length>=2&&t[0]===31&&t[1]===139}function g_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function $c(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function m_(t,e){let r,i;try{r=new H0.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let f=l.entryName;if(!f||$c(f))continue;if(f.startsWith("/")||/^[A-Za-z]:[\\/]/.test(f))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${f}`);if(f.split(/[/\\]/).some(h=>h===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${f}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${f}`)}let o=w_(i),c=Kc(e);for(let l of i){if($c(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=Kc(e,f),h=Vc(c,x);if(h.startsWith("..")||h==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await jc(x,{recursive:!0});continue}await jc(r_(x),{recursive:!0});let _;try{_=l.getData()}catch(w){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${w.message}`,{cause:w})}await Wc(x,_)}}function w_(t){let e;for(let r of t){let i=r.entryName;if(!i||$c(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function __(t,e){await y_(t);let r=y0({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`))},Er);try{await q0(G0.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function y_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`))},Er);try{await q0(G0.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var b_=5e3;async function E_(t,e,r,i){return j0(t,e,r,i,{count:0})}async function j0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await e_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(a_.has(f.name)||f.isSymbolicLink())continue;if(o.count>=b_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=kt(e,f.name),h=i_(kt(r,f.name)),_=null;try{_=await Hc(x)}catch{continue}if(_.isSymbolicLink())continue;o.count++;let w={name:f.name,path:W0(Vc(t,x)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&i>1&&(w.children=await j0(t,x,h,i-1,o)),l.push(w)}return l.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),l}function v_(t){return!t||t<=0?s_:Math.min(t,o_)}function S_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function W0(t){return t.split(U0).join("/")}ne();import{readFileSync as nI}from"node:fs";import{dirname as iI,join as sI}from"node:path";import{fileURLToPath as aI}from"node:url";var vr="0.1.99";var wn=j("agent-health-reporter"),A_=1e4,Oi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??A_}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),wn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),wn.info("heartbeat stopped"))}async tick(){if(this.inFlight){wn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){wn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let f=I_(l);if(!f)continue;let x={agentId:l.agentId,status:f};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){wn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(wn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){wn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){wn.warn("onTickEnd hook failed",{err:String(r)})}}};function I_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as Ey,mkdir as wo,rm as vy,stat as Sy,writeFile as Ay}from"node:fs/promises";import{homedir as Iy}from"node:os";import{join as wu}from"node:path";nn();import{existsSync as j_}from"node:fs";import{release as W_}from"node:os";import{basename as K_,isAbsolute as $_}from"node:path";function Pi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ar(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var ao=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ee={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function K0(t){return"method"in t&&"id"in t&&t.id!==void 0}function $0(t){return"method"in t&&!("id"in t)}function co(t){return!("method"in t)&&"id"in t}var T_={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ee.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ee.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ee.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ee.AGENT_ENV_NOT_READY};function C_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ni(t.message)}:typeof t=="string"?Ni(t):typeof t=="object"?D_(t):t}var R_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Ni(t){let e=t;for(let[r,i]of R_)e=e.replace(r,i);return e}function D_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ni(i):e[r]=i;return e}function Li(t){if(t instanceof T){let e=C_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:T_[t.code]??ee.INTERNAL_ERROR,message:Ni(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:Ni(t instanceof Error?t.message:String(t))}}function V0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...f}=e;c=f}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function J0(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var Y0=10*1024*1024,lo=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>Y0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${Y0} bytes`)}),[]}let r=this.buffer.split(`
|
|
94
|
+
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var X0={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},wI=Object.fromEntries(Object.entries(X0).map(([t,e])=>[e,t])),k_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ir=class{seq=0;next(e,r){this.seq+=1;let i=X0[e]??O_(e),o=k_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>Z0(r?.[x]??"")),f=P_(l).join(":");f&&c.push(f)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>Z0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function O_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Z0(t){return t.replace(/[:_\s]+/g,"-")}function P_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Qr();import{readFileSync as N_}from"node:fs";var L_=384;async function Zc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:L_})}function Xc(t){try{let e=JSON.parse(N_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Q0(t,e,r={},i=o=>o){return{...i({...t,...Xc(e)}),...r}}yn();$r();Ke();ne();ke();import{spawnSync as q_}from"node:child_process";function fo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function uo(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),q_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Qc=new Set;function ru(t){typeof t=="number"&&t>0&&Qc.add(t)}function iu(t){typeof t=="number"&&Qc.delete(t)}function su(){for(let t of Qc)uo(t,"SIGKILL")}var H_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function ou(t,e){if(!e)return null;for(let r of H_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function au(t,e){return ou(t,e)}function cu(t,e){return ou(t,e)}function Tr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function du(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let h=t.suspendedMs+o,_=r-t.startedAt-h;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Tr(_,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Tr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Tr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Tr(c,!1,e)}}var lu=Je("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),V_=200,Y_=40,J_=Je("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Z_=Je("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),X_=Je("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),Q_=Je("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),ey=Je("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),ty=Je("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),fu=500;function ny(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=fu?t:`${e.slice(0,fu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ry(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function uu(t){try{return j_(t)}catch{return}}function iy(t,e){return{platform:process.platform,osRelease:W_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:$_(e.command)?uu(e.command):void 0,cwd:e.cwd,cwdExists:uu(e.cwd),envKeys:e.envKeys}}function sy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${K_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Ot=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new lo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ir;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Q0(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=dt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,ru(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>V_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,iu(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(this.buildExitError(o,c));for(let f of this.exitHandlers)f(o,c)}),i.on("error",o=>{let c=o,l=iy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",sy(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));uo(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||uo(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:ey,phase2GateMs:J_,livenessWindowMs:Z_,absoluteMaxMs:X_,approvalMaxMs:ty,suspendThresholdMs:Q_,...r};return this.call("session/prompt",e,lu,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ar(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_n(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=lu,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Pi(c,e,r),f=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,h)=>{let _={resolve:x,reject:h,timer:null,method:e,promptTimeout:null};if(o){let w=this.now(),S={cfg:o,startedAt:w,lastActivityAt:w,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:w,expectedIntervalMs:Tr(0,!1,o),sessionId:f};_.promptTimeout=S;let b=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},I=this.now(),A=du(v,S.cfg,I),C=P=>{S.armedAt=I,S.expectedIntervalMs=P,_.timer=setTimeout(b,P)};if(A.action==="suspend"){S.suspendedMs+=A.suspendedDeltaMs,S.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),C(A.rearmMs);return}if(A.action==="continue"){C(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),h(A.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),h(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};_.timer=setTimeout(b,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(_.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),h(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,_);try{this.writeFrame(l)}catch(w){_.timer&&clearTimeout(_.timer),this.pending.delete(c),h(w)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(J0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(co(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:ny(e.result)}),r.resolve(e.result));return}if($0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(K0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,f=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!f?e.activeToolCalls.add(c):f&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_n(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(_n(e.id,Li(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=V0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=cu(this.framework,ry(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(Y_).join(`
|
|
95
|
+
`),o=au(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function oy(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var xo=class extends Ot{framework="claude-code";constructor(e){let{command:r,args:i}=Xr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return oy(e)}};nn();import{mkdtempSync as ay,rmSync as cy}from"node:fs";import{tmpdir as dy}from"node:os";import{join as ly}from"node:path";var ho=class extends Ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Xr("codex",e.command,i),l=e.isolateCodexHome?ay(ly(dy(),"coze-bridge-codex-home-")):void 0,f=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...f?{env:f}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{cy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var fy=3e4,Cr=class extends Ot{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},fy))}get acpSessionName(){return this.sessionName}};Ke();ne();ke();function ed(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();var bn=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var po=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new bn,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Mi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();ne();import{constants as xu}from"node:fs";import{access as uy}from"node:fs/promises";import{delimiter as xy,join as hy}from"node:path";var bt=j("framework-detector"),hu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},py=[".exe",".cmd",".bat",".ps1"],Gn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??dt,access:e.access??uy}}async detect(e){let r=hu[e],i=await this.which(r);if(!i)return bt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return l&&(f.defaultAgent=l),f}async detectAll(){let e=await Promise.all(Object.keys(hu).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(xy).filter(Boolean),i=this.env.platform==="win32"?["",...py]:[""];for(let o of r)for(let c of i){let l=hy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?xu.F_OK:xu.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return bt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return bt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return bt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return bt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(bt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(bt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return bt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return bt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||bt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){bt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(my(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,f=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),f(null)},15e3),x.stdout?.on("data",h=>{o+=h.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",h=>f({code:h,stdout:o}))}catch{f(null)}})}},gy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function my(t){return t.replace(gy,"")}import{homedir as wy}from"node:os";import{join as _y}from"node:path";yn();$r();Ke();Qr();ne();async function mu(){let t=_y(wy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var pu=j("openclaw.config"),yy=[0,5e3,5e3],by=Je("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),gu="models.providers.",go="agents.defaults.models",mo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new bn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??yy,this.cliTimeoutMs=e.cliTimeoutMs??by}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,pu.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=dt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,f=h=>{l||(l=!0,clearTimeout(x),h())};o.stderr?.on("data",h=>{c+=h.toString("utf8")});let x=setTimeout(()=>{f(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",h=>f(()=>i(h))),o.on("close",h=>f(()=>{h===0?r():i(new Error(`exit ${h}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){pu.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${gu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${gu}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${go}[${e}]`,()=>this.runCli(["config","set",go,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${go}[${e}]`,`${go}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var pe=j("agent-manager"),Ty=(t,e,r,i,o,c,l,f,x)=>{switch(t){case"claude-code":{let h={...o?{...O0(o),...L0(o,l,f)}:{},...x??{},IS_SANDBOX:"1"};return new xo({cwd:r,env:h,agentId:i})}case"codex":{let _=[...o?[...P0(o),...B0(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],w={...o?N0(o):{},...x??{}},S=!!o;return new ho({cwd:r,agentId:i,..._.length>0?{extraArgs:_}:{},...Object.keys(w).length>0?{env:w}:{},...S?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Cr({command:e,cwd:r,agentId:i,...c?{sessionName:ed(c)}:{}})}};function td(t){return t==="claude-code"||t==="codex"}function Cy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(Ry(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
97
96
|
`)}
|
|
98
|
-
`}function
|
|
99
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var Cy={path:"",version:"cloud-deployed"},hf="openclaw_gateway_unavailable",Dy="openclaw_default_agent_missing";function pf(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 Ry={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},ky=6e4,go=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Iy,this.createTimeoutMs=e.createTimeoutMs??ky,this.detectorFactory=e.detectorFactory??(()=>new Un),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new ho({command:r})),this.openclawConfigDir=e.openclawConfigDir??Qc(Sy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{ge.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=Qc(e,".env");if(await Ey(r).then(c=>c.isFile()).catch(()=>!1)){ge.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await po(e,{recursive:!0});let o=Ay({...process.env,...Yc(this.paths.agentEnvFile)});if(await vy(r,o,"utf8"),process.platform!=="win32")try{await yy(r,384)}catch(c){ge.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}ge.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),ge.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let i=Ti(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")ge.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>ge.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){ge.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await je(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Ze(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){ge.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await je(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Ze(S,this.paths))}return ge.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let u=$e(e.agentId,this.paths),f=Ti(e._meta),x=e.framework==="openclaw"&&f==="local",p;x&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let b=p??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),E=e.workspace??b??u.workspace,T=new AbortController,y=setTimeout(()=>T.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&ed(e.framework)&&await nr(e.framework,T.signal);let S=()=>{if(T.signal.aborted)throw T.signal.reason instanceof Error?T.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await po(u.root,{recursive:!0}),await po(E,{recursive:!0}),await po(u.logs,{recursive:!0}),S(),x||await sr(E,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await I0(E),S();let D=await je(e.agentId,this.paths).catch(()=>null),P=Cl({model:e.model??D?.model}),_=yl(e._meta)??D?.accountId,R=e.patToken??D?.patToken,k=f==="cloud"?e.modelInfo??D?.modelInfo:void 0;if(v=new fo({agentId:e.agentId,framework:e.framework,workspace:E,model:P.model??yt,deployType:f,..._?{accountId:_}:{},...R?{patToken:R}:{},...k?{modelInfo:k}:{}}),v.status="ok",D?.sessions){for(let[J,te]of Object.entries(D.sessions))v.sessions.set(J,{acpSessionId:te.acpSessionId,modelToken:te.modelToken,tokenGeneratedAt:te.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let V=Object.keys(D.sessions).length;V>0&&ge.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:V})}this.registry.register(v),I=!0;let B={agentId:e.agentId,framework:e.framework,workspace:E,cozeIdentity:e.cozeIdentity,createdAt:D?.createdAt??Date.now(),sessions:D?.sessions??{},model:P.model};f==="cloud"&&(B.deployType="cloud"),_&&(B.accountId=_),R&&(B.patToken=R),k&&(B.modelInfo=k),D?.skills&&(B.skills=D.skills),D?.agentName&&(B.agentName=D.agentName),D?.description&&(B.description=D.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,E)):ge.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let F=e.initialSkills??[];if(F.length>0){let V=[...B.skills??[]],J=new Map(V.map((Ee,he)=>[Ee.skillId,he])),te=await Promise.allSettled(F.map(Ee=>$c({agentId:e.agentId,workspace:E,framework:e.framework,skill:Ee}))),Q=0;for(let[Ee,he]of te.entries()){let O=F[Ee];O&&(he.status==="fulfilled"?(Vc(V,J,he.value),Q++):ge.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(he.reason)}))}Q>0&&(B.skills=V,ge.info("initialSkills installed",{agentId:e.agentId,installed:Q,requested:F.length}))}return await Ze(B,this.paths),ge.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:E,framework:e.framework}}catch(S){throw ge.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await by(u.root,{recursive:!0,force:!0}).catch(D=>ge.warn("rm agent dir failed (ignored)",{err:String(D)})),S instanceof C?S:new C("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&ed(e.framework))f=Cy;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);ed(e.framework)&&!os(e.framework)&&(ge.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await nr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:f.path}):p=this.factory(e.framework,f.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),e.framework==="codex"&&e.deployType==="cloud"?Qc($e(e.agentId,this.paths).root,"codex-home"):void 0);try{return await p.start(),await p.initialize(Ry),p}catch(b){let E=p instanceof Ot?p.getStderrTail():[];throw E.length>0&&ge.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:b instanceof C?b.code:"unknown",recentStderr:E}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,f.path,b)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new C("AGENT_ENV_NOT_READY",pf(o),{cause:{reason:hf}})}catch(o){ge.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof C?new C(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new C("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};ge.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 ge.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new C("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:Dy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new C("AGENT_ENV_NOT_READY",pf(r),{cause:{reason:hf}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:u,command:f}=e,x=Xc(o);if(r.deployType==="local"){let T=await this.ensureOpenclawDefaultAgent();return new Dr({command:f,cwd:T.workspace,agentId:T.id,sessionName:x})}let p=await xf(),b=i?Pl(i,c,u):null,E;if(b){let T=Uc(o),v=b.models[0]?.id??yt,I=`${T}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(T,b),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}E=I}return new Dr({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Uc(i),c=`${o}/${e.model}`,u=!0;try{await r.removeProvider(o)}catch(f){u=!1,ge.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){u=!1,ge.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}u&&this.ensuredProviders.delete(c)}}};import{randomUUID as yf}from"node:crypto";import{promises as zy}from"node:fs";import{basename as bf}from"node:path";We();ne();import{promises as Ny}from"node:fs";import{basename as Py}from"node:path";var gf=H("file-upload"),Ly="/api/coze_claw/file/agent_upload",My=6e4;async function mf(t,e={}){let i=`${to(ro(e.handshakeBase))}${Ly}`,o=e.timeoutMs??My,c=await Ny.readFile(t.path),u=new FormData;u.append("agent_id",t.agentId),u.append("session_id",t.sessionId),u.append("file_name",t.name),u.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...vr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);gf.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let b=await fetch(i,{method:"POST",headers:f,body:u,signal:x.signal}),E=b.headers.get("x-tt-logid")??"";if(!b.ok){let v=await b.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${b.status} logid=${E}: ${v.slice(0,200)}`)}let T=await b.json();if(T.code!==void 0&&T.code!==0)throw new C("UPLOAD_FAILED",`upload code=${T.code} msg=${T.msg??"-"} logid=${E}`);let y=T.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(T).slice(0,200)}`);return gf.info("file upload ok",{uri:y,logid:E}),{uri:y}}catch(b){throw b instanceof C?b:b.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Py(t.path)}`):new C("UPLOAD_FAILED",String(b),{cause:b})}finally{clearTimeout(p)}}We();ne();import{extname as By}from"node:path";var Fy={".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 wf(t){let e=By(t).toLowerCase();return Fy[e]??"application/octet-stream"}Oe();var mo=H("agent-send"),_f=50*1024*1024;function Ef(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function vf(t,e,r,i,o,c){let f;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){f=p,x<2&&(mo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(b=>setTimeout(b,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function Sf(t,e){let{session:r,runtime:i}=Ef(e.core,t.agentId,t.sessionId);if(!await Qr(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await zy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>_f)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${_f}`);let c=await wf(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let u=t.name??bf(t.path),f;try{f=await mf({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:u,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw mo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof C?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:yf(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:u,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await vf(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),mo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:u,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function If(t,e){let{session:r,runtime:i}=Ef(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??bf(t.path),c={sessionUpdate:"group_file",messageId:yf(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await vf(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),mo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Af(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 u=r[c]??0,f=i[c]??0;if(u<f)return!0;if(u>f)return!1}return!1}tn();_n();ne();var Nt=H("coze-cli-installer"),Tf="@coze/cli@latest",Uy="coze",Cf="0.1.8",Hy=5e3,qy=5e3,jy=9e4,Df=1e4,Mi=null,wo=!1;async function td(t,e={}){if(wo)return;if(Mi)return Mi;let r=e.exec??ef;return Mi=(async()=>{try{let i=await Gy(Uy,r),o=!1;if(i){let u=await Ky(r);if(u===void 0)Nt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Af(u,Cf))Nt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:u,min:Cf}),o=!0;else{Nt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:u}),wo=!0;return}}let c=o?"upgrade-only":"full";Nt.info("coze-cli install start",{package:Tf,mode:c});try{await r("npm",["i","-g","--prefer-online",Tf],{timeout:jy,maxBuffer:10*1024*1024}),Nt.info("coze-cli install ok")}catch(u){Nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(o){wo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Df}),Nt.info("coze config set xTTEnv ok",{env:t.env})}catch(u){Nt.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Df}),Nt.info("coze auth login ok")}catch(u){Nt.warn("coze auth login failed",{err:String(u)});return}wo=!0}finally{Mi=null}})(),Mi}async function Gy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Hy});return Ia(i)}catch{return}}async function Ky(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:qy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Xr();Oe();var Wy=10*6e4;function Rf(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Wy:e}function _o(t){return rr(t??X().configFile)}function Bi(t,e){return ir(e??X().configFile,t)}import{randomBytes as fb}from"node:crypto";es();We();ne();import{createReadStream as $y}from"node:fs";import{mkdir as Vy,readFile as Jy,realpath as Yy,stat as Zy,writeFile as Xy}from"node:fs/promises";import{basename as Qy,dirname as nd,isAbsolute as eb,join as tb,relative as nb,resolve as kf,sep as rb}from"node:path";import{createInterface as ib}from"node:readline";var Nf=H("fs-rpc"),Fi=Ft("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Pf(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Fi)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Fi} bytes`);let i=await Mf(t.path,e);return await Vy(nd(i),{recursive:!0}),await Xy(i,t.content,"utf8"),Nf.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Lf(t,e){let r=await Mf(t.path,e),i=await Zy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Fi&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Fi} bytes`);let c;if(o&&i.size>Fi)c=await sb(r,t.line??1,t.limit);else{let u=await Jy(r,"utf8");if(o){let f=u.split(`
|
|
100
|
-
`),x=Math.max(0,(t.line??1)-1),
|
|
101
|
-
`)}else c=
|
|
102
|
-
`)}async function Mf(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Of(kf(e)),Of(kf(t))]),o=nb(r,i);if(ob(o,rb,eb(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function ob(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Of(t){let e=[],r=t;for(;r!==nd(r);)try{let i=await Yy(r);return e.length?tb(i,...e.reverse()):i}catch{e.push(Qy(r)),r=nd(r)}return t}ne();var Bf=H("prompt-multimodal"),Ff=10*1024*1024,ab=15e3,cb=6;async function zf(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,u=t[c];u!==void 0&&(e[c]=await db(u))}}let o=Array.from({length:Math.min(cb,t.length)},()=>i());return await Promise.all(o),e}function Uf(t){return t.some(e=>e.type==="image")}async function db(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!eo(e.uri))return t;try{let{buf:r,contentType:i}=await lb(e.uri),o=e.mimeType||ub(i)||"application/octet-stream";return Bf.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 Bf.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ub(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function lb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),ab);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>Ff)throw new Error(`image too large: ${o.byteLength} bytes (max ${Ff})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}nn();We();ne();var $=H("core"),xb=3e4,hb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,pb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",gb="\u5BA1\u6279\u5DF2\u8D85\u65F6",mb=3e4,yo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Cr;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=Rf(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,u)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:u}),Li(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(wn(o,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(u=>$.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(oo(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&&hb.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Tr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Tr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Tr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(wn(r,Pi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,b=Lc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,pb,p,b)}}let u=Date.now(),f=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return f=!0,x}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=bl(i);switch(r){case"session/new":{let c=wb();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,u=c.sessionId;if(!u)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let p=Lc(i._meta);if(p?e.activeGroupIds.set(f.acpSessionId,p):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Uf(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let b=await zf(c.prompt);try{let E=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:b});return f.lastActiveAt=Date.now(),E}catch(E){if(E instanceof C&&E.code==="AGENT_APPROVAL_TIMEOUT"){let T=f.pendingPermission;T&&(T.downstream.respondAgentRequest(T.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(T.upstreamId),f.pendingPermission=void 0);let y=f.acpSessionId,v=y?e.activeTriggers.get(y):void 0,I=y?e.activeGroupIds.get(y):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:u}),await this.synthesizePromptReply(e,f,u,gb,v,I)}throw E}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let E=f.downstream;E&&(f.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),E.stop("reload-after-turn").catch(T=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(T)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=o.sessionId;if(!u)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let x=e.getSessionQueue(u);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:x.size}),x.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new C("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(_t.GEN_MODEL_TOKEN,i,mb);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Li(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,u=i.spawnFailCount??0,f=i.spawnFailedAt??0;if(u>=o&&Date.now()-f<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-f))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=u+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let b=await x.sessionNew({cwd:e.workspace});i.acpSessionId=b.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Li(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let u=e.activeTriggers.get(r.acpSessionId);u&&(c.cozeTriggerMsgId=u);let f=e.activeGroupIds.get(r.acpSessionId);f&&(c.cozeGroupId=f)}await this.upstream.send(Ar("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,u){let f={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(f.cozeTriggerMsgId=c),u&&(f.cozeGroupId=u),await this.upstream.send(Ar("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:f})).catch(x=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(bb(r)){$.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}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(Ar("session/update",{...r,sessionId:o,_meta:u})).catch(p=>$.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code: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??{},u=await Pf(c,o);r.respondAgentRequest(i.id,u)}else{let c=i.params??{},u=await Lf(c,o);r.respondAgentRequest(i.id,u)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Pi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},f=c.sessionId,x=f?e.activeTriggers.get(f):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let b=f?e.activeGroupIds.get(f):void 0;b&&(p.cozeGroupId=b);let E=f?this.reverseSessionId(e,f):void 0,T=E?e.sessions.get(E):void 0;T&&(T.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...E?{sessionId:E}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Oi(o,"session/request_permission",y)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:ee.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&_b(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new so(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),u=e.get(c);if(u)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:u,key:c}}}sendRequest(e,r,i=xb){let o=this.upstreamIds.next(e);return new Promise((c,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(o),u(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:u,timer:f}),this.upstream.send(Oi(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),u(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await ei(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(wn(e,{code:r,message:i,data:{bridgeVersion:Ir}}))}};function wb(){return fb(16).toString("hex")}function _b(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var yb=["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 bb(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 yb.some(c=>o.startsWith(c))}ne();Oe();import{randomBytes as Eb}from"node:crypto";import{chmod as vb,mkdir as Sb,writeFile as Hf}from"node:fs/promises";import{createServer as Ib}from"node:http";import{dirname as Ab}from"node:path";var Tb=1e6,rd=H("ipc"),bo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??X()}async start(){this.token=Eb(32).toString("hex");let e=Ib((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(),rd.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 Sb(Ab(this.paths.portFile),{recursive:!0}),await Hf(this.paths.portFile,String(this.port),"utf8"),await Hf(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await vb(this.paths.tokenFile,384)}catch(e){rd.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){zi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){zi(r,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Cb(e)}catch(f){zi(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(u,e);zi(r,200,f??{ok:!0})}catch(f){rd.error("IPC handler failed",{key:o,err:String(f)}),zi(r,500,{error:f instanceof Error?f.message:String(f)})}}};function zi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Cb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Tb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var uh=St(Xf(),1);var cv=St(Vx(),1),dv=St(Bo(),1),uv=St(Or(),1),lv=St(gd(),1),fv=St(_d(),1),xv=St(Id(),1),rh=St(Ho(),1),hv=St(nh(),1);var ih=rh.default;We();ne();var Re=H("upstream.frontier"),oh="application/json",ah="none",gv=15e3;function mv(t){class e extends ih{constructor(i){super(i,vl,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Re.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(d0("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 u=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:u})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Vi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Sl,...vr(this.opts.ppeOverride)},r=mv(e),i=Al(this.opts.urlOverride),o={url:i,ws:r,fpID:El,aID:no,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:oh,force:!0},payloadEncoding:{encoding:ah,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new uh.FWS(o),u=!1,f=null,x,p,b=new Promise((y,v)=>{x=y,p=v}),E=y=>{u||(u=!0,f&&(clearTimeout(f),f=null),y?p(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:y})).catch(I=>Re.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=y=>{this.opened=!1,Re.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Re.warn("frontier error",{code:y.code,msg:y.message}),E(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let T=this.opts.openTimeoutMs??gv;f=setTimeout(()=>{E(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${T}ms (handshake or upgrade slow)`))},T),await c.connect();try{await b}catch(y){try{c.close(1e3,"open failed")}catch(v){Re.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Re.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=f,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;ch(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:oh,payloadEncoding:ah})}catch(f){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new C("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=yv(e);if(!i){Re.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Re.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(u){Re.warn("frontier message JSON parse failed",{err:String(u),head:i.slice(0,80)});return}let c=o;ch(c)||Re.info("frontier frame in",{logid:_v(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:wv(i)}),Promise.resolve(this.handler(o)).catch(u=>Re.warn("frontier frame handler threw",{err:String(u)}))}};function ch(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var dh=2e3;function wv(t){return t.length<=dh?t:`${t.slice(0,dh)}...<truncated, total ${t.length} chars>`}function _v(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function yv(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ne();var Td=H("upstream.switchable"),jo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Td.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 Td.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Td.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var Cd=H("upstream"),Fr=class{handler=null;async start(){Cd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Cd.info("NoopUpstream stopped",{reason:e})}async send(e){Cd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};We();ne();ne();Oe();import{promises as Dd}from"node:fs";import{dirname as bv}from"node:path";var Ev=H("pat-token-store");async function Go(t=X()){try{let r=(await Dd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Ev.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ji(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await Dd.mkdir(bv(e.patTokenFile),{recursive:!0}),await Dd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Oe();Oe();import{promises as Ko}from"node:fs";import{join as vv}from"node:path";function Sv(t,e){return`#!/bin/sh
|
|
97
|
+
`}function Ry(t){if(t.includes(`
|
|
98
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var Dy={path:"",version:"cloud-deployed"},_u="openclaw_gateway_unavailable",ky="openclaw_default_agent_missing";function yu(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var Oy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Py=6e4,_o=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Ty,this.createTimeoutMs=e.createTimeoutMs??Py,this.detectorFactory=e.detectorFactory??(()=>new Gn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new mo({command:r})),this.openclawConfigDir=e.openclawConfigDir??wu(Iy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{pe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=wu(e,".env");if(await Sy(r).then(c=>c.isFile()).catch(()=>!1)){pe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await wo(e,{recursive:!0});let o=Cy({...process.env,...Xc(this.paths.agentEnvFile)});if(await Ay(r,o,"utf8"),process.platform!=="win32")try{await Ey(r,384)}catch(c){pe.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}pe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),pe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=Ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(A=>pe.warn("dispose stale agent failed (ignored)",{err:String(A)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let A=await He(e.agentId,this.paths).catch(()=>null);A&&(A.patToken=e.patToken,await Xe(A,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let A=await He(e.agentId,this.paths).catch(()=>null);A&&(A.modelInfo=e.modelInfo,await Xe(A,this.paths))}return pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=Ze(e.agentId,this.paths),f=Ci(e._meta),x=e.framework==="openclaw"&&f==="local",h;x&&!r?.revive&&(h=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=h??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),w=e.workspace??_??l.workspace,S=new AbortController,b=setTimeout(()=>S.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&td(e.framework)&&await er(e.framework,S.signal);let A=()=>{if(S.signal.aborted)throw S.signal.reason instanceof Error?S.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await wo(l.root,{recursive:!0}),await wo(w,{recursive:!0}),await wo(l.logs,{recursive:!0}),A(),x||await rr(w,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Il(w,f),A();let C=await He(e.agentId,this.paths).catch(()=>null),P=D0({model:e.model??C?.model}),y=E0(e._meta)??C?.accountId,R=e.patToken??C?.patToken,D=f==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new po({agentId:e.agentId,framework:e.framework,workspace:w,model:P.model??yt,deployType:f,...y?{accountId:y}:{},...R?{patToken:R}:{},...D?{modelInfo:D}:{}}),v.status="ok",C?.sessions){for(let[J,te]of Object.entries(C.sessions))v.sessions.set(J,{acpSessionId:te.acpSessionId,modelToken:te.modelToken,tokenGeneratedAt:te.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let Y=Object.keys(C.sessions).length;Y>0&&pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:Y})}this.registry.register(v),I=!0;let B={agentId:e.agentId,framework:e.framework,workspace:w,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:P.model};f==="cloud"&&(B.deployType="cloud"),y&&(B.accountId=y),R&&(B.patToken=R),D&&(B.modelInfo=D),C?.skills&&(B.skills=C.skills),C?.agentName&&(B.agentName=C.agentName),C?.description&&(B.description=C.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,w)):pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let G=e.initialSkills??[];if(G.length>0){let Y=[...B.skills??[]],J=new Map(Y.map((be,he)=>[be.skillId,he])),te=await Promise.allSettled(G.map(be=>Yc({agentId:e.agentId,workspace:w,framework:e.framework,skill:be}))),Q=0;for(let[be,he]of te.entries()){let O=G[be];O&&(he.status==="fulfilled"?(Jc(Y,J,he.value),Q++):pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(he.reason)}))}Q>0&&(B.skills=Y,pe.info("initialSkills installed",{agentId:e.agentId,installed:Q,requested:G.length}))}return await Xe(B,this.paths),pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:w,framework:e.framework}}catch(A){throw pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(A)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await vy(l.root,{recursive:!0,force:!0}).catch(C=>pe.warn("rm agent dir failed (ignored)",{err:String(C)})),A instanceof T?A:new T("AGENT_SPAWN_FAILED",String(A),{cause:A})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&td(e.framework))f=Dy;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);td(e.framework)&&!cs(e.framework)&&(pe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:f.path}):h=this.factory(e.framework,f.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(Oy),h}catch(_){let w=h instanceof Ot?h.getStderrTail():[];throw w.length>0&&pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof T?_.code:"unknown",recentStderr:w}),await h.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,f.path,_)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",yu(o),{cause:{reason:_u}})}catch(o){pe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};pe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return pe.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:ky}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",yu(r),{cause:{reason:_u}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,x=ed(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Cr({command:f,cwd:S.workspace,agentId:S.id,sessionName:x})}let h=await mu(),_=i?M0(i,c,l):null,w;if(_){let S=qc(o),v=_.models[0]?.id??yt,I=`${S}/${v}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(S,_),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}w=I}return new Cr({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...w?{slashModelOnStart:w}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=qc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(f){l=!1,pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){l=!1,pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as Au}from"node:crypto";import{promises as Gy}from"node:fs";import{basename as Iu}from"node:path";Ke();ne();import{promises as Ly}from"node:fs";import{basename as My}from"node:path";var bu=j("file-upload"),By="/api/coze_claw/file/agent_upload",Fy=6e4;async function Eu(t,e={}){let i=`${ro(so(e.handshakeBase))}${By}`,o=e.timeoutMs??Fy,c=await Ly.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...br(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);bu.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(i,{method:"POST",headers:f,body:l,signal:x.signal}),w=_.headers.get("x-tt-logid")??"";if(!_.ok){let v=await _.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${w}: ${v.slice(0,200)}`)}let S=await _.json();if(S.code!==void 0&&S.code!==0)throw new T("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${w}`);let b=S.data?.file?.file_url;if(!b)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(S).slice(0,200)}`);return bu.info("file upload ok",{uri:b,logid:w}),{uri:b}}catch(_){throw _ instanceof T?_:_.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${My(t.path)}`):new T("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(h)}}Ke();ne();import{extname as zy}from"node:path";var Uy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function vu(t){let e=zy(t).toLowerCase();return Uy[e]??"application/octet-stream"}ke();var yo=j("agent-send"),Su=50*1024*1024;function Tu(t,e,r){let i=t.get(e);if(!i)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function Cu(t,e,r,i,o,c){let f;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(h){f=h,x<2&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(_=>setTimeout(_,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function Ru(t,e){let{session:r,runtime:i}=Tu(e.core,t.agentId,t.sessionId);if(!await ei(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Gy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Su)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${Su}`);let c=await vu(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new T("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??Iu(t.path),f;try{f=await Eu({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw yo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:h instanceof T?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Au(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:l,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Cu(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),yo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function Du(t,e){let{session:r,runtime:i}=Tu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new T("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??Iu(t.path),c={sessionUpdate:"group_file",messageId:Au(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Cu(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),yo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function ku(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,f=i[c]??0;if(l<f)return!0;if(l>f)return!1}return!1}nn();yn();ne();var Pt=j("coze-cli-installer"),Ou="@coze/cli@latest",qy="coze",Pu="0.1.8",Hy=5e3,jy=5e3,Wy=9e4,Nu=1e4,Bi=null,bo=!1;async function nd(t,e={}){if(bo)return;if(Bi)return Bi;let r=e.exec??nu;return Bi=(async()=>{try{let i=await Ky(qy,r),o=!1;if(i){let l=await $y(r);if(l===void 0)Pt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(ku(l,Pu))Pt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:Pu}),o=!0;else{Pt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),bo=!0;return}}let c=o?"upgrade-only":"full";Pt.info("coze-cli install start",{package:Ou,mode:c});try{await r("npm",["i","-g","--prefer-online",Ou],{timeout:Wy,maxBuffer:10*1024*1024}),Pt.info("coze-cli install ok")}catch(l){Pt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){bo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Nu}),Pt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Pt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Nu}),Pt.info("coze auth login ok")}catch(l){Pt.warn("coze auth login failed",{err:String(l)});return}bo=!0}finally{Bi=null}})(),Bi}async function Ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Hy});return Ta(i)}catch{return}}async function $y(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:jy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Qr();ke();var Vy=10*6e4;function Lu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Vy:e}function Eo(t){return tr(t??X().configFile)}function Fi(t,e){return nr(e??X().configFile,t)}import{randomBytes as hb}from"node:crypto";$r();Ke();ne();import{createReadStream as Yy}from"node:fs";import{mkdir as Jy,readFile as Zy,realpath as Xy,stat as Qy,writeFile as eb}from"node:fs/promises";import{basename as tb,dirname as rd,isAbsolute as nb,join as rb,relative as ib,resolve as Mu,sep as sb}from"node:path";import{createInterface as ob}from"node:readline";var Fu=j("fs-rpc"),zi=Je("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function zu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>zi)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${zi} bytes`);let i=await Gu(t.path,e);return await Jy(rd(i),{recursive:!0}),await eb(i,t.content,"utf8"),Fu.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Uu(t,e){let r=await Gu(t.path,e),i=await Qy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>zi&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${zi} bytes`);let c;if(o&&i.size>zi)c=await ab(r,t.line??1,t.limit);else{let l=await Zy(r,"utf8");if(o){let f=l.split(`
|
|
99
|
+
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=f.slice(x,h).join(`
|
|
100
|
+
`)}else c=l}return Fu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function ab(t,e,r){let i=ob({input:Yy(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],f=0;try{for await(let x of i)if(f>=o&&f<c&&l.push(x),f++,f>=c)break}finally{i.close()}return l.join(`
|
|
101
|
+
`)}async function Gu(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Bu(Mu(e)),Bu(Mu(t))]),o=ib(r,i);if(cb(o,sb,nb(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function cb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Bu(t){let e=[],r=t;for(;r!==rd(r);)try{let i=await Xy(r);return e.length?rb(i,...e.reverse()):i}catch{e.push(tb(r)),r=rd(r)}return t}ne();var qu=j("prompt-multimodal"),Hu=10*1024*1024,db=15e3,lb=6;async function ju(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await fb(l))}}let o=Array.from({length:Math.min(lb,t.length)},()=>i());return await Promise.all(o),e}function Wu(t){return t.some(e=>e.type==="image")}async function fb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!no(e.uri))return t;try{let{buf:r,contentType:i}=await xb(e.uri),o=e.mimeType||ub(i)||"application/octet-stream";return qu.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return qu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ub(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function xb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),db);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Hu)throw new Error(`image too large: ${o.byteLength} bytes (max ${Hu})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();Ke();ne();var V=j("core"),pb=3e4,gb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,mb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",wb="\u5BA1\u6279\u5DF2\u8D85\u65F6",_b=3e4,vo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ir;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Lu(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),V.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){V.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),V.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){V.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&V.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{V.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Mi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){V.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(_n(o,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>V.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){V.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(co(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&gb.test(i)?this.currentCozeEnv=i:i&&V.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):V.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ar(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ar(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ar(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):V.warn("drop unknown notification",{method:e.method})}catch(o){V.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,Li(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let h=r._meta?.cozeTriggerMsgId,_=Bc(r._meta);return V.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,mb,h,_)}}let l=Date.now(),f=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return f=!0,x}finally{V.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:f})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=v0(i);switch(r){case"session/new":{let c=yb();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,l);if(f.replySeq=0,await this.ensureDownstream(e,l,f),!f.downstream||!f.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let h=Bc(i._meta);if(h?e.activeGroupIds.set(f.acpSessionId,h):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Wu(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await ju(c.prompt);try{let w=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:_});return f.lastActiveAt=Date.now(),w}catch(w){if(w instanceof T&&w.code==="AGENT_APPROVAL_TIMEOUT"){let S=f.pendingPermission;S&&(S.downstream.respondAgentRequest(S.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(S.upstreamId),f.pendingPermission=void 0);let b=f.acpSessionId,v=b?e.activeTriggers.get(b):void 0,I=b?e.activeGroupIds.get(b):void 0;return V.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,wb,v,I)}throw w}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(S=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(S)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(_t.GEN_MODEL_TOKEN,i,_b);if(!o?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof T&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new T("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Mi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,f=i.spawnFailedAt??0;if(l>=o&&Date.now()-f<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-f))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(V.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),h}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let _=await x.sessionNew({cwd:e.workspace});i.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}}catch(h){throw V.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,h}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Mi(i),this.isRuntimeBusy(e,i)){V.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){V.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}V.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>V.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let f=e.activeGroupIds.get(r.acpSessionId);f&&(c.cozeGroupId=f)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let f={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(f.cozeTriggerMsgId=c),l&&(f.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:f})).catch(x=>V.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){V.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){V.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(vb(r)){V.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(h=>V.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}V.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:ee.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await zu(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Uu(c,o);r.respondAgentRequest(i.id,l)}}catch(o){V.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Li(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},f=c.sessionId,x=f?e.activeTriggers.get(f):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let _=f?e.activeGroupIds.get(f):void 0;_&&(h.cozeGroupId=_);let w=f?this.reverseSessionId(e,f):void 0,S=w?e.sessions.get(w):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let b={...c,...w?{sessionId:w}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:w}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:w,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Pi(o,"session/request_permission",b)).catch(v=>{this.pendingUpstream.delete(o),V.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:ee.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(V.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&bb(e.result,o),V.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new ao(e.error)):i.value.resolve(e.result);return}V.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return V.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=pb){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let f=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:f}),this.upstream.send(Pi(o,e,r)).catch(x=>{let h=this.pendingBridge.get(o);h&&(clearTimeout(h.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await ti(e.agentId,r,this.paths)}catch(r){V.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(_n(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function yb(){return hb(16).toString("hex")}function bb(t,e){if(!t||typeof t!="object"){V.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){V.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){V.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&V.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var Eb=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function vb(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return Eb.some(c=>o.startsWith(c))}ne();ke();import{randomBytes as Sb}from"node:crypto";import{chmod as Ab,mkdir as Ib,writeFile as Ku}from"node:fs/promises";import{createServer as Tb}from"node:http";import{dirname as Cb}from"node:path";var Rb=1e6,id=j("ipc"),So=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??X()}async start(){this.token=Sb(32).toString("hex");let e=Tb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),id.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await Ib(Cb(this.paths.portFile),{recursive:!0}),await Ku(this.paths.portFile,String(this.port),"utf8"),await Ku(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Ab(this.paths.tokenFile,384)}catch(e){id.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Ui(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Ui(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Db(e)}catch(f){Ui(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);Ui(r,200,f??{ok:!0})}catch(f){id.error("IPC handler failed",{key:o,err:String(f)}),Ui(r,500,{error:f instanceof Error?f.message:String(f)})}}};function Ui(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Db(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Rb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ph=St(rx(),1);var lv=St(Qx(),1),fv=St(Uo(),1),uv=St(kr(),1),xv=St(md(),1),hv=St(yd(),1),pv=St(Id(),1),ch=St(jo(),1),gv=St(ah(),1);var dh=ch.default;Ke();ne();var Re=j("upstream.frontier"),fh="application/json",uh="none",wv=15e3;function _v(t){class e extends dh{constructor(i){super(i,A0,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Re.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(ll("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Yi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:I0,...br(this.opts.ppeOverride)},r=_v(e),i=C0(this.opts.urlOverride),o={url:i,ws:r,fpID:S0,aID:io,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:fh,force:!0},payloadEncoding:{encoding:uh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ph.FWS(o),l=!1,f=null,x,h,_=new Promise((b,v)=>{x=b,h=v}),w=b=>{l||(l=!0,f&&(clearTimeout(f),f=null),b?h(b):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let b=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:b,openCount:this.openCount}),b&&w();for(let v of this.connectHandlers)Promise.resolve(v({initial:b})).catch(I=>Re.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=b=>{this.opened=!1,Re.info("frontier closed",{code:b.code,reason:b.reason,willReconnect:b.willReconnect})},c.onerror=b=>{Re.warn("frontier error",{code:b.code,msg:b.message}),w(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${b.code} msg=${b.message??""}`))},c.onmessage=b=>this.handleMessage(b),this.fws=c;let S=this.opts.openTimeoutMs??wv;f=setTimeout(()=>{w(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await _}catch(b){try{c.close(1e3,"open failed")}catch(v){Re.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,b}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Re.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=f,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;xh(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:fh,payloadEncoding:uh})}catch(f){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=Ev(e);if(!i){Re.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Re.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Re.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;xh(c)||Re.info("frontier frame in",{logid:bv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:yv(i)}),Promise.resolve(this.handler(o)).catch(l=>Re.warn("frontier frame handler threw",{err:String(l)}))}};function xh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var hh=2e3;function yv(t){return t.length<=hh?t:`${t.slice(0,hh)}...<truncated, total ${t.length} chars>`}function bv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Ev(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ne();var Cd=j("upstream.switchable"),Ko=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Cd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Cd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Cd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var Rd=j("upstream"),Br=class{handler=null;async start(){Rd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Rd.info("NoopUpstream stopped",{reason:e})}async send(e){Rd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Ke();ne();ne();ke();import{promises as Dd}from"node:fs";import{dirname as vv}from"node:path";var Sv=j("pat-token-store");async function $o(t=X()){try{let r=(await Dd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Sv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ji(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await Dd.mkdir(vv(e.patTokenFile),{recursive:!0}),await Dd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}ke();ke();import{promises as Vo}from"node:fs";import{join as Av}from"node:path";function Iv(t,e){return`#!/bin/sh
|
|
103
102
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
104
|
-
`}function
|
|
103
|
+
`}function Tv(t,e){return`@echo off\r
|
|
105
104
|
"${e}" "${t}" %*\r
|
|
106
|
-
`}async function lh(t,e=X()){let r=e.binDir;await Ko.mkdir(r,{recursive:!0});let i=vv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Iv(t,o):Sv(t,o);return await Ko.readFile(i,"utf8").catch(()=>null)===c||(await Ko.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Ko.chmod(i,493)),r}ne();Oe();import{execSync as fh}from"node:child_process";import{readFileSync as xh,unlinkSync as Av}from"node:fs";import{mkdir as Tv,readFile as hh,unlink as ph,writeFile as Cv}from"node:fs/promises";import{dirname as Dv}from"node:path";function Wo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var Rv=H("single-instance"),$o=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(Rv.warn("removing stale pid file",{stalePid:e}),await ph(this.pidFile).catch(()=>{})),await Tv(Dv(this.pidFile),{recursive:!0}),await Cv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await hh(this.pidFile,"utf8")).trim()===String(process.pid)&&await ph(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await hh(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Wo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=xh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=fh(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=fh(`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{xh(this.pidFile,"utf8").trim()===String(process.pid)&&Av(this.pidFile)}catch{}})}};Vo();ne();var Wn=H("daemon.upstream-watchdog"),Fv=12e4,zv=9e5,Uv=3e4;function kd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Jo=class{constructor(e){this.opts=e;this.softMs=e.softMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Fv),this.hardMs=e.hardMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",zv),this.intervalMs=e.intervalMs??kd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Uv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Wn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Wn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Wn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Wn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Wn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Wn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Wn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var G=H("daemon"),Hv="coze-bridge-daemon";async function wh(){let t=X();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&a0({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>$e(O,t).logs,listAgentIds:()=>as(t)});let e=new $o({processTitle:Hv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await _o(),o=i??{};is({pid:process.pid}),G.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Un;o.frameworksCache=await O.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){G.warn("framework detection failed",{err:String(O)})}await Bi(o);let c=new jo(new Fr),u=null,f=new yo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,j,K,ie)=>{if(!u)throw new Error("agentManager not ready");return u.spawnSessionDownstream(O,j,K,ie)}});await jv(t,f);let x=new go({paths:t,config:o,registry:f});u=x;let p,b,E=null,T={},y,v=null,I=null,S=null,D=new yn;function P(O,j){return D.enqueue(()=>R(O,j))}function _(){I||(I=new Jo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?P(S,{force:!0}):void 0,onFatal:O=>{if(process.env[Yi]==="1"){G.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}G.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),I.start()}async function R(O,j){let K=O,ie=K?.privatecode;if(!ie)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Je=Di(K.env),le=K.handshake_url,fe=K.frontier_url,vt=mh(K.env,le,fe);if(S=K,!j?.force&&p===ie&&b===vt){let we=await qv(t);return f.agents.size===0&&we?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Zo(t,x).catch(Ae=>G.warn("connect-noop auto-revive error (ignored)",{err:String(Ae)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ft=!!p&&p!==ie,Zt=b!==void 0&&b!==vt,Bt=ft||Zt,Xt=await Mc({privatecode:ie,...le?{endpoint:le}:{},ppeOverride:Je});if(Bt){G.warn("connect config switched, resetting agents",{pcChanged:ft,envChanged:Zt,previousPc:p?Yo(p):"",nextPc:Yo(ie)});for(let we of[...f.agents.values()])await we.dispose("connect config switch").catch(()=>{}),f.agents.delete(we.agentId);f.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Fr,"connect switch").catch(()=>{})}E=Xt.deviceId,is({deviceId:E,pid:process.pid}),td({patToken:ie,env:K.env}).catch(we=>G.warn("coze-cli setup error (ignored)",{err:String(we)}));let jr=new Vi({handshake:Xt,privatecode:ie,...fe?{urlOverride:fe}:{},ppeOverride:Je,getPatTokenForAgent:we=>f.agents.get(we)?.patToken});return await c.swap(jr,"connect"),p=ie,b=vt,T=Je,y=le,K.mock_scenario!==void 0&&(f.setMockScenario(K.mock_scenario),G.info("mock scenario set",{scenario:K.mock_scenario})),v||(v=new ki({core:f,getDeviceId:()=>E??"",onTickEnd:()=>F.retryPending().catch(we=>G.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:V})),v.start(),_(),Bt&&Zo(t,x).catch(we=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(we)})),Ji(ie,t).catch(we=>G.warn("writePatToken after /connect failed (ignored)",{err:String(we)})),G.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async O=>x.createAgent(O.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let k={},B=new io({agents:f.agents,disposeAndMarkDisconnected:async(O,j)=>{let K=f.agents.get(O);if(K){await x.cleanupOpenclawSessionProviders(K).catch(Je=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Je)}));let ie=!0;try{await K.dispose(`disconnect: ${j}`)}catch(Je){ie=!1,G.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Je)}),K.status="error"}ie&&(K.status="disconnected",f.unregister(O),f.disconnectedAgents.add(O))}else f.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,j)=>{await x.openclawRepair(O,j)},isRuntimePendingPermission:O=>f.hasPendingPermissionFor(O)});f.registerExtension("_agent/listSkills",O=>B.listSkills(O.params)),f.registerExtension("_agent/addSkills",O=>B.addSkills(O.params)),f.registerExtension("_agent/removeSkills",O=>B.removeSkills(O.params)),f.registerExtension("_agent/getFileTree",O=>B.getFileTree(O.params)),f.registerExtension("_agent/getFileContent",O=>B.getFileContent(O.params)),f.registerExtension("_agent/update",O=>B.updateAgent(O.params)),f.registerExtension("_agent/disconnect",O=>B.disconnectAgent(O.params)),f.registerExtension("_agent/switchModel",O=>B.switchModel(O.params)),f.registerExtension("_agent/reset",O=>B.resetAgent(O.params)),f.registerExtension("_agent/repair",O=>B.repairAgent(O.params));let F=new ls({paths:t,handlers:B,sendDetail:O=>f.sendRequest("_agent/detail",O)});k.ref=F;let V=async O=>{await Promise.allSettled(O.map(async j=>{try{await B.disconnectAgent({agentId:j.agentId,reason:`auth_failure: code=${j.code} ${j.message}`}),G.info("agent disconnected due to auth failure from heartbeat response",{agentId:j.agentId,code:j.code,message:j.message})}catch(K){G.warn("disconnect during authFailure handling failed (ignored)",{agentId:j.agentId,err:String(K)})}}))};c.onConnect(({initial:O})=>{G.info("frontier upstream connected, triggering detail sync",{initial:O}),F.syncAll(O?"initial-connect":"reconnect").catch(j=>G.warn("detail sync top-level error (ignored)",{err:String(j)}))});let J=new bo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Yi]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let j=O,K=j?.privatecode,ie=j?.pairing_code;if(!K||!ie)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=Di(j.env),le=j.handshake_url,fe=j.frontier_url,vt=mh(j.env,le,fe),ft=!!p&&p!==K,Zt=b!==void 0&&b!==vt,Bt=ft||Zt,Xt=await Mc({privatecode:K,...le?{endpoint:le}:{},ppeOverride:Je});if(Bt){G.warn("pair config switched, resetting agents",{pcChanged:ft,envChanged:Zt,previousPc:p?Yo(p):"",nextPc:Yo(K),previousEnvKey:b??"",nextEnvKey:vt});for(let Ae of[...f.agents.values()])await Ae.dispose("pair config switch").catch(()=>{}),f.agents.delete(Ae.agentId);f.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Fr,"pair switch").catch(()=>{})}E=Xt.deviceId,is({deviceId:E,pid:process.pid}),td({patToken:K,env:j.env}).catch(Ae=>G.warn("coze-cli setup error (ignored)",{err:String(Ae)}));let jr=new Vi({handshake:Xt,privatecode:K,...fe?{urlOverride:fe}:{},ppeOverride:Je,getPatTokenForAgent:Ae=>f.agents.get(Ae)?.patToken});await c.swap(jr,"pair");try{let Ae=new Un;o.frameworksCache=await Ae.detectAll(),await Bi(o),G.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ae){G.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ae)})}let we=Object.keys(o.frameworksCache??{});try{let Ae=await f.sendRequest("_agent/pair",{pairCode:ie,patToken:K,frameworks:we,_meta:{cozeDeviceId:E}});G.info("_agent/pair ok",{pairResult:Ae}),p=K,b=vt,T=Je,y=le,j.mock_scenario!==void 0&&(f.setMockScenario(j.mock_scenario),G.info("mock scenario set",{scenario:j.mock_scenario})),Ji(K,t).catch(ke=>G.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),v||(v=new ki({core:f,getDeviceId:()=>E??"",onTickEnd:()=>F.retryPending().catch(ke=>G.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:V})),v.start(),_(),Bt&&Zo(t,x).catch(ke=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let $n;return j.agent_id&&($n=await Gv(j.agent_id,t,x,ke=>f.sendRequest("_agent/detail",ke),K).catch(ke=>(G.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",...$n?{agent:$n}:{}}}catch(Ae){return G.error("_agent/pair failed",{err:String(Ae)}),{ok:!1,note:`pair failed: ${String(Ae)}`}}}},{method:"POST",path:"/connect",handler:O=>P(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let j=O;return{ok:!0,result:await x.createAgent(j)}}},{method:"POST",path:"/agent/send",handler:async O=>{let j=O;if(!j?.agentId||!j?.sessionId||!j?.kind||!j?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let K=j;return await(K.groupFile?If:Sf)(K,{core:f,patToken:p,handshakeBase:y,ppeOverride:T})}catch(K){if(K instanceof C)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/reload",handler:async O=>{let j=O?.agent_id,K=await f.reloadAgents(j);return G.info("IPC /reload: recycled agent subprocesses",{agentId:j??"(all)",recycled:K}),{ok:!0,recycled:K}}},{method:"POST",path:"/shutdown",handler:async()=>(G.info("IPC /shutdown received"),setImmediate(()=>{he.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:te,token:Q}=await J.start();try{await lh(t.libEntry,t)}catch(O){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await f.start(),Zo(t,x).catch(O=>G.warn("auto-revive top-level error (ignored)",{err:String(O)})),m0().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(tn(),p0));for(let j of["claude-code","codex"]){let K=await O(j);K&&G.info("acp wrapper version",{framework:j,version:K})}}).catch(O=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let Ee=null,he={port:te,token:Q,core:f,ipc:J,shutdown(O){return Ee||(G.info("daemon shutdown",{reason:O}),Ee=(async()=>{v?.stop(),I?.stop(),await f.stop(O),await J.stop(),await e.release()})(),Ee)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{he.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{G.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
107
|
-
`)}catch{}process.exit(1)}),
|
|
108
|
-
`;await
|
|
109
|
-
`).filter(
|
|
110
|
-
`)}async function
|
|
111
|
-
`),1;for(let
|
|
112
|
-
`);return 0}let o=t.date??In(new Date),c=
|
|
105
|
+
`}async function gh(t,e=X()){let r=e.binDir;await Vo.mkdir(r,{recursive:!0});let i=Av(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Tv(t,o):Iv(t,o);return await Vo.readFile(i,"utf8").catch(()=>null)===c||(await Vo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Vo.chmod(i,493)),r}ne();ke();import{execSync as mh}from"node:child_process";import{readFileSync as wh,unlinkSync as Cv}from"node:fs";import{mkdir as Rv,readFile as _h,unlink as yh,writeFile as Dv}from"node:fs/promises";import{dirname as kv}from"node:path";var Ov=j("single-instance"),Yo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(Ov.warn("removing stale pid file",{stalePid:e}),await yh(this.pidFile).catch(()=>{})),await Rv(kv(this.pidFile),{recursive:!0}),await Dv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await _h(this.pidFile,"utf8")).trim()===String(process.pid)&&await yh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await _h(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return fo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=wh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=mh(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=mh(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{wh(this.pidFile,"utf8").trim()===String(process.pid)&&Cv(this.pidFile)}catch{}})}};Jo();ne();var $n=j("daemon.upstream-watchdog"),Uv=12e4,Gv=9e5,qv=3e4;function Od(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Zo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Uv),this.hardMs=e.hardMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Gv),this.intervalMs=e.intervalMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",qv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var K=j("daemon"),Hv="coze-bridge-daemon";async function vh(){let t=X();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&cl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>Ze(O,t).logs,listAgentIds:()=>ds(t)});let e=new Yo({processTitle:Hv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Eo(),o=i??{};as({pid:process.pid}),K.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Gn;o.frameworksCache=await O.detectAll(),K.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){K.warn("framework detection failed",{err:String(O)})}await Fi(o);let c=new Ko(new Br),l=null,f=new vo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,W,$,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,W,$,ie)}});await Wv(t,f);let x=new _o({paths:t,config:o,registry:f});l=x;let h,_,w=null,S={},b,v=null,I=null,A=null,C=new bn;function P(O,W){return C.enqueue(()=>R(O,W))}function y(){I||(I=new Zo({isConnected:()=>c.isConnected(),forceReconnect:()=>A?P(A,{force:!0}):void 0,onFatal:O=>{if(process.env[Zi]==="1"){K.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}K.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),I.start()}async function R(O,W){let $=O,ie=$?.privatecode;if(!ie)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Di($.env),fe=$.handshake_url,ue=$.frontier_url,vt=Eh($.env,fe,ue);if(A=$,!W?.force&&h===ie&&_===vt){let me=await jv(t);return f.agents.size===0&&me?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Qo(t,x).catch(Ae=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Ae)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ut=!!h&&h!==ie,Zt=_!==void 0&&_!==vt,Bt=ut||Zt,Xt=await Fc({privatecode:ie,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Bt){K.warn("connect config switched, resetting agents",{pcChanged:ut,envChanged:Zt,previousPc:h?Xo(h):"",nextPc:Xo(ie)});for(let me of[...f.agents.values()])await me.dispose("connect config switch").catch(()=>{}),f.agents.delete(me.agentId);f.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Br,"connect switch").catch(()=>{})}w=Xt.deviceId,as({deviceId:w,pid:process.pid}),nd({patToken:ie,env:$.env}).catch(me=>K.warn("coze-cli setup error (ignored)",{err:String(me)}));let qr=new Yi({handshake:Xt,privatecode:ie,...ue?{urlOverride:ue}:{},ppeOverride:Ve,getPatTokenForAgent:me=>f.agents.get(me)?.patToken});return await c.swap(qr,"connect"),h=ie,_=vt,S=Ve,b=fe,$.mock_scenario!==void 0&&(f.setMockScenario($.mock_scenario),K.info("mock scenario set",{scenario:$.mock_scenario})),v||(v=new Oi({core:f,getDeviceId:()=>w??"",onTickEnd:()=>G.retryPending().catch(me=>K.warn("detailSync.retryPending failed (ignored)",{err:String(me)})),onAuthFailures:Y})),v.start(),y(),Bt&&Qo(t,x).catch(me=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(me)})),Ji(ie,t).catch(me=>K.warn("writePatToken after /connect failed (ignored)",{err:String(me)})),K.info("/connect: WS established",{deviceId:w}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async O=>x.createAgent(O.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let D={},B=new oo({agents:f.agents,disposeAndMarkDisconnected:async(O,W)=>{let $=f.agents.get(O);if($){await x.cleanupOpenclawSessionProviders($).catch(Ve=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Ve)}));let ie=!0;try{await $.dispose(`disconnect: ${W}`)}catch(Ve){ie=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Ve)}),$.status="error"}ie&&($.status="disconnected",f.unregister(O),f.disconnectedAgents.add(O))}else f.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,W)=>{await x.openclawRepair(O,W)},isRuntimePendingPermission:O=>f.hasPendingPermissionFor(O)});f.registerExtension("_agent/listSkills",O=>B.listSkills(O.params)),f.registerExtension("_agent/addSkills",O=>B.addSkills(O.params)),f.registerExtension("_agent/removeSkills",O=>B.removeSkills(O.params)),f.registerExtension("_agent/getFileTree",O=>B.getFileTree(O.params)),f.registerExtension("_agent/getFileContent",O=>B.getFileContent(O.params)),f.registerExtension("_agent/update",O=>B.updateAgent(O.params)),f.registerExtension("_agent/disconnect",O=>B.disconnectAgent(O.params)),f.registerExtension("_agent/switchModel",O=>B.switchModel(O.params)),f.registerExtension("_agent/reset",O=>B.resetAgent(O.params)),f.registerExtension("_agent/repair",O=>B.repairAgent(O.params));let G=new xs({paths:t,handlers:B,sendDetail:O=>f.sendRequest("_agent/detail",O)});D.ref=G;let Y=async O=>{await Promise.allSettled(O.map(async W=>{try{await B.disconnectAgent({agentId:W.agentId,reason:`auth_failure: code=${W.code} ${W.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:W.agentId,code:W.code,message:W.message})}catch($){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:W.agentId,err:String($)})}}))};c.onConnect(({initial:O})=>{K.info("frontier upstream connected, triggering detail sync",{initial:O}),G.syncAll(O?"initial-connect":"reconnect").catch(W=>K.warn("detail sync top-level error (ignored)",{err:String(W)}))});let J=new So({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Zi]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:w??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let W=O,$=W?.privatecode,ie=W?.pairing_code;if(!$||!ie)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Di(W.env),fe=W.handshake_url,ue=W.frontier_url,vt=Eh(W.env,fe,ue),ut=!!h&&h!==$,Zt=_!==void 0&&_!==vt,Bt=ut||Zt,Xt=await Fc({privatecode:$,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Bt){K.warn("pair config switched, resetting agents",{pcChanged:ut,envChanged:Zt,previousPc:h?Xo(h):"",nextPc:Xo($),previousEnvKey:_??"",nextEnvKey:vt});for(let Ae of[...f.agents.values()])await Ae.dispose("pair config switch").catch(()=>{}),f.agents.delete(Ae.agentId);f.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Br,"pair switch").catch(()=>{})}w=Xt.deviceId,as({deviceId:w,pid:process.pid}),nd({patToken:$,env:W.env}).catch(Ae=>K.warn("coze-cli setup error (ignored)",{err:String(Ae)}));let qr=new Yi({handshake:Xt,privatecode:$,...ue?{urlOverride:ue}:{},ppeOverride:Ve,getPatTokenForAgent:Ae=>f.agents.get(Ae)?.patToken});await c.swap(qr,"pair");try{let Ae=new Gn;o.frameworksCache=await Ae.detectAll(),await Fi(o),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ae){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ae)})}let me=Object.keys(o.frameworksCache??{});try{let Ae=await f.sendRequest("_agent/pair",{pairCode:ie,patToken:$,frameworks:me,_meta:{cozeDeviceId:w}});K.info("_agent/pair ok",{pairResult:Ae}),h=$,_=vt,S=Ve,b=fe,W.mock_scenario!==void 0&&(f.setMockScenario(W.mock_scenario),K.info("mock scenario set",{scenario:W.mock_scenario})),Ji($,t).catch(De=>K.warn("writePatToken after /pair failed (ignored)",{err:String(De)})),v||(v=new Oi({core:f,getDeviceId:()=>w??"",onTickEnd:()=>G.retryPending().catch(De=>K.warn("detailSync.retryPending failed (ignored)",{err:String(De)})),onAuthFailures:Y})),v.start(),y(),Bt&&Qo(t,x).catch(De=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(De)}));let Vn;return W.agent_id&&(Vn=await Kv(W.agent_id,t,x,De=>f.sendRequest("_agent/detail",De),$).catch(De=>(K.error("--agent-id ensureAgent failed",{agentId:W.agent_id,err:String(De)}),{ok:!1,agentId:W.agent_id??"",note:String(De)}))),{ok:!0,note:"paired with cloud",...Vn?{agent:Vn}:{}}}catch(Ae){return K.error("_agent/pair failed",{err:String(Ae)}),{ok:!1,note:`pair failed: ${String(Ae)}`}}}},{method:"POST",path:"/connect",handler:O=>P(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let W=O;return{ok:!0,result:await x.createAgent(W)}}},{method:"POST",path:"/agent/send",handler:async O=>{let W=O;if(!W?.agentId||!W?.sessionId||!W?.kind||!W?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let $=W;return await($.groupFile?Du:Ru)($,{core:f,patToken:h,handshakeBase:b,ppeOverride:S})}catch($){if($ instanceof T)return{ok:!1,code:$.code,message:$.message};throw $}}},{method:"POST",path:"/reload",handler:async O=>{let W=O?.agent_id,$=await f.reloadAgents(W);return K.info("IPC /reload: recycled agent subprocesses",{agentId:W??"(all)",recycled:$}),{ok:!0,recycled:$}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{he.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:te,token:Q}=await J.start();try{await gh(t.libEntry,t)}catch(O){K.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await f.start(),Qo(t,x).catch(O=>K.warn("auto-revive top-level error (ignored)",{err:String(O)})),wl().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(nn(),gl));for(let W of["claude-code","codex"]){let $=await O(W);$&&K.info("acp wrapper version",{framework:W,version:$})}}).catch(O=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let be=null,he={port:te,token:Q,core:f,ipc:J,shutdown(O){return be||(K.info("daemon shutdown",{reason:O}),be=(async()=>{v?.stop(),I?.stop(),await f.stop(O),await J.stop(),await e.release()})(),be)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{he.shutdown(O).then(()=>process.exit(0))});return process.on("exit",()=>su()),process.on("unhandledRejection",O=>{K.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{K.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
+
`)}catch{}process.exit(1)}),K.info("daemon ready",{port:te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),$v({cliSpawned:process.env[Zi]==="1",readPatToken:()=>$o(t),connect:P}).catch(O=>K.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(O)})),he}async function jv(t){return ds(t).length>0}function Xo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Eh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Wv(t,e){let r=ds(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),us));for(let c of r){await o(c,t).catch(l=>K.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),K.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){K.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Kv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),us)),l=await c(t,e);if(l){K.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let _={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(_),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}K.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let f=await i({_meta:{cozeAgentId:t}});if(!f.framework)throw new T("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...o?{patToken:o}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await r.createAgent(x);let h=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function Qo(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(rn(),us));K.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let f of i){let x;try{x=await o(f,t)}catch(h){K.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(h)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){K.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{K.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:x.framework});let h=Vv(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}},{revive:!0}),c+=1}catch(h){K.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:x.framework,err:String(h)}),l+=1}}return K.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function $v(t){let e=t.logger??K;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 Vv(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Jo();ke();import{readFile as Sh}from"node:fs/promises";var Jt=class{paths;constructor(e){this.paths=e??X()}async probe(e=1e3){let r=await ea(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:Jv(i)}}}async request(e){let r=await ea(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),x=await f.text();return{status:f.status,body:Yv(x)}}finally{clearTimeout(l)}}};async function ea(t){try{let[e,r]=await Promise.all([Sh(t.portFile,"utf8"),Sh(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 Yv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Jv(t){return t instanceof Error?t.message:String(t)}yn();ne();ke();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let f of e){if(c===f){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${f}=`)){i=c.slice(f.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}nn();import{chmod as Zv,copyFile as Ah,mkdir as Th,readFile as ta,rename as Ih,rm as Pd,stat as Ch,writeFile as Xv}from"node:fs/promises";import{homedir as NR}from"node:os";import{dirname as Qv,join as Fr,resolve as Nd,sep as Xi}from"node:path";import{fileURLToPath as eS}from"node:url";yn();ne();ke();var Ld=j("dist-install");function tS(t){let e=eS(t),r=Qv(e),i=`${Xi}src${Xi}`;if(r.includes(i)||r.endsWith(`${Xi}src${Xi}cli`))return null;let o=Nd(r,"index.js"),c=Nd(r,"..","package.json");return{dist:o,pkgJson:c}}async function Bd(t={}){let e=t.paths??X(),r=tS(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let S=JSON.parse(await ta(o,"utf8"));c=S.version??"unknown",l=S.dependencies??{}}catch(S){return Ld.warn("cannot read source package.json,skip dist install",{err:String(S)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(S)}`}}let f=Zr.map(S=>`${S}@${l[S]??"latest"}`),x=await Eo(e.configFile)??{},h=x.libVersion,_=await ta(e.libEntry).then(()=>!0).catch(()=>!1),w=h===c;if(w&&_&&await Md(e))return{kind:"already-current",libVersion:c};if(!w||!_){await Th(e.libDir,{recursive:!0}),await Ah(i,e.libEntry),await Ah(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let S=Nd(e.libDir,"package.json"),b=`${JSON.stringify({type:"module"},null,2)}
|
|
107
|
+
`;await ta(S,"utf8").catch(()=>null)!==b&&await Xv(S,b)}return(!w||!await Md(e))&&await(t.installWrappers??nS)(e,f),x.libVersion=c,await Fi(x,e.configFile),Ld.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:c}),w&&_?{kind:"already-current",libVersion:c}:h?{kind:"version-changed",fromVersion:h,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Md(t){for(let e of Zr){let r=Fr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Ch(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function nS(t,e){await sS(t.installLock,async()=>{if(await Md(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Xi}.staging-${process.pid}-${r}`,o=Fr(i,"node_modules"),c=Fr(t.libDir,"node_modules");try{await Th(i,{recursive:!0}),await rS(e,i),await iS(o);let l=`${c}.trash-${r}`;await Ih(c,l).catch(()=>{}),await Ih(o,c),await Pd(l,{recursive:!0,force:!0}).catch(()=>{}),Ld.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Pd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function rS(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=dt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",x=>{l.length<8192&&(l+=x.toString("utf8"))});let f=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(f),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(f),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${l.trim().slice(0,2e3)}`))})})}async function iS(t){for(let e of Zr){let r=Fr(t,...e.split("/")),i=JSON.parse(await ta(Fr(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Fr(t,".bin",o),l=await Ch(c);process.platform!=="win32"&&!(l.mode&73)&&await Zv(c,l.mode|73).catch(()=>{})}}async function sS(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 Pd(t,{force:!0}).catch(()=>{})}}va();ne();ke();import{closeSync as Dh,fstatSync as kh,openSync as Oh,readFileSync as oS,readSync as aS,readdirSync as cS,statSync as dS}from"node:fs";import{join as na}from"node:path";var lS=new Set(["debug","info","warn","error"]);function Ph(t){let e=t,r=Sn(e,"--agent-id");e=r.rest;let i=Sn(e,"--date");e=i.rest;let o=Sn(e,"-n","--lines");e=o.rest;let c=Sn(e,"--level");e=c.rest;let l=Sn(e,"--grep");e=l.rest;let f=o.value===void 0?200:Number(o.value),x=Number.isInteger(f)&&f>=0?f:200,h=c.value&&lS.has(c.value)?c.value:void 0,_={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(_.agentId=r.value),i.value&&(_.date=i.value),h&&(_.level=h),l.value&&(_.grep=l.value),_}function fS(t,e){return t.agentId?na(Ze(t.agentId,e).logs,Xn("agent",t.date)):na(e.bridgeLogsDir,Xn("bridge",t.date))}function uS(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function xS(t,e){let r;try{r=cS(t)}catch{return[]}let i=[];for(let o of r){let c=Ea(o,e);if(!c)continue;let l=0;try{l=dS(na(t,o)).size}catch{}i.push({file:na(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function Nh(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"&&!fl(r,e.level))return!1}return!0}var Rh={debug:"90",info:"36",warn:"33",error:"31"},hS=new Set(["ts","level","module","msg"]);function pS(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Lh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=pS(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&Rh[o]&&(c=`\x1B[${Rh[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",f=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([h])=>!hS.has(h)).map(([h,_])=>` ${h}=${typeof _=="string"?_:JSON.stringify(_)}`).join("");return`${i} ${c} ${l} ${f}${x}`}function gS(t,e,r){let c=oS(t,"utf8").split(`
|
|
108
|
+
`).filter(l=>l.length>0).filter(l=>Nh(l,{level:e.level,grep:e.grep}));for(let l of uS(c,e.lines))process.stdout.write(`${Lh(l,{raw:e.raw,color:r})}
|
|
109
|
+
`)}async function Mh(t,e){let r=e.paths??X(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Ze(t.agentId,r).logs:r.bridgeLogsDir,f=t.agentId?"agent":"bridge",x=xS(l,f);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
110
|
+
`),1;for(let h of x)process.stdout.write(`${h.date} ${(h.size/1024).toFixed(1)}KB ${h.file}
|
|
111
|
+
`);return 0}let o=t.date??In(new Date),c=fS({agentId:t.agentId,date:o},r);try{gS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
113
112
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
114
113
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
115
|
-
`),1}return t.follow&&await
|
|
116
|
-
`);o=x.pop()??"";for(let
|
|
117
|
-
`)}await new Promise(x=>setTimeout(x,
|
|
114
|
+
`),1}return t.follow&&await _S(c,t,i),0}var mS=500;function wS(t){try{let e=Oh(t,"r");try{return kh(e).size}finally{Dh(e)}}catch{return 0}}async function _S(t,e,r){let i=wS(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let f="";try{let x=Oh(t,"r");try{let h=kh(x).size;if(h>i){let _=Buffer.allocUnsafe(h-i),w=aS(x,_,0,_.length,i);f=_.subarray(0,w).toString("utf8"),i+=w}}finally{Dh(x)}}catch{}if(f){let x=(o+f).split(`
|
|
115
|
+
`);o=x.pop()??"";for(let h of x)h.length>0&&Nh(h,{level:e.level,grep:e.grep})&&process.stdout.write(`${Lh(h,{raw:e.raw,color:r})}
|
|
116
|
+
`)}await new Promise(x=>setTimeout(x,mS))}}finally{process.off("SIGINT",l)}}import{basename as yS,resolve as bS}from"node:path";ke();var ES=9e4,vS={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function SS(t){return vS[t]??1}async function Bh(t,e={}){let r=e.paths??X();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
118
117
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
119
|
-
`),3;let i=await
|
|
120
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
118
|
+
`),3;let i=await ea(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
119
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:bS(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 AS(i,"/agent/send",o,ES)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
121
120
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
122
|
-
`),
|
|
123
|
-
`);else{let
|
|
124
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
125
|
-
`)}return 0}async function
|
|
126
|
-
`)}function
|
|
121
|
+
`),SS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
122
|
+
`);else{let l=t.name??yS(o.path);if(t.groupFile){let f=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${f})
|
|
123
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${IS(c.bytes)})
|
|
124
|
+
`)}return 0}async function AS(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),f=await l.text(),x=f?JSON.parse(f):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${f.slice(0,200)}`}}finally{clearTimeout(c)}}function IS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Kh=j("cli");function Ge(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function ca(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
125
|
+
`)}function JS(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="reload"){let{value:C}=Ge(e.slice(1),"--agent-id");return C?{mode:"reload",agentId:C}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return ZS(e.slice(1));if(e[0]==="log")return{mode:"log",...Ph(e.slice(1))};if(e[0]==="connect")return XS(e.slice(1));if(e.includes("--status"))return ca("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ca("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ca("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ca("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=Ge(r,"--pat-token");r=o;let{value:c,rest:l}=Ge(r,"--pair-code");r=l;let{value:f,rest:x}=Ge(r,"--env");r=x;let{value:h,rest:_}=Ge(r,"--handshake-url");r=_;let{value:w,rest:S}=Ge(r,"--frontier-url");r=S;let{value:b,rest:v}=Ge(r,"--mock-scenario");r=v;let{value:I}=Ge(r,"--agent-id");if(!i||!c)return{mode:"help"};let A={mode:"pair",privatecode:i,pairingCode:c};return f&&(A.env=f),h&&(A.handshakeUrl=h),w&&(A.frontierUrl=w),b&&(A.mockScenario=b),I&&(A.agentId=I),A}function ZS(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=Ge(i,"--caption");i=c;let{value:l,rest:f}=Ge(i,"--name");i=f;let{value:x,rest:h}=Ge(i,"--agent-id");i=h;let{value:_,rest:w}=Ge(i,"--session-id");i=w;let{value:S,rest:b}=Ge(i,"--mime");i=b;let v=i.includes("--group-file");i=i.filter(C=>C!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:r,json:I};return o&&(A.caption=o),l&&(A.name=l),x&&(A.agentId=x),_&&(A.sessionId=_),v&&(A.groupFile=!0),S&&(A.mimeType=S),A}function XS(t){let e=t,{value:r,rest:i}=Ge(e,"--pat-token");e=i;let{value:o,rest:c}=Ge(e,"--env");e=c;let{value:l,rest:f}=Ge(e,"--handshake-url");e=f;let{value:x,rest:h}=Ge(e,"--frontier-url");e=h;let{value:_,rest:w}=Ge(e,"--mock-scenario");e=w;let S={mode:"connect"};return r&&(S.privatecode=r),o&&(S.env=o),l&&(S.handshakeUrl=l),x&&(S.frontierUrl=x),_&&(S.mockScenario=_),S}var QS=`
|
|
127
126
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
128
127
|
|
|
129
128
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -202,56 +201,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
202
201
|
|
|
203
202
|
Internal:
|
|
204
203
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
205
|
-
`.trimStart();async function
|
|
206
|
-
`),0;case"daemon":{try{await
|
|
207
|
-
`),1;if(i.kind==="stale")return await
|
|
204
|
+
`.trimStart();async function $h(t=process.argv,e={}){let r=JS(t);switch(r.mode){case"help":return process.stdout.write(QS),0;case"version":return process.stdout.write(`${vr}
|
|
205
|
+
`),0;case"daemon":{try{await vh()}catch(i){return Kh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return e1(e);case"stop":return Yh(e);case"reload":return r1(r.agentId,e);case"log":return Mh(r,e);case"update":return t1(e);case"purge":return i1(e);case"service-install":return s1(e);case"service-uninstall":return o1(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),a1(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),c1(r.privatecode,e,i)}case"send":return Bh({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 Vh(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 e1(t){let e=t.paths??X(),r=new Jt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
206
|
+
`),1;if(i.kind==="stale")return await Vh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
208
207
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
209
208
|
${JSON.stringify(o.body,null,2)}
|
|
210
|
-
`),0}async function
|
|
209
|
+
`),0}async function Yh(t){let e=t.paths??X(),r=new Jt(e),i=await es(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
211
210
|
`)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
212
211
|
`:`coze-bridge: not running
|
|
213
|
-
`),0;if(c.kind==="stale")return await
|
|
212
|
+
`),0;if(c.kind==="stale")return await Vh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
214
213
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
215
|
-
`),0}catch(
|
|
216
|
-
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(
|
|
217
|
-
`),1)}}async function
|
|
218
|
-
`),e(1)})})}async function
|
|
214
|
+
`),0}catch(l){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
215
|
+
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
|
|
216
|
+
`),1)}}async function t1(t){return await Yh(t),(t.spawnNpx??n1)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function n1(t){return new Promise(e=>{let r=dt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
217
|
+
`),e(1)})})}async function r1(t,e){let r=new Jt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
219
218
|
`),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
220
219
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
221
220
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
222
221
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
223
|
-
`),1}}async function
|
|
222
|
+
`),1}}async function es(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:f=>c.install(l,f),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(jh(),Hh)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Jh(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??bh,o=t.waitTimeoutMs??15e3,c=t.sleep??l1,l=t.paths??X(),f=await es(t);if(f&&(f.platform==="darwin"||f.platform==="linux")){try{await f.install({activate:!0});let x=await Wh(e,o,c);if(x.kind==="connected")return x;Yr(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){Yr(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}await f.uninstall().catch(()=>{}),await d1(l.pidFile,c)}else f&&await f.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
|
|
224
223
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
225
|
-
`),await i({paths:t.paths}),
|
|
226
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
227
|
-
`)}await new Promise(
|
|
228
|
-
`)}catch(
|
|
224
|
+
`),await i({paths:t.paths}),Wh(e,o,c)}async function i1(t){let e=new Jt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
225
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
226
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await es(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
227
|
+
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
229
228
|
`)}let o=t.paths??X(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
230
|
-
`)}catch(
|
|
229
|
+
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
231
230
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
232
|
-
`),0}async function
|
|
231
|
+
`),0}async function s1(t){let e=await es(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
233
232
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
234
233
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
235
|
-
`),1}}async function
|
|
234
|
+
`),1}}async function o1(t){let e=await es(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
236
235
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
237
|
-
`),1}}async function
|
|
238
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
239
|
-
`)}let f=await
|
|
240
|
-
`),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let
|
|
236
|
+
`),1}}async function a1(t,e,r,i={},o){let c=new Jt(r.paths),l=r.paths??X();if(await Zc(l).catch(h=>Yr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!r.skipDistInstall){let h=await Bd({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
237
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
238
|
+
`)}let f=await Jh(r,c);if(f.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
239
|
+
`),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let _=h.body.agent;return _&&!_.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${_.agentId}): ${_.note}
|
|
241
240
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
242
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
243
|
-
`),1}catch(
|
|
244
|
-
`),1}}async function
|
|
245
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
246
|
-
`)}let
|
|
241
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
|
|
242
|
+
`),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
|
|
243
|
+
`),1}}async function c1(t,e,r={}){let i=e.paths??X(),o=t??await $o(i);if(!o)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Jt(e.paths);if(await Zc(i).catch(x=>Yr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!e.skipDistInstall){let x=await Bd({paths:e.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
244
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
245
|
+
`)}let l=await Jh(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
247
246
|
`),1;let f={privatecode:o};r.env&&(f.env=r.env),r.handshakeUrl&&(f.handshake_url=r.handshakeUrl),r.frontierUrl&&(f.frontier_url=r.frontierUrl),r.mockScenario&&(f.mock_scenario=r.mockScenario);try{let x=await c.request({method:"POST",path:"/connect",body:f,timeoutMs:35e3});return x.status===200&&x.body?.ok?(process.stdout.write(`coze-bridge: connected (${x.body.note??"ok"})
|
|
248
|
-
`),await Ji(o,i).catch(
|
|
247
|
+
`),await Ji(o,i).catch(h=>Kh.warn("writePatToken after connect failed (ignored)",{err:String(h)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
|
|
249
248
|
`),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
|
|
250
|
-
`),1}}async function
|
|
249
|
+
`),1}}async function Wh(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 d1(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let f=Number.parseInt(l.trim(),10);if(!Number.isFinite(f)||f<=0||!fo(f))return;await e(i)}}function l1(t){return new Promise(e=>setTimeout(e,t))}ne();function f1(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function Zh(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=f1(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
|
|
251
250
|
`),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
252
251
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
253
252
|
npx -y coze-bridge@latest stop
|
|
254
253
|
npx -y coze-bridge@latest connect
|
|
255
254
|
|
|
256
|
-
`)}
|
|
255
|
+
`)}Zh();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&dl("warn");$h(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
257
256
|
`),process.exit(1)});
|