coze-bridge 0.1.96-beta.2 → 0.1.96

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.
Files changed (2) hide show
  1. package/dist/index.js +76 -76
  2. 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 Dp=Object.create;var ha=Object.defineProperty;var kp=Object.getOwnPropertyDescriptor;var Op=Object.getOwnPropertyNames;var Pp=Object.getPrototypeOf,Np=Object.prototype.hasOwnProperty;var ce=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ze=(t,e)=>()=>(t&&(e=t(t=0)),e);var ie=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xa=(t,e)=>{for(var r in e)ha(t,r,{get:e[r],enumerable:!0})},Lp=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Op(e))!Np.call(t,o)&&o!==r&&ha(t,o,{get:()=>e[o],enumerable:!(i=kp(e,o))||i.enumerable});return t};var It=(t,e,r)=>(r=t!=null?Dp(Pp(t)):{},Lp(e||!t||!t.__esModule?ha(r,"default",{value:t,enumerable:!0}):r,t));function Ft(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Zi=Ze(()=>{"use strict"});import{createWriteStream as Mp,mkdirSync as Bp,readdirSync as zp,unlinkSync as Fp}from"node:fs";import{join as Xd}from"node:path";function An(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Xn(t,e){return`${t}-${e}.log`}function pa(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Up(t,e,r){let i=c=>{let[l,u,h]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,h??1)};return Math.floor((i(e)-i(t))/864e5)>r}function Xi(t,e,r,i){let o;try{o=zp(t)}catch{return}for(let c of o){let l=pa(c,e);if(l&&Up(l,r,i))try{Fp(Xd(t,c))}catch{}}}var Gr,ga=Ze(()=>{"use strict";Gr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>An(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Bp(this.dir,{recursive:!0});let r=Mp(Xd(this.dir,Xn(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
8
+ var Rp=Object.create;var ga=Object.defineProperty;var kp=Object.getOwnPropertyDescriptor;var Pp=Object.getOwnPropertyNames;var Op=Object.getPrototypeOf,Lp=Object.prototype.hasOwnProperty;var ue=(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 Qe=(t,e)=>()=>(t&&(e=t(t=0)),e);var ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ma=(t,e)=>{for(var r in e)ga(t,r,{get:e[r],enumerable:!0})},Np=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Pp(e))!Lp.call(t,o)&&o!==r&&ga(t,o,{get:()=>e[o],enumerable:!(i=kp(e,o))||i.enumerable});return t};var Tt=(t,e,r)=>(r=t!=null?Rp(Op(t)):{},Np(e||!t||!t.__esModule?ga(r,"default",{value:t,enumerable:!0}):r,t));function qt(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var ns=Qe(()=>{"use strict"});import{createWriteStream as Mp,mkdirSync as Bp,readdirSync as zp,unlinkSync as Fp}from"node:fs";import{join as tl}from"node:path";function Rn(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function nr(t,e){return`${t}-${e}.log`}function wa(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Up(t,e,r){let i=c=>{let[l,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 rs(t,e,r,i){let o;try{o=zp(t)}catch{return}for(let c of o){let l=wa(c,e);if(l&&Up(l,r,i))try{Fp(tl(t,c))}catch{}}}var Vr,_a=Qe(()=>{"use strict";Vr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>Rn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Bp(this.dir,{recursive:!0});let r=Mp(tl(this.dir,nr(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
9
9
  `)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
10
- `),this.stream=void 0;return}this.currentDate!==void 0&&Xi(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as qp,mkdirSync as Hp}from"node:fs";import{join as jp}from"node:path";function el(t){let e=t.retentionDays??Kp,r=t.clock??(()=>An(new Date));es={bridgeSink:new Gr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Gr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();Xi(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])Xi(t.agentLogsDir(o),"agent",i,e)}function $p(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function tl(t){ma=t}function nl(t){return Qn[ma]<=Qn[t]}function rl(t,e){let r=Qn[t];return r===void 0?!0:r>=Qn[e]}function ts(t){Qd={...t}}function il(t){let e=(u,h=2)=>String(u).padStart(h,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${An(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Wr(t,e,r,i,o){try{let c=`${JSON.stringify({ts:il(new Date),level:e,module:r,msg:i,...o})}
11
- `;Hp(t,{recursive:!0}),qp(jp(t,Xn("bridge",An(new Date))),c)}catch{}}function Jp(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function Qi(t,e,r,i,o){if(Qn[t]<Qn[ma])return;let c=`${JSON.stringify({ts:il(new Date),level:t,module:e,msg:r,...Qd,...i})}
12
- `;if(es){let l=Jp(o,i),u=l?$p(es,l):es.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Wp.write(c):Gp.write(c)}function U(t,e){return{debug:(r,i)=>Qi("debug",t,r,i,e),info:(r,i)=>Qi("info",t,r,i,e),warn:(r,i)=>Qi("warn",t,r,i,e),error:(r,i)=>Qi("error",t,r,i,e),child:r=>U(`${t}.${r}`,e),forAgent:r=>U(t,r)}}var Qn,ma,Gp,Wp,Qd,Kp,es,te=Ze(()=>{"use strict";Zi();ga();Qn={debug:10,info:20,warn:30,error:40},ma=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gp=process.stdout,Wp=process.stderr,Qd={},Kp=Ft("COZE_BRIDGE_LOG_RETENTION_DAYS",30),es=null});var R,$e=Ze(()=>{"use strict";R=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var cl={};xa(cl,{ACP_WRAPPER_NPM_PACKAGES:()=>$r,_resetAcpInstallerForTests:()=>eg,_setBinaryPathCacheForTests:()=>tg,buildAcpSpawn:()=>Jr,ensureAcpInstalled:()=>er,getAcpBinaryPath:()=>ns,pickWhichLine:()=>ya,probeAcpVersion:()=>Qp,resolveAcpCommand:()=>al});import{readFileSync as sl}from"node:fs";import{createRequire as Vp}from"node:module";import{dirname as Yp,resolve as Zp}from"node:path";function ya(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function Xp(t){let e=ol.resolve(`${t.npmPackage}/package.json`),r=Yp(e),i=JSON.parse(sl(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return Zp(r,o)}async function er(t,e){let r=_a[t];if(!r)throw new R("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Kr.get(t);if(i)return i;try{let o=Xp(r);return Kr.set(t,o),wa.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw wa.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new R("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
13
- `),{cause:o})}}async function Qp(t){let e=_a[t];if(e)try{let r=ol.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(sl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){wa.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function ns(t){return Kr.get(t)}function al(t,e){if(e)return e;let r=ns(t);if(!r)throw new R("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Jr(t,e,r){if(e)return{command:e,args:[...r]};let i=al(t);return{command:process.execPath,args:[i,...r]}}function eg(){Kr.clear()}function tg(t,e){Kr.set(t,e)}var wa,_a,$r,ol,Kr,nn=Ze(()=>{"use strict";$e();te();wa=U("agents.acp-installer"),_a={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},$r=Object.values(_a).filter(t=>t!==void 0).map(t=>t.npmPackage),ol=Vp(import.meta.url),Kr=new Map});import{chmod as rg,mkdir as ig,readFile as sg,rename as ul,writeFile as fl}from"node:fs/promises";import{dirname as og}from"node:path";async function tr(t){try{let e=await sg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nr(t,e,r){await ig(og(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
14
- `,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await fl(o,i,{encoding:"utf8",mode:r.mode}):await fl(o,i,"utf8"),await ul(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await ul(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Vr=Ze(()=>{"use strict"});import{promises as hl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as Re,resolve as xl}from"node:path";function Z(t){let e=t??cg(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function Xe(t,e=Z()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function rs(t=Z()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Yr(t,e){let r=await hl.realpath(xl(t)).catch(()=>null);if(!r)return!1;let i=await hl.realpath(xl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+dg)}var Ne=Ze(()=>{"use strict"});var os={};xa(os,{AGENT_CONFIG_FILE_MODE:()=>is,enforceAgentConfigMode:()=>fg,loadAgentConfig:()=>Ge,persistAgentSessions:()=>Zr,persistAgentSkills:()=>ss,saveAgentConfig:()=>Qe});import{chmod as lg,stat as ug}from"node:fs/promises";function Ge(t,e){return tr(Xe(t,e).config)}function Qe(t,e){return nr(Xe(t.agentId,e).config,t,{mode:is})}async function fg(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await ug(r);if(!i.isFile())return;let o=i.mode&511;o!==is&&(await lg(r,is),pl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;pl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Zr(t,e,r){let i=await Ge(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function ss(t,e,r){let i=await Ge(t,r);i&&(i.skills=e,await Qe(i,r))}var pl,is,rn=Ze(()=>{"use strict";Vr();te();Ne();pl=U("agent-config"),is=384});var ba=ie((N1,_l)=>{_l.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var cs=ie(El=>{var yl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function mg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(yl))El[t]=mg(yl[t])});var Al=ie((M1,Il)=>{var wg=ce("fs"),Le=ce("path"),bl=ba(),_g=cs(),yg=typeof process=="object"&&process.platform==="win32",vl=t=>typeof t=="object"&&t!==null,Sl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function ve(t){this.sep=Le.sep,this.fs=wg,vl(t)&&vl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Il.exports=ve;ve.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw _g.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Le.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};ve.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,h){if(l&&h.isDirectory())return o(!1);var p=Le.dirname(t);c.fs.exists(p,function(m){m||c.makeDir(p),c.fs.open(t,"w",438,function(E,T){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):T?c.fs.write(T,e,0,e.length,0,function(){c.fs.close(T,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let h=Le.join(i,u),p=e.fs.statSync(h);(!o||o.test(h))&&l.push(Le.normalize(h)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Le.join(t,u),r.fs.stat(u,function(h,p){if(h)return e(h);p&&(i.push(Le.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(m,E){if(m)return e(m);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return Sl[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case bl.STORED:return"STORED ("+t+")";case bl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.posix.join(".",e)};ve.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ve.sanitize=function(t,e){t=Le.resolve(Le.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Le.normalize(Le.join(t,r.slice(i,o).join(Le.sep)));if(c.indexOf(t)===0)return c}return Le.normalize(Le.join(t,Le.basename(e)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};ve.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};ve.isWin=yg;ve.crcTable=Sl});var Rl=ie((B1,Tl)=>{var Eg=ce("path");Tl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Eg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Dl=ie((z1,Cl)=>{Cl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=ie((F1,ir)=>{ir.exports=Al();ir.exports.Constants=ba();ir.exports.Errors=cs();ir.exports.FileAttr=Rl();ir.exports.decoder=Dl()});var Ol=ie((U1,kl)=>{var sn=sr(),F=sn.Constants;kl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,p=0,m=0,E=0,T=0,_=0,v=0;t|=sn.isWin?2560:768,r|=F.FLG_EFS;let I={extraLen:0},S=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,N=y=>Math.max(0,y)&255;return o=sn.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&F.FLG_EFS)>0},set flags_efs(y){y?r|=F.FLG_EFS:r&=~F.FLG_EFS},get flags_desc(){return(r&F.FLG_DESC)>0},set flags_desc(y){y?r|=F.FLG_DESC:r&=~F.FLG_DESC},get method(){return i},set method(y){switch(y){case F.STORED:this.version=10;case F.DEFLATED:default:this.version=20}i=y},get time(){return sn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=sn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=S(y)},get timeHighByte(){return N(o>>>8)},get crc(){return c},set crc(y){c=S(y)},get compressedSize(){return l},set compressedSize(y){l=S(y)},get size(){return u},set size(y){u=S(y)},get fileNameLength(){return h},set fileNameLength(y){h=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return m},set commentLength(y){m=y},get diskNumStart(){return E},set diskNumStart(y){E=S(y)},get inAttr(){return T},set inAttr(y){T=S(y)},get attr(){return _},set attr(y){_=S(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return v},set offset(y){v=S(y)},get encrypted(){return(r&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+h+p+m},get realDataOffset(){return v+F.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var D=y.slice(v,v+F.LOCHDR);if(D.readUInt32LE(0)!==F.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=D.readUInt16LE(F.LOCVER),I.flags=D.readUInt16LE(F.LOCFLG),I.flags_desc=(I.flags&F.FLG_DESC)>0,I.method=D.readUInt16LE(F.LOCHOW),I.time=D.readUInt32LE(F.LOCTIM),I.crc=D.readUInt32LE(F.LOCCRC),I.compressedSize=D.readUInt32LE(F.LOCSIZ),I.size=D.readUInt32LE(F.LOCLEN),I.fnameLen=D.readUInt16LE(F.LOCNAM),I.extraLen=D.readUInt16LE(F.LOCEXT);let k=v+F.LOCHDR+I.fnameLen,M=k+I.extraLen;return y.slice(k,M)},loadFromBinary:function(y){if(y.length!==F.CENHDR||y.readUInt32LE(0)!==F.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(F.CENVEM),e=y.readUInt16LE(F.CENVER),r=y.readUInt16LE(F.CENFLG),i=y.readUInt16LE(F.CENHOW),o=y.readUInt32LE(F.CENTIM),c=y.readUInt32LE(F.CENCRC),l=y.readUInt32LE(F.CENSIZ),u=y.readUInt32LE(F.CENLEN),h=y.readUInt16LE(F.CENNAM),p=y.readUInt16LE(F.CENEXT),m=y.readUInt16LE(F.CENCOM),E=y.readUInt16LE(F.CENDSK),T=y.readUInt16LE(F.CENATT),_=y.readUInt32LE(F.CENATX),v=y.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(F.LOCHDR);return y.writeUInt32LE(F.LOCSIG,0),y.writeUInt16LE(e,F.LOCVER),y.writeUInt16LE(r,F.LOCFLG),y.writeUInt16LE(i,F.LOCHOW),y.writeUInt32LE(o,F.LOCTIM),y.writeUInt32LE(c,F.LOCCRC),y.writeUInt32LE(l,F.LOCSIZ),y.writeUInt32LE(u,F.LOCLEN),y.writeUInt16LE(h,F.LOCNAM),y.writeUInt16LE(I.extraLen,F.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(F.CENHDR+h+p+m);return y.writeUInt32LE(F.CENSIG,0),y.writeUInt16LE(t,F.CENVEM),y.writeUInt16LE(e,F.CENVER),y.writeUInt16LE(r,F.CENFLG),y.writeUInt16LE(i,F.CENHOW),y.writeUInt32LE(o,F.CENTIM),y.writeUInt32LE(c,F.CENCRC),y.writeUInt32LE(l,F.CENSIZ),y.writeUInt32LE(u,F.CENLEN),y.writeUInt16LE(h,F.CENNAM),y.writeUInt16LE(p,F.CENEXT),y.writeUInt16LE(m,F.CENCOM),y.writeUInt16LE(E,F.CENDSK),y.writeUInt16LE(T,F.CENATT),y.writeUInt32LE(_,F.CENATX),y.writeUInt32LE(v,F.CENOFF),y},toJSON:function(){let y=function(D){return D+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(h),extraLength:y(p),commentLength:y(m),diskNumStart:E,inAttr:T,attr:_,offset:v,centralHeaderSize:y(F.CENHDR+h+p+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Nl=ie((q1,Pl)=>{var or=sr(),me=or.Constants;Pl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return me.ENDHDR+o},loadFromBinary:function(c){if((c.length!==me.ENDHDR||c.readUInt32LE(0)!==me.ENDSIG)&&(c.length<me.ZIP64HDR||c.readUInt32LE(0)!==me.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===me.ENDSIG?(t=c.readUInt16LE(me.ENDSUB),e=c.readUInt16LE(me.ENDTOT),r=c.readUInt32LE(me.ENDSIZ),i=c.readUInt32LE(me.ENDOFF),o=c.readUInt16LE(me.ENDCOM)):(t=or.readBigUInt64LE(c,me.ZIP64SUB),e=or.readBigUInt64LE(c,me.ZIP64TOT),r=or.readBigUInt64LE(c,me.ZIP64SIZE),i=or.readBigUInt64LE(c,me.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(me.ENDHDR+o);return c.writeUInt32LE(me.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,me.ENDSUB),c.writeUInt16LE(e,me.ENDTOT),c.writeUInt32LE(r,me.ENDSIZ),c.writeUInt32LE(i,me.ENDOFF),c.writeUInt16LE(o,me.ENDCOM),c.fill(" ",me.ENDHDR),c},toJSON:function(){let c=function(l,u){let h=l.toString(16).toUpperCase();for(;h.length<u;)h="0"+h;return"0x"+h};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Sa=ie(va=>{va.EntryHeader=Ol();va.MainHeader=Nl()});var Ml=ie((j1,Ll)=>{Ll.exports=function(t){var e=ce("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var p=0;p<c.length;p++){var m=c[p];m.copy(u,h),h+=m.length}i&&i(u)}),o.end(t)}}}});var zl=ie((G1,Bl)=>{var bg=+(process.versions?process.versions.node:"").split(".")[0]||0;Bl.exports=function(t,e){var r=ce("zlib");let i=bg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),p=0;h.fill(0);for(var m=0;m<l.length;m++){var E=l[m];E.copy(h,p),p+=E.length}o&&o(h)}),c.end(t)}}}});var jl=ie((W1,Hl)=>{"use strict";var{randomFillSync:Fl}=ce("crypto"),vg=cs(),Sg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),ql=(t,e)=>Math.imul(t,e)>>>0,Ul=(t,e)=>Sg[(t^e)&255]^t>>>8,Xr=()=>typeof Fl=="function"?Fl(Buffer.alloc(12)):Xr.node();Xr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var ds={genSalt:Xr};function ls(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}ls.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ul(e[0],t),e[1]+=e[0]&255,e[1]=ql(e[1],134775813)+1,e[2]=Ul(e[2],e[1]>>>24),t};ls.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return ql(t,t^1)>>8&255};function Ig(t){let e=new ls(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Ag(t){let e=new ls(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ig(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Rg(t){Buffer.isBuffer(t)&&t.length>=12?ds.genSalt=function(){return t.slice(0,12)}:t==="node"?ds.genSalt=Xr.node:ds.genSalt=Xr}function Cg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ag(r),c=ds.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Hl.exports={decrypt:Tg,encrypt:Cg,_salter:Rg}});var Gl=ie(us=>{us.Deflater=Ml();us.Inflater=zl();us.ZipCrypto=jl()});var Aa=ie(($1,Wl)=>{var se=sr(),Dg=Sa(),Se=se.Constants,Ia=Gl();Wl.exports=function(t,e){var r=new Dg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),p=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:se.decoder;p=E.hasOwnProperty("efs")?E.efs:!1;function T(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(h=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(se.crc32(y)!==r.localHeader.crc)return!1}else{let D={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Se.LOCSIG||e.readUInt32LE(k)==Se.CENSIG)throw se.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Se.EXTSIG)D.crc=e.readUInt32LE(k+Se.EXTCRC),D.compressedSize=e.readUInt32LE(k+Se.EXTSIZ),D.size=e.readUInt32LE(k+Se.EXTLEN);else if(e.readUInt16LE(k+12)===19280)D.crc=e.readUInt32LE(k+Se.EXTCRC-4),D.compressedSize=e.readUInt32LE(k+Se.EXTSIZ-4),D.size=e.readUInt32LE(k+Se.EXTLEN-4);else throw se.Errors.DESCRIPTOR_UNKNOWN();if(D.compressedSize!==r.compressedSize||D.size!==r.size||D.crc!==r.crc)throw se.Errors.DESCRIPTOR_FAULTY();if(se.crc32(y)!==D.crc)return!1}return!0}function v(y,D,k){if(typeof D>"u"&&typeof y=="string"&&(k=y,y=void 0),c)return y&&D&&D(Buffer.alloc(0),se.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=T();if(M.length===0)return y&&D&&D(M),M;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw se.Errors.INVALID_PASS_PARAM();M=Ia.ZipCrypto.decrypt(M,r,k)}var B=Buffer.alloc(r.size);switch(r.method){case se.Constants.STORED:if(M.copy(B),_(B))return y&&D&&D(B),B;throw y&&D&&D(B,se.Errors.BAD_CRC()),se.Errors.BAD_CRC();case se.Constants.DEFLATED:var J=new Ia.Inflater(M,r.size);if(y)J.inflateAsync(function(V){V.copy(V,0),D&&(_(V)?D(V):D(V,se.Errors.BAD_CRC()))});else{if(J.inflate(B).copy(B,0),!_(B))throw se.Errors.BAD_CRC(`"${E.decode(i)}"`);return B}break;default:throw y&&D&&D(Buffer.alloc(0),se.Errors.UNKNOWN_METHOD()),se.Errors.UNKNOWN_METHOD()}}function I(y,D){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&D&&D(T()),T();if(l.length&&!c){var k;switch(r.method){case se.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),y&&D&&D(k),k;default:case se.Constants.DEFLATED:var M=new Ia.Deflater(l);if(y)M.deflateAsync(function(J){k=Buffer.alloc(J.length),r.compressedSize=J.length,J.copy(k),D&&D(k)});else{var B=M.deflate();return r.compressedSize=B.length,B}M=null;break}}else if(y&&D)D(Buffer.alloc(0));else return Buffer.alloc(0)}function S(y,D){return se.readBigUInt64LE(y,D)}function C(y){try{for(var D=0,k,M,B;D+4<y.length;)k=y.readUInt16LE(D),D+=2,M=y.readUInt16LE(D),D+=2,B=y.slice(D,D+M),D+=M,Se.ID_ZIP64===k&&N(B)}catch{throw se.Errors.EXTRA_FIELD_PARSE_ERROR()}}function N(y){var D,k,M,B;y.length>=Se.EF_ZIP64_SCOMP&&(D=S(y,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=D)),y.length>=Se.EF_ZIP64_RHO&&(k=S(y,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=k)),y.length>=Se.EF_ZIP64_DSN&&(M=S(y,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=M)),y.length>=Se.EF_ZIP64_DSN+4&&(B=y.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(y){i=se.toBuffer(y,E.encode);var D=i[i.length-1];c=D===47||D===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,C(y)},get comment(){return E.decode(o)},set comment(y){if(o=se.toBuffer(y,E.encode),r.commentLength=o.length,o.length>65535)throw se.Errors.COMMENT_TOO_LONG()},get name(){var y=E.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){l=se.toBuffer(y,se.decoder.encode),!c&&l.length?(r.size=l.length,r.method=se.Constants.DEFLATED,r.crc=se.crc32(y),r.changed=!0):r.method=se.Constants.STORED},getData:function(y){return r.changed?l:v(!1,null,y)},getDataAsync:function(y,D){r.changed?y(l):v(!0,y,D)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),D=se.Constants.CENHDR;return i.copy(y,D),D+=i.length,u.copy(y,D),D+=r.extraLength,o.copy(y,D),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let D=r.localHeaderToBinary(),k=Buffer.alloc(D.length+i.length+r.extraLocalLength);return D.copy(k,y),y+=D.length,i.copy(k,y),y+=i.length,h.copy(k,y),y+=h.length,k},toJSON:function(){let y=function(D){return"<"+(D&&D.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Jl=ie((J1,$l)=>{var Kl=Aa(),kg=Sa(),We=sr();$l.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,u=null;let h=new Set,p=e,{noSort:m,decoder:E}=p;t?v(p.readEntries):l=!0;function T(){let S=new Set;for(let C of Object.keys(i)){let N=C.split("/");if(N.pop(),!!N.length)for(let y=0;y<N.length;y++){let D=N.slice(0,y+1).join("/")+"/";S.add(D)}}for(let C of S)if(!(C in i)){let N=new Kl(p);N.entryName=C,N.attr=16,N.temporary=!0,r.push(N),i[N.entryName]=N,h.add(N)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/We.Constants.CENHDR)throw We.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,C=0;C<r.length;C++){var N=S,y=new Kl(p,t);y.header=t.slice(N,N+=We.Constants.CENHDR),y.entryName=t.slice(N,N+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(N,N+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(N,N+y.header.commentLength)),S+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}h.clear(),T()}function v(S){var C=t.length-We.Constants.ENDHDR,N=Math.max(0,C-65535),y=N,D=t.length,k=-1,M=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(N=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===We.Constants.ENDSIG){k=C,M=C,D=C+We.Constants.ENDHDR,y=C-We.Constants.END64HDR;continue}if(t.readUInt32LE(C)===We.Constants.END64SIG){y=N;continue}if(t.readUInt32LE(C)===We.Constants.ZIP64SIG){k=C,D=C+We.readBigUInt64LE(t,C+We.Constants.ZIP64SIZE)+We.Constants.ZIP64LEAD;break}}if(k==-1)throw We.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,D)),c.commentLength&&(o=t.slice(M+We.Constants.ENDHDR)),S&&_()}function I(){r.length>1&&!m&&r.sort((S,C)=>S.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(S=>!h.has(S))},get comment(){return E.decode(o)},set comment(S){o=We.toBuffer(S,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||_(),i[S]||null},setEntry:function(S){l||_(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,C=!0){l||_();let N=i[S];this.getEntryChildren(N,C).map(D=>D.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||_();let C=i[S],N=r.indexOf(C);N>=0&&(r.splice(N,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,C=!0){if(l||_(),typeof S=="object")if(S.isDirectory&&C){let N=[],y=S.entryName;for(let D of r)D.entryName.startsWith(y)&&N.push(D);return N}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let C=this.getEntryChildren(S);return C.includes(S)?C.length-1:C.length}return 0},compressToBuffer:function(){l||_(),I();let S=[],C=[],N=0,y=0;c.size=0,c.offset=0;let D=0;for(let B of this.entries){let J=B.getCompressedData();B.header.offset=y;let V=B.packLocalHeader(),ee=V.length+J.length;y+=ee,S.push(V),S.push(J);let X=B.packCentralHeader();C.push(X),c.size+=X.length,N+=ee+X.length,D++}N+=c.mainHeaderSize,c.offset=y,c.totalEntries=D,y=0;let k=Buffer.alloc(N);for(let B of S)B.copy(k,y),y+=B.length;for(let B of C)B.copy(k,y),y+=B.length;let M=c.toBinary();return o&&o.copy(M,We.Constants.ENDHDR),M.copy(k,y),t=k,l=!1,k},toAsyncBuffer:function(S,C,N,y){try{l||_(),I();let D=[],k=[],M=0,B=0,J=0;c.size=0,c.offset=0;let V=function(ee){if(ee.length>0){let X=ee.shift(),ye=X.entryName+X.extra.toString();N&&N(ye),X.getCompressedDataAsync(function(fe){y&&y(ye),X.header.offset=B;let P=X.packLocalHeader(),q=P.length+fe.length;B+=q,D.push(P),D.push(fe);let W=X.packCentralHeader();k.push(W),c.size+=W.length,M+=q+W.length,J++,V(ee)})}else{M+=c.mainHeaderSize,c.offset=B,c.totalEntries=J,B=0;let X=Buffer.alloc(M);D.forEach(function(fe){fe.copy(X,B),B+=fe.length}),k.forEach(function(fe){fe.copy(X,B),B+=fe.length});let ye=c.toBinary();o&&o.copy(ye,We.Constants.ENDHDR),ye.copy(X,B),t=X,l=!1,S(X)}};V(Array.from(this.entries))}catch(D){C(D)}}}}});var Zl=ie((V1,Yl)=>{var _e=sr(),we=ce("path"),Og=Aa(),Pg=Jl(),Tn=(...t)=>_e.findLast(t,e=>typeof e=="boolean"),Vl=(...t)=>_e.findLast(t,e=>typeof e=="string"),Ng=(...t)=>_e.findLast(t,e=>typeof e=="function"),Lg={noSort:!1,readEntries:!1,method:_e.Constants.NONE,fs:null};Yl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Lg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=_e.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new _e(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=_e.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=_e.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw _e.Errors.INVALID_FILENAME();let c=new Pg(r,i),{canonical:l,sanitize:u,zipnamefix:h}=_e;function p(_){if(_&&c){var v;if(typeof _=="string"&&(v=c.getEntry(we.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(v=c.getEntry(_.entryName)),v)return v}return null}function m(_){let{join:v,normalize:I,sep:S}=we.posix;return v(we.isAbsolute(_)?"/":".",I(S+_.split("\\").join(S)+S))}function E(_){return _ instanceof RegExp?(function(v){return function(I){return v.test(I)}})(_):typeof _!="function"?()=>!0:_}let T=(_,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",we.relative(_,v)+I};return{readFile:function(_,v){var I=p(_);return I&&I.getData(v)||null},childCount:function(_){let v=p(_);if(v)return c.getChildCount(v)},readFileAsync:function(_,v){var I=p(_);I?I.getDataAsync(v):v(null,"getEntry failed for:"+_)},readAsText:function(_,v){var I=p(_);if(I){var S=I.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(_,v,I){var S=p(_);S?S.getDataAsync(function(C,N){if(N){v(C,N);return}C&&C.length?v(C.toString(I||"utf8")):v("")}):v("")},deleteFile:function(_,v=!0){var I=p(_);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(_){var v=p(_);v&&c.deleteEntry(v.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,v){var I=p(_);I&&(I.comment=v)},getZipEntryComment:function(_){var v=p(_);return v&&v.comment||""},updateFile:function(_,v){var I=p(_);I&&I.setData(v)},addLocalFile:function(_,v,I,S){if(o.fs.existsSync(_)){v=v?m(v):"";let C=we.win32.basename(we.win32.normalize(_));v+=I||C;let N=o.fs.statSync(_),y=N.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);N.isDirectory()&&(v+=o.sep),this.addFile(v,y,S,N)}else throw _e.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,v){_=typeof _=="object"?_:{localPath:_};let I=we.resolve(_.localPath),{comment:S}=_,{zipPath:C,zipName:N}=_,y=this;o.fs.stat(I,function(D,k){if(D)return v(D,!1);C=C?m(C):"";let M=we.win32.basename(we.win32.normalize(I));if(C+=N||M,k.isFile())o.fs.readFile(I,function(B,J){return B?v(B,!1):(y.addFile(C,J,S,k),setImmediate(v,void 0,!0))});else if(k.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),S,k),setImmediate(v,void 0,!0)})},addLocalFolder:function(_,v,I){if(I=E(I),v=v?m(v):"",_=we.normalize(_),o.fs.existsSync(_)){let S=o.findFiles(_),C=this;if(S.length)for(let N of S){let y=we.join(v,T(_,N));I(y)&&C.addLocalFile(N,we.dirname(y))}}else throw _e.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,v,I,S){S=E(S),I=I?m(I):"",_=we.normalize(_);var C=this;o.fs.open(_,"r",function(N){if(N&&N.code==="ENOENT")v(void 0,_e.Errors.FILE_NOT_FOUND(_));else if(N)v(void 0,N);else{var y=o.findFiles(_),D=-1,k=function(){if(D+=1,D<y.length){var M=y[D],B=T(_,M).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(M,function(J,V){J&&v(void 0,J),V.isFile()?o.fs.readFile(M,function(ee,X){ee?v(void 0,ee):(C.addFile(I+B,X,"",V),k())}):(C.addFile(I+B+"/",Buffer.alloc(0),"",V),k())}):process.nextTick(()=>{k()})}else v(!0,void 0)};k()}})},addLocalFolderAsync2:function(_,v){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=we.resolve(m(_.localPath));let{zipPath:S,filter:C,namefix:N}=_;C instanceof RegExp?C=(function(k){return function(M){return k.test(M)}})(C):typeof C!="function"&&(C=function(){return!0}),S=S?m(S):"",N=="latin1"&&(N=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof N!="function"&&(N=k=>k);let y=k=>we.join(S,N(T(localPath,k))),D=k=>we.win32.basename(we.win32.normalize(N(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?v(void 0,_e.Errors.FILE_NOT_FOUND(localPath)):k?v(void 0,k):o.findFilesAsync(localPath,function(M,B){if(M)return v(M);B=B.filter(J=>C(y(J))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(J,V){return function(ee,X){if(ee||X===!1)return setImmediate(J,ee,!1);I.addLocalFileAsync({localPath:V,zipPath:we.dirname(y(V)),zipName:D(V)},J)}},v))})})},addLocalFolderPromise:function(_,v){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},v),(C,N)=>{C&&S(C),N&&I(this)})})},addFile:function(_,v,I,S){_=h(_);let C=p(_),N=C!=null;N||(C=new Og(i),C.entryName=_),C.comment=I||"";let y=typeof S=="object"&&S instanceof o.fs.Stats;y&&(C.header.time=S.mtime);var D=C.isDirectory?16:0;let k=C.isDirectory?16384:32768;return y?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=C.isDirectory?493:420,D=(D|k<<16)>>>0,C.attr=D,C.setData(v),N||c.setEntry(C),C},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return p(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,v,I,S,C,N){S=Tn(!1,S),C=Tn(!1,C),I=Tn(!0,I),N=Vl(C,N);var y=p(_);if(!y)throw _e.Errors.NO_ENTRY();var D=l(y.entryName),k=u(v,N&&!y.isDirectory?N:I?D:we.basename(D));if(y.isDirectory){var M=c.getEntryChildren(y);return M.forEach(function(V){if(V.isDirectory)return;var ee=V.getData();if(!ee)throw _e.Errors.CANT_EXTRACT_FILE();var X=l(V.entryName),ye=u(v,I?X:we.basename(X));let fe=C?V.header.fileAttr:void 0;o.writeFileTo(ye,ee,S,fe)}),!0}var B=y.getData(c.password);if(!B)throw _e.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!S)throw _e.Errors.CANT_OVERRIDE();let J=C?_.header.fileAttr:void 0;return o.writeFileTo(k,B,S,J),!0},test:function(_){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,v,I,S){if(I=Tn(!1,I),S=Vl(I,S),v=Tn(!1,v),!c)throw _e.Errors.NO_ZIP();c.entries.forEach(function(C){var N=u(_,l(C.entryName));if(C.isDirectory){o.makeDir(N);return}var y=C.getData(S);if(!y)throw _e.Errors.CANT_EXTRACT_FILE();let D=I?C.header.fileAttr:void 0;o.writeFileTo(N,y,v,D);try{o.fs.utimesSync(N,C.header.time,C.header.time)}catch{throw _e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,v,I,S){if(S=Ng(v,I,S),I=Tn(!1,I),v=Tn(!1,v),!S)return new Promise((k,M)=>{this.extractAllToAsync(_,v,I,function(B){B?M(B):k(this)})});if(!c){S(_e.Errors.NO_ZIP());return}_=we.resolve(_);let C=k=>u(_,we.normalize(l(k.entryName))),N=(k,M)=>new Error(k+': "'+M+'"'),y=[],D=[];c.entries.forEach(k=>{k.isDirectory?y.push(k):D.push(k)});for(let k of y){let M=C(k),B=I?k.header.fileAttr:void 0;try{o.makeDir(M),B&&o.fs.chmodSync(M,B),o.fs.utimesSync(M,k.header.time,k.header.time)}catch{S(N("Unable to create folder",M))}}D.reverse().reduce(function(k,M){return function(B){if(B)k(B);else{let J=we.normalize(l(M.entryName)),V=u(_,J);M.getDataAsync(function(ee,X){if(X)k(X);else if(!ee)k(_e.Errors.CANT_EXTRACT_FILE());else{let ye=I?M.header.fileAttr:void 0;o.writeFileToAsync(V,ee,v,ye,function(fe){fe||k(N("Unable to write file",V)),o.fs.utimes(V,M.header.time,M.header.time,function(P){P?k(N("Unable to set times",V)):k()})})}})}}},S)()},writeZip:function(_,v){if(arguments.length===1&&typeof _=="function"&&(v=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(_,I,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(_,v){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},v);return new Promise((C,N)=>{!_&&i.filename&&(_=i.filename),_||N("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let D=k=>k?C(k):N("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,I,S,D)},N)})},toBufferPromise:function(){return new Promise((_,v)=>{c.toAsyncBuffer(_,v)})},toBuffer:function(_,v,I,S){return typeof _=="function"?(c.toAsyncBuffer(_,v,I,S),null):c.compressToBuffer()}}}});import{execFile as I_,spawn as A_,spawnSync as cA}from"node:child_process";import{promisify as T_}from"node:util";function C_(t){if(process.platform!=="win32")return!1;if(Kf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Kf,"").toLowerCase();return R_.has(r)}function $f(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return C_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function lt(t,e=[],r={}){return A_(t,e,$f(t,r))}function Jf(t,e=[],r={}){return D_(t,e,$f(t,r))}var R_,Kf,D_,yn=Ze(()=>{"use strict";R_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Kf=/\.(cmd|bat|ps1)$/i;D_=T_(I_)});var j0=ie(ke=>{"use strict";var L=H;(function(t,e){let r=H,i=t();for(;;)try{if(-parseInt(r(870))/1+parseInt(r(1234))/2+parseInt(r(1050))/3+-parseInt(r(1568))/4*(-parseInt(r(832))/5)+-parseInt(r(363))/6+-parseInt(r(829))/7+parseInt(r(1762))/8===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(yo,624207);var pE=Object[L(1529)+L(1021)],gE=Object[L(805)+"opertyNames"],z0=(t,e)=>function(){return t&&(e=(0,t[{PGlfz:function(c,l){return c(l)}}[L(388)](gE,t)[0]])(t=0)),e},mE=(t,e)=>{for(var r in e)pE(t,r,{get:e[r],enumerable:!0})};function wE(){return P0||(P0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _E(){let t=L;return N0||(N0=[IDBCursor[t(497)+"e"][t(392)],IDBCursor[t(497)+"e"].continue,IDBCursor.prototype[t(446)+t(1073)+"ey"]])}function yE(t){let e=L,r={wMXVM:"success",vXOJn:e(1304),PaBWC:function(o,c){return o(c)},MxnXh:function(o){return o()},ASoMO:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={atnMz:function(E,T){return r[H(1534)](E,T)},wtumj:function(E){return r[H(1289)](E)}},h=()=>{let E=H;t[E(1699)+E(1262)+"ner"](r.wMXVM,p),t[E(1699)+E(1262)+"ner"](r[E(1078)],m)},p=()=>{u[H(746)](o,u.atnMz(Mt,t.result)),h()},m=()=>{let E=H;u[E(746)](c,t[E(1304)]),u[E(1815)](h)};t[l(510)+l(1469)](r[l(1686)],p),t["addEvent"+l(1469)](r[l(1078)],m)});return i[e(1491)](o=>{let c=e;r[c(409)](o,IDBCursor)&&Xc[c(941)](o,t)})[e(1554)](()=>{}),bo[e(941)](i,t),i}function H(t,e){t=t-347;let r=yo(),i=r[t];if(H.kvCSId===void 0){var o=function(h){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let T=0,_,v,I=0;v=h.charAt(I++);~v&&(_=T%4?_*64+v:v,T++%4)?m+=String.fromCharCode(255&_>>(-2*T&6)):0)v=p.indexOf(v);for(let T=0,_=m.length;T<_;T++)E+="%"+("00"+m.charCodeAt(T).toString(16)).slice(-2);return decodeURIComponent(E)};H.cuUwva=o,H.AoSuSV={},H.kvCSId=!0}let c=r[0],l=t+c,u=H.AoSuSV[l];return u?i=u:(i=H.cuUwva(i),H.AoSuSV[l]=i),i}function EE(t){let e=L,r={jeztj:e(1304),QfBnB:"abort",ujDjM:function(o){return o()},mRxZs:e(542)+"or"};if(Eo.has(t))return;let i=new Promise((o,c)=>{let l=e,u=()=>{let m=H;t[m(1699)+m(1262)+m(1231)](m(479),h),t["removeEv"+m(1262)+"ner"](r[m(776)],p),t[m(1699)+m(1262)+m(1231)](r[m(1606)],p)},h=()=>{r[H(866)](o),u()},p=()=>{let m=H;c(t[m(1304)]||new DOMException(m(542)+"or",r[m(1290)])),r.ujDjM(u)};t[l(510)+l(1469)](l(479),h),t[l(510)+l(1469)](r[l(776)],p),t[l(510)+l(1469)](r.QfBnB,p)});Eo[e(941)](t,i)}function bE(t){vo={Faqpi:function(i,o){return i(o)}}[L(702)](t,vo)}function vE(t){let e=L,r={vZfrl:e(1646),RdvXP:function(i,o){return i(o)},krrLB:function(i,o){return i===o},EjBLD:function(i,o){return i in o},fWcyk:e(1072)+e(381),cnxDy:function(i){return i()}};return r.krrLB(t,IDBDatabase[e(497)+"e"]["transact"+e(564)])&&!r[e(781)](r.fWcyk,IDBTransaction[e(497)+"e"])?function(i,...o){let c=e;if(r[c(1115)]==="ssidx")_0x811d92.d=(l,u)=>{let h=c;for(var p in u)_0x214fd8.o(u,p)&&!_0x55cde0.o(l,p)&&_0x1f0828[h(1529)+h(1021)](l,p,{enumerable:!0,get:u[p]})};else{let l=t.call(Bi(this),i,...o);return Zc[c(941)](l,i.sort?i[c(894)]():[i]),r.RdvXP(Mt,l)}}:r[e(1312)](_E).includes(t)?function(...i){let o=e;return t[o(898)](Bi(this),i),Mt(Xc[o(633)](this))}:function(...i){return Mt(t[e(898)](Bi(this),i))}}function SE(t){let e=L,r={MBYqo:e(1588),hFXgQ:function(i,o){return i(o)},rBsfA:function(i,o){return i instanceof o},ZYBJk:function(i,o,c){return i(o,c)},wXeKV:function(i){return i()}};return typeof t===r.MBYqo?r[e(1308)](vE,t):(r[e(872)](t,IDBTransaction)&&r.hFXgQ(EE,t),r[e(1089)](F0,t,r.wXeKV(wE))?new Proxy(t,vo):t)}function Mt(t){let e=L,r={SYIYy:function(o,c){return o instanceof c},WnBWm:function(o,c){return o(c)},sreVW:function(o,c){return o!==c}};if(r[e(560)](t,IDBRequest))return yE(t);if(wo[e(1596)](t))return wo[e(633)](t);let i=r[e(1364)](SE,t);return r.sreVW(i,t)&&(wo[e(941)](t,i),bo[e(941)](i,t)),i}function yo(){let t=["zMzmAw5L","rwjmsem","tLnfqxq","Aw1LCYbPBIa","uM9OtLO","zxjYtM8","Avb5zwO","AwztqMi","s1LntLK","Dw50","A1nYu3u","quXiz2m","zxjFywnRx20","s3z1wMG","CMvpCKi","C2v0sxrLBq","ig1LC3nHz2u","z2v0sxrLBq","CIb0DhDjra","Cg9LDem","ChbmBui","yw1LoIa","mteWnZuYntz6z1Hqy3a","ueLYuuC","CgzsBKq","yMrKv3O","D3nZoI8V","BwLZzq","z1DlAva","zM9Yy2u","zufJAW","vw5PBxbSzw0","Cwz5wLy","BezSDxnO","Axzpwee","rLLMzNC","CKLWDhe","CMfUzg9T","yxLoAuu","CLb1rhO","sNLNwMS","CufRrgq","y3vYDMfSDwu","EKjrDwO","CNzHBa","rKHQq3m","q2fQyxi","reLXrve","x2n1CNnVCKy","ExvWC2u","CMLLC0nVDw4","wKToy0W","EMnuDgi","z2v0s2v5","m3W0Fdj8mhW","CKrQAMi","C2v0q3vYC28","vK1YChK","ChPkrLG","sKj4BfC","q1bPzg8","z2vtEw5J","yM9KEq","wxnbD1e","Dhr3Awq","Bwf4uMv0CMK","Exf0tui","DunHAfC","quXm","ihrPBwvZ","uvHvDLi","rMPNC2q","twLZC2LUzYa","zxjFAxnFywm","C0fbwvi","D3r1BwO","y1b6sui","x29UtwvZC2e","ExfirKy","CgvYC2LZDgu","qMPythe","tuntrvm","wfHLCui","C2HPzNq","ChjVy2vZCW","tLvStK0","C2HKDuy","y2uGBM90igK","D2LSBfjLy28","rvv6v20","x2LUAxq","uM9pu0u","yMfJA3vWigu","v054AvG","y2XVC2u","tKfUChe","wNP6vwG","AeLlsK8","y3ruAw1LB3u","ww1iq3G","s3bjqxm","x29UugfNzu4","CMvZzxruCMK","suvtx0vsuK8","sff0s0G","vwfjrKe","AhPPB3u","u3vTvxe","CMvHzhDYAxq","mdaWmdaWmda","A2v5","zuLZu1O","Ee1csNq","q0Xpu0ve","yLDRy1e","x3bYzwzPEa","tuztsvO","yNL0zu9MzNm","vhHREgW","q2Hqs3C","z2vY","Aw9xv2O","BwPyEw8","DeLUDgvYy2u","u0LcEgq","Ahb4DLG","v25vqw8","x3bHDgHlzxK","AxnAzxjV","zfnwDNy","DujhzfG","x2rLC3rYB3K","AxnmB25N","nJe2mZi0mMLkAgXetG","ENzqs0i","z2v0q3vYC28","DeLK","z3zkve0","uNjyyuq","mxWZFdr8mhW","ELvbtK4","r09guva","CK9kue8","nxWY","zg1RDNG","y29UC3rYDwm","zhvKqLy","wuryCNa","yxv0BW","BhPHsMu","DMfSDwu","B3jLtMfTzxm","BMnVzgLUzW","A1npC2W","tMn0vNy","qKjSsuO","rNvQBhu","EuH1wKO","ueDSzNO","vefzCgm","vgf3s2O","Bhzky3G","ywr2yw5Jzq","C1HivMi","Dg9cExrLCW","B25szwnLAxy","tMjfC3a","BxnN","zv90Aw1LB3u","BujSrKi","CMvWBgfJzui","DhjHBNnHy3q","t1bftL9fuLi","A2v0ignVBNm","CgLUz09Uy2u","ugPLwva","ALzcBfK","BNrLCG","CNjVCK1LC3m","qvnVtu8","AxDcr1a","rwX4q3q","vfDKCwG","x2vUzhbVAw4","BgvUz3rO","swvrzLK","swPXtKq","Bgzmqwq","wfnwz3C","Axnby2TdBgu","y2XVC2veqG","DKryENi","B25dBg9Zzq","m3WXFdj8nhW","qNjPzgDL","s0rcz2q","wKjVExa","x29UrxjYB3i","BuXcsNm","zuP4zNK","Bxv6swq","v3nxtMu","icSG","Cfz6y0m","igXHCMDLCIa","qLvJt24","zxjYtxnN","BKXPBMu","zhLJB3m","tgf0rhK","vfPLsuO","qKfRqNa","CMvZDwX0","y3jLyxrLrwW","A2TtwfK","rxjYB3jdB2q","y29UDgLUDwu","z2PAuMW","svfwwxe","CM92AwrLigi","wMfQqLi","tMv3qNa","wMHzshm","EhvPBvG","sgLqD0u","CMngshO","vKHVweO","y3vYC29Y","EerJEfK","CNjgBxu","qvDtq2W","s0zHuKC","Aw5JBhvKzxm","DxrMofDYAxq","r0f0AhC","tLjhqw8","qMrftw4","CNnVCL92ywW","CMvKDwnL","qNjsvwO","zfbnqu0","vwr5A00","CLzUqMy","z2vrDwv1zuW","DxLfEfy","r1fjAgy","DLnwtLO","zhP1yw8","s01bAfy","y29TCgXLDgu","C2X1tuG","y3jLyxrLq2W","q1bLsvu","BNzmteW","DhDVCMTdAge","Aw47y2HHCNm","zwn0","uK1tyxO","zKPiyuS","x2DLDeLUDgu","zgXLtgK","txnHB0m","sgDZB2m","swDPrKG","B25Uzwn0Aw4","DxnLCKLW","Ew1KD0G","ChjVDg90Exa","v1HVswi","qKDvz00","rxvzzwO","yMHxBhO","Ew9hBg8","Cg9W","rwPzr2i","Bg93","r3r0DxK","EwPntNi","qw1VDw50","CNnVCKzPBgu","ywrKrxzLBNq","B2LUDfjLywm","sw5Ry2m","DcbSAw1PDa","DfvZywy","x2nYzwf0zvm","D3n3r0m","seDnwfy","tuvtu0fhrv8","qu1Vq1q","lcbOB3n0BMe","mxW0Fda","u2rxy3i","t3jNwe0","AejHrhm","Du9zr0q","x2nSzwfYvgK","rNjVBNrPzxi","D3jPDgvvAw4","mNWW","BNruCMLLC0m","C3rYAw5NAwy","zNjVBu51Bwi","Bg9NsurozxC","yMXVy2TLza","zwnVBM5Ly3q","tg9Nsuq","DgfYz2v0","sNveA1m","zv9ZDwnJzxm","ugXmv2S","BwDYAuK","qwjVCNrfCNi","yw5ZzM9YBvq","x2rYB3bhBg8","x29Uq2XVC2u","rKfHCvG","sKPMBfy","z0TlvNK","D2HcqKq","CMvHzg9UBhK","zgfIzve","EefMwgS","EujTEey","BM5Ly3q","rxvZEM8","tvDvt0i","DLLxr2u","Dw5ZAwDUzwq","DfPlCM4","u1LjwxK","x2LZtwLUAvC","AefJA01LC3m","Au9VsvG","Aw9U","Dev2zw50","C2nYAxb0","EsbJBg9Zzwq","rvjst1i","Ce9vtxO","ExbZChC","CNzHBfzHBhu","qxHbEgG","C0TszNu","tw9KDwXL","nxWYFdz8m3W","Dg9Y","DgPjreK","vw5Oyw5KBgu","uxrhDLq","tKrPseK","Chf6s2q","uvDJqKy","s0DbtLm","C3bSAxq","qu5ouLG","AvHAu28","svzQt2K","EfH5qxu","B3bLBG","seHzvuu","Ae1LC3nHz2u","s3DQrKe","ywDLu2HVDW","DhnOweC","rLDt","zNH2vfa","twvZC2fNzuu","CNbTtuu","Ahn5Chq","r1PjDMq","rM5yBee","qvDVqKy","B2nRzxrtDwm","s1LpCuy","y29SBM8","CMvZzxrdB3u","uvfKCw8","yMjqDui","DgLTzw91DcW","rgXusgq","ihrVihjLDhi","sNjAqLm","De93CKW","suXgCw0","uMTSrhi","Aw5PDcbrB1m","zNDZxZeUmc4","ueXJBhu","rLHYt0O","yw5Nzq","tM1oB04","tMLnC0C","aaaaaaaaaaa","wK5Wuu0","CgfYC2u","zNb6Cfi","A0XcCwC","uer2AMC","CMvJzxzPzwq","DvjKEM0","x29Ut3bLBG","Bwv0Ag9K","z2v0","ywWGy3vYC28","x2HHBMrSzva","sefkDNG","q3vZDg9Tq2W","zMLSDgvY","CM92AwrLihy","D05szNu","AMLewee","Ec1TC2CTy3u","y3z1sMO","ufvbBMS","CuLXtfq","C3vJy2vZCW","x2nSzwfYugK","ywT1zwu","uxDvqK0","x2LUDgvYDMe","uLHHrK4","EKL1v1i","x3jLywr5q2W","sLnptLa","zxmGCMvHy2G","CMvTB3zLq2G","BMCGB3iGyw4","y2HLy2Tszwe","FdH8oxWY","yxnL","igzPzwXKoIa","t1PRyKK","CM11Ehu","DMX5wxy","v2zVy1C","senbsem","CgXLyxnLiha","tgP1y3m","EMXjrha","mNW1Fdf8na","AfrpzuK","yMjWreG","y3jLyxrLt3a","twTTuwO","v2XruKq","vff6AwW","B2zMC2v0","wvPvA0m","BNvTyMvY","tLP3CuO","B0noAMK","B25VCgvU","s01jDLy","ugn4rwG","AhLLuum","BNHuuLq","DgvZDa","DNnIA1G","z2v0qwXSs2u","vwzwuhy","x2HHBMrSzu8","wMHXEhG","y29UDgv4Da","Cu5IugO","Ahr0Chm6","zMX1C2HfEha","EwPKqK8","r1vZANq","y2XVC2uSihC","zKzqC2u","sK54Cem","rMfXCgK","AwXLx25HBwu","uhPKwha","ywnOzwqSihC","zcWG","ihjLy29UBMu","quTpD0q","A2jdyNy","yLzIAMK","CKLsDLG","zMzLCG","vxDWAgO","EK5nyu0","tNzlzMS","u2TPCcbWyxm","x3DZsw5ZDge","v3nTvNq","C3rYAw5N","zw5HyMXLuw8","rhrLAuK","rvrmCuy","q3nvA0i","AM9PBG","vgfN","z2v0q3vYCMu","C3bSAwnL","D2rmquK","B25JBg9Zzq","vMXssMW","C21xAMm","Aw5L","Dg9cExrLC0i","x3bPBMC","Dw5RBM93BIa","yxrLq291BNq","AwXLtMfTzq","ChvZAa","C2nHwgG","DMPyBK8","D3m6lY8","yw1owgO","wvLlr2i","A3rRvKW","q0Xpu0LorW","yxrUtxO","DfDwCu4","ru93yKK","ywnRtxnNswq","BfrPBwvVDxq","v3vxsKK","DvDev0K","y3jLyxrLrxi","BNjMCfO","uwnJywu","suHcs1y","Bg9N","sKX3AuK","z05eD0m","CgLUz0XVC3m","x19LC01Vzhu","yLfuAwO","x2LZsw5PDa","ExDRAwi","zMLvBvC","BMrSyNu","y1P5zu8","zw5XDwv1zq","u2zeqMy","sKj2DLa","q29UzMLN","CKHLCKy","BwLUAvbYB2C","EMXouNC","uNfuy3C","AMv6DgO","y29Kzq","B25TzxnZywC","AxjKy2K","sLzXCve","rwPcteq","Dujys0y","qKHcsMi","rhPnqxy","BwfW","C0XPC3rLBMu","mxWW","DxPUCeu","Def4ywm","Cgr3A3u","B3bLBKrc","ww96y1O","suTrrKe","ywXPzcb1CMW","wvPLD0S","tg9NsurozxC","ELPwt1O","whjzu1q","wxzbqLa","zMXYvKK","ELLMBMm","rMLACLK","Du5gseO","rezuzeC","z2v0t3DUuhi","tvfeEgm","CxPgs0m","AxnrB1nby2S","x0rctMfTzq","vu9uuee","zun0qxG","A3rTtve","DcbVzIbYyw4","A2rwAxC","zw1PDa","yxv0B21HDgK","ywDLrxzLBNq","DxjS","BeT5yxq","Ef9MCM9UDgK","weHYy0y","CffIsuS","C29NvvO","y2HLy2TdDxi","tffXyvq","Dg9oDw1Izxi","v25MzxG","x21LC3nHz2u","nte0nJq0ouPtvK5eCW","BefWt0i","BujWzg8","mJG1ntyZnuv0twfIrW","C3vIC3rYAw4","q3vZDg9Trxi","D09HwKS","BgLTAxq","qKjbEKW","uNjkvvK","sMP0EhG","pxv0zI04","BKPHAuO","Cgf5Bg9Hzfq","zK1JEMK","BgLUzw5V","sKvvD3C","AgvHzgvY","CgLUz19VBMm","y3Hdyw4","yxLmBfC","tNHgAwe","werTBw0","ywzL","yw5Hz2vY","C0z0CwO","B2nRzxrgywK","BgTsu2S","Avffz0q","AgDfy1y","z3Hithq","quvYEw8","uMvJB25Uzwm","x3DZ","u29nz1m","CM92AwrLihC","y3vYCMvUDeK","DwPeAK0","x3bYB3rVy28","DMvYC2LVBMm","BeTWswG","nZK4otC5tKDwEKLe","vfzTuxG","CKjZzKe","u0PfqKq","r2Dqr2i","x2fKzfDZtgK","yMrFzgLK","zxHWB3j0CW","ruP3yvm","CgTQvNy","B25cvKq","sMnrsMe","x21PBMLoyxy","Dg9tDhjPBMC","t2vdr28","v1jhs3y","vejfB0q","BwvZC2fNztO","CMTLCKDSB2i","CgrxANi","uMvHzcbWyxm","zgv2AwnLx2K","DhjPBq","D3jPDgu","C29YDa","q0vwuNO","uufVD3m","wMHSqK8","yxbWBhK","yNL0zxm","te1Otey","wLvvAhy","vu5Yq1u","zM9YrwfJAa","DNDIvKe","zMLSzw5HBwu","Dgv4DfbHEwW","x2LZtM9Kzq","u0TIqLG","BML0AwfSAxO","AfjeEw8","x2n1CNnVCK4","zw5wEKq","CM92AwrLige","z2v0u3rVCMe","sfLps3i","C2vAsNu","qMPMBfC","wxziuNG","rur5C2K","EuDyqvG","uMnRwvK","BeHHBMrSzxi","mxWZFdv8nhW","ysbTDxn0igi","z3HQzwS","x3nLBMrby2S","y3vYCMvUDeu","BMv4DcGPigm","BgPovw0","BM93","BwvKAwf0zwW","y291BNq","teD2EK4","C3rVCMu","vwjVyKO","v0L4Cfa","sLLJuxG","EgnzzhO","zNnvzgW","zMDrvKG","C2v0","AfrUD08","mhWXFdn8nhW","ruzyvwm","zgTmqLG","rwDxvLK","zwjJB3C","AhDky3C","Dfn1tvK","B21itMS","D0rJB3K","t3bLBKv2zw4","swj1tuG","rMLjt0S","x194x21Zz18","DgT5z3C","CLzHBhvLCW","BLveCha","z29UBMy","AwDHDg9Yt24","uuL0EvK","uePxue8","sMHXtNy","z1rqwu4","x29WDgLVBNm","B2fK","Cgu6ia","zw50","uezKreO","rw1ewe4","v1zuqNm","rgfXu28","yxbWzw5Kq2G","qNDhCgS","q291BNq","Exn6CwS","zfDVCMTLCKC","uwvgrMe","C3nHz2vfDMu","wgzOAhq","B3jRig9MzMW","thb1swe","Chv0","u3vkC3y","CwHxDvC","BNrfBMrWB2K","ExbL","Cg14Dha","C2TXufC","zxbxC2K","rgvKAwnHDgu","A0P2whu","tufyx1jfvfi","CMvJzwL2zwq","nhWZFdf8mNW","x25HDMLNyxq","shbYuxO","CMvHzhLtDge","BePWC08","ignVzgu6ia","yurJqM4","Ee9Hzu8","t01Qy2q","Bg5gq0i","reLWDfe","rxn0wKO","ALDXz2S","yNPtANy","wNfPA2m","q09otKvdveK","DgLUzYbZzxi","BK9pAwC","uev5zMm","sKH0Eve","x2LZtwLUAvq","CMToveu","sfjksvu","Cw9Zx18","re1XDM8","AwXK","B3bLCNr5","C2v0zgi","Dg1JzxK","whLcENO","r3L6qum","yw1L","BxnNsuq","vfbWvKy","AenSB3nLrxy","tuTZq3i","veDLr3e","C0nVDw50zxi","zMzMzG","zer0qvO","B3jpBMXPBMu","q2fWwuC","CMv0CNLdB3u","wvr6Bui","BLrUuuC","quPqveC","AgfZt3DUuhi","CunNCfe","zxjFDhrS","DxDtDeO","v1jZv3i","terYCxe","A0nmq1i","Cg93","x3DHAxq","ndaWmdHxue1jENm","Aw9Ul2PZB24","yMLUza","yNvMzMvY","sNrgA0G","Aw9UvgLTzw8","BKjUCve","v05ewMy","zwjdyuW","yw51Ce1LC3m","t1bftG","uMvhwhe","zNjVBuj5Dgu","mNW0Fdf8mhW","uurIv20","y2Lvywy","qLH1Aeq","qwXRruy","wgT5DhK","u1LmCe0","A3LcAwe","m3W0Fdf8mhW","B2jQzwn0u3q","uhjPBwfYEuS","zw5JB2rPBMC","rffvzxe","sxnICMW","lcbxzwjtB2m","DLHpsM4","BLHKrxK","qMHmrve","y29UBMvJDca","r2zfC0y","zgvIDwC","ywDLsgLKzq","uMLdExy","AgfUz2u","Aw5KzxHpzG","ywXty29Wzq","wLLcsMS","C01Usei","vhPvyxC","t0PrAwS","v2LUzg93","D1vNDLu","EMHVsvK","DMffzhO","DgLLCKPtt04","twvtDw4","Dg9iyxnO","Dg9VigXHCMC","BMTWvhK","ruPPDNC","EwXKtKC","CMvHzfvjBNq","AxjLza","EuDLwhi","B0XQq2u","tvbdB24","y3bZC00","x2zVCM1HDeu","u0XNsw8","z2u6ia","yxnJCMLWDa","mhW1Fdf8mta","DLPMCMW","y3jLyxrLtwu","y2HHCKnVzgu","BwX1vxi","CgfNzxnOB3C","s0LTA1m","q1DdAfa","AM1TBLK","vvn6EuO","rwvPquW","CLrwy3a","sfzmzKC","AvD3ywu","BwvZC2fNzq","B3nLrxzLBNq","C2v0y3vYC28","ExztEvC","B25tDgfYDfi","zsbHihn0CMK","x2TLEvbHDgG","zvvXtvK","AgvHzgvYCW","t3nUBfO","zK5vyvC","x2LUAxrhBg8","z0rUwu0","zhfjA20","x2rLyNvN","rfHQCMy","v0LTqM8","ChjVDg9JB2W","AxnrB1nnzxm","AhfYzuW","rLjptLrjrvi","ihzHBgLKigq","ywrK","ANnrCNO","t3DLC1K","tLzpsMu","uLrbCxK","BIWGAg9ZDg4","x2n1CNnVCK0","BwvY","q29Kzq","AxmGDw5Kzwy","BNnKwfC","C3rLBMvYCW","Cg5TAMu","ywnR","BhnZt2q","Efz4s2u","Au9nufK","Aw5KzxG","B2jXD28","A09myMS","yM1ct2q","D2vI","AgzXAKe","zw5KCg9PBNq","A2vzv2G","B05PB1e","wej5t1e","zNbZqxu","y3HoD1i","DgLTzw91Da","D2vQEKq","D0nTswq","B2zMBgLUzq","zxrxB3jRq2G","x2rPC3bHDgm","AeHvswq","q3LhANK","D21Xq0y","x3bPBMDqB24","zePOtLi","vufuzgO","vvr1BNi","BhfJzLK","CMvXDwLYzwq","zgvJB2rLzey","y3j6Eva","zK1qu1O","BMCGzMfPBgu","uKvxswq","AvLcwfe","vhP3zgy","Avz4Bhy","rLb2zgG","Evj5vfi","uu9sAhu","CMvHC29U","Cgf5Bg9Hza","AevYCM9Yrxy","AuXyAxC","x2LZqNjVD3m","yNvMzMvYzwq","Cg9PBNrdB24","uur5q0q","yMLMuMO","rfb6suu","wNrQzM0","C3vIyxjYyxK","yxnZAwDU","yxbWBgLJyxq","ywDL","x2HHBMrSzvi","y2XLyxi","BhLJz1i","DMHVBfG","x3fVC0rc","DMfSDwvZ","ywrKt25L","yNL0zuXLBMC","AKT1wge","BM9Uzv9UB24","weTurge","BMvY","ugLkvuC","wg1vsfm","mJqZmZq2mgHLuNL6wq","tKTSyNO","suHds3y","uxfMBhK","v3Hwufe","BKnnweq","CMvZB2X2zq","yxjYyxLIDwy","wMreEgK","CMfTugfYyw0","y3fHshe","vxj4qu0","Bhm6ia","yxKSig5LDhC","wNzPvKm","qvbUBgO","v1H2A3e","C29Tzq","DwXNA3m","vxbKyxrLq28","tgr4zxC","twTJwLG","yvHvAei","x3nVy2TLDa","CMvUDevUzha","EvDlz3y","Cxjdsuq","ExzOAem","zw50tgLZDgu","z3PkD24","mdaWma","u2HHCMvKv28","EuDNAu0","zw5fDMvUDa","zcWGDw5RBM8","yvfMCwm","vuHZr2K","DhLWzq","wuTnuMO","rwndDNG","D1nbqLC","A1n0yxr1C0m","zgvSzxrL","sxbuquq","quzstM4","C2vUzf9Hy2S","DMvUDa","Ag9zEve","rMTZBuq","vLnkwLm","zMXVB3i","x3jLy29UBMu","ruDOBw8","Bg9IywXty28","wuvzB08","txHUwgG","Bvj4wNm","z2LREMm","q0jRueC","tKfdtNG","ruHAvLi","tfL6Axe","zvfSqLa","tMn4uKu","sMv0q0i","reXmD3G","Eu9jAhy","C0jf","ChrVCG","EgPgDwC","zxjYB3i","yKHvCfy","DhbizwfKzxi","su5tvefova","Aezyz1e","tg1dtNu","BMfTzq","C2vUDa","y254rhK","tKzKDge","ihzHBgLKihm","q2Tuvxm","q2L1EMy","uLPJB1i","wvvsExG","y2HnyxHuCMK","CMXOzfu","BwvZC2fNzv8","vuLTsuO","DNzXt1m","zLDKzem","zNjVBunOyxi","ywXSzwqGBxu","zfbQuNO","igfYCMf5yNu","yKTIzgm","r3Pfv00","vKzqt2O","wLDSvKq","D2fZq2XLyw4","Dhr4CgW","y3vYC29Yx2y","CMvWBgfJzq","u2juwgC","u0LQuhu","Bw5fA2y","rxbds0q","CuL1rhO","zuzXBKq","id4G","C252qxu","sfHmu24","z3vtDKm","zNjVBNrPzxi","yMnrs1G","uLnfqxu","B3HTtgy","DgXnC3G","y0DTB0y","A1PvC1e","y29UBMvJDfm","y3vYC29YlNm","qLDVAuO","vMPYv1m","x2DLBMvYyxq","DKPQA0C","su9bueC","t0LgsNC","qKjJBu8","DhPWzfO","v25cv20","zMLUza","EKXSs3e","BgvY","vfLHAw8","r2res3a","tKDFrvjst1i","z0r4AMu","wwTXwNO","C2vYDMLJzq","v05WEMm","uxvLDwu","AgLNAa","CM9YrxzLBNq","uNzqtKu","rMP2D1y","BKneu0W","rNf5yMu","B25ozxr3B3i","ueXNrM4","ELnxB1O","DxrVuMvJB24","uM5tru8","wMvYse8","A2H4u3C","zxjHDg9Y","yK1pv3e","CvbUAhe","rKjiB0O","C2XPy2u","CgLUz0LUDgu","v1rQs2u","zxvZzeK","AxnszwfKEq","y09Wzw4","CNnVCL9Uyw0","AxnFywnR","C2v0u3rVCMe","BwLUzW","AMvNu3i","yw1Lu3bHy2u","BhrPCgXLihq","AxPowgm","vNzMu2K","x2rPC2nVBM4","CMfTzq","CvDWzwS","x3bPBMDmB3m","DgfIyxnL","rhHbve0","q09oveLovuu","zMPOtva","DxbKyxrLq3u","B3H0BxG","D0Hpr0i","sejVyKW","Cg1TDg4","A053B24","CMvJB25Uzwm","wuPICu0","yMfSrxzLBNq","x3nLCuLK","y29UBMvJDa","BMrWB2LUDca","y3r4","z2TJwhO","zg9Uzq","DhDLzgC","zNjVBujPDhm","BKvJB20","y0nivuu","CYbPBNn0yw4","swPzseC","zNjHBwvuExa","uw1QBgS","zxjFCw9Z","Cwn6qwO","r1jpuxa","Bg9Nsurhzw4","DNDlEvC","tvLYzgK","BMvJDa","EhLgq1i","t2jQzwn0","zxfOzha","BMrWB2LUDfq","zvvYBa","DhLiDuC","CxztALK","zgXpswO","zvr4tuu","A0nfCfe","rwTmqxq","tMfTzq","DMjOBLG","vKzftwu","x2jPBMfYEvq","B2frvuq","A2v5CW","wejyCvm","tgHUuu4","CeLgwxO","B3nLza","AxnbCNjHEq","wNr2EKO","tgLZDgvUzxi","sNLyuwu","C2fNzq","y3LKq3q","Dgv4Dc9WBge","uLP3vhq","uerqsuG","ihn1y2nLC3m","B25tDg9Wsw0","zw5JB2rLrNi","zgf0yq","A3HjBMm","z2v0qwXS","qMHushG","ANLTuNC","ChPdrvu","yMLUyxj5vhK","DMvY","CufHu0u","C3rVCcbPBw0","y3vZDg9Tshq","yNLL","DgHLBG","z1rPBwvVDxq","AgvKtwf4uMu","B3LRv2u","DhjPzxmGCMu","DMrmEMW","z09nCuG","A2HkEg4","rxzLBNq","DMLJzuLeig8","C2vYDMvYvgK","AufrD2C","zxH0ugf5Bg8","yxKSihrYEsa","A3HZB2m","ywnOzwq","B2HjBhO","DxDrtNe","Ae9Wzw5fDMu","qNvHuNO","wuDmreq","tM1Wy1O","shz4AuC","ruPRq1y","uMH0v2i","Ce1bv2q","zw50zwqGDhK","BMrLEa","BgTTDfC","Dgv4Dc9Qyxy","tKXdq2C","B25pCgvU","C0zbELa","y3jLyxrLt2i","y2fSBa","B2rTAfi","D24GCMvHC28","x2XPC3rLBMu","zgvMAw5Luhi","ENbozNC","zcbLCNjVCI4","AwrI","EM56r1G","ugfcv0m","zerRsNK","t0D5z2m","tg9JAW","De1HBMfNzxi","BwT0ufm","tNP3Ee0","lcbTyxGGCMu","zMvY","rMPPuva","zezpuLG","svDWBMi","u3rYyxrLz3K","DhvsD0y","Dxrjza","y2vZC0HHBMq","DMfS","C0j0y2S","r0TVELe","zxf1ywXZ","y2f0y2G","x2rItMfTzq","ywXSq3vYC28","BMDLza","shvPzLG","zKHPrKS","vKPWz0G","uxDPCwK","uLnxrKi","DeTcDK4","ywXSB2nvBNm","wgntDfO","zu9Lr2m","DLPbAxC","neDIEeTIBa","EePlBvm","vNjouK0","B3bLBIa","C0Xf","C2vUza","rhrJuvG","Dg9mB3DLCKm","qwvbB3q","ww5hwum","BNrbBMrvCgq","B2XKvMvYC2K","rhjjvxC","zwrPyxrLBhK","v0TMC0y","qMndthO","ywnRDxbfBMq","B2nRzxq","zgLZywjSzue","BuXxsem","zNvUy3rPB24","x2LUAxrqCM8","CMvxAwK","nNWZFdD8mhW","x2nVBM5Ly3q","uNrNu1m","rvveEeG","DeHwr1i","AgfZ","CMvQzwn0","q0D2rfO","rurZAK4","CvfVC08","B25fCNjVCG","z0vWuvi","zgDMEwS","BgLUzq","y29UBMvJDgK","uwzcBKi","C0vZyuG","BMX0zwq","C3jJ","ywnRpwzYB24","Du5oCfG","rgDoEhm","EuLfqNa","y29UBMvJDeu","zKjIEKe","C2DPza","Dg56Bxu","BMrkv0O","D3PIsfK","BMnLq2XVC2u","z2vjBMzVu3K","Ahr0Ca","yufzDgi","Bwf4twvZC2e","ywrKq291BNq","yMfSu2nVCgu","Cgf5Bg9Hzeu","CgfNzwHPzgu","zMLN","ign1CNnVCIa","wKDMqwu","s1LLBha","vvjkvhO","CgjICdi","zgvS","tKfusvzfx0u","x3jLBw92zvC","z29PBMCGyxC","rfbirKm","ihbYB3rVy28","rKXmsgm","v2vIu29JA2u","x2LZv29YA2u","q3L5v2C","CMvZzxrfBMq","D3bHzLq","wNPtu1C","A0Pxs0W","rwLICKu","vKPjC28","Exr1we0","u2r2De4","t2X4AvG","zwzPzMS","AgP4D0W","DMPsqKS","Dw5KzwzPBMu","tgn6Ehi","uKnnv1i","EvjLy29UBMu","vxfHCM0","CgLUz1rPBwu","ihrPBwvVDxq","Bwf4tg9ZC0m","BMHrELO","wNjYzNO","swnwD0S","BxzZBvi","y3jLyxrLuMu","ywXS","B2zM","qxvdqNi","ruf5zKi","qKzAvNq","EMjAwgK","AfDztMW","u2fWCNO","Cg9PBNrbBMq","x1fVu01HBMe","sKPuD1q","ywLfzw8","wKPVDgK","DhjPzxm","u2vXsuq","A3zHvfC","D01yvK0","u05ot2K","yxGGCMv0CMK","vxjsDgW","r0TXDwi","ueX6D2i","CvnPyMy","C3rHCNq","rhfbBfq","y3vYC29Yx24","ywnRx2nVzgu","x3vYBa","rxzrwhu","CMvTB3zLrxy","u3ftAuq","wwL0thO","jMPZy2fSBgi","zgvSzxrLrge","yMLUyxj5","vgLTzw91Da","uvf5qLe","z2DxzxO","BMDuAw1LCG","v2zOsxm","qNHvsxm","BMCGDxjSoIa","B25LCNjVCG","D1b2C04","y29Uy2f0","vKrxzM8","m3WYFdr8nxW","igzHAwWSig0","uLLzy04","DwfPvKG","B3vUDa","DgvmB2Djre4","CxjLEKy","B1HXyuW","ENjeD0K","Bwu6ia","CYbHBhjLywq","swfHr1q","sxfkzKW","wNL3wMK","rfz4tve","sejeAuC","u0jYy04","zxH0zw5ZAw8","wKHxAhi","s2DWzem","DgPiteG","wLr1v0i","t2fTr1q","vwLXC3e"];return yo=function(){return t},yo()}var F0,P0,N0,Xc,Eo,Zc,wo,bo,vo,Bi,L0=z0({"node_modules/idb/build/wrap-idb-value.js"(){let t=L,e={skqPW:function(r,i){return r instanceof i},dudBV:function(r,i){return r!==i},eGRhI:t(1789),tjIDI:t(1334),OsnlZ:function(r,i){return r===i},FjvwV:t(1430),rVnBf:t(1072)+t(381),UrRtl:t(934),CPido:function(r,i){return r(i)},YtpJo:function(r,i){return r in i}};F0=(r,i)=>i[t(1251)](o=>r instanceof o),Xc=new WeakMap,Eo=new WeakMap,Zc=new WeakMap,wo=new WeakMap,bo=new WeakMap,vo={get(r,i,o){let c=t;if(e[c(989)](r,IDBTransaction))if(e[c(376)](e.eGRhI,e[c(577)])){if(e[c(1137)](i,e[c(1379)]))return Eo[c(633)](r);if(e[c(1137)](i,e[c(472)]))return r[c(1072)+c(381)]||Zc[c(633)](r);if(i===e.UrRtl)return o[c(1072)+c(381)][1]?void 0:o[c(1072)+"ore"](o["objectSt"+c(381)][0])}else _0x1d875f.log(_0xca51c2);return e[c(1800)](Mt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(989)](r,IDBTransaction)&&(e.OsnlZ(i,e[o(1379)])||i===e[o(1689)])?!0:e.YtpJo(i,r)}},Bi=r=>bo[t(633)](r)}}),U0={};mE(U0,{deleteDB:()=>AE,openDB:()=>IE,unwrap:()=>Bi,wrap:()=>Mt});function IE(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=L,u={hwJcw:function(m,E){return m!==E},dmkvx:"MrMxN",PEyfc:function(m,E,T,_,v){return m(E,T,_,v)},DteiI:function(m,E){return m(E)},SYLpM:function(m,E){return m(E)},IWpnb:function(m,E){return m===E},ZTuWB:function(m,E){return m===E},uznpE:function(m,E){return m===E},xjFug:l(1034),OlxiX:l(1797),snvAu:l(1834),LMhLF:l(868)+l(1086),RCMWR:"upgradeneeded",sKRfu:"blocked"},h=indexedDB[l(589)](t,e),p=Mt(h);return i&&h["addEvent"+l(1469)](u[l(1659)],m=>{let E=l;if(u[E(948)](u[E(374)],u.dmkvx))return new _0x5ffe12(_0x6e7563,{code:_0x50c4a4,reason:_0x2fed3a,wasClean:_0x5cfe5b,willReconnect:_0x503a24});u[E(1013)](i,u[E(721)](Mt,h[E(442)]),m[E(1579)+"on"],m.newVersion,u[E(1069)](Mt,h[E(401)+E(564)]))}),r&&h[l(510)+l(1469)](u[l(573)],()=>r()),p[l(1491)](m=>{let E=l,T={cxNwR:function(_,v){return _!==v},zcTtb:function(_,v){return u[H(1545)](_,v)},YsAwQ:function(_,v){return _>>>v},LDrqq:function(_,v){return u[H(1737)](_,v)}};if(u[E(788)](u[E(1303)],u[E(1653)]))return _0x2caca5[E(362)](_0x56d4a1)||(_0x6895e4=_0xdbec04[E(532)+"er"](_0x24ee67)),T[E(1178)](this[E(558)],_0x539223.unsigned)&&T.zcTtb(T[E(1803)](this[E(1376)],31),1)&&T[E(1792)](_0x184730.high>>>31,1)?!1:this[E(1376)]===_0x21bc44.high&&T[E(1046)](this[E(505)],_0xed7add[E(505)]);c&&m["addEvent"+E(1469)](u[E(1344)],()=>c()),o&&m[E(510)+E(1469)](u[E(900)],()=>o())})[l(1554)](()=>{}),p}function AE(t,{blocked:e}={}){let r=L,i={UNrCU:function(c,l){return c(l)}},o=indexedDB[r(1703)+r(1412)](t);return e&&o[r(510)+"Listener"](r(534),()=>e()),i[r(902)](Mt,o)[r(1491)](()=>{})}function M0(t,e){let r=L,i={obqwo:r(1848)+"e",QwUBM:r(550),UUwto:function(h,p){return h instanceof p},oykWe:function(h,p){return h in p},CBkPG:function(h,p){return h===p},bhWlz:r(719)};if(!(i.UUwto(t,IDBDatabase)&&!i[r(1494)](e,t)&&i[r(1292)](typeof e,i[r(501)])))return;if(_o[r(633)](e))return _o.get(e);let o=e[r(1336)](/FromIndex$/,""),c=e!==o,l=H0[r(462)](o);if(!i[r(1494)](o,(c?IDBIndex:IDBObjectStore)[r(497)+"e"])||!(l||q0.includes(o)))return;let u=async function(h,...p){let m=r,E=this[m(401)+m(564)](h,l?i[m(1168)]:i[m(649)]),T=E[m(934)];return c&&(T=T[m(1167)](p[m(1823)]())),(await Promise[m(1670)]([T[o](...p),l&&E[m(1430)]]))[0]};return _o[r(941)](e,u),u}var q0,H0,_o,TE=z0({"node_modules/idb/build/index.js"(){let t=L,e={Pczmk:t(1071)+t(373),MsaoC:t(1150),DLLwx:t(1221),eusdI:t(633),ulgks:t(1793),zrDwI:t(1481),sFAzP:t(689)+"ys",UOTPA:t(932),Ztjfm:function(o){return o()}},r=e.Pczmk[t(584)]("|"),i=0;for(;;){switch(r[i++]){case"0":H0=[t(983),e[t(491)],t(1276),e[t(1299)]];continue;case"1":q0=[e[t(1396)],e[t(1252)],e[t(1724)],e[t(1523)],e[t(810)]];continue;case"2":bE(o=>({...o,get:(c,l,u)=>M0(c,l)||o[t(633)](c,l,u),has:(c,l)=>!!M0(c,l)||o[t(1596)](c,l)}));continue;case"3":e[t(1215)](L0);continue;case"4":L0();continue;case"5":_o=new Map;continue}break}}}),RE={idb:function(t){let e=L;t.exports=Promise[e(1240)]()[e(1491)](()=>(TE(),U0)).then(function(r){return r})}},B0={};function Lt(t){let e=L,r={vDJCv:e(1794)+"1"},i=r.vDJCv.split("|"),o=0;for(;;){switch(i[o++]){case"0":RE[t](c,c[e(877)],Lt);continue;case"1":return c.exports;case"2":var c=B0[t]={exports:{}};continue;case"3":var l=B0[t];continue;case"4":if(l!==void 0)return l.exports;continue}break}}(()=>{let t=L,e={eOeGc:function(r,i){return r===i},whBBD:t(370),TmJdb:"zDcoz"};Lt.d=(r,i)=>{let o=t;if(e[o(1566)](e[o(549)],e.TmJdb))return"frontier_"+ke._DBName;for(var c in i)Lt.o(i,c)&&!Lt.o(r,c)&&Object[o(1529)+o(1021)](r,c,{enumerable:!0,get:i[c]})}})(),(()=>{let t=L;Lt.o=(e,r)=>Object.prototype[t(1041)+t(1021)][t(1525)](e,r)})(),(()=>{let t=L,e={kCLCR:function(r,i){return r!=i},kyBia:t(1657)+"d"};Lt.r=r=>{let i=t;e[i(1047)](e[i(1070)],typeof Symbol)&&Symbol[i(883)+"Tag"]&&Object[i(1529)+i(1021)](r,Symbol[i(883)+i(725)],{value:i(574)}),Object[i(1529)+i(1021)](r,i(761)+"le",{value:!0})}})();var De={};(()=>{let t=L,e={fNUaW:function(a,n){return a(n)},XHrcF:function(a,n){return a+n},HBobL:function(a,n){return a+n},pqzKd:function(a,n){return a+n},khJxn:function(a,n){return a*n},KvlwQ:function(a,n){return a*n},PZzSc:function(a,n){return a*n},SbTXg:function(a,n){return a>>>n},HprQz:function(a,n){return a(n)},RtgSS:function(a,n,s){return a(n,s)},DVxMQ:function(a,n){return a!==n},ypspw:"QckaE",SdWcr:function(a,n){return a+n},DlTHd:"0000",YZUkC:t(1033),yvhhC:function(a,n){return a(n)},EhWQo:function(a,n){return a(n)},JkTNz:t(1849)+t(1849)+t(1849)+t(1849),oaQUD:function(a,n){return a>n},EeiAL:function(a,n){return a<n},JrZBS:function(a,n){return a>n},VrNRM:function(a,n){return a<n},KGANS:function(a,n){return a-n},cGmoF:function(a,n){return a===n},fJHaK:function(a,n){return a-n},JyXQe:function(a,n){return a!==n},jsQrz:t(735)+t(1205),GBNNn:t(1085),teqJw:t(831),rHerF:function(a,n,s){return a(n,s)},rIRvX:function(a,n){return a(n)},Isbrl:function(a,n,s){return a(n,s)},yGgiM:function(a,n){return a&n},Jjtxx:t(1812)+t(1193)+t(661)+t(1850),XSVgw:function(a){return a()},Tzwdf:function(a,n){return a!==n},ZJoti:function(a,n,s){return a(n,s)},UImIJ:function(a,n){return a!==n},dJhNR:function(a,n,s){return a(n,s)},WXoIb:function(a,n,s){return a(n,s)},XyBzz:function(a,n){return a(n)},MCSES:function(a,n){return a!==n},EkLAt:function(a,n,s){return a(n,s)},qAkDd:function(a,n,s){return a(n,s)},GKozQ:function(a,n,s){return a(n,s)},tmcey:function(a,n,s){return a(n,s)},yBmxF:function(a,n,s){return a(n,s)},cPzIB:t(921),Lczxr:function(a,n,s){return a(n,s)},yvSyW:function(a,n,s){return a(n,s)},NewBp:function(a,n){return a!==n},nmiQz:"ZeaMj",zmpFm:t(669),jbYOx:function(a,n){return a!==n},ZBoyp:function(a,n){return a(n)},GzEWM:function(a,n){return a(n)},WfocW:function(a,n){return a(n)},MKsCr:function(a,n){return a>>>n},nxXIL:function(a,n){return a(n)},IjYHG:function(a,n){return a(n)},dabeQ:function(a,n){return a(n)},CPeIU:function(a,n,s){return a(n,s)},nCDSL:function(a,n){return a(n)},DwzRH:function(a,n){return a(n)},NctVv:function(a,n,s){return a(n,s)},yqtMB:function(a,n){return a(n)},ivOXA:function(a,n,s){return a(n,s)},vSVNZ:function(a,n,s){return a(n,s)},PxTHl:"Missing required"+t(661)+t(1684),bcQKX:"Missing required"+t(661)+t(536),KFaRG:t(1812)+t(1193)+t(661)+t(1373),yqHFF:"Missing required"+t(661)+"method",OwesY:function(a,n,s){return a(n,s)},cxCan:function(a,n){return a>>n},iwBGP:function(a,n){return a>=n},lfLAd:function(a,n){return a===n},EstZJ:function(a,n){return a>n},QkoLy:t(716)+t(513),WRsWr:function(a,n){return a>=n},YURyx:t(1464),iOMPY:function(a,n){return a*n},bmBOd:t(990),ALHgc:function(a,n){return a>n},DPHFC:t(890)+t(513),wdLAI:function(a,n){return a+n},PDPIH:function(a,n,s,d){return a(n,s,d)},NiMsG:function(a,n){return a===n},fMPSZ:"hpdNX",AFRNn:"MXuUo",wNRfu:function(a,n,s){return a(n,s)},aAYtb:function(a,n){return a<n},Zqikc:function(a,n){return a===n},eqhdp:function(a,n){return a>=n},tlMsx:function(a,n){return a+n},IHBKV:function(a,n){return a+n},lkmtW:function(a,n){return a!==n},XrYST:function(a,n){return a|n},GQIhf:function(a,n){return a<<n},TQzil:function(a,n){return a&n},pzJFX:function(a,n){return a(n)},dPMAM:function(a,n){return a==n},xJKmS:t(626),efifk:function(a,n){return a|n},EibrE:function(a,n){return a&n},ndJWJ:function(a,n){return a<<n},Qwiqi:function(a,n){return a&n},UaIFA:function(a,n){return a(n)},kZUsQ:function(a,n){return a&n},BUcOn:function(a,n){return a+n},FPvdh:function(a,n){return a+n},hoYyQ:function(a,n){return a+n},dDkJy:function(a,n){return a+n},HRJIU:function(a,n){return a&n},MQDxc:function(a,n){return a<<n},GUsjt:function(a,n){return a&n},pVzcC:function(a,n){return a<n},hBaDs:function(a,n,s){return a(n,s)},tUsaf:function(a,n){return a+n},GzYWT:t(423)+"0",uRdzm:function(a,n){return a<n},GyzAC:function(a,n){return a<=n},EGhmo:function(a,n){return a<<n},wCmId:function(a,n){return a<n},nJaiJ:function(a,n,s){return a(n,s)},XKTDa:function(a,n){return a<n},RTAqy:function(a,n){return a<n},AJPTG:function(a,n){return a|n},nUDpp:function(a,n){return a<n},flrVI:function(a,n){return a===n},GAIvm:t(1507),zlNRw:function(a,n){return a&n},pdwku:function(a,n){return a>>n},tyHuG:function(a,n){return a&n},odmhR:function(a,n){return a&n},Ciuzf:function(a,n,s){return a(n,s)},eJxfy:function(a,n){return a+n},dlwsE:function(a,n,s){return a(n,s)},VDWfo:function(a,n){return a===n},WsmVt:t(1651),OMjcd:function(a,n){return a<n},RZwTt:function(a,n){return a<<n},YZewK:function(a,n){return a&n},kkSXY:function(a,n,s){return a(n,s)},seZJu:"undefined",qfyZV:t(574),GAthw:t(761)+"le",FiZrY:t(1814),mdlQY:t(879),Uwphj:function(a,n){return a<<n},kbCbv:function(a,n){return a&n},SoMgS:function(a,n){return a<<n},DtcQX:function(a,n){return a&n},PLclu:function(a,n){return a&n},QQyBQ:t(1203),IqJfL:function(a,n){return a(n)},SfDBf:function(a,n){return a&n},nrfpZ:function(a,n){return a<<n},sMnHB:function(a,n){return a|n},smWjc:function(a,n){return a>>>n},ljNUm:t(479),CWChP:"abort",RklDr:t(1381),KlHUp:t(1739),DqAlT:function(a,n){return a|n},hLDdi:function(a,n){return a>>>n},pzCEU:function(a,n){return a===n},FXrOJ:function(a,n){return a<n},jiDXA:function(a,n){return a<n},YTzmB:function(a,n){return a<n},tHVGR:function(a,n,s){return a(n,s)},EOwbI:function(a,n){return a&n},BNrNS:function(a,n){return a!==n},eFqnD:function(a,n){return a+n},bbPuB:function(a,n){return a>>>n},nEcom:function(a,n){return a!==n},sBtck:function(a,n){return a+n},UogJe:function(a,n){return a>>>n},dSVvv:function(a,n){return a>>>n},PJWPO:function(a,n){return a+n},znzGX:function(a,n){return a!==n},khxSw:function(a,n){return a&n},kCEpQ:function(a,n){return a>>>n},GZIvd:function(a,n){return a+n},SDuaW:function(a,n){return a>>>n},OIFJw:function(a,n){return a&n},HQtKH:function(a,n){return a>>>n},vwbVA:function(a,n){return a|n},KImkS:function(a,n){return a&n},SBrcN:function(a,n){return a|n},tkygw:function(a,n){return a(n)},ggWez:function(a,n){return a(n)},iAQwg:function(a,n){return a|n},kSrSu:function(a,n){return a===n},RrXaD:function(a,n){return a|n},BxUIs:function(a,n){return a|n},eIsSZ:function(a,n){return a|n},mktPS:function(a,n){return a<<n},tzpdZ:function(a,n){return a<<n},MeSun:function(a,n){return a|n},dkLBX:function(a,n){return a<<n},gNDwC:function(a,n){return a<<n},EvQXu:function(a,n){return a|n},ZrHkh:function(a,n){return a<<n},NUlNM:function(a,n){return a>>>n},HXLSn:function(a,n){return a|n},iLXiw:function(a,n){return a<<n},dvHpJ:function(a,n){return a&n},kLBqg:function(a,n){return a&n},nTnQG:function(a,n){return a&n},sqldc:function(a,n){return a>>>n},TzUaw:function(a,n){return a>>>n},HAJvx:function(a,n){return a>>>n},SuJsv:function(a,n){return a&n},itUUT:function(a,n){return a>=n},ciUaf:function(a,n){return a<=n},HVLfG:function(a,n){return a+n},TWdqh:function(a,n){return a|n},ifSBb:function(a,n){return a|n},qSibf:function(a,n){return a/n},keYWh:function(a,n){return a+n},wDcoy:function(a,n){return a+n},uaiVH:function(a,n){return a>>>n},oNioQ:function(a,n){return a>>>n},RnSEO:function(a,n){return a+n},wmctd:function(a,n){return a>>>n},cvuJj:function(a,n){return a<<n},bQTij:function(a,n){return a<<n},ymdwH:function(a,n){return a!==n},URJTz:function(a,n){return a===n},kxInc:function(a,n){return a===n},muzId:function(a,n){return a===n},KpIAs:function(a,n){return a===n},YmHCx:function(a,n){return a+n},KYelp:function(a,n){return a+n},eTxME:function(a,n){return a&n},pmxtp:function(a,n){return a>>>n},Euszo:function(a,n){return a&n},wmqCF:function(a,n){return a>>>n},iHMqu:function(a,n){return a>>>n},vvqOS:function(a,n){return a&n},zZVOZ:function(a,n){return a>>>n},hpxvX:function(a,n){return a&n},jmmnY:function(a,n){return a&n},WNpzc:t(1010)+t(1370),WIllv:t(1636)+"RROR",GJepP:t(993)+"IES_ERROR",IrNUG:"MESSAGE_ERROR",dzuao:t(369)+"2",BeqOk:function(a,n,s){return a(n,s)},JuDkS:function(a,n,s){return a(n,s)},LmCNu:t(1516),LQqaT:function(a,n){return a<n},APnlj:function(a,n,s){return a(n,s)},fHiFK:function(a,n,s){return a(n,s)},gzJwn:t(1384),TYaio:t(1304),Ljucs:function(a,n){return a!==n},WVTBs:t(372),crzyP:"tKGTM",ZUUhv:function(a,n){return a+n},xjtnz:t(1441),JetCB:function(a,n){return a>=n},oxtmx:function(a,n){return a==n},VJIso:function(a,n){return a>n},AlkEF:function(a,n){return a+n},PzBcB:function(a,n){return a===n},JLwiI:t(646),JEUww:t(1602),enZly:"GChUH",ETLqF:function(a,n){return a instanceof n},iHrHj:function(a,n){return a+n},XlaQT:t(578)+t(1531),iOoIX:function(a,n){return a+n},IHCKv:function(a,n){return a+n},ikLtN:function(a,n){return a&n},iQEgD:function(a,n){return a<n},JNxpC:function(a,n){return a|n},TBEoD:function(a,n){return a>>>n},gkcXz:function(a,n){return a<<n},bjiZu:function(a,n){return a<<n},EbLHC:function(a,n){return a|n},dLzMf:function(a,n){return a>>>n},NKlbz:function(a,n){return a|n},BjXLq:function(a,n){return a<n},qCgpQ:function(a,n){return a>>>n},WfhIs:function(a,n,s,d){return a(n,s,d)},ZerHO:function(a,n){return a|n},OeCGo:t(1677),FBHoJ:"KYWST",xtfws:function(a,n){return a===n},wJLbG:function(a,n){return a===n},gjZRl:t(1834),BAkBp:function(a,n,s){return a(n,s)},Txkxl:t(1128),DXjrf:t(589),MkmQj:function(a,n){return a instanceof n},gTPYN:function(a,n){return a<<n},JJflV:t(976),ktmMQ:t(961),EJwaS:t(978),OJQik:function(a,n){return a===n},vsbkX:function(a,n){return a!==n},shduF:t(1349),rDjjb:function(a,n){return a||n},NACNx:function(a,n){return a!=n},IcVwK:t(995)+"0",aXUhB:function(a,n){return a||n},tjHLH:t(928)+t(1326)+t(1405)+t(1743)+t(1824),oCNji:function(a,n){return a<n},CGvDZ:function(a,n){return a&n},IgiFH:function(a,n){return a(n)},dycos:function(a,n){return a===n},tWVqN:t(1279),llaTr:t(1056),XByOQ:"qkcZp",tOwrL:function(a,n){return a<n},rcjpA:function(a,n){return a>=n},Qqfly:function(a,n){return a&n},AEryo:function(a,n){return a<n},RYYcN:function(a,n){return a|n},EJkCV:function(a,n){return a&n},tmscF:function(a,n){return a&n},poetC:function(a,n){return a&n},xAfXk:function(a,n){return a-n},gDxje:function(a,n){return a<<n},FAaqX:function(a,n){return a&n},KMIvV:function(a,n){return a<<n},ndlbu:function(a,n){return a&n},YozcZ:function(a,n){return a<n},GgPGb:function(a,n){return a|n},PDvjg:function(a,n){return a===n},sXHVb:"5|3|2|4|"+t(787),SxStB:function(a,n){return a|n},jVBlY:function(a,n){return a|n},SIjPu:function(a,n){return a&n},ypVOG:function(a,n){return a>>n},PcxEh:function(a,n){return a+n},yHuZJ:function(a,n){return a<<n},kFYwS:function(a,n){return a|n},Fjgsd:function(a,n){return a>>n},WaMHe:function(a,n){return a|n},PUAnk:function(a,n){return a&n},uNFHJ:t(719),vvPRL:"XnOTf",Uqarm:function(a,n){return a(n)},vZAiw:t(450),HHYUE:t(985),QKKHU:t(1218)+"ion/json",tshXG:t(1473)+t(485)+"et=utf-8",JfjXZ:"boe",nsdXW:"ppe",KYMNY:function(a,n){return a!==n},ayNiE:"WciJT",pfRnD:t(1465),MPCon:function(a,n){return a(n)},rcFHz:"text/jav"+t(1113),XbBUq:t(1702)+t(1610)+t(1097)+"P",NRGAo:function(a,n){return a===n},bifRj:t(469),BuaRz:function(a){return a()},WlQRD:function(a,n,s,d){return a(n,s,d)},mnEkf:function(a,n,s){return a(n,s)},IKQFA:t(1360),yWKgv:t(1125),gxjek:function(a,n,s){return a(n,s)},PjeYP:function(a,n){return a<=n},iPyej:function(a,n){return a>=n},YnGYC:t(500),PiJUG:t(1057),EAyfB:t(516),ioWWj:t(1423),lssOd:t(1430),nOOig:function(a,n){return a===n},oHwWd:function(a,n){return a in n},BWoiJ:t(1594),QDyCD:function(a,n){return a||n},nvLLL:function(a,n){return a||n},KnWPp:function(a,n){return a||n},pdWjr:function(a,n){return a||n},RhtWb:function(a,n){return a(n)},ppLmB:"KjuyD",NDiHI:function(a,n){return a||n},xYYUA:function(a,n){return a||n},GdDKp:function(a,n){return a!=n},QtGvT:t(616)+"DB failed",WXvkq:t(1754),HuifX:function(a,n){return a(n)},FHjCs:function(a,n){return a+n},qIuDz:"gBKdV",COJyp:t(1854),ANNRX:function(a,n,s){return a(n,s)},ReGXq:t(1727),VjrWS:"FILE_NOT_EXIST",vholX:t(1066),XEOOA:function(a,n){return a!==n},qvSjY:t(1005),yOIhv:"EwvDC",PzdXp:"x_fronti"+t(1439),KvuZh:t(820)+"er_qos_ack",vlyYv:function(a,n,s){return a(n,s)},JBvvP:t(820)+t(1752)+t(1616),IeQfY:function(a,n){return a&&n},EcCvx:t(1400),yldNG:"ack_id",DFsME:t(1696),ZHWhr:t(994),rkNTE:t(1704),CyyWg:function(a,n,s,d){return a(n,s,d)},fsUdl:function(a){return a()},uBGdX:function(a,n){return a<n},DQUeq:function(a,n){return a+n},MjRDU:function(a,n){return a&n},qPnhq:function(a,n){return a||n},NmpcZ:function(a,n){return a+n},FksmD:t(432),zbZXi:function(a,n){return a||n},uyExV:t(1343),KCvfV:t(1532),CEVRz:function(a,n){return a===n},FiIOK:t(456),OGygc:t(1095),tSuMY:t(541),nkpTy:function(a,n,s,d){return a(n,s,d)},FYffw:function(a,n){return a|n},RrJUY:function(a,n){return a|n},rlhdU:function(a,n){return a<<n},NLCCg:function(a,n){return a<<n},DPzIE:function(a,n){return a+n},nlted:function(a,n){return a<<n},CyGjy:function(a,n){return a+n},lzaJe:function(a,n){return a<<n},AWoBF:function(a,n){return a+n},lKpIh:function(a,n){return a<<n},RohNZ:function(a,n){return a+n},WImBo:function(a,n){return a+n},YTQdm:function(a,n,s){return a(n,s)},VYenR:function(a,n){return a+n},WNxiX:"yzscE",YWAHh:function(a,n){return a&n},UbobJ:function(a,n){return a>>>n},fjhMP:function(a,n){return a&n},hRDyo:function(a,n){return a&n},eCtAx:function(a,n){return a+n},wOaZK:function(a,n){return a&n},VJpgH:function(a,n){return a>>>n},fxvTP:function(a,n){return a&n},xyFCR:function(a,n){return a&n},Xfhht:function(a,n){return a>>>n},ZtzBQ:function(a,n){return a+n},bzSjv:function(a,n){return a<n},onBVD:function(a,n){return a|n},JHtyQ:function(a,n){return a<n},zcTUA:function(a,n){return a|n},xgTcl:function(a,n){return a<<n},ARxGw:t(1080),mLBJs:"ImrFk",xVxKe:function(a,n){return a!==n},hsypt:t(504),bddWz:t(452),gvJTM:function(a,n){return a+n},kJvXu:function(a,n){return a!==n},JYcQx:"QboVY",ELQDt:t(1373),wQrjw:t(1355)+"ervice",ChPKw:t(846),EcuUH:"name",amNXj:function(a,n){return a(n)},TPpVF:function(a,n,s){return a(n,s)},zCyVp:function(a,n){return a===n},aQfqc:t(416),pXrNp:function(a,n){return a+n},EJivw:function(a,n,s){return a(n,s)},oaBXu:t(1335)+t(703),scaXh:function(a,n,s){return a(n,s)},WuWJI:"cursor_n"+t(1026),lnFCB:t(1556)+t(957),PlLWk:t(1808),rIptq:t(1307),rrFmu:t(1414),qzFKC:t(1022),rpmME:function(a,n){return a+n},uBXKF:function(a,n){return a+n},GOFQP:function(a,n){return a&n},vqkFu:function(a,n){return a<<n},OZkbI:function(a,n){return a<<n},ZzzUh:function(a,n){return a&n},rPuDz:function(a,n){return a&n},yjMNr:function(a,n){return a>=n},QWcBF:function(a,n){return a<=n},Xkyty:function(a,n){return a(n)},YvHRx:function(a,n){return a===n},RvPNE:t(651),BHBJb:"JgvTj",hIKJO:t(777),bVbji:function(a,n,s){return a(n,s)},zNMaM:t(820)+"er_msgid",vjRBK:function(a,n){return a(n)},BghyF:t(820)+t(1043),TAYpc:"x-msg-qos",PLgFn:t(642)+t(1399)+"e",UtKre:function(a,n){return a(n)},LGvzN:t(642)+t(467)+"ue",Yaqez:function(a,n){return a>n},OrgXM:function(a,n){return a!==n},ebCaL:"WNUuG",sTLIz:t(784),TawKj:function(a){return a()},BtQNA:"qIzgT",ZviVC:t(1463),TxkSH:function(a,n){return a<n},qrezF:function(a,n){return a&&n},SLgIo:function(a){return a()},iWwae:function(a){return a()},Wnfex:function(a,n){return a(n)},qAaSE:function(a){return a()},nCMXD:function(a,n){return a!==n},iXZSo:function(a){return a()},dqIkm:function(a,n){return a<n},YYKGb:function(a,n,s){return a(n,s)},kNwon:function(a){return a()},PFdDJ:function(a,n,s){return a(n,s)},YitLz:t(923)+t(529),QORhu:function(a){return a()},UfVPv:t(983),IVjOi:t(1150),EDysi:t(1221),KMAhV:t(689)+"ys",wSABW:t(932),CapYG:function(a,n){return a===n},lycgR:function(a,n){return a===n},ZNpQM:function(a,n){return a!==n},BGUgM:t(847)+t(539)+"s",gOMqH:function(a,n){return a+n},HCAHC:t(897),aiEeo:function(a,n){return a===n},NbEsp:t(1490),oLOOh:function(a,n){return a(n)},REWId:function(a,n){return a!==n},hjxwL:t(1241)+t(1542),lKyat:t(1634),HQmyD:function(a,n){return a==n},TOTOf:t(667)+t(864)+"s params"+t(1077)+t(403)+"tructor "+t(1159)+"ined",zvPKB:function(a,n,s){return a(n,s)},vwKyW:t(1587),gDnYM:"reconnect",jegSr:t(1488)+t(1581)+t(707)+"ct",XXeqB:"online",uwQNq:t(1182),NmNoN:t(1628),xDcxY:t(1119),fBbzA:function(a,n){return a!=n},vaEdz:"yEWfc",HYOKr:function(a,n,s){return a(n,s)},fFPse:"teJYK",TGeGq:function(a,n){return a==n},tMeGm:t(695),XYmXL:t(1766),jKuXa:t(876),NFdta:t(1804),ZywZi:t(891)+"d",lJpsO:t(667)+t(449)+"ddID, de"+t(1500)+t(1758),BBlIJ:function(a,n,s){return a(n,s)},hqreL:t(1171),gonnf:t(617)+"0",AWSCl:function(a,n){return a===n},MTCoz:"zLlKq",YvABP:function(a,n,s){return a(n,s)},iVxlv:function(a,n){return a||n},mlUnQ:t(1799),tnzmu:t(1693),dlOIj:function(a,n){return a>n},bbpDH:function(a,n,s){return a(n,s)},NxFia:function(a,n){return a(n)},TZeIJ:t(1148)+">",BBcmO:function(a,n){return a*n},qQosO:function(a,n){return a-n},zpNfw:function(a,n,s){return a(n,s)},FnXlA:t(847)+"e_timeout",WTjKe:t(1179),ZDCUY:function(a,n){return a&n},dPjRz:function(a,n){return a+n},Qmjlk:function(a,n){return a!==n},IQVYq:t(607),pOUMz:t(609)+" try rec"+t(494)+"g",nXdEy:function(a,n){return a!==n},HiPwE:t(1329),DaqSo:function(a,n,s){return a(n,s)},cCHUE:t(421),ywkib:t(1580),cqaHq:function(a,n,s){return a(n,s)},ktkVL:t(1638)+t(1247)+t(981)+t(732),IFESq:function(a,n){return a||n},guSvC:t(1768),zBQuj:function(a,n,s,d){return a(n,s,d)},vdLzl:t(1713),KRVHO:t(399),QDbWm:t(1163),mluUr:t(1324),AMoCT:function(a,n){return a+n},TpbmG:function(a,n){return a<n},YkqZz:function(a,n){return a&n},RMSaz:function(a,n){return a&n},xXyAu:t(1277),jWqgk:function(a,n,s){return a(n,s)},SdvtN:function(a,n){return a===n},RoOSE:t(1255),EFXUc:t(920),EmDXN:t(1591)+t(670),kSOsl:"close, w"+t(1726)+t(567),lqcfY:t(699)+t(1435)+t(1827)+t(909)+"ed",bMOWq:t(667)+t(913)+t(1149)+"ata, dat"+t(924)+t(1133)+t(657)+t(1328)+t(712),NVOJe:t(679),QSYit:function(a,n){return a!=n},YEYoO:function(a,n){return a instanceof n},hyeQC:function(a,n){return a instanceof n},yJero:function(a,n){return a(n)},SumUq:function(a,n){return a||n},YaWya:t(667)+t(913)+t(1314)+"ervice",SJEBD:function(a,n){return a instanceof n},fpsAu:function(a,n){return a===n},IhGFs:t(680),oxmLf:t(768),HkfWs:function(a,n){return a==n},VFEMe:function(a,n){return a!==n},EDsjN:"manual r"+t(535)+"ing",hjjLf:function(a,n,s){return a(n,s)},GKqub:function(a){return a()},JhqNv:function(a,n,s){return a(n,s)},AKOwD:function(a,n,s){return a(n,s)},pmmtn:"WMWnq",YDXrp:t(1063)+"3",KeOWc:function(a,n){return a!==n},qrCID:t(1191),kxsoc:function(a,n){return a*n},VvfSi:t(1093),AuCBr:function(a,n){return a===n},UATdj:function(a,n){return a===n},JygZk:"Object",vYWGe:t(991)+t(977)+t(1287)+"pe",WnUAo:function(a,n){return a!=n},YKMRj:"ServiceWorkerGlo"+t(1626),ElxCt:function(a,n){return a!=n},uAIgB:function(a,n){return a!=n},PBLSD:function(a,n){return a!=n},LjhhO:t(955)+t(1018)};Lt.r(De),Lt.d(De,{FWS:()=>Ap,CustomErrorEvent:()=>Md,createCloseEvent:()=>xt,ReconnectEvent:()=>Ld,createErrorEvent:()=>at,decodedFrame:()=>Xt,createOpenEvent:()=>Hd,CustomCloseEvent:()=>Bd,createReconnectEvent:()=>na,FrontierMessageEvent:()=>Fd,encodeFrame:()=>zt,createMessageEvent:()=>qd,OpenEvent:()=>Ud,ErrorCode:()=>en,Event:()=>Vn,MessageEvent:()=>zd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(930)](),f=r||(r=e[n(1138)](h,a)),g=Math[n(1777)]()[n(883)](16)[n(1393)](-6);return e[n(821)](e[n(1419)](s+d,f),g)}function o(){let a=t;return e.pqzKd(e[a(1498)](1e4,Date[a(930)]()),Math[a(1284)](e.KvlwQ(1e4,Math.random())))}function c(a){let n=t;return e.HBobL(Array(8)[n(724)]("0"),parseInt(a,10)[n(883)](2))[n(1393)](-8)}function l(a){let n=t,s={eUqMY:function(d,f){return e[H(581)](d,f)},kJWKL:function(d,f){return e.PZzSc(d,f)},BjflW:function(d,f){return e.SbTXg(d,f)}};return n(1700)!==n(466)?e[n(581)](e.HprQz(Array,4)[n(724)]("0"),e.RtgSS(parseInt,a,2)[n(883)](16))[n(1393)](-4):this.unsigned?s.eUqMY(s[n(1648)](this[n(1376)]>>>0,_0x3dfc35),s[n(917)](this[n(505)],0)):s[n(1135)](s[n(1648)](this[n(1376)],_0x1197e4),this.low>>>0)}function u(a){let n=t;if(e[n(1730)](n(1440),e[n(570)])){let s=a[n(584)](/\./)[n(785)](g=>c(g)),d=[];return d[0]=e[n(997)](l,e[n(522)](s[0],s[1])),d[1]=l(e[n(581)](s[2],s[3])),[e[n(610)],e[n(610)],e[n(610)],e[n(610)],e[n(610)],e[n(678)],d[0],d[1]][n(724)]("")}else return _0x34dfe3||(_0x2a2939=[_0x2b1042,_0x30be63,_0x4bafca,_0x1d6238,_0x5e3c43])}function h(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(687)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(687)](a);return s?e.yvhhC(u,a):d?e.EhWQo(p,a):e.JkTNz}function p(a){let n=t,s="",d=[],f=0,g=0,w=!0,b="0000";if(e[n(1461)](a[n(1087)]("::"),-1)){let x=a[n(584)]("::");for(let O=0;e.EeiAL(O,x[n(414)]);O++){let z=x[O];if(e[n(612)](z.indexOf(":"),0)){let G=z[n(584)](":");w&&(f=G.length),g+=G[n(414)];for(let K=0;e[n(1570)](K,G[n(414)]);K++)if(e[n(1730)](4,G[K][n(414)])){let he=b[n(833)+"g"](0,e[n(583)](4,G[K][n(414)])),Ee=he[n(1714)](G[K]);d[n(738)](Ee)}else d[n(738)](G[K]);w=!1}else{if(e[n(1730)](4,z[n(414)])){let G=b[n(833)+"g"](0,4-z[n(414)]),K=G[n(1714)](z);d[n(738)](K)}else d[n(738)](z);w&&(f+=1),g+=1,w=!1}}let A="";for(let O=0;e.VrNRM(O,8-g);O++)A=A.concat(b);for(let O=0;e[n(1124)](O,d[n(414)]);O++)e[n(1352)](O,f)?(s=s[n(1714)](A),s=s[n(1714)](d[O])):s=s.concat(d[O]);return s}{let x=a[n(584)](":");for(let A=0;A<x[n(414)];A++){let O=x[A];if(e[n(1730)](4,x[A][n(414)])){let z=b[n(833)+"g"](0,e[n(488)](4,x[A][n(414)])),G=z[n(1714)](O);s=s[n(1714)](G)}else s=s[n(1714)](O)}return s}}function m(a,n){let s=t,d=a[s(1850)];e[s(1470)](void 0,d)&&(e[s(1593)](le,n,10),q(n,d));let f=a[s(380)];e.JyXQe(void 0,f)&&(e[s(1593)](le,n,18),e[s(1593)](q,n,f))}function E(a){let n=t;if(e[n(1352)](n(1109),e.GBNNn))return new _0x3b3490(_0x3d5461,{data:_0x35df42,message:_0x524d56});{let s={};e:for(;!V(a);)if(e[n(1352)](e.teqJw,n(1054)))_0xf2e8b0[n(1347)+"JSONP"]=void 0,e[n(1138)](_0x2b7128,e[n(1151)]);else{let d=de(a);switch(e[n(1337)](d,3)){case 0:break e;case 1:s[n(1850)]=e[n(1593)](P,a,e[n(1261)](de,a));break;case 2:s.value=e.rHerF(P,a,e[n(711)](de,a));break;default:e.Isbrl(C,a,e[n(1266)](7,d))}}if(s.key===void 0)throw new Error(e[n(839)]);if(s.value===void 0)throw new Error(n(1812)+"required field: "+n(380));return s}}function T(a){let n=t,s=e[n(418)](D);return _(a,s),e[n(711)](B,s)}function _(a,n){let s=t,d={Ldxew:function(be,Ie){return e[H(1570)](be,Ie)}},f=a[s(1684)];e[s(1200)](void 0,f)&&(e[s(1682)](le,n,8),e[s(772)](ht,n,f));let g=a.LogID;e[s(1730)](void 0,g)&&(le(n,16),ht(n,g));let w=a[s(1373)];e[s(1322)](void 0,w)&&(e[s(1076)](le,n,24),e[s(1189)](ht,n,e.HprQz(N,w)));let b=a[s(632)];e[s(1200)](void 0,b)&&(le(n,32),e[s(498)](ht,n,e[s(1024)](N,b)));let x=a.headers;if(e[s(1200)](void 0,x))for(let be of x){e[s(1076)](le,n,42);let Ie=e.XSVgw(D);e[s(498)](m,be,Ie),e[s(1189)](le,n,Ie[s(836)]),e[s(1189)](W,n,Ie),k(Ie)}let A=a["payloadE"+s(382)];e[s(1821)](void 0,A)&&(e[s(498)](le,n,50),e[s(1456)](q,n,A));let O=a[s(842)+s(987)];e[s(1821)](void 0,O)&&(e[s(1781)](le,n,58),e[s(1552)](q,n,O));let z=a.payload;e.UImIJ(void 0,z)&&(e[s(1023)](le,n,66),e[s(553)](le,n,z.length),e.qAkDd(fe,n,z));let G=a[s(796)];if(e[s(1821)](void 0,G))if(e[s(1352)](e[s(1816)],e.cPzIB))e[s(1658)](le,n,74),q(n,G);else{let be=0,Ie={};for(let Ye=0;d[s(1254)](Ye,_0x22e3a7[s(414)]);Ye++)Ie[_0x3f7242[Ye][s(1695)+s(1026)]]=_0x529281(_0x52afa7[Ye]["cursor_n"+s(1026)]),be+=14+Ie[_0x4dbb7d[Ye][s(1695)+s(1026)]];return[be,Ie]}let K=a[s(1501)+s(1402)];e[s(1730)](void 0,K)&&(e[s(1131)](le,n,82),e[s(1131)](q,n,K));let he=a[s(1027)];if(e[s(451)](void 0,he)){if(e.nmiQz===e.zmpFm)return this.count>=this[s(1664)+"ount"];e[s(553)](le,n,90),e[s(1682)](q,n,he)}let Ee=a[s(1437)+"e"];e.jbYOx(void 0,Ee)&&(e.yBmxF(le,n,96),ht(n,e[s(426)](N,Ee)))}function v(a){let n=t;return e[n(1330)](I,e[n(1261)](M,a))}function I(a){let n=t,s={};e:for(;!e[n(665)](V,a);){let d=e[n(711)](de,a);switch(e[n(1030)](d,3)){case 0:break e;case 1:s.SeqID=St(a,!0);break;case 2:s[n(536)]=St(a,!0);break;case 3:s.service=e.nxXIL(de,a);break;case 4:s[n(632)]=e[n(1436)](de,a);break;case 5:{let f=e[n(426)](S,a);(s[n(1136)]||(s[n(1136)]=[])).push(e[n(1024)](E,a)),a[n(836)]=f;break}case 6:s[n(1627)+n(382)]=e[n(553)](P,a,e.dabeQ(de,a));break;case 7:s[n(842)+n(987)]=e[n(482)](P,a,e[n(1380)](de,a));break;case 8:s.payload=ye(a,e.DwzRH(de,a));break;case 9:s[n(796)]=e[n(384)](P,a,e[n(1806)](de,a));break;case 10:s.serverTiming=e[n(1131)](P,a,de(a));break;case 11:s[n(1027)]=e.ivOXA(P,a,e.DwzRH(de,a));break;case 12:s[n(1437)+"e"]=de(a);break;default:e.vSVNZ(C,a,e[n(1266)](7,d))}}if(s[n(1684)]===void 0)throw new Error(e.PxTHl);if(e[n(1352)](void 0,s[n(536)]))throw new Error(e[n(1348)]);if(s[n(1373)]===void 0)throw new Error(e[n(461)]);if(e[n(1352)](void 0,s.method))throw new Error(e[n(1818)]);return s}function S(a){let n=t,s=de(a),d=a[n(836)];return a[n(836)]=a[n(677)]+s,d}function C(a,n){let s=t;switch(n){case 0:for(;e[s(1266)](128,e.XyBzz(re,a)););break;case 2:e[s(1152)](J,a,e[s(1024)](de,a));break;case 5:e[s(1456)](J,a,4);break;case 1:J(a,8);break;default:throw new Error(e.pqzKd(s(1771)+s(1517)+s(967),n))}}function N(a){let n=t;return a|=0,{low:a,high:e[n(848)](a,31),unsigned:e.iwBGP(a,0)}}let y=[];function D(){let a=t,n=y[a(503)]();return n?(n[a(677)]=n[a(836)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){y[t(738)](a)}function M(a){return{bytes:a,offset:0,limit:a[t(414)]}}function B(a){let n=t,s=a.bytes,d=a[n(836)];return e[n(417)](s[n(414)],d)?s:s[n(1216)](0,d)}function J(a,n){let s=t;if(e[s(1006)](e[s(522)](a[s(677)],n),a[s(836)]))throw new Error(e.QkoLy);a[s(677)]+=n}function V(a){let n=t;return e[n(1045)](a[n(677)],a[n(836)])}function ee(a,n){let s=t,d={zIuWR:function(f,g){return f instanceof g},WxVPQ:function(f,g){return e.yvhhC(f,g)},fiUmW:function(f,g){return e[H(551)](f,g)},xcYdz:function(f,g){return f!==g}};if(e[s(1352)](e.YURyx,e[s(1318)])){let f=a[s(899)],g=a.offset,w=a[s(836)],b=e[s(821)](g,n);if(e[s(612)](b,f[s(414)])){let x=new Uint8Array(e[s(1166)](2,b));x[s(941)](f),a.bytes=x}return a[s(677)]=b,e[s(1006)](b,w)&&(a.limit=b),g}else{if(JMYGgu[s(652)](_0x385b15,_0x44bbe2))return JMYGgu[s(1238)](_0x16322c,_0x1879df);if(_0x4dfd30[s(1596)](_0x52ae5b))return _0x15bd70[s(633)](_0x40e067);let f=JMYGgu[s(765)](_0x4d7ec2,_0x283508);return JMYGgu[s(938)](f,_0x5351bf)&&(_0x6e6dd8[s(941)](_0x351f17,f),_0x2117ab[s(941)](f,_0x281d73)),f}}function X(a,n){let s=t;if(e.bmBOd!==e[s(1170)]){let d=_0x172f5e.pop();return d?(d.offset=d[s(836)]=0,d):{bytes:new _0x3e289e(64),offset:0,limit:0}}else{let d=a.offset;if(e[s(1751)](d+n,a.limit))throw new Error(e[s(1639)]);return a.offset+=n,d}}function ye(a,n){let s=t,d=X(a,n);return a.bytes[s(1216)](d,e[s(728)](d,n))}function fe(a,n){let s=t;if(e[s(622)](e[s(1196)],e[s(1278)]))e[s(1475)](_0x51a6f0,this,_0x4fbd27,[_0x167102,_0x3bb9ae,_0x156456,_0x323018,_0x207a49,_0x244ea1]);else{let d=e[s(640)](ee,a,n[s(414)]);a.bytes[s(941)](n,d)}}function P(a,n){let s=t,d=X(a,n),f=String[s(1325)+s(1158)],g=a.bytes,w="\uFFFD",b="";for(let x=0;e.aAYtb(x,n);x++){let A=g[x+d],O,z,G,K;if(e.yGgiM(128,A)===0)b+=e[s(1436)](f,A);else if(e[s(1009)](e.yGgiM(224,A),192))e[s(1448)](e[s(1351)](x,1),n)?b+=w:(O=g[e[s(728)](e[s(756)](x,d),1)],e[s(1519)](e[s(1266)](192,O),128)?b+=w:(K=e[s(798)](e[s(475)](e[s(676)](31,A),6),63&O),K<128?b+=w:(b+=e[s(1798)](f,K),x++)));else if(e.dPMAM(e.yGgiM(240,A),224)){if(e[s(1045)](e.SdWcr(x,2),n))b+=w;else if(e[s(1352)](e.xJKmS,e[s(1569)]))O=g[e.tlMsx(x,d)+1],z=g[e[s(522)](e.XHrcF(x,d),2)],e.yGgiM(O|e[s(475)](z,8),49344)!==32896?b+=w:(K=e[s(798)](e.efifk(e[s(475)](e[s(1649)](15,A),12),e.ndJWJ(e.Qwiqi(63,O),6)),63&z),K<2048||e[s(410)](K,55296)&&K<=57343?b+=w:(b+=e.UaIFA(f,K),x+=2));else if(_0x42dc3a>=_0x2dd8b6)return _0x4bc1ab}else e[s(1353)](248,A)==240?e[s(410)](e.BUcOn(x,3),n)?b+=w:(O=g[e[s(522)](x+d,1)],z=g[e[s(435)](e[s(1202)](x,d),2)],G=g[e[s(1281)](e.dDkJy(x,d),3)],e.HRJIU(e[s(798)](e.efifk(O,z<<8),e[s(475)](G,16)),12632256)!==8421504?b+=w:(K=e.efifk(e.efifk(e[s(798)](e[s(475)](7&A,18),e[s(806)](e[s(1649)](63,O),12)),e[s(475)](e[s(698)](63,z),6)),63&G),e[s(433)](K,65536)||K>1114111?b+=w:(K-=65536,b+=e[s(524)](f,e.HBobL(K>>10,55296),e[s(514)](e[s(1561)](1023,K),56320)),x+=3))):b+=w}return b}function q(a,n){let s=t,d={Inkcc:e.GzYWT},f=n[s(414)],g=0;for(let x=0;e[s(630)](x,f);x++){let A=n[s(1117)+"At"](x);e[s(1448)](A,55296)&&e.GyzAC(A,56319)&&e[s(433)](x+1,f)&&(A=e[s(1351)](e.EGhmo(A,10),n.charCodeAt(++x))-56613888),g+=e.aAYtb(A,128)?1:e[s(1623)](A,2048)?2:e[s(1181)](A,65536)?3:4}le(a,g);let w=e[s(841)](ee,a,g),b=a[s(899)];for(let x=0;e[s(1230)](x,f);x++){let A=n.charCodeAt(x);if(e[s(1045)](A,55296)&&e[s(1025)](A,56319)&&e.pVzcC(x+1,f)&&(A=e[s(583)](e[s(821)](e[s(1618)](A,10),n.charCodeAt(++x)),56613888)),e[s(1154)](A,128))b[w++]=A;else{if(A<2048)b[w++]=e[s(1040)](e[s(676)](e[s(848)](A,6),31),192);else{if(e[s(958)](A,65536))b[w++]=e[s(798)](A>>12&15,224);else if(e.flrVI(e.GAIvm,e.GAIvm))b[w++]=e[s(1654)](e[s(774)](e[s(790)](A,18),7),240),b[w++]=e[s(1451)](e[s(848)](A,12),63)|128;else if(!this[s(1592)+s(1537)]){let O=d[s(512)][s(584)]("|"),z=0;for(;;){switch(O[z++]){case"0":this[s(1592)]();continue;case"1":this[s(1411)+s(1032)]?.[s(606)+s(407)]();continue;case"2":this["_readyCl"+s(1466)]=!1;continue;case"3":this[s(413)+s(1538)]?.["resetEndpointCon"+s(1629)]();continue;case"4":this[s(763)]=!0;continue}break}}b[w++]=e.pdwku(A,6)&63|128}b[w++]=e[s(1654)](e[s(1526)](63,A),128)}}}function W(a,n){let s=t,d=e[s(1316)](ee,a,n[s(836)]),f=a.bytes,g=n[s(899)];for(let w=0,b=n[s(836)];e[s(1623)](w,b);w++)f[e.eJxfy(w,d)]=g[w]}function re(a){return a[t(899)][e.dlwsE(X,a,1)]}function Ve(a,n){let s=t,d=e[s(476)](ee,a,1);a.bytes[d]=n}function de(a){let n=t,s=0,d=0,f;do if(e[n(1470)](e[n(718)],e[n(718)])){if(e[n(1715)](void 0,_0x3dc0e5))this._listeners={};else if(e[n(622)](void 0,_0x28826c))this[n(1528)+"rs"][_0x130eda]=null;else{let g=this[n(1528)+"rs"][_0x332868];if(g)for(let w=0;e[n(433)](w,g[n(414)]);)e[n(1009)](g[w].fn,_0x38f48b)?g[n(727)](w,1):++w}return this}else f=e.nxXIL(re,a),e[n(1003)](s,32)&&(d|=e[n(1474)](127&f,s)),s+=7;while(e.HRJIU(128,f));return d}function le(a,n){let s=t;for(n>>>=0;n>=128;)e[s(1552)](Ve,a,e[s(1654)](e[s(795)](127,n),128)),n>>>=7;e[s(444)](Ve,a,n)}function St(a,n){let s=t,d=0,f=0,g=0,w;if(w=e[s(1330)](re,a),d=e[s(676)](127,w),128&w)if(e[s(1821)](e[s(802)],e.mdlQY)){if(w=re(a),d|=e[s(713)](e[s(1266)](127,w),7),e.zlNRw(128,w)&&(w=e.dabeQ(re,a),d|=(127&w)<<14,e[s(709)](128,w)&&(w=re(a),d|=e[s(863)](e[s(774)](127,w),21),128&w&&(w=re(a),f=e.zlNRw(127,w),e[s(1561)](128,w)&&(w=e[s(997)](re,a),f|=e[s(863)](e[s(1574)](127,w),7),e[s(618)](128,w))))))if(e[s(800)](e[s(1706)],s(1444))){let b={ZzSSW:sRXERx[s(916)],Hgsoc:sRXERx[s(1772)],hfqjA:sRXERx[s(464)]};_0x1638c7.r=x=>{let A=s;b[A(1647)]!=typeof _0x56255d&&_0x23ffcc[A(883)+A(725)]&&_0x3f6669[A(1529)+A(1021)](x,_0x134dca[A(883)+A(725)],{value:b[A(492)]}),_0x35e5eb[A(1529)+A(1021)](x,b[A(1172)],{value:!0})}}else w=e[s(1845)](re,a),f|=e[s(863)](e[s(1574)](127,w),14),128&w&&(w=e[s(1436)](re,a),f|=e.RZwTt(e[s(1017)](127,w),21),e.Qwiqi(128,w)&&(w=e[s(1728)](re,a),g=e[s(1561)](127,w),e[s(769)](128,w)&&(w=re(a),g|=e[s(754)](127&w,7))))}else _0x41fd2b[s(906)+s(966)]="",_0x394d3a.log(_0x59d27e);return{low:e[s(1090)](d,e[s(475)](f,28)),high:e[s(798)](e.smWjc(f,4),e[s(754)](g,24)),unsigned:n}}function ht(a,n){let s=t,d={EUzWm:function(f){return e.XSVgw(f)},xRDyy:function(f,g){return f(g)},DFTdG:e[s(929)],AxAxh:e[s(1121)]};if(e[s(615)]!==e.KlHUp){let f=n[s(505)]>>>0,g=e[s(1030)](e[s(1694)](e.hLDdi(n.low,28),e[s(1474)](n[s(1376)],4)),0),w=e[s(731)](n.high,24),b=e.pzCEU(0,w)?g===0?f<16384?f<128?1:2:f<2097152?3:4:e[s(619)](g,16384)?e[s(641)](g,128)?5:6:e[s(1154)](g,2097152)?7:8:e[s(1038)](w,128)?9:10,x=e.tHVGR(ee,a,b),A=a.bytes;switch(b){case 10:A[e.FPvdh(x,9)]=e.EOwbI(w>>>7,1);case 9:A[e[s(429)](x,8)]=e.BNrNS(9,b)?128|w:e.EOwbI(127,w);case 8:A[e[s(1342)](x,7)]=e[s(1322)](8,b)?e.XrYST(g>>>21,128):e[s(608)](g,21)&127;case 7:A[e.tUsaf(x,6)]=e.nEcom(7,b)?e[s(1090)](g>>>14,128):e[s(769)](g>>>14,127);case 6:A[e[s(1551)](x,5)]=b!==6?e.UogJe(g,7)|128:e.Qwiqi(e.dSVvv(g,7),127);case 5:A[e.BUcOn(x,4)]=e[s(1322)](5,b)?e[s(1090)](128,g):e[s(1649)](127,g);case 4:A[e[s(962)](x,3)]=e[s(1533)](4,b)?e[s(1090)](f>>>21,128):e.khxSw(e.kCEpQ(f,21),127);case 3:A[e[s(600)](x,2)]=b!==3?e[s(1090)](e.SDuaW(f,14),128):e[s(1361)](e[s(1844)](f,14),127);case 2:A[x+1]=b!==2?e.vwbVA(e.UogJe(f,7),128):e[s(1120)](f>>>7,127);case 1:A[x]=b!==1?e[s(1732)](128,f):127&f}}else{let f={yoGlo:"error",tZKrn:function(x){let A=s;return aKvhWu[A(1829)](x)},Zrrfz:function(x){let A=s;return aKvhWu[A(1829)](x)},dRBDR:function(x,A){return aKvhWu.xRDyy(x,A)},BwGpk:s(542)+"or"},g=()=>{let x=s;_0x212e5d[x(1699)+x(1262)+x(1231)](x(479),w),_0x4fef7a[x(1699)+x(1262)+x(1231)](f[x(502)],b),_0xca5462["removeEventListe"+x(1231)]("abort",b)},w=()=>{let x=s;f[x(559)](_0x155707),f[x(1666)](g)},b=()=>{let x=s;f.dRBDR(_0xb908a6,_0x14bb53[x(1304)]||new _0x255be8(f[x(974)],x(542)+"or")),g()};_0x1a6cd6[s(510)+"Listener"](aKvhWu[s(804)],w),_0x4dac92[s(510)+s(1469)](s(1304),b),_0x1ff27c[s(510)+s(1469)](aKvhWu[s(572)],b)}}function Xt(a){return e[t(956)](v,a)}function zt(a){return e[t(1707)](T,a)}let Qt=65536,qr=t(623),ge=e.BBcmO(Qt,Qt),Te=e[t(1505)](ge,ge),Jn=Te/2,Pe=String[t(497)+"e"][t(1117)+"At"];class ae{constructor(n,s,d){let f=t;this[f(362)]=!0,this[f(505)]=e[f(1090)](0,n),this[f(1376)]=e[f(1502)](0,s),this.unsigned=!!d}static isLong(n){let s=t;return n&&e[s(1750)](!0,n[s(362)])}static fromBits(n,s,d){return new ae(n,s,d)}static[t(1062)+"s"](n,s,d){let f=t;return d?ae[f(1062)+"sLE"](n,s):ae["fromByte"+f(1301)](n,s)}static["fromByte"+t(1572)](n,s){let d=t;return new ae(e[d(368)](e[d(904)](n[0],e[d(475)](n[1],8))|e[d(475)](n[2],16),e.nrfpZ(n[3],24)),e.BxUIs(e.eIsSZ(n[4],e[d(1539)](n[5],8)),e[d(1363)](n[6],16))|e[d(1618)](n[7],24),s)}static[t(1062)+t(1301)](n,s){let d=t;return new ae(e[d(1098)](e.iAQwg(e[d(1732)](n[4]<<24,e[d(945)](n[5],16)),n[6]<<8),n[7]),e[d(1710)](e[d(1694)](e[d(1474)](n[0],24),e[d(759)](n[1],16)),e[d(713)](n[2],8))|n[3],s)}static fromHash(n){let s=t;return n===qr?Nd:new ae(e[s(1455)](e[s(1698)](e.DqAlT(e[s(1694)](Pe[s(1525)](n,0),Pe[s(1525)](n,1)<<8),e[s(475)](Pe[s(1525)](n,2),16)),e.ZrHkh(Pe[s(1525)](n,3),24)),0),e[s(1825)](e[s(1732)](e.HXLSn(e[s(1694)](Pe.call(n,4),Pe[s(1525)](n,5)<<8),Pe[s(1525)](n,6)<<16),e[s(1208)](Pe[s(1525)](n,7),24)),0),!0)}[t(1099)](){let n=t;return String["fromChar"+n(1158)](e.dvHpJ(255,this[n(505)]),e[n(627)](e[n(1844)](this[n(505)],8),255),e.nTnQG(e.sqldc(this.low,16),255),e[n(1091)](this[n(505)],24),255&this.high,e[n(636)](this[n(1376)],8)&255,e[n(984)](this.high>>>16,255),e[n(636)](this[n(1376)],24))}static[t(532)+"er"](n,s=!0){let d=t;if(isNaN(n))return s?zx:Nd;if(s){if(e.itUUT(n,Te))return Ux}else{if(e[d(1065)](n,-Jn))return qx;if(e[d(1448)](e[d(1126)](n,1),Jn))return Fx}return ae[d(1432)](e[d(412)](n%ge,0),e[d(1747)](e[d(1692)](n,ge),0),s)}[t(826)](){let n=t;return this[n(558)]?e[n(1174)](e[n(1166)](e.kCEpQ(this[n(1376)],0),ge),e[n(1455)](this[n(505)],0)):e[n(951)](e.PZzSc(this[n(1376)],ge),e.uaiVH(this.low,0))}[t(358)](){let n=t;return e[n(1750)](0,this.high)&&e[n(1484)](0,this[n(505)])}[t(1150)](n){let s=t;ae.isLong(n)||(n=ae[s(532)+"er"](n));let d=e.SDuaW(this.high,16),f=e[s(1388)](65535,this[s(1376)]),g=e[s(1175)](this[s(505)],16),w=65535&this[s(505)],b=n.high>>>16,x=e[s(1039)](65535,n[s(1376)]),A=e[s(1719)](n[s(505)],16),O=65535&n[s(505)],z=0,G=0,K=0,he=0;return he+=e[s(522)](w,O),K+=e[s(359)](he,16),he&=65535,K+=e[s(1419)](g,A),G+=K>>>16,K&=65535,G+=e[s(1386)](f,x),z+=e.wmctd(G,16),G&=65535,z+=e[s(581)](d,b),z&=65535,ae.fromBits(e[s(643)](K,16)|he,e[s(1040)](e[s(762)](z,16),G),this[s(558)])}[t(1553)](n){let s=t;return ae[s(362)](n)||(n=ae[s(532)+"er"](n)),e[s(496)](this[s(558)],n.unsigned)&&e[s(1337)](this.high,31)===1&&e.URJTz(e[s(1337)](n.high,31),1)?!1:this.high===n[s(1376)]&&e[s(1480)](this.low,n.low)}[t(1226)](){let n=t;return e.muzId(-1,this.low)&&e.KpIAs(-1,this[n(1376)])?ae[n(1432)](0,0,this[n(558)]):this.low===-1?ae.fromBits(0,e.YmHCx(this[n(1376)],1),this[n(558)]):ae[n(1432)](e[n(1632)](this[n(505)],1),this[n(1376)],this[n(558)])}[t(394)](n){return n?this.toBytesLE():this.toBytesBE()}toBytesLE(){let n=t,s=this[n(1376)],d=this[n(505)];return[255&d,e[n(1825)](d,8)&255,e.eTxME(e[n(988)](d,16),255),e[n(608)](d,24),255&s,e[n(1526)](e[n(1844)](s,8),255),e[n(555)](s>>>16,255),s>>>24]}[t(733)+"E"](){let n=t,s=this[n(1376)],d=this[n(505)];return[e[n(731)](s,24),e[n(1187)](s,16)&255,e[n(709)](e.iHMqu(s,8),255),e[n(748)](255,s),d>>>24,e[n(1323)](e[n(797)](d,16),255),e[n(355)](d>>>8,255),e[n(1122)](255,d)]}}let Nd=new ae(0,0,!1),zx=new ae(0,0,!0),Fx=ae[t(1432)](-1,2147483647,!1),Ux=ae[t(1432)](-1,-1,!0),qx=ae[t(1432)](0,-2147483648,!1);var en=(function(a){let n=t,s=(n(1716)+"0|1")[n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[n(402)+"OR"]=5005]="OPEN_ERROR";continue;case"1":return a;case"2":a[a[e.WNpzc]=5002]=e[n(1374)];continue;case"3":a[a[e.WIllv]=5001]=e.WIllv;continue;case"4":a[a[e.GJepP]=5003]=n(993)+n(1843)+"R";continue;case"5":a[a[e.IrNUG]=5004]=n(518)+"ERROR";continue}break}})({});class Vn{constructor(n){let s=t;this[s(1271)]=n,this[s(537)]=null}}class Ld extends Vn{constructor(n,s){let d=t;super(n),this[d(1128)]=s&&s.message||null}}class Md extends Vn{constructor(n,s){let d=t,f=(d(575)+d(521)).split("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(777)]=s&&s[d(777)]||5001;continue;case"1":this[d(844)]=s&&s.lineno||0;continue;case"2":this[d(1304)]=s&&s[d(1304)]||null;continue;case"3":this[d(905)]=s&&s.filename||"";continue;case"4":this[d(1128)]=s&&s[d(1128)]||"";continue;case"5":super(n);continue;case"6":this[d(605)]=s&&s[d(605)]||0;continue}break}}}class Bd extends Vn{constructor(n,s){let d=t,f=e[d(477)][d(584)]("|"),g=0;for(;;){switch(f[g++]){case"0":this.wasClean=s&&s[d(1333)]||!1;continue;case"1":super(n);continue;case"2":this[d(1828)+d(554)]=s&&s[d(1828)+d(554)]||!1;continue;case"3":this[d(777)]=s&&s.code||0;continue;case"4":this[d(1205)]=s&&s[d(1205)]||"";continue}break}}}class zd extends Vn{constructor(n,s){let d=t;super(n),this[d(1479)]=s&&s[d(1479)]||null}}class Fd extends zd{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1479)]||null,this[d(1128)]=s&&s[d(1128)]||null}}class Ud extends Vn{constructor(n,s){let d=t;super(n),this[d(1479)]=s&&s[d(1479)]||null}}function at(a,{message:n,code:s,error:d}){return new Md(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){let g=t;if(e[g(1519)](e[g(1309)],"pMAWd"))e.BeqOk(_0x754f9b,_0xc81b01,32),e[g(538)](_0x320b1f,_0x28afd1,_0x5d16b6(_0x1a77cc));else return new Bd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function qd(a,{data:n,message:s}){return new Fd(a,{data:n,message:s})}function Hd(a,{data:n}){let s=t,d={sogUZ:function(f,g){return e[H(825)](f,g)},uOYGD:function(f,g,w){return e[H(1249)](f,g,w)},hTOeI:function(f,g,w){return e[H(1559)](f,g,w)},uxWIe:function(f,g,w,b){return e[H(1475)](f,g,w,b)},XcStZ:function(f,g){return f+g}};if(e[s(1263)]==="zSWoZ")return new Ud(a,{data:n});{let f=0,g=[];for(;d[s(823)](f,_0x16411e[s(1227)+"th"]);){let{offset:w}=d[s(525)](_0x5050ac,_0x265a40,f);f=w;let b={cursor_name:"",cursor:0,service:0},{value:x,offset:A}=_0x1441ad(_0x21e437,f);b.service=x,f=A;let{value:O,offset:z}=d[s(671)](_0xf0298b,_0x4cec40,f);f=z,b[s(1695)+s(1026)]=d.uxWIe(_0x2288b6,_0x447fb3,f,d[s(1565)](f,O)),f+=O;let{value:G,offset:K}=d.hTOeI(_0x578d55,_0x195d86,f);b[s(457)]=G[s(826)](),f=K,g[s(738)](b)}return g}}function na(a,{message:n}){let s=t,d={EEHmG:function(f,g,w){return f(g,w)},hgEcV:e.TYaio,enVzD:function(f,g){return e[H(1009)](f,g)},EgWVY:function(f,g,w){return e[H(1658)](f,g,w)}};if(e[s(668)](e[s(971)],e[s(1195)]))return new Ld(a,{message:n});{let f=this[s(413)+s(1538)]?.[s(658)+s(1319)+"es"](),g=this[s(413)+s(1538)]?.[s(726)+s(986)+"nt"]();if(f&&!_0x4b8310[s(1128)]){let w=s(1081)+g+(s(1717)+s(1688)+s(655)+"ed");this[s(1184)+s(1207)+s(968)](d.EEHmG(_0x5cdec6,d[s(858)],{message:w,code:_0x34b1d4[s(993)+s(1843)+"R"],error:_0xd890a6}));return}this[s(862)]&&d[s(912)](this[s(862)][s(998)+"te"],this.OPEN)&&this[s(1408)+s(486)](),this["_dispatc"+s(1207)+s(968)](d[s(946)](_0x29b139,d.hgEcV,{message:_0x118543[s(1128)],code:_0x155daa.NATIVE_ERROR,error:_0x51a0d1}))}}class jd{constructor(n,s){let d=t;this.endpoints=n,this[d(1805)+"es"]=s,this[d(865)+d(1518)]=0,this["currentE"+d(1449)+d(1790)+"t"]=0}[t(1645)+t(1211)+"fig"](){let n=t;this[n(865)+n(1518)]=0,this[n(927)+n(1449)+n(1790)+"t"]=0}[t(1842)+"es"](){let n=t;if(e.xjtnz===n(1441))this[n(927)+"ndpointT"+n(1790)+"t"]=0;else{let d=""+_0x895839[n(930)](),f=_0x17887c||(_0x33431e=_0x4cf285(_0x27b07f)),g=_0x13be4b.random().toString(16)[n(1393)](-6);return e.KYelp(e[n(901)]("02",d),f)+g}}[t(726)+t(986)+"nt"](){let n=t;return this[n(1173)+"s"][this[n(865)+n(1518)]]}[t(726)+"ntEndpoi"+t(530)+t(1720)](){let n=t;return this[n(927)+n(1449)+"riesCount"]}[t(658)+t(1319)+"es"](){let n=t;return!!(e[n(1298)](this[n(865)+n(1518)],this[n(1173)+"s"].length)||e[n(1750)](this.currentIndex,e[n(488)](this.endpoints[n(414)],1))&&this["currentE"+n(1449)+n(1790)+"t"]===this[n(1805)+"es"])}[t(824)+t(1258)+t(511)+"hedMaxRe"+t(1683)](){let n=t;return e[n(1417)](this[n(865)+n(1518)],this[n(1173)+"s"].length)?!0:e[n(1650)](this[n(927)+n(1449)+n(1790)+"t"],this[n(1805)+"es"])}[t(400)+t(1584)+t(1678)+"UpdateCo"+t(1749)](){let n=t;if(e.PzBcB(n(663),n(1107)))_0x193814-=65536,_0x410765+=e[n(1595)](_0x192a50,e[n(1351)](_0x1dabbc>>10,55296),e.AlkEF(e.HRJIU(1023,_0x22c438),56320)),_0x4baa46+=3;else return this[n(927)+n(1449)+n(1790)+"t"]=1,this[n(865)+n(1518)]++,this[n(1173)+"s"][this.currentIndex]}[t(726)+t(986)+t(1578)+t(736)](){let n=t;return this[n(927)+n(1449)+n(1790)+"t"]++,this[n(726)+"ntEndpoint"]()}}let Yn=(e[t(1615)]("undefined",typeof globalThis)&&e[t(1012)](e[t(1407)],globalThis["construc"+t(576)][t(1310)])||e.QSYit(t(1657)+"d",typeof window)&&e[t(1672)](e[t(1407)],window["construc"+t(576)][t(1310)]))&&e.GdDKp(e[t(916)],typeof document),In=e[t(916)]!=typeof globalThis&&(e[t(1190)](e[t(1780)],globalThis[t(375)+t(576)][t(1310)])||e[t(557)]===globalThis[t(375)+"tor"].name)&&e[t(356)](e[t(916)],typeof tt),Hr=(e[t(1293)](e[t(916)],typeof globalThis)&&e.aiEeo(e[t(1780)],globalThis[t(375)+t(576)].name)||e[t(1031)](e[t(916)],typeof globalThis)||e.QSYit(e[t(916)],typeof globalThis)&&!!globalThis["WeixinJS"+t(424)])&&e[t(916)]!=typeof wx,jr=e[t(1615)]("undefined",typeof globalThis)&&(e[t(557)]===globalThis[t(375)+t(576)][t(1310)]||t(1265)+t(888)+t(1088)===globalThis[t(375)+"tor"][t(1310)]||e.PzBcB(e[t(1272)],globalThis[t(375)+"tor"][t(1310)]))&&e[t(916)]!=typeof self,Hx=e[t(411)](e[t(916)],typeof globalThis)&&e[t(1780)]===globalThis[t(375)+t(576)][t(1310)]&&e.uAIgB(e.seZJu,typeof global)&&e.aiEeo(t(1447),global["construc"+t(576)][t(1310)])&&e[t(411)](e[t(916)],typeof process)&&!!process.version;class ra{constructor(){let n=t;this[n(1528)+"rs"]={}}[t(815)](n,...s){let d=t,f=this[d(1528)+"rs"][n];if(f)f.slice().forEach(g=>g.fn[d(898)](g[d(1428)],s));else if(d(1304)===n&&!this.onerror)if(e[d(845)]===e.enZly)_0x682def[d(1699)+"entListe"+d(1231)](sRXERx[d(758)],_0x56735a),_0xdc15b2[d(1699)+d(1262)+d(1231)](d(1304),_0xa4de49);else{let g=s[d(414)]&&s[0];if(e[d(722)](g,Error))throw g;let w=new Error(e.iHrHj(e.XlaQT,g?e[d(563)](e[d(1236)](" (",g[d(1128)]),")"):""));throw w[d(693)]=g,g}return this}[t(1671)](n,s){let d=t;if(e[d(1750)](e[d(884)],e[d(1392)])){if(_0x494514=e.ikLtN(127,_0x5a344a[_0x41306b])>>>0,e[d(857)](_0x56807f[_0xca022d++],128))return{value:_0x145d06?_0x470283:e[d(701)](0,_0x5c7497),offset:_0x144095};if(_0x274e2c=e[d(886)](e[d(1090)](_0x1106d9,e[d(1429)](e.ikLtN(127,_0x1ab2c6[_0x37d208]),7)),0),e[d(1154)](_0x3d89c1[_0xd493b5++],128))return{value:_0x447989?_0x2b26ad:0|_0x34d307,offset:_0x21f5df};if(_0x2d9d49=e[d(1747)](_0x1d2968,e.bjiZu(e.eTxME(127,_0x63c9c8[_0x18a71e]),14))>>>0,e[d(619)](_0x7dbc79[_0x2bcaf2++],128))return{value:_0x33fe77?_0x2ffc79:e[d(1741)](0,_0x14c616),offset:_0x53d204};if(_0x6ae20=e.dLzMf(e[d(1235)](_0x1eca09,e.TQzil(127,_0x45d65f[_0x5100d8])<<21),0),e[d(1820)](_0xb1e5a6[_0x5b81a8++],128))return{value:_0x5d1dc7?_0x3393bc:e[d(1851)](0,_0x124f4a),offset:_0x405c36};if(_0x5a3ca0=e[d(1042)](_0x160380|e.eTxME(15,_0x412923[_0xf35817])<<28,0),e.wCmId(_0x3469d1[_0x93a783++],128))return{value:_0x25af23?_0x17076b:0|_0x104b45,offset:_0x1b6d1b};if((_0x3a8d4f+=5)>_0x56c603.length)throw _0x235fb3=_0x21d30c[d(414)],e[d(1709)](_0x36fecb,_0x2db20f,10,_0x229f5c[d(414)]);return{value:_0x5f311c?_0x481829:e[d(1387)](0,_0x16b7b8),offset:_0x407dca}}else{if(e.xtfws(void 0,n))this._listeners={};else if(e.wJLbG(void 0,s))this._listeners[n]=null;else{let f=this._listeners[n];if(f)for(let g=0;e[d(433)](g,f[d(414)]);)e[d(1480)](f[g].fn,s)?f[d(727)](g,1):++g}return this}}on(n,s,d){let f=t;return(this._listeners[n]||(this[f(1528)+"rs"][n]=[]))[f(738)]({fn:s,ctx:d||this}),this}}class jx extends ra{[t(1110)+"rrorMess"+t(1219)](n){let s=t;return n[s(436)]||n.errNo?(s(887)+" "+(n[s(436)]||"")+s(1e3)+(n[s(1745)]||""))[s(892)]():JSON[s(531)+"y"](n)}constructor(n,s,d){let f=t;super(),this._socket=null,Hr&&wx[f(1354)+f(1585)]&&(this[f(1257)]=wx[f(1354)+"ocket"]({url:n,protocols:s,header:d,fail:this["_createS"+f(855)+f(922)][f(1052)](this),success:this[f(515)+f(603)+f(1549)+f(1367)][f(1052)](this)})),In&&tt[f(1354)+"ocket"]&&(this._socket=tt[f(1354)+f(1585)]({url:n,protocols:s,header:d,fail:this[f(515)+f(855)+f(922)][f(1052)](this),success:this["_createS"+f(603)+f(1549)+f(1367)].bind(this)}))}[t(515)+t(603)+"cessHand"+t(1367)](){Promise.resolve().then(()=>{this[H(875)+"steners"]()})}[t(515)+t(855)+t(922)](n){let s=t,d={reWii:e[s(1368)],ayLlW:e.gjZRl};Promise[s(1240)]().then(()=>{let f=s,g=at(d[f(1590)],{message:this[f(1110)+"rrorMess"+f(1219)](n)});this[f(815)](f(1304),g);let w=xt(d[f(849)],{reason:this[f(1110)+f(408)+f(1219)](n)});this[f(815)](d[f(849)],w)})}["_addWsLi"+t(1161)](){let n=t,s={kOLbk:e[n(1143)],sSTWX:function(d,f,g){return d(f,g)},PLzwb:n(1304)};this[n(1257)][n(1522)](d=>{let f=n;this[f(815)](s.kOLbk,s.sSTWX(Hd,s[f(1169)],{...d,data:d[f(436)]||""}))}),this[n(1257)][n(422)](d=>{let f=n;this.emit(e[f(447)],e[f(538)](xt,e[f(447)],{...d}))}),this._socket.onMessage(d=>{let f=n;this[f(815)](f(1128),e[f(441)](qd,e[f(348)],{...d}))}),this[n(1257)][n(1601)](d=>{let f=n;this[f(815)](s[f(1691)],at(s.PLzwb,{...d,message:d.errMsg||""}))})}[t(1573)](n){let s=t;if(e[s(674)](n,Uint8Array)){let d=n[s(1053)][s(1393)](n.byteOffset,e[s(600)](n[s(1227)+"th"],n[s(347)+"et"]));this[s(1257)]&&this[s(1257)][s(1573)]({data:d,fail:f=>{let g=s;this[g(815)](e.TYaio,at(g(1304),{message:this[g(1110)+g(408)+"age"](f)}))}})}else this[s(1257)]&&this[s(1257)][s(1573)]({data:n,fail:d=>{let f=s;this[f(815)](e[f(1368)],at(e[f(1368)],{message:this["_formatE"+f(408)+"age"](d)}))}})}[t(1834)](n,s){let d=t;this._socket&&this._socket[d(1834)]({code:n,reason:s})}[t(510)+t(1469)](n,s){let d=t;if(e.UImIJ(e[d(547)],d(648)))this.on(n,s);else{let{value:f,offset:g}=e[d(1131)](_0x33b584,_0x48da51,_0x5a51ea);_0x2f3579=g,_0x21eb37=e[d(636)](e[d(964)](_0x3bd4a0,8),0),_0x49700c+=f}}[t(1699)+"entListe"+t(1231)](n,s){this[t(1671)](n,s)}get readyState(){let n=t;return this[n(1257)][n(998)+"te"]}get binaryType(){let n=t;return e[n(812)]===e[n(878)]?_0x1009d1.readUInt8?{value:_0x24e2fe[n(1104)+"8"](_0xb130cf),offset:_0x30ead1+1}:{value:e.HRJIU(255,_0x48c5dc[_0x4885ad]),offset:e[n(1067)](_0x53dbdc,1)}:this[n(1257)].binaryType}set[t(1485)+"pe"](n){}get[t(818)](){let n=t;return this._socket[n(818)]}get[t(1145)](){let n=t;return this[n(1257)][n(1145)]}get[t(1733)+"ns"](){let n=t,s={sWlPW:function(d,f){return e[H(1092)](d,f)}};return e[n(688)](e[n(1826)],e[n(1826)])?KgtjWn.sWlPW(0,this[n(1376)])&&KgtjWn.sWlPW(0,this[n(505)]):this[n(1257)][n(1733)+"ns"]}get[t(1210)+t(508)](){return 0}}function Gx(a,n){let s=t;if(n)return new n(a[s(818)],a[s(1145)]);if(e[s(1795)](Hr,In))return new jx(a[s(818)],a[s(1145)],a.headers);if((Yn||jr)&&e.NACNx("undefined",typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1145)+"s"])}function Wx(a){let n=t,s=e[n(1667)][n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":return!1;case"1":if(In&&tt[n(1354)+n(1585)])return!0;continue;case"2":if(e[n(1256)](Yn,jr)&&e[n(1293)](e[n(916)],typeof WebSocket)&&WebSocket)return!0;continue;case"3":if(Hr&&wx[n(1354)+n(1585)])return!0;continue;case"4":if(a)return!0;continue}break}}function Gd(a,n,s){let d=t,f=-1;async function g(w){let b=H;return e[b(1025)](w,f)?Promise[b(1597)](new Error(e[b(1736)])):(f=w,e[b(1484)](w,s[b(414)])?Promise[b(1240)]():s[w].bind(a)(n,g.bind(null,e[b(1067)](w,1))))}e[d(997)](g,0)}function Wd(a){let n=t,s=0,d=0;for(let f=0;e.XKTDa(f,a[n(414)]);++f)d=a[n(1117)+"At"](f),e[n(681)](d,128)?s+=1:d<2048?s+=2:e[n(1633)](e[n(355)](64512,d),55296)&&e[n(417)](e[n(1598)](64512,a[n(1117)+"At"](f+1)),56320)?(++f,s+=4):s+=3;return s}function Kd(a,n,s){let d=t,f={NNARl:function(g,w){return e[H(493)](g,w)},vJjkG:function(g,w){return e[H(438)](g,w)},QXUvR:e[d(747)]};if(e[d(1433)](e.llaTr,e[d(1176)])){if(e[d(1570)](e.fJHaK(s,n),1))return"";let g="";for(let w=n;e[d(613)](w,s);){let b=a[w++];if(b<=127)g+=String[d(1325)+d(1158)](b);else if(e.rcjpA(b,192)&&e[d(1181)](b,224))g+=String[d(1325)+d(1158)]((31&b)<<6|e[d(1237)](63,a[w++]));else if(e.eqhdp(b,224)&&e[d(860)](b,240))g+=String[d(1325)+d(1158)](e[d(1718)](e[d(1694)](e[d(1514)](15,b)<<12,e[d(1363)](e.tmscF(63,a[w++]),6)),e[d(1759)](63,a[w++])));else if(e[d(1298)](b,240)){let x=e[d(552)](e.sMnHB(e[d(1040)](e[d(1747)](e[d(1371)](e[d(546)](7,b),18),e[d(683)](e[d(766)](63,a[w++]),12)),e[d(1353)](63,a[w++])<<6),63&a[w++]),65536);g+=String[d(1325)+d(1158)](55296+e[d(848)](x,10)),g+=String[d(1325)+d(1158)](e[d(600)](56320,1023&x))}}return g}else{let g=f.NNARl(_0x4448cf,_0x1c5241);this[d(862)]&&f[d(1359)](this[d(862)][d(998)+"te"],this[d(1060)])&&(this._ws&&this[d(862)][d(1573)](g),this[d(1142)](f[d(1810)],_0x47f8fd))}}function ia(a,n,s){let d=t,f=s,g,w;for(let b=0;b<a[d(414)];++b)if(g=a[d(1117)+"At"](b),g<128)n[s++]=g;else if(e[d(792)](g,2048))n[s++]=e[d(874)](e[d(848)](g,6),192),n[s++]=e[d(1732)](e[d(1454)](63,g),128);else if(e[d(628)](e[d(1237)](64512,g),55296)&&e.kSrSu(64512&(w=a.charCodeAt(b+1)),56320)){let x=e[d(393)][d(584)]("|"),A=0;for(;;){switch(x[A++]){case"0":n[s++]=e.SxStB(63&g,128);continue;case"1":n[s++]=e[d(406)](e[d(1338)](e.ypVOG(g,6),63),128);continue;case"2":n[s++]=e[d(1345)](g>>18,240);continue;case"3":++b;continue;case"4":n[s++]=g>>12&63|128;continue;case"5":g=e[d(435)](e[d(684)](65536,e[d(387)](1023&g,10)),e[d(627)](1023,w));continue}break}}else n[s++]=e.kFYwS(g>>12,224),n[s++]=e[d(1811)](g,6)&63|128,n[s++]=e.WaMHe(e[d(644)](63,g),128);return e[d(583)](s,f)}async function $d(a){let n=t;if(e[n(803)]==typeof a)if(e[n(622)](n(789),e.vvPRL))_0xf46297[n(1802)][n(973)+"ild"](_0x3a03d1);else{let s=new Uint8Array(e[n(1661)](Wd,a));return e.PDPIH(ia,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a[n(347)+"et"],a[n(1227)+"th"])}function Kx(a){let n=t,s={aQhNT:function(d,f){return e[H(612)](d,f)},UrxAM:n(716)+n(513)};if(e[n(1009)](e[n(1567)],e[n(590)])){if(GqtrkV.aQhNT(_0x1ab5ac.offset+_0x4ed3c9,_0xfc24eb[n(836)]))throw new _0x583cdd(GqtrkV[n(1245)]);_0x19c6eb[n(677)]+=_0x4b0ca4}else try{return e[n(1293)](e.uNFHJ,typeof a)&&(a instanceof ArrayBuffer||a[n(1053)]&&e.MkmQj(a[n(1053)],ArrayBuffer))||e[n(803)]!=typeof a?"":(JSON.parse(a),e.QKKHU)}catch{return n(719)==typeof a?e[n(594)]:""}}let $x=(a,n)=>{let s=t;switch(a){case e.JfjXZ:case e[s(1160)]:return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class Jx{constructor(n){let s=t;this[s(1664)+s(1720)]=n,this.count=0}[t(1625)](){let n=t;if(e[n(1748)](e[n(1778)],e[n(1764)]))this[n(932)]++;else{let s=_0x34938b[n(833)+"g"](0,4-_0x54f4cf[_0xa87235][n(414)]),d=s[n(1714)](_0x34f7bb);_0x2ee725=_0x56f408[n(1714)](d)}}[t(658)+"chMaxCount"](){let n=t;return this.count>=this[n(1664)+n(1720)]}[t(606)+t(407)](n=0){let s=t;this[s(1664)+s(1720)]=n,this.count=0}}async function Vx(a){let n=t,s={xOaeO:function(d,f){return e[H(1108)](d,f)},ZGfAe:e[n(1151)],USzyJ:function(d,f,g){return e[n(1131)](d,f,g)},FjiQP:function(d,f){return e[n(1730)](d,f)},evjtL:n(1613),EuvAC:"ioWlR",ggnst:e[n(455)],VlRJl:n(1622),AeAot:e.XbBUq,cREJj:function(d,f){return e[n(493)](d,f)}};return new Promise(d=>{let f=n,g={fgQVH:function(w,b,x){return s[H(1123)](w,b,x)},zYfnc:function(w,b){return w+b}};if(s[f(1543)](s.evjtL,s.EuvAC)){if(!Yn)return d(s.ZGfAe);try{let w=document[f(443)+"ement"](f(566));window[f(1347)+f(654)]=b=>{let x=f;document[x(1802)][x(656)+x(1020)](w),window[x(1347)+x(654)]=void 0,s[x(1002)](d,b&&b[x(397)]||s.ZGfAe)},w[f(1271)]=s.ggnst,w.src=a[f(1336)](/^ws/,s[f(730)])+s[f(1576)];try{document[f(1802)].appendChild(w)}catch{if(s.FjiQP(f(1294),f(1406)))document.body[f(656)+f(1020)](w);else{let b=jqTnpY[f(940)](_0x4c3ebc,_0x1daaa3,_0x3d39f9);return _0x456313[f(899)][f(1216)](b,jqTnpY[f(801)](b,_0x2a3314))}}}catch{window[f(1347)+f(654)]=void 0,s.cREJj(d,s[f(1631)])}}else this[f(809)]=_0x423ea9,this[f(357)]=_0x135641,this[f(1224)]=_0x1887e6?_0x1a3c88:_0x533f3e?_0x55e407:null})}function tn(a,n,s){let d=t;return!!a?.[d(1365)](f=>f.key===n&&f[d(380)]===s)}function Zn(a,n){let s=t;return a?.find(d=>d[s(1850)]===n)?.[s(380)]}let sa=null;async function Yx(){let a=t;if(e[a(465)](e.bifRj,e[a(1213)]))return sa||(sa=Promise.resolve()[a(1491)](Lt[a(1052)](Lt,"idb"))),sa;if(this[a(965)][a(1586)+a(1385)+a(1445)]||this[a(653)+a(1466)])return;this[a(1220)+a(535)]()}class Zx extends ra{constructor(n,s){let d=t;super(),this[d(1555)]=n,this[d(1134)]=s,this[d(1224)]=void 0,this[d(1589)+d(1767)]=null}async[t(791)](){await this._init()}async[t(1830)](){let n=t,s={irdci:function(d,f,g){return e.mnEkf(d,f,g)}};if(e[n(451)](e[n(793)],n(947))){if(this._qosDB)return;if(this["_initPro"+n(1767)])return this["_initPro"+n(1767)];try{let d=this._dbName,f=this._keyPath;this[n(1589)+"mise"]=(async()=>{let g=n,{openDB:w}=await e[g(1510)](Yx);this._qosDB=await e.WlQRD(w,g(1347)+"_"+d,1,{upgrade(b){b[g(1524)+"jectStore"](d,{keyPath:f})}})})(),await this["_initPro"+n(1767)]}catch(d){console[n(757)](d)}finally{this[n(1589)+n(1767)]=null}}else hmBCwM.irdci(_0x4e6918,_0x3b6559,10),hmBCwM[n(779)](_0x40438e,_0x33f1c4,_0x58f7de)}async[t(633)](n){let s=t;try{if(e[s(1484)]("rTVcp",e[s(1259)]))return await this[s(1830)](),this._qosDB?.[s(633)](this._dbName,n);e[s(538)](_0x47de9a,_0x5550e2,82),_0x41f98e(_0x5cfac6,_0x8b156a)}catch(d){console[s(757)](d)}}async set(n,s){let d=t;return await this._init(),this[d(1224)]?.[d(983)](this[d(1555)],n)}async[t(1635)](n){let s=t;try{return await this[s(1830)](),this[s(1224)]?.[s(1276)](this._dbName,n)}catch(d){console[s(757)](d)}}async[t(1221)](){let n=t;try{return await this[n(1830)](),this[n(1224)]?.[n(1221)](this[n(1555)])}catch(s){console[n(757)](s)}}async[t(1462)](){let n=t;return await this[n(1830)](),this[n(1224)]?.[n(689)+"ys"](this[n(1555)])}async[t(1481)](){let n=t;return await this._init(),this[n(1224)]?.[n(1481)](this[n(1555)])}async[t(420)](){let n=t,s={XmUHS:function(d,f){return e.pqzKd(d,f)},DxATM:function(d,f){return e[H(1845)](d,f)},uWDWI:function(d,f,g){return e[H(925)](d,f,g)},HBDiG:function(d,f){return e[H(405)](d,f)},ZWlVD:function(d,f){return e[H(1746)](d,f)}};if(e[n(1533)]("EuYej",e[n(1577)]))return this._ws?this._ws[n(818)]:this._url;try{if(e[n(1232)]===e[n(1673)])return QqblMI[n(1233)](QqblMI[n(1413)](_0x275c3d,4)[n(724)]("0"),QqblMI[n(752)](_0x35ee15,_0x5e4601,2).toString(16))[n(1393)](-4);this._qosDB?.[n(1834)](),this[n(1224)]=void 0}catch(d){if(e[n(351)]===n(1423))console[n(757)](d);else{if(QqblMI[n(1731)](_0x572991,-_0x214c6a))return _0x5ad66f;if(QqblMI[n(1332)](_0x28fa05+1,_0x19e0ca))return _0x42cea9}}}get isReady(){let n=t;try{return!!this[n(1224)]}catch(s){return console[n(757)](s),!1}}}class Xx{constructor(n,s){let d=t;this[d(809)]=n,this._pathKey=s,this[d(1224)]=localStorage}async[t(791)](){}get[t(1855)](){let n=t;return n(1347)+"_"+this[n(809)]}async[t(633)](n){let s=t,d={dUcIh:e[s(1164)],DMqvo:function(f,g){return e.nOOig(f,g)},iYBXQ:function(f,g){return e.oHwWd(f,g)}};if(e.KpIAs(e[s(1356)],e[s(1356)])){let f=this[s(1224)][s(1757)](this[s(1855)]);return JSON.parse(e.QDyCD(f,"{}"))[n]}else return _0x5dad47 instanceof _0x42e4ca&&(_0x306a1a===OybBTB.dUcIh||OybBTB[s(1019)](_0x59208c,s(934)))?!0:OybBTB[s(1199)](_0x1683e1,_0x46247f)}async[t(941)](n,s){let d=t,f=this[d(1224)][d(1757)](this[d(1855)]),g=JSON.parse(f||"{}");return g[s||n[this[d(357)]]]=n,this[d(1224)][d(1755)](this[d(1855)],JSON[d(531)+"y"](g)),s||n[this[d(357)]]}async del(n){let s=t,d=this._qosDB[s(1757)](this[s(1855)]),f=JSON[s(625)](e[s(1256)](d,"{}"));return f[n]=void 0,this._qosDB[s(1755)](this[s(1855)],JSON[s(531)+"y"](f))}async[t(1221)](){let n=t;return this[n(1224)][n(1221)]()}async[t(1462)](){let n=t,s=this[n(1224)][n(1757)](this[n(1855)]),d=JSON.parse(e[n(483)](s,"{}"));return Object[n(1462)](d)}async getAll(){let n=t,s=this[n(1224)][n(1757)](this[n(1855)]),d=JSON[n(625)](e.KnWPp(s,"{}"));return Object.values(d)}[t(420)](){return Promise[t(1240)]()}get[t(1397)](){return!!this._qosDB}}class Qx{constructor(n,s){let d=t;this._DBName=n,this[d(357)]=s,this[d(1224)]=In?tt:Hr?wx:null}async openDB(){}get[t(1855)](){let n=t;return n(1347)+"_"+this[n(809)]}async[t(633)](n){let s=t,d=this[s(1224)][s(914)+s(1801)](this[s(1855)]);return JSON[s(625)](e.pdWjr(d,"{}"))[n]}async[t(941)](n,s){let d=t,f=this._qosDB[d(914)+d(1801)](this[d(1855)]),g=JSON[d(625)](e[d(1212)](f,"{}"));return g[s||n[this[d(357)]]]=n,this._qosDB[d(1401)+d(1801)](this[d(1855)],JSON[d(531)+"y"](g)),s||n[this[d(357)]]}async[t(1635)](n){let s=t,d=this[s(1224)][s(914)+"geSync"](this[s(1855)]),f=JSON[s(625)](e.KnWPp(d,"{}"));return f[n]=void 0,this[s(1224)][s(1401)+s(1801)](this[s(1855)],JSON.stringify(f))}async clear(){return this[t(1224)].clearStorageSync()}async[t(1462)](){let n=t,s={hyuTC:function(d,f){return e[H(1515)](d,f)},XSvpN:n(1520)+"ascript",hLnWW:function(d,f){return e[n(951)](d,f)}};if(e[n(1012)](e[n(1760)],e[n(1760)])){let d=this._qosDB.getStorageInfoSync(this[n(1855)]),f=JSON[n(625)](d||"{}");return Object[n(1462)](f)}else{let d={KwjFA:function(g,w){return MmcAUS.hyuTC(g,w)},qIqLT:n(735)+"reason"},f=_0x28aacc[n(443)+"ement"]("script");_0x2a5b70[n(1347)+n(654)]=g=>{let w=n;_0xb3772f[w(1802)][w(656)+"ild"](f),_0x16dda9.frontierJSONP=void 0,d[w(592)](_0x23a0f6,g&&g[w(397)]||d[w(645)])},f.type=MmcAUS.XSvpN,f[n(1609)]=MmcAUS.hLnWW(_0x4882fe[n(1336)](/^ws/,n(1622)),n(1702)+n(1610)+n(1097)+"P");try{_0x37e359[n(1802)][n(973)+n(1020)](f)}catch{_0x31d98a.body[n(656)+"ild"](f)}}}async[t(1481)](){let n=t,s=this[n(1224)][n(914)+n(1621)+"nc"](this[n(1855)]),d=JSON[n(625)](s||"{}");return Object[n(1225)](d)}[t(420)](){return Promise[t(1240)]()}get[t(1397)](){return!!this[t(1224)]}}function Jd(a,n){let s=t;if(e[s(580)](In,In))return new Qx(a,n);if((Yn||jr)&&e[s(1293)](s(1657)+"d",typeof indexedDB))return new Zx(a,n);if(e.xYYUA(Yn,jr)&&e[s(1369)](s(1657)+"d",typeof localStorage))return new Xx(a,n);throw new Error(e[s(579)])}class ep{constructor(){let n=t;if(n(1754)===e[n(1250)])this[n(650)+n(750)+"Id"]=null,this[n(650)+"l"]=36e5,this[n(1224)]=Jd("qos","message_id");else{let s=n(1081)+_0x3532d3+(n(1663)+", max re"+n(1495)+"ached");this._debug(s),this["_dispatc"+n(1207)+n(968)](_0x318b6f(e[n(1368)],{message:s,code:_0x2ae21b[n(993)+n(1843)+"R"]}));return}}async[t(650)+t(1773)](){let n=t,s={vjXnO:function(d,f){return e[H(1024)](d,f)},XDmmm:function(d,f){return e.FPvdh(d,f)},JPrxm:function(d,f){return e[H(1558)](d,f)},FLLHc:function(d,f){return e[H(1785)](d,f)},qNbPj:e[n(610)],xMBJt:e.YZUkC};if(e[n(1341)]!==e.COJyp)clearInterval(this[n(650)+"lTimeoutId"]),this[n(650)+n(750)+"Id"]=e[n(585)](setInterval,()=>{this["flushExp"+n(1105)]()},this[n(650)+"l"]);else{let d=_0x28f1f1.split(/\./)[n(785)](w=>_0x50c0bf(w)),f=[];return f[0]=IvtuTI[n(740)](_0x166c86,IvtuTI[n(851)](d[0],d[1])),f[1]=IvtuTI.JPrxm(_0x5067ce,IvtuTI[n(1641)](d[2],d[3])),[n(1264),IvtuTI[n(694)],IvtuTI[n(694)],n(1264),"0000",IvtuTI[n(1852)],f[0],f[1]][n(724)]("")}}async[t(791)](){let n=t,s={hTnwO:"sent",vbhnX:function(d,f){return e[H(1092)](d,f)},HvxiG:e[n(1061)]};await this[n(1224)].openDB()[n(1491)](()=>{let d=n,f={MWUOB:s[d(942)]};s[d(1458)](d(614),s[d(1513)])?(this._ws&&this[d(862)][d(1573)](_0x287017),this[d(1142)](f[d(556)],_0x68b6a9)):this[d(650)+d(1773)]()})}async[t(696)+t(1105)](){let n=t;(await this._qosDB?.[n(1481)]()||[])[n(638)](({timestamp:f})=>f<Date[n(930)]()).forEach(f=>{let g=n,w={qWpek:e[g(1357)]};if(e.URJTz(e[g(1223)],g(1066)))this[g(1224)]?.[g(1635)](f[g(1321)+"id"]);else return{frameType:_0x23bc6f,headers:[{key:g(1335)+"ile_name",value:w[g(1410)]}],payload:void 0}})}async[t(1635)](n){let s=t;return this[s(1224)]?.[s(1635)](n)}async[t(941)](n,s){let d=t;return this[d(1224)]?.[d(941)]({message_id:n,timestamp:s})}async get(n){return this._qosDB?.get(n)}async closeDB(){let n=t;e.XEOOA(e[n(1452)],e[n(1300)])?(e.IjYHG(clearInterval,this[n(650)+n(750)+"Id"]),await this[n(1224)]?.closeDB()):(this["_miniNav"+n(960)+n(1604)]=_0x10e4da,_0x442000?this[n(691)+n(437)]():this[n(691)+"ffLine"]())}get isReady(){let n=t;return this[n(1224)]?.[n(1397)]}}function oa(a){let n=t,s=!!this[n(965)][n(720)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1709)](tn,a[n(1128)][n(1136)],e[n(704)],"2"),f=d&&e[n(1475)](tn,a[n(1128)][n(1136)],e[n(1753)],"1"),g=d&&e.WfhIs(tn,a[n(1128)][n(1136)],n(820)+n(1813)+"k","1"),w=g?e[n(664)](Zn,a[n(1128)][n(1136)],e[n(770)])?.[n(584)](",")[n(638)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:g,ackMsgIds:w}}async function Vd(){let a=t;return this[a(1679)+"ger"]||(this[a(1679)+"ger"]=new ep),this["_QoSMana"+a(350)][a(1397)]||await this._QoSManager[a(791)](),this[a(1679)+"ger"]}async function tp(a,n){let s=t,{enableAutoAck:d}=this[s(965)],f=tn(a[s(1128)][s(1136)],"need_ack","1"),g=e[s(1475)](tn,a.message[s(1136)],s(1400),"1"),w=oa[s(1525)](this,a);if(e[s(415)](d,f)){let{SeqID:b,LogID:x,service:A,LogIDNew:O,method:z}=a[s(1128)];this[s(926)]({SeqID:b,LogID:x,LogIDNew:O,service:A,method:z,headers:[{key:e[s(1273)],value:"1"},{key:e[s(1103)],value:e.xYYUA(O,"")},{key:e.DFsME,value:"0"}]})}g&&!w[s(808)]&&this[s(1184)+"hAckMessageEvent"](a),e.BuaRz(n)}async function np(a,n){let s=t;this[s(1142)](e[s(1734)],a[s(1128)]),n()}async function rp(a,n){let s=t,d=Xt(await $d(a.data));try{if(d[s(1206)]instanceof Uint8Array){let f=e[s(722)](this._options[s(1627)+s(382)],Object)?{force:!!this._options[s(1627)+s(382)][s(1769)],encoding:this[s(965)][s(1627)+"ncoding"].encoding?this[s(965)].payloadEncoding.encoding[s(1336)](/\s/g,"").toLowerCase():""}:{force:!1,encoding:this[s(965)][s(1627)+s(382)]?this._options["payloadE"+s(382)][s(1336)](/\s/g,"")[s(1575)+"ase"]():""},g=d[s(1627)+"ncoding"]?d[s(1627)+s(382)][s(1336)](/\s/g,"")[s(1575)+"ase"]():"",w=e[s(722)](this[s(965)].payloadType,Object)?{force:!!this[s(965)][s(842)+"ype"][s(1769)],type:this[s(965)]["payloadT"+s(987)][s(1271)]?this._options["payloadT"+s(987)][s(1271)][s(1336)](/\s/g,"")[s(1575)+s(660)]():""}:{force:!1,type:this[s(965)][s(842)+s(987)]?this[s(965)]["payloadT"+s(987)][s(1336)](/\s/g,"")[s(1575)+"ase"]():""},b=d[s(842)+"ype"]?d[s(842)+"ype"][s(1336)](/\s/g,"")["toLowerC"+s(660)]():"",x=w[s(1769)]?w[s(1271)]:b||w.type,A=f[s(1769)]?f[s(1074)]:g||f.encoding,O=[e[s(594)],"applicat"+s(1051),s(1218)+s(1051)+";charset"+s(840),e[s(803)]],z=[s(1229)+"e",e[s(1016)]];this[s(965)]["enableTr"+s(543)+s(1503)+"ad"]&&O.includes(x)&&(!A||z[s(462)](A))?d[s(906)+s(966)]=e.CyyWg(Kd,d.payload,0,d.payload[s(1227)+"th"]):d[s(906)+s(966)]=""}else d[s(906)+"oad"]=""}catch(f){d[s(906)+"oad"]="",console[s(757)](f)}a[s(1128)]=d,e[s(939)](n)}function ip(a,n,s){let d=t,f={lzEPx:function(A,O){return e[H(360)](A,O)},UdykM:function(A,O){return e[H(1461)](A,O)},LYziq:function(A,O){return e[H(1075)](A,O)},WKfsF:function(A,O){return A(O)},SNNOi:function(A,O){return e.MjRDU(A,O)},fMczi:function(A,O){return e.dDkJy(A,O)},lApOB:function(A,O){return e[H(1040)](A,O)}},g=e[d(1391)](s,8192),w=g>>>1,b=null,x=g;return function(A){let O=d;if(f.lzEPx(A,1)||f[O(471)](A,w))return a(A);f.UdykM(f[O(1295)](x,A),g)&&(b=f[O(1582)](a,g),x=0);let z=n.call(b,x,x+=A);return f[O(1687)](7,x)&&(x=f[O(843)](f[O(830)](7,x),1)),z}}let sp=4294967295;function op(a,n,s){let d=t;return RangeError(e[d(684)](e[d(429)](e[d(1632)](e[d(1512)]("index ou"+d(813)+d(1112),a),e[d(1282)]),e[d(1675)](n,1))+e[d(474)],s))}function ap(a,n,s){let d=t,f={lkRSk:e.KCvfV};if(e[d(895)](e[d(954)],e[d(1536)]))return _0x4e31f4||(_0x2ae75c=_0x1f9b3c[d(1240)]().then(_0x534bfd[d(1052)](_0x3eb83f,cGUdnk[d(856)]))),_0x474436;{if(s>sp)throw new Error("integer "+d(1100)+"e");let g=3;for(;g>=0;){let w=e[d(1122)](255,s);ca(w,a,e[d(522)](n,g)),s>>>=8,g--}return e[d(1785)](n,4)}}function cp(a,n){let s=t;if(e.znzGX(e[s(949)],s(541)))_0x2d4d39(_0x127b3d,18),_0x1891da(_0x1507c1,_0x4b78db);else{let d=0,f=n,g=e[s(1785)](n,4);for(;f<g;){let{value:w,offset:b}=e[s(1339)](aa,a,f);f=b,d=e[s(1286)](d,8)>>>0,d+=w}return{value:d,offset:g}}}function dp(a,n,s){let d=t;return a?e[d(619)](a.length,40)?e[d(1236)](e.WfhIs(ia,a,n,s),s):n[d(463)+"e"]?e[d(1839)](n[d(463)+"e"](a,s),s):n[d(893)]?e.YmHCx(n.write(a,s),s):e.nkpTy(ia,a,n,s)+s:s}function lp(a,n){let s=t,d=new ae(e[s(1775)](e.jVBlY(e[s(838)](e[s(1320)](a[e.keYWh(n,4)],24),e[s(1521)](a[e[s(1214)](n,5)],16)),e[s(1608)](a[n+6],8)),a[e.CyGjy(n,7)]),e.ifSBb(e[s(368)](e[s(379)](a[e[s(602)](n,0)],24)|e[s(869)](a[e.hoYyQ(n,1)],16),e[s(1208)](a[e[s(1744)](n,2)],8)),a[e.PJWPO(n,3)]),!0);return n+=8,{value:d,offset:e[s(1144)](n,8)}}function up(a,n,s){let d=t;if(e[d(1833)]==="yzscE"){let f=a[d(505)],g=a.high;return n[s]=e[d(636)](g,24),n[e[d(901)](s,1)]=e.YWAHh(e[d(935)](g,16),255),n[e.dDkJy(s,2)]=e[d(1415)](e[d(886)](g,8),255),n[s+3]=e[d(774)](255,g),n[e.DPzIE(s,4)]=e[d(636)](f,24),n[e.DQUeq(s,5)]=e[d(910)](e[d(608)](f,16),255),n[e[d(811)](s,6)]=e[d(835)](e[d(1560)](f,8),255),n[e.YmHCx(s,7)]=e[d(596)](255,f),s+=8,s}else{let f={HGMXV:function(w,b,x){return e.YTQdm(w,b,x)},WsWNe:d(1304)},g=_0x40146f[d(1053)].slice(_0x1f9526[d(347)+"et"],e.VYenR(_0x514606[d(1227)+"th"],_0x43f27f[d(347)+"et"]));this._socket&&this[d(1257)][d(1573)]({data:g,fail:w=>{let b=d;this[b(815)]("error",f[b(517)](_0x54217b,f[b(431)],{message:this[b(1110)+b(408)+b(1219)](w)}))}})}}function aa(a,n){let s=t;return a.readUInt8?{value:a.readUInt8(n),offset:e[s(1551)](n,1)}:{value:255&a[n],offset:e[s(1186)](n,1)}}function ca(a,n,s){let d=t;return n[d(528)+"t8"]?n[d(528)+"t8"](a,s):n[s]=e[d(1598)](255,a),e[d(821)](s,1)}let fp=function(a){return new Uint8Array(a)},hp=e.PBLSD(e[t(916)],typeof Buffer)?Buffer[t(1564)+t(852)]:e[t(538)](ip,fp,Uint8Array.prototype[t(1216)]);(()=>{let a=t,n={NzwxM:e[a(447)],kdViw:function(s,d){return s>>>d},wUgvU:function(s,d){return e[a(1446)](s,d)},ZtvzJ:function(s,d){return e[a(980)](s,d)},XvSdn:function(s,d){return s&d},oXqaL:function(s,d){return e.fjhMP(s,d)},Qccae:function(s,d){return s&d},uCahW:function(s,d){return e.ZtzBQ(s,d)},cZyeO:function(s,d){return s+d},KbqdI:function(s,d){return e[a(1281)](s,d)},JJTwT:function(s,d){return s<<d},tKBvN:function(s,d){return e[a(1040)](s,d)},tuRwF:function(s,d){return e[a(387)](s,d)},Fujlu:function(s,d){return e.uaiVH(s,d)},yGeXr:function(s,d){return e.bjiZu(s,d)},sEsaH:function(s,d){return e.zlNRw(s,d)},UHsGi:function(s,d){return e[a(1008)](s,d)},uNNpX:function(s,d){return e[a(880)](s,d)},nhQzZ:function(s,d){return e[a(1014)](s,d)},BBAzL:function(s,d){return e[a(368)](s,d)},wwOxO:function(s,d){return e.TBEoD(s,d)},gikzc:function(s,d){return e.zcTUA(s,d)},KavYm:function(s,d){return e.MQDxc(s,d)},omHNk:function(s,d){return e.VJpgH(s,d)},cydCt:function(s,d){return e.xgTcl(s,d)},Cajar:function(s,d){return e[a(1570)](s,d)},GfEsF:function(s,d){return s>d},BFZVt:e.ARxGw,YGLDD:e[a(428)],gKKVy:function(s,d,f,g){return s(d,f,g)}};if(e[a(1165)](e.hsypt,e[a(599)]))_0x23ebd4&&_0x5c8e4b["addEvent"+a(1469)](MMwggj[a(1540)],()=>_0x12c814()),_0x3b94b6&&_0x2f47c7[a(510)+a(1469)](a(868)+"hange",()=>_0x53e47e());else{let s=4294967295;return function(d,f,g=!0){let w=a;if(s=n[w(386)](127&d[f],0),d[f++]<128)return{value:g?s:0|s,offset:f};if(s=n.kdViw(s|n[w(1106)](n[w(1607)](127,d[f]),7),0),n[w(1270)](d[f++],128))return{value:g?s:n[w(1611)](0,s),offset:f};if(s=n[w(386)](s|n[w(1547)](n.wUgvU(127,d[f]),14),0),n[w(1665)](d[f++],128))return{value:g?s:n.BBAzL(0,s),offset:f};if(s=n.wwOxO(n[w(1291)](s,n.KavYm(n.Qccae(127,d[f]),21)),0),n[w(1270)](d[f++],128))return{value:g?s:n[w(837)](0,s),offset:f};if(s=n[w(950)](s|n[w(1472)](n[w(1607)](15,d[f]),28),0),n[w(1786)](d[f++],128))return{value:g?s:0|s,offset:f};if(n[w(1082)](f+=5,d.length))if(n[w(1674)]===n[w(1511)]){_0x40796f[w(362)](_0x54c94d)||(_0x142330=_0x50b91b[w(532)+"er"](_0x179b16));let b=MMwggj[w(814)](this[w(1376)],16),x=MMwggj[w(1094)](65535,this[w(1376)]),A=MMwggj.ZtvzJ(this[w(505)],16),O=MMwggj.XvSdn(65535,this[w(505)]),z=MMwggj[w(814)](_0x4db00e[w(1376)],16),G=MMwggj[w(1723)](65535,_0x47d13f[w(1376)]),K=MMwggj[w(814)](_0x57874b[w(505)],16),he=MMwggj[w(755)](65535,_0x32fb5b.low),Ee=0,be=0,Ie=0,Ye=0;return Ye+=MMwggj[w(1807)](O,he),Ie+=MMwggj.kdViw(Ye,16),Ye&=65535,Ie+=MMwggj[w(767)](A,K),be+=MMwggj[w(1468)](Ie,16),Ie&=65535,be+=MMwggj[w(767)](x,G),Ee+=MMwggj[w(814)](be,16),be&=65535,Ee+=MMwggj.KbqdI(b,z),Ee&=65535,_0xbf0761[w(1432)](MMwggj[w(1680)](Ie,16)|Ye,MMwggj[w(1563)](MMwggj[w(1547)](Ee,16),be),this[w(558)])}else throw f=d.length,n[w(548)](op,f,10,d[w(414)]);return{value:g?s:0|s,offset:f}}}})();let xp=16,da=32;function pp(a){let n=t,s={eQlBP:n(1128)},d=0,f={};for(let g=0;e[n(1623)](g,a[n(414)]);g++)e.Ljucs(e.bddWz,e[n(1765)])?(this.emit(s[n(1296)],_0x30dfb1),this.onmessage&&this[n(778)+"e"](_0x51b5a3)):(f[a[g].cursor_name]=e[n(1108)](Wd,a[g][n(1695)+n(1026)]),d+=e[n(367)](14,f[a[g][n(1695)+n(1026)]]));return[d,f]}function Yd(a,n,s){let d=t,f={LatDy:function(A,O){return e[H(992)](A,O)},sFtqj:e[d(937)],QAows:d(490),WIxpP:e.ELQDt,ivbUy:"service-"+d(1310),Zhqxx:e.wQrjw,gxHLt:e[d(349)],DSHWO:function(A,O,z,G){return e.nkpTy(A,O,z,G)},nxTRT:e.EcuUH,twedg:function(A,O,z,G){return e[d(1101)](A,O,z,G)}},[g,w]=e.ZBoyp(pp,a),b=e[d(742)](hp,g),x=0;return a[d(903)](A=>{let O=d;if(f[O(439)](f[O(854)],f[O(896)])){let z=("3|4|6|7|"+O(1114)+O(659))[O(584)]("|"),G=0;for(;;){switch(z[G++]){case"0":console[O(757)](f[O(936)],x);continue;case"1":console[O(757)](f.ivbUy,x);continue;case"2":console.log(O(1782),x);continue;case"3":console[O(757)](f[O(692)],A,A[O(1373)]);continue;case"4":x=ca(0,b,x);continue;case"5":x=ca(w[A[O(1695)+O(1026)]],b,x);continue;case"6":console[O(757)](f[O(859)],x);continue;case"7":x=f.DSHWO(ap,b,x,A[O(1373)]||0);continue;case"8":console[O(757)](f[O(686)],x);continue;case"9":x=f.DSHWO(up,ae[O(532)+"er"](A[O(457)]||n),b,x);continue;case"10":x=f[O(1431)](dp,A[O(1695)+O(1026)],b,x);continue}break}}else _0x34d969.body[O(656)+O(1020)](_0x3b42b1)}),{frameType:da,headers:[{key:d(1335)+d(703),value:s}],payload:b}}function gp(a){let n=t;if(e.zCyVp(e[n(1269)],e[n(1269)])){let s=0,d=[];for(;s<a[n(1227)+"th"];){let{offset:f}=e[n(444)](aa,a,s);s=f;let g={cursor_name:"",cursor:0,service:0},{value:w,offset:b}=e[n(1658)](cp,a,s);g[n(1373)]=w,s=b;let{value:x,offset:A}=e[n(1774)](aa,a,s);s=A,g[n(1695)+n(1026)]=e.CyyWg(Kd,a,s,e.pXrNp(s,x)),s+=x;let{value:O,offset:z}=e[n(1102)](lp,a,s);g[n(457)]=O.toNumber(),s=z,d.push(g)}return d}else e[n(1028)](_0x1b130e,_0x35793e,this[n(489)+n(571)+"e"](_0x34c97b))}function mp(){let a=t;return{frameType:da,headers:[{key:e.oaBXu,value:e[a(1357)]}],payload:void 0}}class wp{constructor(n,s,d){let f=t;this[f(911)+f(1404)]=n,this["_cursorF"+f(737)]=s,this[f(828)+f(1546)]=d,this[f(1224)]=e[f(739)](Jd,this[f(911)+"ameSpace"],e[f(751)])}async[t(791)](){let n=t;await this._qosDB[n(791)]()}async[t(365)+"rs"](){let n=t;if(!this._qosDB[n(1397)])return;let s=this[n(828)+"Strategy"],d=await this[n(1224)][n(1481)]();switch(console[n(757)](e[n(1004)],d),s){case e[n(540)]:return d&&d.length?Yd(d,0,this[n(1788)+n(737)]):void 0;case e[n(1776)]:return;case e[n(459)]:return d&&d[n(414)]?e[n(1644)](Yd,d,0,this[n(1788)+n(737)]):mp()}}async[t(941)](n,s,d){let f=t;return console[f(757)](e[f(807)],n,s,d),this._qosDB[f(941)]({cursor_name:n,cursor:s,service:d})}async[t(1796)+"rs"](n){let s=t;if(e[s(918)](e[s(1378)],e[s(783)]))_0x28e0d0=_0x2694e7[e[s(598)](e[s(782)](_0x594045,_0x59aef2),1)],_0x262a02=_0x5a9c6e[_0x321c1b+_0x3ee008+2],e[s(371)](e[s(1502)](_0x46b052,_0x576e6f<<8),49344)!==32896?_0x3219e5+=_0x4811f4:(_0x576b2e=e[s(1345)](e.vqkFu(e[s(555)](15,_0x461958),12),e[s(662)](e[s(1836)](63,_0x4db8ff),6))|e[s(1779)](63,_0x3da228),e[s(1003)](_0x5c0008,2048)||e[s(507)](_0x3cca3a,55296)&&e[s(582)](_0x1b418f,57343)?_0x4e61be+=_0x53d6b4:(_0x53fd83+=e[s(1068)](_0x481f9b,_0x4b1b93),_0x2ce867+=2));else{let d=e[s(1138)](gp,n);for(let f of d)console[s(757)](s(1130)+"r",d),await this[s(1224)][s(941)](f)}}async[t(633)](n){let s=t;return(await this[s(1224)][s(633)](n))?.[s(457)]}async[t(420)](){let n=t;await this._qosDB[n(420)]()}[t(1416)+t(509)+t(1457)](n){let s=t;this["_cursorF"+s(737)]=n}get isReady(){return this[t(1224)].isReady}}let _p=e.LjhhO;async function Zd(a){let n=t;if(!this[n(965)][n(720)+"S"])return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(965)],g=a||_p;try{return this[n(1156)+"anager"]?a&&this[n(1156)+n(853)][n(1416)+n(509)+n(1457)](a):this[n(1156)+n(853)]=new wp(d+"_"+s+"_"+g,g,f),this[n(1156)+"anager"][n(1397)]||await this[n(1156)+n(853)][n(791)](),this[n(1156)+"anager"]}catch{return null}}async function yp(a,n){let s=t,d=e[s(675)](tn,a[s(1128)].headers,e[s(1837)],"-1"),f=tn(a[s(1128)].headers,s(1400),"1"),g=e[s(710)](Zn,a[s(1128)][s(1136)],e[s(714)]),w=e[s(1656)](Number,Zn(a[s(1128)].headers,e.BghyF))||0,b=oa[s(1525)](this,a),x=e[s(1644)](tn,a[s(1128)].headers,e[s(389)],"2"),A=e[s(710)](Zn,a[s(1128)].headers,e[s(1383)]),O=e.UtKre(Number,Zn(a[s(1128)][s(1136)],e[s(933)]));if(b[s(808)])return n();let z=b[s(1146)+s(1471)]?await Vd[s(1525)](this):null;if(e.Yaqez(a[s(1128)][s(1373)],0)&&f&&!d||a[s(1128)][s(1373)]>0){if(g&&b["isQoSMes"+s(1471)]&&z){if(e[s(523)](e[s(1058)],e.sTLIz))return!!!await z[s(633)](g)&&(this[s(1184)+s(591)+s(1499)](a),await z[s(941)](g,e[s(429)](Date[s(930)](),w))),e[s(390)](n);if(!this["_navigat"+s(1035)]()||this[s(653)+"osed"])return;this[s(413)+s(1538)]?.[s(1645)+s(1211)+"fig"](),this[s(1411)+s(1032)]?.[s(606)+"nter"](),this[s(862)]?this["_disconn"+s(486)](1001,s(1638)+"ay, try "+s(1422)+"ting ser"+s(1486),!0):this[s(1592)]()}if(x){let G=await Zd[s(1525)](this);if(!G)return e.BtQNA!==e[s(1248)]?(this[s(1184)+s(591)+s(1499)](a),e[s(418)](n)):_0xae379b||(_0x20128e=[_0x128be4.prototype.advance,_0x29b02b[s(497)+"e"][s(446)],_0x12a726.prototype["continue"+s(1073)+"ey"]]);let K=await G[s(633)](A)??-1;if(e.TxkSH(K,O))this["_dispatc"+s(591)+s(1499)](a),G[s(941)](A,O,a[s(1128)][s(1373)]);else throw new Error(s(629)+s(1756)+s(1630)+O+(s(434)+"than loc"+s(634)+"r ")+K);return e.BuaRz(n)}return this[s(1184)+s(591)+s(1499)](a),n()}}async function Ep(a,n){let s=t,d=oa[s(1525)](this,a);if(!d[s(1146)+"sage"])return e[s(1510)](n);let f=await Vd.call(this);if(d[s(419)+s(1059)+s(1219)]&&d[s(749)+"s"].length)for(let g of d.ackMsgIds)await f[s(1635)](g);e[s(418)](n)}async function bp(a,n){let s=t,d=e[s(1352)](a.message[s(1437)+"e"],xp),f=e[s(1840)](a.message[s(1437)+"e"],da);if(e[s(1722)](!d,!f))return n();let g=Zn(a[s(1128)][s(1136)],s(1335)+s(703));if(!g)return e[s(1111)](n);let w=await Zd[s(1525)](this,g);if(!w)return e[s(1127)](n);if(d){let b=await w[s(365)+"rs"](),x={frameType:b?.[s(1437)+"e"],SeqID:ae[s(532)+"er"](this[s(1425)]++),LogID:ae[s(532)+"er"](this[s(965)][s(1442)+s(1389)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[s(1206)]},A=T(x);this._ws&&this[s(862)][s(998)+"te"]&&this[s(862)][s(1573)](A)}if(f){let b=a[s(1128)][s(1206)];b&&w[s(1796)+"rs"](b)}}let vp=async function(a,n){let s=t;this[s(763)]=!1,e[s(827)](clearTimeout,this[s(1592)+s(1055)+s(1548)]),e[s(1487)](n)},Sp=async function(a,n){let s=t;if(!this[s(862)]||e[s(1239)](this[s(862)][s(998)+"te"],this[s(1060)]))return e[s(586)](n);let{pingInterval:d}=this[s(965)];this[s(413)+"tManager"]?.["resetEnd"+s(1211)+s(1629)]();for(let g=0;e[s(1141)](g,this[s(828)+s(1375)][s(414)]);g++){let w=this[s(828)+s(1375)][g];if(this[s(862)][s(998)+"te"]===this[s(1060)]&&w!==null)this[s(862)]&&this[s(862)].send(w),this[s(828)+s(1375)][g]=null;else break}this["_message"+s(1375)]=this[s(828)+s(1375)][s(638)](g=>!!g),this[s(1188)+s(1492)+"Id"]=e[s(743)](setTimeout,()=>this[s(734)](),d),this[s(1184)+s(1509)+"nt"](a),this[s(1209)+"er"]&&this[s(862)]&&(this[s(862)][s(1485)+"pe"]=this[s(1460)+s(987)]);let f=this[s(413)+s(1538)]?.["getCurre"+s(986)+"nt"]();this[s(1142)](s(1571)+f+s(1476)),e[s(1421)](n)},Ip=async function(a,n){let s=t,d=this[s(413)+s(1538)]?.[s(726)+s(986)+"nt"]();this[s(1142)](s(1571)+d),e[s(390)](n)};class Ap extends ra{constructor(n){let s=t,d={ZdDxi:function(b,x,A){return e[H(969)](b,x,A)},SQxGG:e[s(1701)],oMsrg:function(b){return e[s(1204)](b)},BhTHx:e[s(690)],EpCKD:e[s(587)],kvaTW:e[s(919)],DgNxs:s(633),TxFWZ:e[s(478)],KgpdC:e[s(1274)],RZcoR:function(b,x){return e[s(1036)](b,x)},agFXy:function(b,x){return e[s(1222)](b,x)},wHOGB:"always",wejzD:"auto",JVqqQ:function(b,x){return e[s(624)](b,x)},ZRXwk:s(1315),HVyRv:e.BGUgM,wORPQ:e.JLwiI,bHUpV:s(1304),dFORX:function(b,x){return e[s(1222)](b,x)},hziou:function(b,x){return e[s(895)](b,x)},MFSIZ:function(b,x){return e[s(1497)](b,x)},CsUkB:function(b,x){return b===x},pQbIK:e[s(666)],vNvwI:function(b,x,A){return e[s(1316)](b,x,A)},PIrQG:function(b,x){return e[s(1681)](b,x)},lvJcx:function(b,x,A){return b(x,A)},KYOqF:s(1834),SKbBX:function(b,x,A){return b(x,A)},RqTcw:e.NbEsp,KDBgd:function(b,x){return e.oLOOh(b,x)},yjdBO:function(b,x,A){return e[s(441)](b,x,A)},BcCLz:function(b,x){return e[s(1198)](b,x)}};super(),this[s(882)+"igatorOn"+s(1604)]=!0,this[s(1209)+"er"]=Yn,this[s(907)]=Hx,this[s(1015)+"T"]=In,this._isMiniWX=Hr,this[s(1643)+"r"]=jr,this[s(828)+"Queue"]=[],this[s(413)+s(1538)]=null,this["_readyCl"+s(1466)]=!1,this[s(1460)+"ype"]=e[s(1655)],this[s(1592)+"Lock"]=!1,this[s(1592)+"ionTimeo"+s(1548)]=null,this[s(1285)+s(1838)+s(366)]=null,this._pingPongTimeoutId=null,this[s(1425)]=0,this._isInit=!1,this._url="",this[s(1679)+s(350)]=null,this[s(1156)+s(853)]=null,this[s(1411)+s(1032)]=null,this[s(867)+"ls"]=e[s(819)],this[s(1853)]=3,this.CONNECTING=0,this[s(1060)]=1,this[s(745)]=2,this[s(631)]=b=>{let x=s;try{Gd(this,b,[vp,Sp,Ip])}catch(A){let O=d[x(1242)](at,x(1304),{message:A[x(1128)],code:en[x(402)+"OR"],error:A});this[x(1184)+"hErrorEv"+x(968)](O)}},this[s(1817)+"ge"]=async b=>{let x=s,A={LHtlh:d.SQxGG,IbuMH:function(G){return d.oMsrg(G)},hHUId:d[x(1482)],Kxrxn:d[x(1340)],VFPOj:d[x(1685)],lrTFl:d[x(1612)],NAnpq:x(1481),JcQJa:d.TxFWZ,LpuIa:d[x(1735)]},{pingInterval:O,pingFrequency:z}=this[x(965)];if(d.RZcoR("hi",b.data)&&d.agFXy(d[x(1418)],z)||d[x(1317)](d[x(1180)],z))if(d[x(780)](x(1315),d.ZRXwk)){let G=A.LHtlh[x(584)]("|"),K=0;for(;;){switch(G[K++]){case"0":_0x460deb(he=>({...he,get:(Ee,be,Ie)=>_0x584b93(Ee,be)||he[x(633)](Ee,be,Ie),has:(Ee,be)=>!!_0x4f75e5(Ee,be)||he[x(1596)](Ee,be)}));continue;case"1":_0x15a114();continue;case"2":_0x5302b7=new _0x3eeaf6;continue;case"3":WthzeS[x(953)](_0x621d9d);continue;case"4":_0x1d7d14=[WthzeS[x(1185)],WthzeS.Kxrxn,x(1276),WthzeS[x(1331)]];continue;case"5":_0x1dce78=[WthzeS.lrTFl,x(1793),WthzeS[x(1835)],WthzeS[x(881)],WthzeS[x(982)]];continue}break}}else this[x(647)+x(1708)](),this[x(815)](d.HVyRv,d.wORPQ),this[x(1188)+x(1492)+"Id"]=setTimeout(this[x(734)][x(1052)](this),O);if(b.data!=="hi")try{Gd(this,b,[rp,tp,Ep,bp,yp,np])}catch(G){let K=at(d[x(1305)],{message:G[x(1128)],code:en[x(518)+x(568)],error:G});this[x(1184)+x(1207)+x(968)](K)}},this[s(427)]=b=>{let x=s;if(d[x(723)](d[x(822)],d[x(822)])){let A=this[x(413)+"tManager"]?.[x(658)+x(1319)+"es"](),O=this[x(413)+x(1538)]?.[x(726)+"ntEndpoint"]();if(A&&!b.message){let z="connect "+O+(x(1717)+x(1688)+x(655)+"ed");this[x(1184)+x(1207)+x(968)](d.vNvwI(at,d.bHUpV,{message:z,code:en["MAX_RETR"+x(1843)+"R"],error:b}));return}this._ws&&d[x(1763)](this._ws[x(998)+"te"],this[x(1060)])&&this[x(1408)+x(486)](),this[x(1184)+x(1207)+x(968)](at(x(1304),{message:b[x(1128)],code:en.NATIVE_ERROR,error:b}))}else return JWkkkc[x(1544)](-1,this[x(505)])&&JWkkkc[x(1846)](-1,this[x(1376)])?_0x1b5c81[x(1432)](0,0,this[x(558)]):JWkkkc.RZcoR(-1,this.low)?_0x202cfd[x(1432)](0,this[x(1376)]+1,this[x(558)]):_0x4c8e62[x(1432)](JWkkkc[x(1856)](this[x(505)],1),this[x(1376)],this[x(558)])},this[s(545)]=async b=>{let x=s;this["_clearTi"+x(1157)](),this[x(647)+x(1708)](),this[x(1637)+x(786)+"rs"](),this[x(862)]=null,this._connectLock=!1;let A=this["_endpoin"+x(1538)]?.[x(658)+x(1319)+"es"]();if(!A&&this[x(996)+x(1035)]()&&!this[x(653)+x(1466)]){let O=this[x(413)+x(1538)]?.["getCurre"+x(986)+"nt"](),z=this[x(965)][x(1422)+x(353)+x(1302)](b.code,b[x(1205)]);this[x(1184)+x(1029)+"ent"](d[x(391)](xt,d[x(604)],{code:1006,reason:b.reason||x(1605)+"ng faile"+x(1268)+x(1527)+x(1155)+x(1761)+O,willReconnect:z})),z&&this[x(1592)]();return}if(d[x(780)](1e3,b[x(777)])&&this[x(653)+x(1466)]){this[x(1184)+"hCloseEv"+x(968)](d[x(908)](xt,d[x(604)],{code:1e3,reason:d[x(775)]})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+"sCounter"]?.[x(606)+x(407)]();return}if(b[x(777)]!==1e3&&A){let O=this[x(413)+x(1538)]?.getCurrentEndpoint(),z=b[x(1205)];z||(z=await d[x(425)](Vx,this[x(1697)])),z="connecti"+x(1197)+x(706)+z+(x(520)+x(1725))+O+(x(1541)+x(1495)+x(1506)),this[x(1184)+x(1029)+x(968)](d.yjdBO(xt,x(1834),{code:b[x(777)],reason:z}));let G=x(1081)+O+(x(1717)+"ax retri"+x(655)+"ed");this[x(1184)+x(1207)+x(968)](d[x(697)](at,d[x(1305)],{message:G,code:en["MAX_RETR"+x(1843)+"R"]})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+"nter"]();return}if(d[x(1583)](1e3,b.code)&&!b[x(1205)]){let O=this[x(413)+x(1538)]?.["getCurre"+x(986)+"nt"]();this[x(1184)+x(1029)+"ent"](d[x(391)](xt,d[x(604)],{code:b[x(777)],reason:x(1605)+"ng faile"+x(1268)+"wn reason, hostn"+x(1761)+O})),this[x(413)+x(1538)]?.[x(1645)+x(1211)+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+x(407)]();return}this[x(1184)+x(1029)+x(968)](b),this[x(413)+"tManager"]?.["resetEndpointCon"+x(1629)](),this[x(1411)+x(1032)]?.[x(606)+"nter"]()},this.onclose=null,this[s(1712)]=null,this.onmessage=null,this[s(682)]=null,this[s(1132)+"econnect"]=null,this[s(395)+s(1770)]=null,this[s(1477)+"mediatel"+s(1660)+"ct"]=null,this["_handleO"+s(437)]=this[s(691)+s(437)][s(1052)](this),this[s(691)+s(1740)]=this[s(691)+s(1740)][s(1052)](this),this[s(635)+s(1084)]=this["_handleP"+s(1084)][s(1052)](this),this[s(635)+s(593)]=this["_handleP"+s(593)][s(1052)](this),this[s(965)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:1/0,service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:s(378),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(459)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:g}=n,w=Array[s(1467)](f)?f:e.HQmyD(e[s(803)],typeof f)?[f]:[];if(!w||w[s(414)]===0)throw new Error(s(667)+s(639)+s(794));if(!e[s(1661)](Wx,g))throw new Error(e.TOTOf);Object.assign(this[s(965)],n),this[s(413)+"tManager"]=new jd(w,this._options[s(1805)+"es"]),this[s(1411)+s(1032)]=new Jx(this[s(965)][s(760)+s(975)]),this[s(965)][s(816)+s(1398)]&&(this[s(763)]=!0,this._connect()),this[s(965)]["listenNe"+s(484)+"nged"]&&(this._isMiniTT||this[s(561)+"X"]?this[s(1841)+s(1183)+s(620)]():this[s(1209)+"er"]&&this[s(1139)+"balEvent"+s(1469)]())}[t(691)+"nLine"](){let n=t;this[n(965)][n(1586)+n(1385)+n(1445)]||this[n(653)+n(1466)]||this[n(1220)+n(535)]()}["_handleO"+t(1740)](){let n=t,s={RSWFB:"open",SIBxd:function(d,f,g){return e[H(364)](d,f,g)}};if(e[n(1036)](e[n(1443)],e[n(1443)])){this[n(361)+n(1642)+"t"]();let d=e[n(1189)](na,e[n(1140)],{message:e[n(1403)]});this[n(1477)+n(931)+n(1660)+"ct"]&&this["onStopIm"+n(931)+n(1660)+"ct"](d)}else this[n(815)](NOaFJy.RSWFB,NOaFJy[n(354)](_0x520df5,NOaFJy[n(1562)],{..._0x10cf1a,data:_0x1eddf4.errMsg||""}))}[t(1139)+t(1424)+"Listener"](){let n=t;this[n(1209)+"er"]&&window[n(510)+n(1469)](e[n(1822)],this[n(691)+"nLine"]),this[n(1209)+"er"]&&window[n(510)+n(1469)](e[n(1508)],this["_handleO"+n(1740)]),this[n(1209)+"er"]&&window["addEvent"+n(1469)](e[n(621)],this[n(635)+n(1084)]),this[n(1209)+"er"]&&window["addEvent"+n(1469)](e[n(458)],this[n(635)+"ageShow"])}["_dropGlo"+t(1424)+"Listener"](){let n=t;this[n(1209)+"er"]&&window["removeEv"+n(1262)+n(1231)](e.XXeqB,this[n(691)+n(437)]),this._isBrowser&&window["removeEv"+n(1262)+"ner"](e[n(1508)],this[n(691)+n(1740)]),this[n(1209)+"er"]&&window["removeEv"+n(1262)+n(1231)](e[n(621)],this[n(635)+n(1084)]),this[n(1209)+"er"]&&window[n(1699)+"entListe"+n(1231)](e[n(458)],this[n(635)+"ageShow"])}[t(635)+t(1084)](n){let s=t;!n[s(1819)+"d"]&&(this._isBrowser&&window[s(1699)+s(1262)+s(1231)](e.NmNoN,this[s(635)+"ageHide"]),this._isBrowser&&window[s(1699)+s(1262)+"ner"](e.xDcxY,this[s(635)+s(593)]),this[s(1834)]()),this[s(1209)+"er"]&&window["removeEv"+s(1262)+s(1231)](e[s(1822)],this[s(691)+s(437)]),this._isBrowser&&window[s(1699)+"entListe"+s(1231)](s(1182),this[s(691)+"ffLine"])}[t(635)+"ageShow"](n){let s=t;if(n[s(1819)+"d"])if(e.kxInc(e[s(1096)],e[s(1096)]))this[s(996)+s(1035)]()&&(!this[s(862)]||e[s(688)](this[s(862)][s(998)+"te"],this[s(1060)])||e[s(451)](this[s(862)][s(998)+"te"],this[s(1010)+"NG"]))&&this[s(691)+s(437)](),this[s(1209)+"er"]&&window[s(510)+s(1469)]("online",this[s(691)+s(437)]),this._isBrowser&&window["addEvent"+s(1469)](e[s(1508)],this[s(691)+s(1740)]);else{let d="0|3|4|2|1"[s(584)]("|"),f=0;for(;;){switch(d[f++]){case"0":if(_0x5f0bb4)return!0;continue;case"1":return!1;case"2":if((_0x4c0b23||_0x30bffd)&&e[s(1615)](s(1657)+"d",typeof _0x264bae)&&_0xeead56)return!0;continue;case"3":if(_0x5f11e0&&_0x44b013[s(1354)+s(1585)])return!0;continue;case"4":if(_0x5a1ddf&&_0x1ca1f6[s(1354)+s(1585)])return!0;continue}break}}}async[t(1358)+t(1450)](n){let s=t;if(e.fFPse!==e[s(700)]){let d=this._endpointManager?.[s(726)+"ntEndpoint"](),f=this[s(965)]["reconnectInterce"+s(1302)](_0x4ddf09[s(777)],_0x439d63[s(1205)]);this[s(1184)+s(1029)+s(968)](e[s(915)](_0x10c673,e[s(447)],{code:1006,reason:_0x3acefb[s(1205)]||s(1605)+s(1197)+s(1268)+s(1527)+s(1155)+s(1761)+d,willReconnect:f})),f&&this[s(1592)]();return}else{let{fpID:d,deviceID:f,bddID:g,ttwID:w,accessKey:b,aID:x,customParams:A={},enableAutoAck:O,enableQoS:z,QoSLevel:G,env:K}=this[s(965)],he,Ee,be;this[s(1209)+"er"]||this[s(561)+"X"]||this._isMiniTT?(he=location&&e.TGeGq(e.tMeGm,location[s(1145)])?e.XYmXL:s(741),Ee=n[s(1336)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),be=/^wss(.*:\/\/)/[s(687)](n)?n:""+he+Ee):(he=s(1766),Ee=n[s(1336)](/(^http)((?:[s]*:\/\/))/,""),be=/(^ws)((?:[s]*:\/\/))/[s(687)](Ee)?Ee:""+he+Ee);let Ie=g?e[s(1228)]:w?e[s(1313)]:e[s(1729)],Ye=g||w||f;if(e[s(580)](!Ye,!Ie))throw new Error(e[s(999)]);let Tp=s(1588)==typeof A?await e.fsUdl(A):A,Rp=K?e[s(385)]($x,K.xUseEnv,K.xTTEnv):{},la=Object.assign({device_platform:e[s(1147)],version_code:e[s(959)],access_key:b,fpid:d,aid:x,[Ie]:Ye,xsack:O?1:0,xaack:O?1:0,xsqos:z?1:0,qos_level:z?G:void 0,qos_sdk_version:2,...Rp},Tp),Cp=Object.keys(la)[s(468)]((ua,fa)=>la[fa]!==void 0?""+ua+(ua?"&":"?")+fa+"="+la[fa]:ua,"");return be+"/ws/v2"+Cp}}async _connect(){let n=t;if(!(this["_connect"+n(1537)]||this[n(653)+n(1466)])){this._connectLock=!0;try{let s=this["_endpoin"+n(1538)]?.[n(824)+n(1258)+"ointReac"+n(1493)+n(1683)](),{timeoutInterval:d}=this[n(965)];if(s){let g=this[n(413)+"tManager"]?.["getCurre"+n(986)+"nt"](),w=this[n(413)+"tManager"]?.[n(400)+"ackupEnd"+n(1678)+n(1253)+n(1749)](),b=this[n(413)+n(1538)]?.["getCurre"+n(986)+n(530)+n(1720)]();if(w){let x=n(1081)+g+(n(1663)+n(1541)+n(1495)+n(705)+"ill use "+n(1832)+n(1427))+w+(n(611)+"y"),A=e[n(915)](at,e[n(1368)],{message:x,code:en[n(993)+n(1843)+"R"]});this[n(1142)](x),this[n(1184)+n(1207)+n(968)](A),this[n(1697)]=await this["_generat"+n(1450)](w),this[n(1142)]("connect "+w+" "+b+n(1809)),this[n(1637)+"sListeners"]()}else if(e[n(460)](n(1366),e.MTCoz)){let x="connect "+g+(" timeout"+n(1541)+n(1495)+n(1506));this[n(1142)](x),this[n(1184)+n(1207)+n(968)](e[n(799)](at,e.TYaio,{message:x,code:en["MAX_RETR"+n(1843)+"R"]}));return}else{if(_0x19a475[n(414)]!==4){let x=_0x5a0030.substring(0,4-_0x2716e8[n(414)]),A=x[n(1714)](_0x41fd55);_0x4031a7[n(738)](A)}else _0x1fcbcb.push(_0x2921eb);_0x363be7&&(_0x426c33+=1),_0x56dec0+=1,_0x566897=!1}}else{let g=this[n(413)+n(1538)]?.["getCurre"+n(986)+n(1578)+"ateCount"](),w=this[n(413)+"tManager"]?.[n(726)+"ntEndpoi"+n(530)+n(1720)]();this._url=await this[n(1358)+n(1450)](e[n(1201)](g,"")),this[n(1142)]("connect "+g+" "+w+" times"),this[n(1637)+n(786)+"rs"]()}if(this[n(763)])this[n(763)]=!1;else if(n(1668)===e.mlUnQ)this[n(1015)+"T"]||this[n(561)+"X"]?this[n(1841)+n(1183)+n(620)]():this._isBrowser&&this[n(1139)+n(1424)+n(1469)]();else{let g=na(e[n(1140)],{message:e[n(1617)]});this[n(1132)+n(535)]&&this["onStartR"+n(535)](g)}let f=this[n(413)+n(1538)]?.[n(726)+n(986)+n(530)+"ount"]()||0;e[n(1453)](f,1)&&await this._wait(f-1),this[n(1142)]("connecti"+n(1711)+this._url+(n(1640)+n(1246))+this[n(867)+"ls"]),this[n(862)]=e[n(1131)](Gx,{url:this[n(1697)],protocols:[this[n(867)+"ls"]],headers:this[n(965)][n(773)+n(1243)+"s"][n(1489)+n(1306)]},this[n(965)].ws),(this[n(1209)+"er"]||this[n(1643)+"r"])&&this[n(862)]&&(this[n(862)].binaryType=this[n(1460)+n(987)]),this[n(875)+n(1161)](),this["_connect"+n(1055)+n(1548)]=e[n(672)](setTimeout,this._onTimeout.bind(this),d)}catch(s){throw this["_connect"+n(1537)]=!1,s}}}["_clearTi"+t(1157)](){let n=t;e[n(850)](clearTimeout,this[n(1592)+n(1055)+n(1548)]),this[n(1592)+n(1055)+n(1548)]=null}[t(647)+t(1708)](){let n=t;clearTimeout(this[n(1188)+n(1492)+"Id"]),e[n(1707)](clearTimeout,this[n(1285)+"ctTimeou"+n(366)]),this[n(1188)+n(1492)+"Id"]=null,this[n(1285)+n(1838)+n(366)]=null}[t(1142)](...n){let s=t;this[s(965)][s(1083)]&&console[s(757)][s(898)](console,[e[s(440)],...n])}[t(489)+"rvalValue"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:g}=this[s(965)],w=e[s(1362)](d,Math[s(1048)](g,e[s(1600)](n,1)));return e[s(612)](w,f)?f:w}[t(734)](){let n=t;if(this._ws&&e.Zqikc(this[n(862)][n(998)+"te"],this[n(1010)+"NG"])){this[n(647)+n(1708)](),this[n(1188)+n(1492)+"Id"]=e[n(1530)](setTimeout,this._ping[n(1052)](this),this._options[n(1394)+n(1784)]);return}if(!this._ws||e[n(1730)](this[n(862)][n(998)+"te"],this[n(1060)]))return void this[n(1220)+n(535)]();this[n(862)]&&this[n(862)][n(1573)]("hi"),this[n(1285)+n(1838)+n(366)]=setTimeout(this[n(1220)+n(535)+n(1705)].bind(this),this[n(965)][n(1662)+"outInter"+n(1550)])}[t(1220)+t(535)+t(1705)](){let n=t;this[n(1411)+n(1032)]?.[n(1625)](),this.emit(e[n(601)],e[n(1395)]),this[n(1411)+n(1032)]?.[n(658)+"chMaxCount"]()?this._handleReconnect():this._ping()}[t(996)+t(1035)](){let n=t;return this._isMiniTT||this[n(561)+"X"]?this["_miniNav"+n(960)+n(1604)]:(this[n(1209)+"er"]||this._isWorker)&&this[n(965)]["listenNe"+n(484)+n(1557)]?navigator.onLine:!0}[t(1220)+t(535)](){let n=t;!this["_navigat"+n(1035)]()||this[n(653)+"osed"]||(this[n(413)+n(1538)]?.["resetEnd"+n(1211)+n(1629)](),this[n(1411)+n(1032)]?.["resetCou"+n(407)](),this[n(862)]?this[n(1408)+"ect"](1001,"going aw"+n(1504)+"reconnec"+n(1011)+n(1486),!0):this._connect())}[t(1841)+t(1183)+t(620)](){let n=t;e[n(1681)]("fKxkO",n(715))?this[n(1788)+n(737)]=_0x52bdec:this[n(1015)+"T"]?tt[n(1382)+n(1275)+"hange"](({isConnected:s})=>{let d=n;this[d(882)+d(960)+"line"]=s,s?this[d(691)+d(437)]():this[d(691)+d(1740)]()}):this._isMiniWX&&wx[n(1382)+n(1275)+n(1086)](({isConnected:s})=>{let d=n;this[d(882)+"igatorOnline"]=s,s?this[d(691)+d(437)]():this[d(691)+d(1740)]()})}[t(1049)](n){let s=t,d={DIqEQ:function(f,g){return e.ZDCUY(f,g)},dgfyk:function(f,g,w,b){return e[H(675)](f,g,w,b)},ZKNcL:function(f,g){return e[H(1327)](f,g)}};if(e[s(1438)](s(607),e[s(448)])){let f=EgZRES[s(1787)](255,_0x103a19);EgZRES[s(1603)](_0x1c706d,f,_0x495a7e,EgZRES[s(1791)](_0x2eeed3,_0x375e72)),_0x18fb27>>>=8,_0xf58df8--}else return new Promise(f=>{let g=s;setTimeout(f,this[g(489)+g(571)+"e"](n))})}[t(1408)+t(486)](n=1e3,s="",d=!1){let f=t;this[f(862)]&&this[f(361)+f(1642)+"t"](n,s,d)}_onTimeout(){let n=t,s=this[n(413)+"tManager"]?.[n(726)+n(986)+"nt"]();this._debug(n(1081)+s+n(1663)),this[n(1408)+"ect"](1001,e[n(569)],!0)}[t(926)](n){let s=t,d=e[s(426)](zt,n);this[s(862)]&&e[s(460)](this[s(862)][s(998)+"te"],this[s(1060)])&&(this._ws&&this[s(862)][s(1573)](d),this[s(1142)]("send_ack",n))}[t(1637)+"sListeners"](){let n=t,s=e[n(1667)].split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(862)]["removeEv"+n(1262)+n(1231)](e.TYaio,this[n(427)]);continue;case"1":this[n(862)][n(1699)+n(1262)+"ner"](e.gjZRl,this[n(545)]);continue;case"2":this[n(862)]["removeEv"+n(1262)+"ner"](e.Txkxl,this[n(1817)+"ge"]);continue;case"3":this[n(862)][n(1699)+n(1262)+n(1231)](e[n(1143)],this[n(631)]);continue;case"4":if(!this._ws)return;continue}break}}[t(875)+t(1161)](){let n=t;if(e[n(1079)](e[n(454)],"pIVzA")){let s=(n(943)+"2")[n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this._ws)return;continue;case"1":this._ws[n(510)+"Listener"](e[n(1143)],this[n(631)]);continue;case"2":this[n(862)][n(510)+"Listener"](e[n(1368)],this[n(427)]);continue;case"3":this[n(862)]["addEvent"+n(1469)](e[n(447)],this._onClose);continue;case"4":this[n(862)][n(510)+n(1469)](e[n(348)],this[n(1817)+"ge"]);continue}break}}else return this[n(1224)]?.[n(633)](_0x352a54)}[t(717)+t(1620)](n=1e3,s=""){let d=t,f={wzbHY:function(g,w){return g(w)},Sdmpn:function(g,w,b){return e[H(972)](g,w,b)}};try{e[d(1434)]===e[d(1434)]?this[d(862)]&&this[d(862)][d(1834)](n,s):(FNPTTD[d(1619)](_0xb38999,this._intervalTimeoutId),this["_interva"+d(750)+"Id"]=FNPTTD.Sdmpn(_0x315f2e,()=>{this.flushExpired()},this[d(650)+"l"]))}catch{}}[t(361)+t(1642)+"t"](n=1e3,s="",d=!1){let f=t;if(this[f(647)+f(1708)](),this[f(526)+f(1157)](),this[f(1637)+"sListeners"](),this[f(717)+"nceClose"](1e3,s),this[f(1592)+f(1537)]=!1,d&&this[f(996)+f(1035)]()&&!this[f(653)+"osed"]){if(this[f(413)+"tManager"]?.[f(658)+"chMaxTries"]()){if(e[f(1748)](f(1580),e[f(764)]))return this[f(1224)].isReady;{let w=this[f(413)+f(1538)]?.getCurrentEndpoint();this[f(1184)+f(1029)+f(968)](e.Isbrl(xt,e[f(447)],{code:1006,reason:"connect "+w+(" timeout"+f(1541)+f(1495)+f(1506)),wasClean:!0}))}}else{let w=this[f(965)][f(1422)+f(353)+f(1302)](n,s);this[f(1184)+"hCloseEv"+f(968)](xt(e[f(447)],{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this[f(1592)]()}return}this[f(996)+"orOnline"]()||this[f(653)+f(1466)]?this[f(1184)+f(1029)+f(968)](e[f(1244)](xt,e[f(447)],{code:n,reason:e[f(396)]})):this[f(1184)+"hCloseEv"+f(968)](e[f(538)](xt,e[f(447)],{code:1006,reason:e[f(744)]})),this[f(862)]=null,this[f(413)+"tManager"]?.[f(1645)+f(1211)+f(1629)](),this[f(1411)+f(1032)]?.["resetCou"+f(407)]()}[t(1184)+"hOpenEvent"](n){let s=t,d={WRGKv:function(f,g){return e.IFESq(f,g)},NSEAt:function(f,g){return e[H(1369)](f,g)},xuimX:e[s(916)],VSJZS:function(f,g){return e.zbZXi(f,g)},Gttuy:e[s(579)]};if(e[s(1346)]===e[s(1346)])this[s(815)](e[s(1143)],n),this.onopen&&this[s(682)](n);else{if(RgkAOa[s(885)](_0x50e6d3,_0x3c9d45))return new _0x3cd124(_0x4d0b85,_0x2b18ed);if((_0x2d0cfb||_0xf2dc0b)&&RgkAOa[s(1742)](RgkAOa[s(453)],typeof _0xd26d05))return new _0xcc7c63(_0x190328,_0x1c6719);if(RgkAOa[s(1283)](_0x49eb2c,_0x147c73)&&RgkAOa[s(1742)](RgkAOa[s(453)],typeof _0x5a4efe))return new _0x498e10(_0x5de71c,_0x746ac1);throw new _0x4e1c84(RgkAOa[s(506)])}}[t(1184)+t(591)+t(1499)](n){let s=t;this[s(815)](e[s(348)],n),this[s(778)+"e"]&&this[s(778)+"e"](n)}[t(1184)+t(562)+t(817)](n){let s=t,d={TVmQx:function(f,g,w,b){return e.zBQuj(f,g,w,b)},aDcBn:function(f,g){return e[H(821)](f,g)},VrsKE:function(f,g){return e[H(1126)](f,g)},NcxRE:function(f,g,w,b){return e[H(1783)](f,g,w,b)}};if(e.Tzwdf(e[s(1496)],e.KRVHO))this.emit(e[s(1064)],n),this[s(395)+"eAck"]&&this[s(395)+s(1770)](n);else return _0x43aaa4?_0x19db54.length<40?PKffle[s(871)](_0x569557,_0x1aab95,_0x10c89a,_0x15c59b)+_0x46b5fe:_0x6388a1[s(463)+"e"]?PKffle[s(1001)](_0x21474d[s(463)+"e"](_0x59bd16,_0x4fe653),_0x2c72ed):_0x3bdb1d.write?PKffle.VrsKE(_0x4067fe.write(_0x34a149,_0x31e26f),_0x361b11):PKffle[s(1001)](PKffle[s(1297)](_0x270b71,_0x164ac8,_0x5108aa,_0x57f624),_0x5063ef):_0x46d32f}[t(1184)+t(1207)+"ent"](n){let s=t;this[s(815)](e[s(1368)],n),this[s(1712)]&&this.onerror(n)}[t(1184)+t(1029)+t(968)](n){let s=t;this.emit(e[s(447)],n),this[s(729)]&&this[s(729)](n)}get[t(1485)+"pe"](){let n=t;return this[n(862)]?this[n(862)][n(1485)+"pe"]:this[n(1460)+"ype"]}set[t(1485)+"pe"](n){let s=t;e[s(1118)]===e.mluUr?(this[s(1460)+s(987)]=n,this[s(862)]&&(this[s(862)][s(1485)+"pe"]=n)):(_0x3b16c7=_0x4d3ffa[s(1714)](_0x5528f1),_0x2ccb86=_0xa59803.concat(_0x416ead[_0x361f59]))}get[t(1037)+"nt"](){let n=t;return this["_endpoin"+n(1538)]?.[n(726)+n(986)+"ntTriesC"+n(1720)]()||0}get[t(1210)+t(508)](){let n=t,s=this[n(828)+n(1375)].reduce((d,f)=>(d+=f&&f[n(1227)+"th"]||0,d),0);return e[n(519)](s,this[n(862)]?this[n(862)].bufferedAmount:0)}get[t(1733)+"ns"](){let n=t;return this[n(862)]?this[n(862)][n(1733)+"ns"]:""}get[t(1145)](){let n=t;if(e[n(624)]("IpTAD",e[n(588)]))_0x5682c2=_0x30a9ed[n(1117)+"At"](_0x4213be),e.TpbmG(_0x1d85b0,128)?_0x46cb1f+=1:_0x1300b2<2048?_0x590801+=2:e[n(430)](e[n(1372)](64512,_0x1ec808),55296)&&e[n(430)](e[n(487)](64512,_0x1c4589[n(1117)+"At"](e[n(1535)](_0xab6356,1))),56320)?(++_0x340a45,_0x6d6da7+=4):_0x245b68+=3;else return this[n(862)]?this[n(862)][n(1145)]:""}get[t(998)+"te"](){let n=t;if(e[n(1652)](e[n(1831)],e[n(944)])){let s=e[n(1007)](_0x504990,_0x30a706,_0x113868[n(836)]),d=_0x239851[n(899)],f=_0x566019[n(899)];for(let g=0,w=_0x3a276c[n(836)];g<w;g++)d[e.PcxEh(g,s)]=f[g]}else return this._ws?this[n(862)][n(998)+"te"]:this[n(965)].automaticOpen?this[n(1010)+"NG"]:this[n(1853)]}get url(){let n=t;return this[n(862)]?this[n(862)].url:this[n(1697)]}close(n=1e3,s){let d=t,f=e[d(970)][d(584)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(544)+"balEventListener"]();continue;case"1":if(this[d(862)][d(998)+"te"]===this[d(1853)]||e[d(895)](this[d(862)][d(998)+"te"],this[d(745)]))return void this[d(1142)](e[d(383)]);continue;case"2":this["_QoSMana"+d(350)]?.closeDB();continue;case"3":this[d(526)+d(1157)]();continue;case"4":this[d(361)+d(1642)+"t"](n,s);continue;case"5":if(!this[d(862)])return void this[d(1142)](e[d(1192)]);continue;case"6":this[d(653)+d(1466)]=!0;continue;case"7":this._clearPingTimer();continue}break}}async send(n,s){let d=t;if(e[d(470)](null,n))throw new Error(e[d(1390)]);e[d(1031)](e[d(1153)],typeof n)&&(n=JSON[d(531)+"y"](n)),e.QSYit(e[d(803)],typeof n)&&!e[d(1288)](n,ArrayBuffer)&&!(n.buffer&&e[d(685)](n.buffer,ArrayBuffer))&&(n=JSON[d(531)+"y"](n));let f=await $d(n),g=e[d(551)](Kx,n),{method:w=0,service:b=this[d(965)][d(1373)],logID:x=this[d(965)][d(1442)+d(1389)](),headers:A=this[d(965)][d(1136)],payloadEncoding:O=this[d(965)][d(1627)+d(382)],payloadType:z=this[d(965)][d(842)+d(987)],logIDNew:G=this._options[d(533)+d(771)]["enableAutoGenera"+d(1721)+"ew"]?e.yJero(i,this._options["logIDNew"+d(771)][d(495)]):""}=e[d(1847)](s,{});if(!b)throw new Error(e.YaWya);let K={SeqID:ae[d(532)+"er"](this._seqId++),LogID:ae[d(532)+"er"](x),service:b,method:w,headers:A,payloadEncoding:e[d(685)](O,Object)?O[d(1074)]?O[d(1074)]:"":O,payloadType:e[d(873)](z,Object)?z[d(1271)]?z[d(1271)]:g:z||g,payload:f,LogIDNew:G},he=e.yvhhC(zt,K);if(this[d(862)]&&e[d(1177)](this[d(862)][d(998)+"te"],this.OPEN))this[d(862)]&&this._ws[d(1573)](he),this._debug(d(1311),K);else if(e[d(1124)](this._messageQueue[d(414)],this._options[d(1624)+d(473)+"ength"]))if(e[d(417)]("NZwqJ",e.IhGFs))this._messageQueue[d(738)](he),this[d(1142)](e[d(1350)],K);else return this._ws?this[d(862)].protocol:"";else this[d(828)+d(1375)][d(1823)](),this._messageQueue[d(738)](he);return{seqID:this[d(1425)],logID:x,logIDNew:G}}async[t(1422)+"t"](n){let s=t,{url:d}=e[s(889)](n,{}),f=Array.isArray(d)?d:e.HkfWs(e[s(803)],typeof d)?[d]:[];n&&Object[s(1217)](this[s(965)],n),f&&f[s(414)]?this._endpointManager=new jd(f,this[s(965)][s(1805)+"es"]):this[s(413)+s(1538)]?.[s(1645)+s(1211)+s(1629)](),this[s(1411)+"sCounter"]?.[s(606)+s(407)](this[s(965)]["pingLoss"+s(975)]),this["_readyCl"+s(1466)]=!1,this._ws&&e[s(1459)](this[s(862)][s(998)+"te"],this[s(1853)])?this[s(1408)+s(486)](1e3,e[s(1599)],!0):(this._isInit=!0,this[s(1592)]())}async[t(1426)](){let n=t;if(!this["_connect"+n(1537)])if(e[n(1200)](e[n(1420)],e[n(1420)])){e.hjjLf(_0x3b9aad,_0x332979,42);let s=e[n(1690)](_0x525f79);_0x4a8691(_0x3be897,s),e[n(963)](_0x1c3630,_0x249b11,s.limit),e[n(708)](_0x527426,_0x32038a,s),_0xb61c35(s)}else{let s=e[n(377)][n(584)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(763)]=!0;continue;case"1":this._readyClosed=!1;continue;case"2":this[n(413)+"tManager"]?.[n(1645)+"pointCon"+n(1629)]();continue;case"3":this[n(1592)]();continue;case"4":this[n(1411)+n(1032)]?.[n(606)+n(407)]();continue}break}}}["addEvent"+t(1469)](n,s){this.on(n,s)}dispatchEvent(n){let s=t,{type:d}=n;this[s(815)](d,n)}["removeEv"+t(1262)+t(1231)](n,s){this.off(n,s)}[t(404)](){let n=t,s={mjXyo:function(d,f){return d(f)},OamGT:e[n(758)],SOKjt:n(847)+n(539)+"s",uwStJ:e[n(601)],sluMH:function(d,f){return e[n(1656)](d,f)},pnmje:n(1179)};return new Promise((d,f)=>{let g=n,w={Lxqvl:function(b,x){return b(x)},hWYNl:e.JLwiI,jymRw:e[g(499)],RdVaw:"ping_onc"+g(398)+"t"};if(e.KeOWc(e[g(1260)],g(1191)))w.Lxqvl(_0x33ae7b,w[g(1676)]),this[g(1671)](w[g(1483)],_0x5d7808),this[g(1671)](w.RdVaw,_0x5215c7);else{this[g(647)+g(1708)](),this[g(1188)+g(1492)+"Id"]=setTimeout(this[g(734)][g(1052)](this),this[g(965)][g(1394)+"rval"]);let b=()=>{let A=g;s[A(352)](d,s[A(1738)]),this[A(1671)](s.SOKjt,b),this[A(1671)](s[A(1044)],x)},x=()=>{let A=g;s[A(480)](f,s[A(1162)]),this.off(s.SOKjt,b),this[A(1671)](s[A(1044)],x)};this.on(e.BGUgM,b),this.on(e.FnXlA,x),this._ping()}})}}})(),ke[L(637)+L(1129)]=De[L(637)+L(1129)],ke[L(834)+L(1377)]=De[L(834)+"rorEvent"],ke[L(445)+"e"]=De[L(445)+"e"],ke[L(1499)]=De[L(1499)],ke.FWS=De[L(595)],ke[L(527)+L(597)+L(1280)]=De["Frontier"+L(597)+"vent"],ke[L(597)+L(1280)]=De["MessageE"+L(1280)],ke[L(952)+"t"]=De[L(952)+"t"],ke[L(861)+"tEvent"]=De[L(861)+L(565)],ke[L(481)+L(1129)]=De[L(481)+L(1129)],ke[L(753)+"rorEvent"]=De["createEr"+L(1377)],ke["createMe"+L(979)+"nt"]=De[L(1116)+"ssageEvent"],ke[L(673)+L(1267)]=De[L(673)+L(1267)],ke["createRe"+L(1614)+"vent"]=De[L(1669)+L(1614)+L(1280)],ke[L(1194)+L(1409)]=De[L(1194)+L(1409)],ke[L(1478)+L(1026)]=De.encodeFrame;for(mo in De)[L(637)+L(1129),L(834)+L(1377),L(445)+"e",L(1499),L(595),L(527)+L(597)+L(1280),L(597)+"vent","OpenEvent",L(861)+L(565),"createCloseEvent",L(753)+L(1377),L(1116)+"ssageEvent",L(673)+"enEvent",L(1669)+L(1614)+L(1280),L(1194)+L(1409),"encodeFrame"][L(1087)](mo)===-1&&(ke[mo]=De[mo]);var mo;Object[L(1529)+L(1021)](ke,"__esModule",{value:!0})});var $t=ie((N3,K0)=>{"use strict";var G0=["nodebuffer","arraybuffer","fragments"],W0=typeof Blob<"u";W0&&G0.push("blob");K0.exports={BINARY_TYPES:G0,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:W0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var zi=ie((L3,So)=>{"use strict";var{EMPTY_BUFFER:CE}=$t(),Qc=Buffer[Symbol.species];function DE(t,e){if(t.length===0)return CE;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Qc(r.buffer,r.byteOffset,i):r}function $0(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function J0(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function kE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ed(t){if(ed.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Qc(t):ArrayBuffer.isView(t)?e=new Qc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ed.readOnly=!1),e}So.exports={concat:DE,mask:$0,toArrayBuffer:kE,toBuffer:ed,unmask:J0};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ce("bufferutil");So.exports.mask=function(e,r,i,o,c){c<48?$0(e,r,i,o,c):t.mask(e,r,i,o,c)},So.exports.unmask=function(e,r){e.length<32?J0(e,r):t.unmask(e,r)}}catch{}});var Z0=ie((M3,Y0)=>{"use strict";var V0=Symbol("kDone"),td=Symbol("kRun"),nd=class{constructor(e){this[V0]=()=>{this.pending--,this[td]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[td]()}[td](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[V0])}}};Y0.exports=nd});var Dr=ie((B3,th)=>{"use strict";var Fi=ce("zlib"),X0=zi(),OE=Z0(),{kStatusCode:Q0}=$t(),PE=Buffer[Symbol.species],NE=Buffer.from([0,0,255,255]),Ao=Symbol("permessage-deflate"),Jt=Symbol("total-length"),Rr=Symbol("callback"),bn=Symbol("buffers"),Cr=Symbol("error"),Io,rd=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Io){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Io=new OE(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Rr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Io.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Io.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Fi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Ao]=this,this._inflate[Jt]=0,this._inflate[bn]=[],this._inflate.on("error",ME),this._inflate.on("data",eh)}this._inflate[Rr]=i,this._inflate.write(e),r&&this._inflate.write(NE),this._inflate.flush(()=>{let c=this._inflate[Cr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=X0.concat(this._inflate[bn],this._inflate[Jt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Jt]=0,this._inflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Fi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Fi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Jt]=0,this._deflate[bn]=[],this._deflate.on("data",LE)}this._deflate[Rr]=i,this._deflate.write(e),this._deflate.flush(Fi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=X0.concat(this._deflate[bn],this._deflate[Jt]);r&&(c=new PE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Rr]=null,this._deflate[Jt]=0,this._deflate[bn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};th.exports=rd;function LE(t){this[bn].push(t),this[Jt]+=t.length}function eh(t){if(this[Jt]+=t.length,this[Ao]._maxPayload<1||this[Jt]<=this[Ao]._maxPayload){this[bn].push(t);return}this[Cr]=new RangeError("Max payload size exceeded"),this[Cr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Cr][Q0]=1009,this.removeListener("data",eh),this.reset()}function ME(t){if(this[Ao]._inflate=null,this[Cr]){this[Rr](this[Cr]);return}t[Q0]=1007,this[Rr](t)}});var kr=ie((z3,To)=>{"use strict";var{isUtf8:nh}=ce("buffer"),{hasBlob:BE}=$t(),zE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function FE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function id(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function UE(t){return BE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}To.exports={isBlob:UE,isValidStatusCode:FE,isValidUTF8:id,tokenChars:zE};if(nh)To.exports.isValidUTF8=function(t){return t.length<24?id(t):nh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ce("utf-8-validate");To.exports.isValidUTF8=function(e){return e.length<32?id(e):t(e)}}catch{}});var dd=ie((F3,dh)=>{"use strict";var{Writable:qE}=ce("stream"),rh=Dr(),{BINARY_TYPES:HE,EMPTY_BUFFER:ih,kStatusCode:jE,kWebSocket:GE}=$t(),{concat:sd,toArrayBuffer:WE,unmask:KE}=zi(),{isValidStatusCode:$E,isValidUTF8:sh}=kr(),Ro=Buffer[Symbol.species],ut=0,oh=1,ah=2,ch=3,od=4,ad=5,Co=6,cd=class extends qE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||HE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[GE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=ut}_write(e,r,i){if(this._opcode===8&&this._state==ut)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Ro(i.buffer,i.byteOffset+e,i.length-e),new Ro(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Ro(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case ut:this.getInfo(e);break;case oh:this.getPayloadLength16(e);break;case ah:this.getPayloadLength64(e);break;case ch:this.getMask();break;case od:this.getData(e);break;case ad:case Co:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[rh.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=oh:this._payloadLength===127?this._state=ah:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=ch:this._state=od}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=od}getData(e){let r=ih;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&KE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ad,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[rh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===ut&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ut;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=sd(i,r):this._binaryType==="arraybuffer"?o=WE(sd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit("message",o,!0),this._state=ut,this.startLoop(e)}))}else{let o=sd(i,r);if(!this._skipUTF8Validation&&!sh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ad||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit("message",o,!1),this._state=ut,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ih),this.end();else{let i=e.readUInt16BE(0);if(!$E(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Ro(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!sh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=ut;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ut):(this._state=Co,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ut,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[jE]=o,l}};dh.exports=cd});var fd=ie((q3,fh)=>{"use strict";var{Duplex:U3}=ce("stream"),{randomFillSync:JE}=ce("crypto"),lh=Dr(),{EMPTY_BUFFER:VE,kWebSocket:YE,NOOP:ZE}=$t(),{isBlob:Or,isValidStatusCode:XE}=kr(),{mask:uh,toBuffer:Hn}=zi(),ft=Symbol("kByteLength"),QE=Buffer.alloc(4),Do=8*1024,jn,Pr=Do,vt=0,eb=1,tb=2,ld=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=vt,this.onerror=ZE,this[YE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||QE,r.generateMask?r.generateMask(i):(Pr===Do&&(jn===void 0&&(jn=Buffer.alloc(Do)),JE(jn,0,Do),Pr=0),i[0]=jn[Pr++],i[1]=jn[Pr++],i[2]=jn[Pr++],i[3]=jn[Pr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ft]!==void 0?u=r[ft]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let h=u;u>=65536?(c+=8,h=127):u>125&&(c+=2,h=126);let p=Buffer.allocUnsafe(o?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=h,h===126?p.writeUInt16BE(u,2):h===127&&(p[2]=p[3]=0,p.writeUIntBE(u,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(uh(e,i,p,c,u),[p]):(uh(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=VE;else{if(typeof e!="number"||!XE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ft]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==vt?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Or(e)?(o=e.size,c=!1):(e=Hn(e),o=e.length,c=Hn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==vt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[lh.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Or(e)?(u=e.size,h=!1):(e=Hn(e),u=e.length,h=Hn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[ft]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Or(e)?this._state!==vt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==vt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ft],this._state=tb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(ud,this,u,o);return}this._bufferedBytes-=i[ft];let l=Hn(c);r?this.dispatch(l,r,i,o):(this._state=vt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(nb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[lh.extensionName];this._bufferedBytes+=i[ft],this._state=eb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");ud(this,h,o);return}this._bufferedBytes-=i[ft],this._state=vt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===vt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ft],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ft],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};fh.exports=ld;function ud(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function nb(t,e,r){ud(t,e,r),t.onerror(e)}});var Eh=ie((H3,yh)=>{"use strict";var{kForOnEventAttribute:Ui,kListener:hd}=$t(),hh=Symbol("kCode"),xh=Symbol("kData"),ph=Symbol("kError"),gh=Symbol("kMessage"),mh=Symbol("kReason"),Nr=Symbol("kTarget"),wh=Symbol("kType"),_h=Symbol("kWasClean"),Vt=class{constructor(e){this[Nr]=null,this[wh]=e}get target(){return this[Nr]}get type(){return this[wh]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var Gn=class extends Vt{constructor(e,r={}){super(e),this[hh]=r.code===void 0?0:r.code,this[mh]=r.reason===void 0?"":r.reason,this[_h]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[hh]}get reason(){return this[mh]}get wasClean(){return this[_h]}};Object.defineProperty(Gn.prototype,"code",{enumerable:!0});Object.defineProperty(Gn.prototype,"reason",{enumerable:!0});Object.defineProperty(Gn.prototype,"wasClean",{enumerable:!0});var Lr=class extends Vt{constructor(e,r={}){super(e),this[ph]=r.error===void 0?null:r.error,this[gh]=r.message===void 0?"":r.message}get error(){return this[ph]}get message(){return this[gh]}};Object.defineProperty(Lr.prototype,"error",{enumerable:!0});Object.defineProperty(Lr.prototype,"message",{enumerable:!0});var qi=class extends Vt{constructor(e,r={}){super(e),this[xh]=r.data===void 0?null:r.data}get data(){return this[xh]}};Object.defineProperty(qi.prototype,"data",{enumerable:!0});var rb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ui]&&o[hd]===e&&!o[Ui])return;let i;if(t==="message")i=function(c,l){let u=new qi("message",{data:l?c:c.toString()});u[Nr]=this,ko(e,this,u)};else if(t==="close")i=function(c,l){let u=new Gn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Nr]=this,ko(e,this,u)};else if(t==="error")i=function(c){let l=new Lr("error",{error:c,message:c.message});l[Nr]=this,ko(e,this,l)};else if(t==="open")i=function(){let c=new Vt("open");c[Nr]=this,ko(e,this,c)};else return;i[Ui]=!!r[Ui],i[hd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[hd]===e&&!r[Ui]){this.removeListener(t,r);break}}};yh.exports={CloseEvent:Gn,ErrorEvent:Lr,Event:Vt,EventTarget:rb,MessageEvent:qi};function ko(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Oo=ie((j3,bh)=>{"use strict";var{tokenChars:Hi}=kr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ib(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,p=-1,m=-1,E=0;for(;E<t.length;E++)if(p=t.charCodeAt(E),l===void 0)if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(E!==0&&(p===32||p===9))m===-1&&h!==-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(h,m);p===44?(Bt(e,_,r),r=Object.create(null)):l=_,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(p===32||p===9)m===-1&&h!==-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Bt(r,t.slice(h,m),!0),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),h=m=-1}else if(p===61&&h!==-1&&m===-1)u=t.slice(h,E),h=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(Hi[p]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);h===-1?h=E:i||(i=!0),o=!1}else if(c)if(Hi[p]===1)h===-1&&(h=E);else if(p===34&&h!==-1)c=!1,m=E;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(p===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Hi[p]===1)h===-1&&(h=E);else if(h!==-1&&(p===32||p===9))m===-1&&(m=E);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(h,m);i&&(_=_.replace(/\\/g,""),i=!1),Bt(r,u,_),p===44&&(Bt(e,l,r),r=Object.create(null),l=void 0),u=void 0,h=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(h===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let T=t.slice(h,m);return l===void 0?Bt(e,T,r):(u===void 0?Bt(r,T,!0):i?Bt(r,u,T.replace(/\\/g,"")):Bt(r,u,T),Bt(e,l,r)),e}function sb(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bh.exports={format:sb,parse:ib}});var Mo=ie((K3,Nh)=>{"use strict";var ob=ce("events"),ab=ce("https"),cb=ce("http"),Ih=ce("net"),db=ce("tls"),{randomBytes:lb,createHash:ub}=ce("crypto"),{Duplex:G3,Readable:W3}=ce("stream"),{URL:xd}=ce("url"),vn=Dr(),fb=dd(),hb=fd(),{isBlob:xb}=kr(),{BINARY_TYPES:vh,CLOSE_TIMEOUT:pb,EMPTY_BUFFER:Po,GUID:gb,kForOnEventAttribute:pd,kListener:mb,kStatusCode:wb,kWebSocket:He,NOOP:Ah}=$t(),{EventTarget:{addEventListener:_b,removeEventListener:yb}}=Eh(),{format:Eb,parse:bb}=Oo(),{toBuffer:vb}=zi(),Th=Symbol("kAborted"),gd=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],Sb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pe=class t extends ob{constructor(e,r,i){super(),this._binaryType=vh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Po,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Rh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vh.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new fb({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new hb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[He]=this,c[He]=this,e[He]=this,o.on("conclude",Tb),o.on("drain",Rb),o.on("error",Cb),o.on("message",Db),o.on("ping",kb),o.on("pong",Ob),c.onerror=Pb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",kh),e.on("data",Lo),e.on("end",Oh),e.on("error",Ph),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[vn.extensionName]&&this._extensions[vn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Dh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Po,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Po,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){md(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Po,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ot(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(pe,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(pe.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(pe,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(pe.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(pe,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(pe.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(pe,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(pe.prototype,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(pe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(pe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[pd])return e[mb];return null},set(e){for(let r of this.listeners(t))if(r[pd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[pd]:!0})}})});pe.prototype.addEventListener=_b;pe.prototype.removeEventListener=yb;Nh.exports=pe;function Rh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:pb,protocolVersion:gd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!gd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${gd.join(", ")})`);let c;if(e instanceof xd)c=e;else try{c=new xd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",u=c.protocol==="ws+unix:",h;if(c.protocol!=="ws:"&&!l&&!u?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?h="The URL's pathname is empty":c.hash&&(h="The URL contains a fragment identifier"),h){let I=new SyntaxError(h);if(t._redirects===0)throw I;No(t,I);return}let p=l?443:80,m=lb(16).toString("base64"),E=l?ab.request:cb.request,T=new Set,_;if(o.createConnection=o.createConnection||(l?Ab:Ib),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Eb({[vn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Sb.test(I)||T.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,C]of Object.entries(I))i.headers[S.toLowerCase()]=C}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{ot(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Th]||(v=t._req=null,No(t,I))}),v.on("response",I=>{let S=I.headers.location,C=I.statusCode;if(S&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){ot(t,v,"Maximum redirects exceeded");return}v.abort();let N;try{N=new xd(S,e)}catch{let D=new SyntaxError(`Invalid URL: ${S}`);No(t,D);return}Rh(t,N,r,i)}else t.emit("unexpected-response",v,I)||ot(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,S,C)=>{if(t.emit("upgrade",I),t.readyState!==pe.CONNECTING)return;v=t._req=null;let N=I.headers.upgrade;if(N===void 0||N.toLowerCase()!=="websocket"){ot(t,S,"Invalid Upgrade header");return}let y=ub("sha1").update(m+gb).digest("base64");if(I.headers["sec-websocket-accept"]!==y){ot(t,S,"Invalid Sec-WebSocket-Accept header");return}let D=I.headers["sec-websocket-protocol"],k;if(D!==void 0?T.size?T.has(D)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":T.size&&(k="Server sent no subprotocol"),k){ot(t,S,k);return}D&&(t._protocol=D);let M=I.headers["sec-websocket-extensions"];if(M!==void 0){if(!_){ot(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=bb(M)}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(B);if(J.length!==1||J[0]!==vn.extensionName){ot(t,S,"Server indicated an extension that was not requested");return}try{_.accept(B[vn.extensionName])}catch{ot(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=_}t.setSocket(S,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function No(t,e){t._readyState=pe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ib(t){return t.path=t.socketPath,Ih.connect(t)}function Ab(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ih.isIP(t.host)?"":t.host),db.connect(t)}function ot(t,e,r){t._readyState=pe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ot),e.setHeader?(e[Th]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(No,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function md(t,e,r){if(e){let i=xb(e)?e.size:vb(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Yt[t.readyState]})`);process.nextTick(r,i)}}function Tb(t,e){let r=this[He];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[He]!==void 0&&(r._socket.removeListener("data",Lo),process.nextTick(Ch,r._socket),t===1005?r.close():r.close(t,e))}function Rb(){let t=this[He];t.isPaused||t._socket.resume()}function Cb(t){let e=this[He];e._socket[He]!==void 0&&(e._socket.removeListener("data",Lo),process.nextTick(Ch,e._socket),e.close(t[wb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Sh(){this[He].emitClose()}function Db(t,e){this[He].emit("message",t,e)}function kb(t){let e=this[He];e._autoPong&&e.pong(t,!this._isServer,Ah),e.emit("ping",t)}function Ob(t){this[He].emit("pong",t)}function Ch(t){t.resume()}function Pb(t){let e=this[He];e.readyState!==pe.CLOSED&&(e.readyState===pe.OPEN&&(e._readyState=pe.CLOSING,Dh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Dh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function kh(){let t=this[He];if(this.removeListener("close",kh),this.removeListener("data",Lo),this.removeListener("end",Oh),t._readyState=pe.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[He]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Sh),t._receiver.on("finish",Sh))}function Lo(t){this[He]._receiver.write(t)||this.pause()}function Oh(){let t=this[He];t._readyState=pe.CLOSING,t._receiver.end(),this.end()}function Ph(){let t=this[He];this.removeListener("error",Ph),this.on("error",Ah),t&&(t._readyState=pe.CLOSING,this.destroy())}});var zh=ie((J3,Bh)=>{"use strict";var $3=Mo(),{Duplex:Nb}=ce("stream");function Lh(t){t.emit("close")}function Lb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Mh(t){this.removeListener("error",Mh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Mb(t,e){let r=!0,i=new Nb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Lh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(Lh,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",Lb),i.on("error",Mh),i}Bh.exports=Mb});var wd=ie((V3,Fh)=>{"use strict";var{tokenChars:Bb}=kr();function zb(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&Bb[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Fh.exports={parse:zb}});var Kh=ie((Z3,Wh)=>{"use strict";var Fb=ce("events"),Bo=ce("http"),{Duplex:Y3}=ce("stream"),{createHash:Ub}=ce("crypto"),Uh=Oo(),Wn=Dr(),qb=wd(),Hb=Mo(),{CLOSE_TIMEOUT:jb,GUID:Gb,kWebSocket:Wb}=$t(),Kb=/^[+/0-9A-Za-z]{22}==$/,qh=0,Hh=1,Gh=2,_d=class extends Fb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:jb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Hb,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Bo.createServer((i,o)=>{let c=Bo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=$b(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=qh}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Gh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ji,this);return}if(e&&this.once("close",e),this._state!==Hh)if(this._state=Hh,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(ji,this):process.nextTick(ji,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{ji(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",jh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Kb.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Gi(r,400);return}let h=e.headers["sec-websocket-protocol"],p=new Set;if(h!==void 0)try{p=qb.parse(h)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let T=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=Uh.parse(m);_[Wn.extensionName]&&(T.accept(_[Wn.extensionName]),E[Wn.extensionName]=T)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let T={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(T,(_,v,I,S)=>{if(!_)return Gi(r,v||401,I,S);this.completeUpgrade(E,c,p,e,r,i,o)});return}if(!this.options.verifyClient(T))return Gi(r,401)}this.completeUpgrade(E,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[Wb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>qh)return Gi(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ub("sha1").update(r+Gb).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(p.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[Wn.extensionName]){let E=e[Wn.extensionName].params,T=Uh.format({[Wn.extensionName]:[E]});p.push(`Sec-WebSocket-Extensions: ${T}`),m._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
10
+ `),this.stream=void 0;return}this.currentDate!==void 0&&rs(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as qp,mkdirSync as Gp}from"node:fs";import{join as jp}from"node:path";function rl(t){let e=t.retentionDays??Kp,r=t.clock??(()=>Rn(new Date));ss={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();rs(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])rs(t.agentLogsDir(o),"agent",i,e)}function $p(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function il(t){ya=t}function sl(t){return rr[ya]<=rr[t]}function ol(t,e){let r=rr[t];return r===void 0?!0:r>=rr[e]}function os(t){nl={...t}}function al(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`${Rn(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:al(new Date),level:e,module:r,msg:i,...o})}
11
+ `;Gp(t,{recursive:!0}),qp(jp(t,nr("bridge",Rn(new Date))),c)}catch{}}function Jp(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function is(t,e,r,i,o){if(rr[t]<rr[ya])return;let c=`${JSON.stringify({ts:al(new Date),level:t,module:e,msg:r,...nl,...i})}
12
+ `;if(ss){let l=Jp(o,i),f=l?$p(ss,l):ss.bridgeSink;try{f.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Wp.write(c):Hp.write(c)}function q(t,e){return{debug:(r,i)=>is("debug",t,r,i,e),info:(r,i)=>is("info",t,r,i,e),warn:(r,i)=>is("warn",t,r,i,e),error:(r,i)=>is("error",t,r,i,e),child:r=>q(`${t}.${r}`,e),forAgent:r=>q(t,r)}}var rr,ya,Hp,Wp,nl,Kp,ss,se=Qe(()=>{"use strict";ns();_a();rr={debug:10,info:20,warn:30,error:40},ya=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Hp=process.stdout,Wp=process.stderr,nl={},Kp=qt("COZE_BRIDGE_LOG_RETENTION_DAYS",30),ss=null});var T,Ye=Qe(()=>{"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 fl={};ma(fl,{ACP_WRAPPER_NPM_PACKAGES:()=>Xr,_resetAcpInstallerForTests:()=>eg,_setBinaryPathCacheForTests:()=>tg,buildAcpSpawn:()=>Qr,ensureAcpInstalled:()=>ir,getAcpBinaryPath:()=>as,pickWhichLine:()=>va,probeAcpVersion:()=>Qp,resolveAcpCommand:()=>ll});import{readFileSync as cl}from"node:fs";import{createRequire as Vp}from"node:module";import{dirname as Yp,resolve as Zp}from"node:path";function va(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function Xp(t){let e=dl.resolve(`${t.npmPackage}/package.json`),r=Yp(e),i=JSON.parse(cl(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return Zp(r,o)}async function ir(t,e){let r=ba[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Zr.get(t);if(i)return i;try{let o=Xp(r);return Zr.set(t,o),Ea.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw Ea.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new T("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
13
+ `),{cause:o})}}async function Qp(t){let e=ba[t];if(e)try{let r=dl.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(cl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){Ea.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function as(t){return Zr.get(t)}function ll(t,e){if(e)return e;let r=as(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 Qr(t,e,r){if(e)return{command:e,args:[...r]};let i=ll(t);return{command:process.execPath,args:[i,...r]}}function eg(){Zr.clear()}function tg(t,e){Zr.set(t,e)}var Ea,ba,Xr,dl,Zr,sn=Qe(()=>{"use strict";Ye();se();Ea=q("agents.acp-installer"),ba={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Xr=Object.values(ba).filter(t=>t!==void 0).map(t=>t.npmPackage),dl=Vp(import.meta.url),Zr=new Map});import{chmod as rg,mkdir as ig,readFile as sg,rename as hl,writeFile as pl}from"node:fs/promises";import{dirname as og}from"node:path";async function sr(t){try{let e=await sg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function or(t,e,r){await ig(og(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
14
+ `,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await pl(o,i,{encoding:"utf8",mode:r.mode}):await pl(o,i,"utf8"),await hl(o,t),r?.mode!==void 0&&await rg(t,r.mode)}catch(c){await hl(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var ei=Qe(()=>{"use strict"});import{promises as gl,readdirSync as ag}from"node:fs";import{homedir as cg}from"node:os";import{sep as dg,join as Re,resolve as ml}from"node:path";function Q(t){let e=t??cg(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function et(t,e=Q()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function cs(t=Q()){try{return ag(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ti(t,e){let r=await gl.realpath(ml(t)).catch(()=>null);if(!r)return!1;let i=await gl.realpath(ml(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+dg)}var Ne=Qe(()=>{"use strict"});var fs={};ma(fs,{AGENT_CONFIG_FILE_MODE:()=>ds,enforceAgentConfigMode:()=>ug,loadAgentConfig:()=>$e,persistAgentSessions:()=>ni,persistAgentSkills:()=>ls,saveAgentConfig:()=>nt});import{chmod as lg,stat as fg}from"node:fs/promises";function $e(t,e){return sr(et(t,e).config)}function nt(t,e){return or(et(t.agentId,e).config,t,{mode:ds})}async function ug(t,e){if(process.platform==="win32")return;let r=et(t,e).config;try{let i=await fg(r);if(!i.isFile())return;let o=i.mode&511;o!==ds&&(await lg(r,ds),wl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;wl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ni(t,e,r){let i=await $e(t,r);i&&(i.sessions=Object.fromEntries(e),await nt(i,r))}async function ls(t,e,r){let i=await $e(t,r);i&&(i.skills=e,await nt(i,r))}var wl,ds,on=Qe(()=>{"use strict";ei();se();Ne();wl=q("agent-config"),ds=384});var Ia=ce((LS,bl)=>{bl.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 xs=ce(Sl=>{var vl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function mg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(vl))Sl[t]=mg(vl[t])});var Cl=ce((MS,Dl)=>{var wg=ue("fs"),Me=ue("path"),Il=Ia(),_g=xs(),yg=typeof process=="object"&&process.platform==="win32",Al=t=>typeof t=="object"&&t!==null,Tl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ie(t){this.sep=Me.sep,this.fs=wg,Al(t)&&Al(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Dl.exports=Ie;Ie.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(l&&l.isFile())throw _g.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ie.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Me.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};Ie.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(f,x){if(l&&x.isDirectory())return o(!1);var h=Me.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(E,A){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ie.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(f){let x=Me.join(i,f),h=e.fs.statSync(x);(!o||o.test(x))&&l.push(Me.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};Ie.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(f){f=Me.join(t,f),r.fs.stat(f,function(x,h){if(x)return e(x);h&&(i.push(Me.normalize(f)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(f,function(m,E){if(m)return e(m);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};Ie.prototype.getAttributes=function(){};Ie.prototype.setAttributes=function(){};Ie.crc32update=function(t,e){return Tl[(t^e)&255]^t>>>8};Ie.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ie.crc32update(r,t[i++]);return~r>>>0};Ie.methodToString=function(t){switch(t){case Il.STORED:return"STORED ("+t+")";case Il.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ie.canonical=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.join(".",e)};Ie.zipnamefix=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.posix.join(".",e)};Ie.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ie.sanitize=function(t,e){t=Me.resolve(Me.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Me.normalize(Me.join(t,r.slice(i,o).join(Me.sep)));if(c.indexOf(t)===0)return c}return Me.normalize(Me.join(t,Me.basename(e)))};Ie.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ie.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ie.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Ie.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Ie.isWin=yg;Ie.crcTable=Tl});var kl=ce((BS,Rl)=>{var Eg=ue("path");Rl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Eg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ol=ce((zS,Pl)=>{Pl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var dr=ce((FS,cr)=>{cr.exports=Cl();cr.exports.Constants=Ia();cr.exports.Errors=xs();cr.exports.FileAttr=kl();cr.exports.decoder=Ol()});var Nl=ce((US,Ll)=>{var an=dr(),F=an.Constants;Ll.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,f=0,x=0,h=0,m=0,E=0,A=0,y=0,b=0;t|=an.isWin?2560:768,r|=F.FLG_EFS;let I={extraLen:0},S=w=>Math.max(0,w)>>>0,C=w=>Math.max(0,w)&65535,O=w=>Math.max(0,w)&255;return o=an.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&F.FLG_EFS)>0},set flags_efs(w){w?r|=F.FLG_EFS:r&=~F.FLG_EFS},get flags_desc(){return(r&F.FLG_DESC)>0},set flags_desc(w){w?r|=F.FLG_DESC:r&=~F.FLG_DESC},get method(){return i},set method(w){switch(w){case F.STORED:this.version=10;case F.DEFLATED:default:this.version=20}i=w},get time(){return an.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=an.fromDate2DOS(w)},get timeval(){return o},set timeval(w){o=S(w)},get timeHighByte(){return O(o>>>8)},get crc(){return c},set crc(w){c=S(w)},get compressedSize(){return l},set compressedSize(w){l=S(w)},get size(){return f},set size(w){f=S(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return h},set extraLength(w){h=w},get extraLocalLength(){return I.extraLen},set extraLocalLength(w){I.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return E},set diskNumStart(w){E=S(w)},get inAttr(){return A},set inAttr(w){A=S(w)},get attr(){return y},set attr(w){y=S(w)},get fileAttr(){return(y||0)>>16&4095},get offset(){return b},set offset(w){b=S(w)},get encrypted(){return(r&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+x+h+m},get realDataOffset(){return b+F.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(w){var R=w.slice(b,b+F.LOCHDR);if(R.readUInt32LE(0)!==F.LOCSIG)throw an.Errors.INVALID_LOC();I.version=R.readUInt16LE(F.LOCVER),I.flags=R.readUInt16LE(F.LOCFLG),I.flags_desc=(I.flags&F.FLG_DESC)>0,I.method=R.readUInt16LE(F.LOCHOW),I.time=R.readUInt32LE(F.LOCTIM),I.crc=R.readUInt32LE(F.LOCCRC),I.compressedSize=R.readUInt32LE(F.LOCSIZ),I.size=R.readUInt32LE(F.LOCLEN),I.fnameLen=R.readUInt16LE(F.LOCNAM),I.extraLen=R.readUInt16LE(F.LOCEXT);let k=b+F.LOCHDR+I.fnameLen,B=k+I.extraLen;return w.slice(k,B)},loadFromBinary:function(w){if(w.length!==F.CENHDR||w.readUInt32LE(0)!==F.CENSIG)throw an.Errors.INVALID_CEN();t=w.readUInt16LE(F.CENVEM),e=w.readUInt16LE(F.CENVER),r=w.readUInt16LE(F.CENFLG),i=w.readUInt16LE(F.CENHOW),o=w.readUInt32LE(F.CENTIM),c=w.readUInt32LE(F.CENCRC),l=w.readUInt32LE(F.CENSIZ),f=w.readUInt32LE(F.CENLEN),x=w.readUInt16LE(F.CENNAM),h=w.readUInt16LE(F.CENEXT),m=w.readUInt16LE(F.CENCOM),E=w.readUInt16LE(F.CENDSK),A=w.readUInt16LE(F.CENATT),y=w.readUInt32LE(F.CENATX),b=w.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(F.LOCHDR);return w.writeUInt32LE(F.LOCSIG,0),w.writeUInt16LE(e,F.LOCVER),w.writeUInt16LE(r,F.LOCFLG),w.writeUInt16LE(i,F.LOCHOW),w.writeUInt32LE(o,F.LOCTIM),w.writeUInt32LE(c,F.LOCCRC),w.writeUInt32LE(l,F.LOCSIZ),w.writeUInt32LE(f,F.LOCLEN),w.writeUInt16LE(x,F.LOCNAM),w.writeUInt16LE(I.extraLen,F.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(F.CENHDR+x+h+m);return w.writeUInt32LE(F.CENSIG,0),w.writeUInt16LE(t,F.CENVEM),w.writeUInt16LE(e,F.CENVER),w.writeUInt16LE(r,F.CENFLG),w.writeUInt16LE(i,F.CENHOW),w.writeUInt32LE(o,F.CENTIM),w.writeUInt32LE(c,F.CENCRC),w.writeUInt32LE(l,F.CENSIZ),w.writeUInt32LE(f,F.CENLEN),w.writeUInt16LE(x,F.CENNAM),w.writeUInt16LE(h,F.CENEXT),w.writeUInt16LE(m,F.CENCOM),w.writeUInt16LE(E,F.CENDSK),w.writeUInt16LE(A,F.CENATT),w.writeUInt32LE(y,F.CENATX),w.writeUInt32LE(b,F.CENOFF),w},toJSON:function(){let w=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:an.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(l),size:w(f),fileNameLength:w(x),extraLength:w(h),commentLength:w(m),diskNumStart:E,inAttr:A,attr:y,offset:b,centralHeaderSize:w(F.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Bl=ce((qS,Ml)=>{var lr=dr(),ye=lr.Constants;Ml.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return ye.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ye.ENDHDR||c.readUInt32LE(0)!==ye.ENDSIG)&&(c.length<ye.ZIP64HDR||c.readUInt32LE(0)!==ye.ZIP64SIG))throw lr.Errors.INVALID_END();c.readUInt32LE(0)===ye.ENDSIG?(t=c.readUInt16LE(ye.ENDSUB),e=c.readUInt16LE(ye.ENDTOT),r=c.readUInt32LE(ye.ENDSIZ),i=c.readUInt32LE(ye.ENDOFF),o=c.readUInt16LE(ye.ENDCOM)):(t=lr.readBigUInt64LE(c,ye.ZIP64SUB),e=lr.readBigUInt64LE(c,ye.ZIP64TOT),r=lr.readBigUInt64LE(c,ye.ZIP64SIZE),i=lr.readBigUInt64LE(c,ye.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ye.ENDHDR+o);return c.writeUInt32LE(ye.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ye.ENDSUB),c.writeUInt16LE(e,ye.ENDTOT),c.writeUInt32LE(r,ye.ENDSIZ),c.writeUInt32LE(i,ye.ENDOFF),c.writeUInt16LE(o,ye.ENDCOM),c.fill(" ",ye.ENDHDR),c},toJSON:function(){let c=function(l,f){let x=l.toString(16).toUpperCase();for(;x.length<f;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ta=ce(Aa=>{Aa.EntryHeader=Nl();Aa.MainHeader=Bl()});var Fl=ce((jS,zl)=>{zl.exports=function(t){var e=ue("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),x=0;f.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(f,x),x+=m.length}i&&i(f)}),o.end(t)}}}});var ql=ce((HS,Ul)=>{var bg=+(process.versions?process.versions.node:"").split(".")[0]||0;Ul.exports=function(t,e){var r=ue("zlib");let i=bg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],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 m=0;m<l.length;m++){var E=l[m];E.copy(x,h),h+=E.length}o&&o(x)}),c.end(t)}}}});var Kl=ce((WS,Wl)=>{"use strict";var{randomFillSync:Gl}=ue("crypto"),vg=xs(),Sg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),Hl=(t,e)=>Math.imul(t,e)>>>0,jl=(t,e)=>Sg[(t^e)&255]^t>>>8,ri=()=>typeof Gl=="function"?Gl(Buffer.alloc(12)):ri.node();ri.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var hs={genSalt:ri};function ps(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])}ps.prototype.updateKeys=function(t){let e=this.keys;return e[0]=jl(e[0],t),e[1]+=e[0]&255,e[1]=Hl(e[1],134775813)+1,e[2]=jl(e[2],e[1]>>>24),t};ps.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Hl(t,t^1)>>8&255};function Ig(t){let e=new ps(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Ag(t){let e=new ps(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Tg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ig(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw vg.WRONG_PASSWORD();return i(t.slice(12))}function Dg(t){Buffer.isBuffer(t)&&t.length>=12?hs.genSalt=function(){return t.slice(0,12)}:t==="node"?hs.genSalt=ri.node:hs.genSalt=ri}function Cg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Ag(r),c=hs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Wl.exports={decrypt:Tg,encrypt:Cg,_salter:Dg}});var $l=ce(gs=>{gs.Deflater=Fl();gs.Inflater=ql();gs.ZipCrypto=Kl()});var Ca=ce(($S,Jl)=>{var de=dr(),Rg=Ta(),Ae=de.Constants,Da=$l();Jl.exports=function(t,e){var r=new Rg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:de.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(de.crc32(w)!==r.localHeader.crc)return!1}else{let R={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==Ae.LOCSIG||e.readUInt32LE(k)==Ae.CENSIG)throw de.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==Ae.EXTSIG)R.crc=e.readUInt32LE(k+Ae.EXTCRC),R.compressedSize=e.readUInt32LE(k+Ae.EXTSIZ),R.size=e.readUInt32LE(k+Ae.EXTLEN);else if(e.readUInt16LE(k+12)===19280)R.crc=e.readUInt32LE(k+Ae.EXTCRC-4),R.compressedSize=e.readUInt32LE(k+Ae.EXTSIZ-4),R.size=e.readUInt32LE(k+Ae.EXTLEN-4);else throw de.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw de.Errors.DESCRIPTOR_FAULTY();if(de.crc32(w)!==R.crc)return!1}return!0}function b(w,R,k){if(typeof R>"u"&&typeof w=="string"&&(k=w,w=void 0),c)return w&&R&&R(Buffer.alloc(0),de.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=A();if(B.length===0)return w&&R&&R(B),B;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw de.Errors.INVALID_PASS_PARAM();B=Da.ZipCrypto.decrypt(B,r,k)}var z=Buffer.alloc(r.size);switch(r.method){case de.Constants.STORED:if(B.copy(z),y(z))return w&&R&&R(z),z;throw w&&R&&R(z,de.Errors.BAD_CRC()),de.Errors.BAD_CRC();case de.Constants.DEFLATED:var V=new Da.Inflater(B,r.size);if(w)V.inflateAsync(function(Y){Y.copy(Y,0),R&&(y(Y)?R(Y):R(Y,de.Errors.BAD_CRC()))});else{if(V.inflate(z).copy(z,0),!y(z))throw de.Errors.BAD_CRC(`"${E.decode(i)}"`);return z}break;default:throw w&&R&&R(Buffer.alloc(0),de.Errors.UNKNOWN_METHOD()),de.Errors.UNKNOWN_METHOD()}}function I(w,R){if((!l||!l.length)&&Buffer.isBuffer(e))return w&&R&&R(A()),A();if(l.length&&!c){var k;switch(r.method){case de.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),w&&R&&R(k),k;default:case de.Constants.DEFLATED:var B=new Da.Deflater(l);if(w)B.deflateAsync(function(V){k=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(k),R&&R(k)});else{var z=B.deflate();return r.compressedSize=z.length,z}B=null;break}}else if(w&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function S(w,R){return de.readBigUInt64LE(w,R)}function C(w){try{for(var R=0,k,B,z;R+4<w.length;)k=w.readUInt16LE(R),R+=2,B=w.readUInt16LE(R),R+=2,z=w.slice(R,R+B),R+=B,Ae.ID_ZIP64===k&&O(z)}catch{throw de.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(w){var R,k,B,z;w.length>=Ae.EF_ZIP64_SCOMP&&(R=S(w,Ae.EF_ZIP64_SUNCOMP),r.size===Ae.EF_ZIP64_OR_32&&(r.size=R)),w.length>=Ae.EF_ZIP64_RHO&&(k=S(w,Ae.EF_ZIP64_SCOMP),r.compressedSize===Ae.EF_ZIP64_OR_32&&(r.compressedSize=k)),w.length>=Ae.EF_ZIP64_DSN&&(B=S(w,Ae.EF_ZIP64_RHO),r.offset===Ae.EF_ZIP64_OR_32&&(r.offset=B)),w.length>=Ae.EF_ZIP64_DSN+4&&(z=w.readUInt32LE(Ae.EF_ZIP64_DSN),r.diskNumStart===Ae.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(w){i=de.toBuffer(w,E.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(w){f=w,r.extraLength=w.length,C(w)},get comment(){return E.decode(o)},set comment(w){if(o=de.toBuffer(w,E.encode),r.commentLength=o.length,o.length>65535)throw de.Errors.COMMENT_TOO_LONG()},get name(){var w=E.decode(i);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(w){I(!0,w)},setData:function(w){l=de.toBuffer(w,de.decoder.encode),!c&&l.length?(r.size=l.length,r.method=de.Constants.DEFLATED,r.crc=de.crc32(w),r.changed=!0):r.method=de.Constants.STORED},getData:function(w){return r.changed?l:b(!1,null,w)},getDataAsync:function(w,R){r.changed?w(l):b(!0,w,R)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=f.length;var w=r.centralHeaderToBinary(),R=de.Constants.CENHDR;return i.copy(w,R),R+=i.length,f.copy(w,R),R+=r.extraLength,o.copy(w,R),w},packLocalHeader:function(){let w=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,w),w+=R.length,i.copy(k,w),w+=i.length,x.copy(k,w),w+=x.length,k},toJSON:function(){let w=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:w(e),data:w(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Zl=ce((JS,Yl)=>{var Vl=Ca(),kg=Ta(),Je=dr();Yl.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new kg.MainHeader,l=!1,f=null;let x=new Set,h=e,{noSort:m,decoder:E}=h;t?b(h.readEntries):l=!0;function A(){let S=new Set;for(let C of Object.keys(i)){let O=C.split("/");if(O.pop(),!!O.length)for(let w=0;w<O.length;w++){let R=O.slice(0,w+1).join("/")+"/";S.add(R)}}for(let C of S)if(!(C in i)){let O=new Vl(h);O.entryName=C,O.attr=16,O.temporary=!0,r.push(O),i[O.entryName]=O,x.add(O)}}function y(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/Je.Constants.CENHDR)throw Je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,C=0;C<r.length;C++){var O=S,w=new Vl(h,t);w.header=t.slice(O,O+=Je.Constants.CENHDR),w.entryName=t.slice(O,O+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(O,O+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(O,O+w.header.commentLength)),S+=w.header.centralHeaderSize,r[C]=w,i[w.entryName]=w}x.clear(),A()}function b(S){var C=t.length-Je.Constants.ENDHDR,O=Math.max(0,C-65535),w=O,R=t.length,k=-1,B=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(O=0),C;C>=w;C--)if(t[C]===80){if(t.readUInt32LE(C)===Je.Constants.ENDSIG){k=C,B=C,R=C+Je.Constants.ENDHDR,w=C-Je.Constants.END64HDR;continue}if(t.readUInt32LE(C)===Je.Constants.END64SIG){w=O;continue}if(t.readUInt32LE(C)===Je.Constants.ZIP64SIG){k=C,R=C+Je.readBigUInt64LE(t,C+Je.Constants.ZIP64SIZE)+Je.Constants.ZIP64LEAD;break}}if(k==-1)throw Je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,R)),c.commentLength&&(o=t.slice(B+Je.Constants.ENDHDR)),S&&y()}function I(){r.length>1&&!m&&r.sort((S,C)=>S.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(S=>!x.has(S))},get comment(){return E.decode(o)},set comment(S){o=Je.toBuffer(S,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||y(),i[S]||null},setEntry:function(S){l||y(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,C=!0){l||y();let O=i[S];this.getEntryChildren(O,C).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||y();let C=i[S],O=r.indexOf(C);O>=0&&(r.splice(O,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,C=!0){if(l||y(),typeof S=="object")if(S.isDirectory&&C){let O=[],w=S.entryName;for(let R of r)R.entryName.startsWith(w)&&O.push(R);return O}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let C=this.getEntryChildren(S);return C.includes(S)?C.length-1:C.length}return 0},compressToBuffer:function(){l||y(),I();let S=[],C=[],O=0,w=0;c.size=0,c.offset=0;let R=0;for(let z of this.entries){let V=z.getCompressedData();z.header.offset=w;let Y=z.packLocalHeader(),re=Y.length+V.length;w+=re,S.push(Y),S.push(V);let te=z.packCentralHeader();C.push(te),c.size+=te.length,O+=re+te.length,R++}O+=c.mainHeaderSize,c.offset=w,c.totalEntries=R,w=0;let k=Buffer.alloc(O);for(let z of S)z.copy(k,w),w+=z.length;for(let z of C)z.copy(k,w),w+=z.length;let B=c.toBinary();return o&&o.copy(B,Je.Constants.ENDHDR),B.copy(k,w),t=k,l=!1,k},toAsyncBuffer:function(S,C,O,w){try{l||y(),I();let R=[],k=[],B=0,z=0,V=0;c.size=0,c.offset=0;let Y=function(re){if(re.length>0){let te=re.shift(),ve=te.entryName+te.extra.toString();O&&O(ve),te.getCompressedDataAsync(function(ge){w&&w(ve),te.header.offset=z;let P=te.packLocalHeader(),G=P.length+ge.length;z+=G,R.push(P),R.push(ge);let K=te.packCentralHeader();k.push(K),c.size+=K.length,B+=G+K.length,V++,Y(re)})}else{B+=c.mainHeaderSize,c.offset=z,c.totalEntries=V,z=0;let te=Buffer.alloc(B);R.forEach(function(ge){ge.copy(te,z),z+=ge.length}),k.forEach(function(ge){ge.copy(te,z),z+=ge.length});let ve=c.toBinary();o&&o.copy(ve,Je.Constants.ENDHDR),ve.copy(te,z),t=te,l=!1,S(te)}};Y(Array.from(this.entries))}catch(R){C(R)}}}}});var e0=ce((VS,Ql)=>{var be=dr(),Ee=ue("path"),Pg=Ca(),Og=Zl(),kn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),Xl=(...t)=>be.findLast(t,e=>typeof e=="string"),Lg=(...t)=>be.findLast(t,e=>typeof e=="function"),Ng={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};Ql.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Ng);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=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 Og(r,i),{canonical:l,sanitize:f,zipnamefix:x}=be;function h(y){if(y&&c){var b;if(typeof y=="string"&&(b=c.getEntry(Ee.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(b=c.getEntry(y.entryName)),b)return b}return null}function m(y){let{join:b,normalize:I,sep:S}=Ee.posix;return b(Ee.isAbsolute(y)?"/":".",I(S+y.split("\\").join(S)+S))}function E(y){return y instanceof RegExp?(function(b){return function(I){return b.test(I)}})(y):typeof y!="function"?()=>!0:y}let A=(y,b)=>{let I=b.slice(-1);return I=I===o.sep?o.sep:"",Ee.relative(y,b)+I};return{readFile:function(y,b){var I=h(y);return I&&I.getData(b)||null},childCount:function(y){let b=h(y);if(b)return c.getChildCount(b)},readFileAsync:function(y,b){var I=h(y);I?I.getDataAsync(b):b(null,"getEntry failed for:"+y)},readAsText:function(y,b){var I=h(y);if(I){var S=I.getData();if(S&&S.length)return S.toString(b||"utf8")}return""},readAsTextAsync:function(y,b,I){var S=h(y);S?S.getDataAsync(function(C,O){if(O){b(C,O);return}C&&C.length?b(C.toString(I||"utf8")):b("")}):b("")},deleteFile:function(y,b=!0){var I=h(y);I&&c.deleteFile(I.entryName,b)},deleteEntry:function(y){var b=h(y);b&&c.deleteEntry(b.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,b){var I=h(y);I&&(I.comment=b)},getZipEntryComment:function(y){var b=h(y);return b&&b.comment||""},updateFile:function(y,b){var I=h(y);I&&I.setData(b)},addLocalFile:function(y,b,I,S){if(o.fs.existsSync(y)){b=b?m(b):"";let C=Ee.win32.basename(Ee.win32.normalize(y));b+=I||C;let O=o.fs.statSync(y),w=O.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);O.isDirectory()&&(b+=o.sep),this.addFile(b,w,S,O)}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,b){y=typeof y=="object"?y:{localPath:y};let I=Ee.resolve(y.localPath),{comment:S}=y,{zipPath:C,zipName:O}=y,w=this;o.fs.stat(I,function(R,k){if(R)return b(R,!1);C=C?m(C):"";let B=Ee.win32.basename(Ee.win32.normalize(I));if(C+=O||B,k.isFile())o.fs.readFile(I,function(z,V){return z?b(z,!1):(w.addFile(C,V,S,k),setImmediate(b,void 0,!0))});else if(k.isDirectory())return C+=o.sep,w.addFile(C,Buffer.alloc(0),S,k),setImmediate(b,void 0,!0)})},addLocalFolder:function(y,b,I){if(I=E(I),b=b?m(b):"",y=Ee.normalize(y),o.fs.existsSync(y)){let S=o.findFiles(y),C=this;if(S.length)for(let O of S){let w=Ee.join(b,A(y,O));I(w)&&C.addLocalFile(O,Ee.dirname(w))}}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,b,I,S){S=E(S),I=I?m(I):"",y=Ee.normalize(y);var C=this;o.fs.open(y,"r",function(O){if(O&&O.code==="ENOENT")b(void 0,be.Errors.FILE_NOT_FOUND(y));else if(O)b(void 0,O);else{var w=o.findFiles(y),R=-1,k=function(){if(R+=1,R<w.length){var B=w[R],z=A(y,B).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(z)?o.fs.stat(B,function(V,Y){V&&b(void 0,V),Y.isFile()?o.fs.readFile(B,function(re,te){re?b(void 0,re):(C.addFile(I+z,te,"",Y),k())}):(C.addFile(I+z+"/",Buffer.alloc(0),"",Y),k())}):process.nextTick(()=>{k()})}else b(!0,void 0)};k()}})},addLocalFolderAsync2:function(y,b){let I=this;y=typeof y=="object"?y:{localPath:y},localPath=Ee.resolve(m(y.localPath));let{zipPath:S,filter:C,namefix:O}=y;C instanceof RegExp?C=(function(k){return function(B){return k.test(B)}})(C):typeof C!="function"&&(C=function(){return!0}),S=S?m(S):"",O=="latin1"&&(O=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=k=>k);let w=k=>Ee.join(S,O(A(localPath,k))),R=k=>Ee.win32.basename(Ee.win32.normalize(O(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?b(void 0,be.Errors.FILE_NOT_FOUND(localPath)):k?b(void 0,k):o.findFilesAsync(localPath,function(B,z){if(B)return b(B);z=z.filter(V=>C(w(V))),z.length||b(void 0,!1),setImmediate(z.reverse().reduce(function(V,Y){return function(re,te){if(re||te===!1)return setImmediate(V,re,!1);I.addLocalFileAsync({localPath:Y,zipPath:Ee.dirname(w(Y)),zipName:R(Y)},V)}},b))})})},addLocalFolderPromise:function(y,b){return new Promise((I,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},b),(C,O)=>{C&&S(C),O&&I(this)})})},addFile:function(y,b,I,S){y=x(y);let C=h(y),O=C!=null;O||(C=new Pg(i),C.entryName=y),C.comment=I||"";let w=typeof S=="object"&&S instanceof o.fs.Stats;w&&(C.header.time=S.mtime);var R=C.isDirectory?16:0;let k=C.isDirectory?16384:32768;return w?k|=4095&S.mode:typeof S=="number"?k|=4095&S:k|=C.isDirectory?493:420,R=(R|k<<16)>>>0,C.attr=R,C.setData(b),O||c.setEntry(C),C},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return h(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,b,I,S,C,O){S=kn(!1,S),C=kn(!1,C),I=kn(!0,I),O=Xl(C,O);var w=h(y);if(!w)throw be.Errors.NO_ENTRY();var R=l(w.entryName),k=f(b,O&&!w.isDirectory?O:I?R:Ee.basename(R));if(w.isDirectory){var B=c.getEntryChildren(w);return B.forEach(function(Y){if(Y.isDirectory)return;var re=Y.getData();if(!re)throw be.Errors.CANT_EXTRACT_FILE();var te=l(Y.entryName),ve=f(b,I?te:Ee.basename(te));let ge=C?Y.header.fileAttr:void 0;o.writeFileTo(ve,re,S,ge)}),!0}var z=w.getData(c.password);if(!z)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!S)throw be.Errors.CANT_OVERRIDE();let V=C?y.header.fileAttr:void 0;return o.writeFileTo(k,z,S,V),!0},test:function(y){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var I=c.entries[b].getData(y);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(y,b,I,S){if(I=kn(!1,I),S=Xl(I,S),b=kn(!1,b),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(C){var O=f(y,l(C.entryName));if(C.isDirectory){o.makeDir(O);return}var w=C.getData(S);if(!w)throw be.Errors.CANT_EXTRACT_FILE();let R=I?C.header.fileAttr:void 0;o.writeFileTo(O,w,b,R);try{o.fs.utimesSync(O,C.header.time,C.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,b,I,S){if(S=Lg(b,I,S),I=kn(!1,I),b=kn(!1,b),!S)return new Promise((k,B)=>{this.extractAllToAsync(y,b,I,function(z){z?B(z):k(this)})});if(!c){S(be.Errors.NO_ZIP());return}y=Ee.resolve(y);let C=k=>f(y,Ee.normalize(l(k.entryName))),O=(k,B)=>new Error(k+': "'+B+'"'),w=[],R=[];c.entries.forEach(k=>{k.isDirectory?w.push(k):R.push(k)});for(let k of w){let B=C(k),z=I?k.header.fileAttr:void 0;try{o.makeDir(B),z&&o.fs.chmodSync(B,z),o.fs.utimesSync(B,k.header.time,k.header.time)}catch{S(O("Unable to create folder",B))}}R.reverse().reduce(function(k,B){return function(z){if(z)k(z);else{let V=Ee.normalize(l(B.entryName)),Y=f(y,V);B.getDataAsync(function(re,te){if(te)k(te);else if(!re)k(be.Errors.CANT_EXTRACT_FILE());else{let ve=I?B.header.fileAttr:void 0;o.writeFileToAsync(Y,re,b,ve,function(ge){ge||k(O("Unable to write file",Y)),o.fs.utimes(Y,B.header.time,B.header.time,function(P){P?k(O("Unable to set times",Y)):k()})})}})}}},S)()},writeZip:function(y,b){if(arguments.length===1&&typeof y=="function"&&(b=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var I=c.compressToBuffer();if(I){var S=o.writeFileTo(y,I,!0);typeof b=="function"&&b(S?null:new Error("failed"),"")}}},writeZipPromise:function(y,b){let{overwrite:I,perm:S}=Object.assign({overwrite:!0},b);return new Promise((C,O)=>{!y&&i.filename&&(y=i.filename),y||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let R=k=>k?C(k):O("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,w,I,S,R)},O)})},toBufferPromise:function(){return new Promise((y,b)=>{c.toAsyncBuffer(y,b)})},toBuffer:function(y,b,I,S){return typeof y=="function"?(c.toAsyncBuffer(y,b,I,S),null):c.compressToBuffer()}}}});import{execFile as I_,spawn as A_,spawnSync as cA}from"node:child_process";import{promisify as T_}from"node:util";function C_(t){if(process.platform!=="win32")return!1;if(Vf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Vf,"").toLowerCase();return D_.has(r)}function Yf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return C_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function ut(t,e=[],r={}){return A_(t,e,Yf(t,r))}function Zf(t,e=[],r={}){return R_(t,e,Yf(t,r))}var D_,Vf,R_,bn=Qe(()=>{"use strict";D_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Vf=/\.(cmd|bat|ps1)$/i;R_=T_(I_)});var Ku=ce(Fe=>{"use strict";var M=ee;(function(t,e){let r=ee,i=t();for(;;)try{if(parseInt(r(1057))/1+-parseInt(r(1519))/2+parseInt(r(1858))/3*(-parseInt(r(1918))/4)+-parseInt(r(1946))/5*(-parseInt(r(1713))/6)+-parseInt(r(745))/7+parseInt(r(1181))/8*(-parseInt(r(1236))/9)+parseInt(r(1173))/10===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Do,797557);var pE=Object[M(487)+M(1366)],gE=Object[M(552)+"opertyNames"],qu=(t,e)=>function(){return t&&(e=(0,t[{wluLf:function(c,l){return c(l)}}[M(1338)](gE,t)[0]])(t=0)),e},mE=(t,e)=>{let r={FaAsK:function(o,c,l,f){return o(c,l,f)}};for(var i in e)r.FaAsK(pE,t,i,{get:e[i],enumerable:!0})};function wE(){return Mu||(Mu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function _E(){let t=M;return Bu||(Bu=[IDBCursor.prototype[t(1579)],IDBCursor[t(1895)+"e"].continue,IDBCursor[t(1895)+"e"]["continue"+t(1444)+"ey"]])}function yE(t){let e=M,r={mvnks:e(1316),SJqxb:"error",OkyZA:function(o,c){return o(c)},SdTex:function(o,c){return o(c)},CEjzq:function(o){return o()},XtxpJ:function(o,c){return o!==c},UYbQP:e(1583),qGZBv:function(o,c,l){return o(c,l)},LtCFV:function(o,c,l){return o(c,l)},xldvq:e(651),nUgTS:e(1563),HGwkO:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,f={LOBme:function(x,h){return r[ee(1533)](x,h)},eolOO:function(x,h){return r[ee(522)](x,h)},PhyMH:function(x){return x()},gMTEa:function(x){return r[ee(1085)](x)}};if(!r[l(1873)](r[l(967)],"JSrNU")){let x=()=>{let E=l;t[E(1663)+E(1834)+E(1792)](r[E(1553)],h),t[E(1663)+E(1834)+E(1792)](r[E(1434)],m)},h=()=>{let E=l;f.LOBme(o,f[E(1310)](zt,t[E(1374)])),f[E(611)](x)},m=()=>{let E=l;c(t[E(583)]),f[E(467)](x)};t.addEventListener("success",h),t[l(514)+l(1379)](r[l(1434)],m)}});return i[e(1138)](o=>{let c=e;r[c(1873)](r[c(1407)],r.nUgTS)?r[c(1802)](o,IDBCursor)&&td[c(497)](o,t):(r[c(667)](_0xd67eab,_0x58477f,66),r[c(1e3)](_0x4bf644,_0xe86ded,_0x2a0046[c(546)]),_0x7edff4(_0x1d40c6,_0x4f1869))})[e(1732)](()=>{}),Ao.set(i,t),i}function EE(t){let e=M,r={ubKUf:function(o,c){return o!==c},LUxyr:e(1460),ttXwm:function(o){return o()},kkIuv:e(1512),ptqLP:function(o,c){return o(c)},RPxKr:"error",odywJ:e(1736)};if(Io[e(1195)](t))return;let i=new Promise((o,c)=>{let l=e,f={VLJJL:r.kkIuv,TRShg:l(583),tjtWA:l(1736),ZWRDG:function(E,A){return r[l(566)](E,A)}},x=()=>{let E=l;t["removeEv"+E(1834)+E(1792)](f[E(1260)],h),t[E(1663)+E(1834)+"ner"](f[E(1256)],m),t[E(1663)+"entListener"](f[E(1744)],m)},h=()=>{let E=l;if(r.ubKUf(r[E(1354)],E(1460)))return _0x446c31(_0xa80365);r[E(1370)](o),r[E(1370)](x)},m=()=>{let E=l;f[E(1019)](c,t[E(583)]||new DOMException(E(1175)+"or",E(1175)+"or")),x()};t[l(514)+l(1379)](r[l(645)],h),t["addEvent"+l(1379)](r[l(1142)],m),t[l(514)+l(1379)](r[l(1861)],m)});Io[e(497)](t,i)}function bE(t){To=t(To)}function vE(t){let e=M,r={dZrfw:function(i,o){return i(o)},vtRtB:function(i,o,c){return i(o,c)},zmoqT:e(872),TYgEh:e(1283),nbGbh:e(1552)+"ay, network offl"+e(747),OMWnX:function(i,o){return i(o)},oYtiA:function(i,o){return i(o)},lxYJr:function(i,o){return i===o},qtdGU:function(i,o){return i in o},qzUsJ:e(1956)+e(1863),fNRJb:function(i){return i()},bgKRr:e(1469)};if(r[e(688)](t,IDBDatabase[e(1895)+"e"][e(499)+e(1778)])&&!r[e(1042)](r[e(791)],IDBTransaction[e(1895)+"e"]))return function(i,...o){let c=e,l=t[c(1449)](r.dZrfw(Gi,this),i,...o);return ed[c(497)](l,i[c(1265)]?i.sort():[i]),zt(l)};if(r[e(1348)](_E)[e(758)](t))if(r.bgKRr===e(525)){if(this[e(1131)+"ngTimer"](),this[e(1572)+"mer"](),this[e(1847)+"sListeners"](),this["_wsInsta"+e(755)](1e3,_0x3a2dc3),this[e(512)+e(1546)]=!1,_0x29bef0&&this["_navigat"+e(1454)]()&&!this[e(1027)+e(1516)]){if(this[e(1039)+e(1603)]?.[e(1737)+e(807)+"es"]()){let o=this[e(1039)+e(1603)]?.[e(843)+"ntEndpoint"]();this["_dispatc"+e(938)+e(1789)](r[e(931)](_0x381e45,r[e(1442)],{code:1006,reason:e(752)+o+(" timeout"+e(864)+e(749)+e(740)),wasClean:!0}))}else{let o=this[e(1638)][e(660)+"tInterce"+e(674)](_0x3791a1,_0x1f14ec);this[e(640)+e(938)+e(1789)](_0x5a2cad("close",{code:_0x2f9dd8,reason:_0x26d82f,wasClean:!0,willReconnect:o})),o&&this[e(512)]()}return}this._navigatorOnline()||this["_readyCl"+e(1516)]?this[e(640)+e(938)+"ent"](_0x58df53(r.zmoqT,{code:_0x20230b,reason:r[e(599)]})):this[e(640)+e(938)+e(1789)](_0x481b5e(e(872),{code:1006,reason:r.nbGbh})),this[e(1476)]=null,this[e(1039)+e(1603)]?.[e(1293)+e(1566)+e(1969)](),this[e(652)+e(743)]?.["resetCou"+e(970)]()}else return function(...i){let o=e;return t[o(787)](r[o(1486)](Gi,this),i),zt(td[o(1616)](this))};return function(...i){let o=e;return r[o(1443)](zt,t[o(787)](r[o(1216)](Gi,this),i))}}function SE(t){let e=M,r={KqWYD:function(i,o){return i===o},DVbDC:e(1751),wkqlg:function(i,o){return i instanceof o},hkvyf:function(i,o,c){return i(o,c)},bAAtz:function(i){return i()}};return r.KqWYD(typeof t,r[e(639)])?vE(t):(r[e(1750)](t,IDBTransaction)&&EE(t),r[e(825)](Gu,t,r.bAAtz(wE))?new Proxy(t,To):t)}function zt(t){let e=M,r={HeHII:function(o,c){return o instanceof c},pPfMb:function(o,c){return o(c)},EZjro:e(617)};if(r[e(1581)](t,IDBRequest))return r.pPfMb(yE,t);if(vo[e(1195)](t))return vo.get(t);let i=r[e(859)](SE,t);return i!==t&&(r.EZjro===r[e(1210)]?(vo[e(497)](t,i),Ao.set(i,t)):_0x49b3e2.createObjectStore(_0x7ef229,{keyPath:_0x399380})),i}var Gu,Mu,Bu,td,Io,ed,vo,Ao,To,Gi,zu=qu({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={GYCmo:function(r,i){return r instanceof i},FNEgg:t(1477),yAMJB:function(r,i){return r===i},lKOwY:t(1956)+"oreNames",cMMIi:t(1606),tbadz:function(r,i){return r(i)},qbSdK:function(r,i,o,c){return r(i,o,c)},GKHxk:function(r,i){return r!==i},TyrvJ:function(r,i){return r===i},gcYxQ:function(r,i){return r===i},fccxT:function(r,i){return r in i}};Gu=(r,i)=>i[t(558)](o=>r instanceof o),td=new WeakMap,Io=new WeakMap,ed=new WeakMap,vo=new WeakMap,Ao=new WeakMap,To={get(r,i,o){let c=t;if(e[c(1235)](r,IDBTransaction)){if(i===e[c(1922)])return Io[c(1616)](r);if(e[c(1059)](i,e[c(1430)]))return r.objectStoreNames||ed[c(1616)](r);if(e.yAMJB(i,e.cMMIi))return o[c(1956)+c(1863)][1]?void 0:o["objectSt"+c(483)](o["objectSt"+c(1863)][0])}return e[c(1077)](zt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;if(e[o(1104)]("PaYfP",o(590)))throw _0x2d1478=_0x522156[o(546)],e[o(1244)](_0x36ef26,_0x26923c,10,_0x473c10.length);return r instanceof IDBTransaction&&(e[o(1143)](i,e[o(1922)])||e[o(1201)](i,e[o(485)]))?!0:e[o(1784)](i,r)}},Gi=r=>Ao[t(1616)](r)}}),ju={};mE(ju,{deleteDB:()=>AE,openDB:()=>IE,unwrap:()=>Gi,wrap:()=>zt});function IE(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,f={hUZrH:function(m,E){return m(E)},DaWTJ:function(m,E){return m(E)},QSLRT:l(872),dAytz:l(1910)+"hange",ZUReZ:function(m,E){return m(E)},WcYVf:function(m,E){return m!==E},LFvqV:l(934),VhdNR:l(797)+"eeded",usNak:l(1190)},x=indexedDB[l(1071)](t,e),h=f[l(1839)](zt,x);if(i)if(f[l(648)](f[l(1298)],f.LFvqV))try{return!!this[l(1924)]}catch(m){return _0x10e4e1[l(839)](m),!1}else x[l(514)+l(1379)](f[l(1456)],m=>{let E=l;i(f[E(959)](zt,x[E(1374)]),m[E(1110)+"on"],m[E(867)+"on"],f[E(1255)](zt,x[E(499)+"ion"]))});return r&&x[l(514)+l(1379)](f.usNak,()=>r()),h[l(1138)](m=>{let E=l;c&&m[E(514)+E(1379)](f.QSLRT,()=>c()),o&&m[E(514)+"Listener"](f[E(922)],()=>o())})[l(1732)](()=>{}),h}function AE(t,{blocked:e}={}){let r=M,i={ZEZcr:function(c,l){return c(l)}},o=indexedDB[r(1725)+"tabase"](t);return e&&o["addEvent"+r(1379)](r(1190),()=>e()),i[r(756)](zt,o).then(()=>{})}function Do(){let t=["BNrbBMrvCgq","Aw9U","BxPbwhi","DND0qLq","t1bftG","rKLmrv9ot1q","C2DPza","zMnJEfq","BxnN","u2vYDMLJzvC","zvvYBa","yw1L","zw50","tNrfqvO","C2nYAxb0","BMvY","s3n2zuK","Ew1es3m","CevJBw0","tMfTzq","qvfysg4","vfP0C0C","DeLK","wg1os3u","DLfTs0O","seD3A08","s09esNy","r0XvseK","zfLjqK0","EeH4sfK","BxnzDuq","DgfIyxnL","vM1kB2u","zxjFDhrS","mxW0Fdb8mNW","tenIreq","BMDuAw1LCG","DKz2rKe","AxnmB25N","AxnszwfKEq","zhzPyui","yMHeAva","zv9ZDwnJzxm","ywXSq3vYC28","zKfhBei","x3bPBMC","z2vjBMzVu3K","B0jju0u","CMvWBgfJzq","ALPVr3e","uLrjEMK","B25ozxr3B3i","D3rxu3i","sKTPEgG","Chv0","EwvPB3m","B0vkwgO","zw50tgLZDgu","z2v0q3vYC28","AxnrB1nby2S","ELbMufK","tw1Kqxe","wLvszvO","B3jXAgC","y29Zsxi","Dff0B0W","y3ruAw1LB3u","sw5XwgS","x19LC01Vzhu","x2n1CNnVCK0","x3jLBw92zvC","tfDHD0C","CfnOAMy","CuLAywy","C3Putum","ruPbEK0","DfLODfa","Eujtr2u","q0Xpu0LorW","mdaWma","Dhj1y3rVCIa","mtmXn0LLDxbIvG","CNzHBfzHBhu","Axnby2TdBgu","B2r5D0O","y3jLyxrLtwu","B3jLtMfTzxm","Ae9Wzw5fDMu","wuL6uwi","teDRBLC","wgX4r1i","zM9YrwfJAa","D3m6lY8","zxjFCw9Zx2e","BwL6y0W","Cg9W","whr4CeO","B3bLBKrc","x2LZtwLUAvq","EKPWv08","u0HkEwu","x2HHBMrSzu8","r0HtzNy","AvHrCu8","r0rsrxm","D1PKyMS","CMvXDwLYzwq","C3rYAw5N","BMfTzq","x2DLDeLUDgu","AgvKtwf4uMu","DKzJqKu","A05KCKO","zwXorNO","v0LtteC","zwnVBM5Ly3q","BMDLza","B1vgA3y","ChjVDg90Exa","jMPZy2fSBgi","vLDJCuK","ELrXC3a","wvrMCvO","A3PXrwq","z2v0s2v5","txLcEu4","uxj3rK8","x21LC3nHz2u","wg5WDKu","zhLkuey","uxHoAKK","zgvIDwC","zMzmAw5L","DMvYC2LVBMm","x2rYB3bhBg8","zentqu8","BeHHBMrSzxi","B1fwvMG","A0fzDeW","Ee5gvxq","zw5NDgG","mJeZnMDpyuziDq","tMzRqwK","t2Pwz3C","vgHuBeS","rK5fz2C","BgvQD2O","x3fVC0rc","vu9jvLu","ywrKq291BNq","CMvQzwn0","AM9PBG","BKzHAxa","ywnRx2LK","DhPTrM8","AefZwfm","qvjJuuy","A2v5","x29UugfNzu4","z1LfrwK","uMvJB25Uzwm","vfzXD1e","yw5ZzM9YBvq","Aw1LCYbPBIa","Eun0tuG","BKHWu2q","thPRuKS","D2vI","x3bPBMDqB24","mZu4ndCWnxDPqNLmsa","A3b3rvm","uxntqM0","ywDLrxzLBNq","tLLryvC","BwvKAwf0zwW","BK1hDwq","ugHMyKq","z2v0u3rVCMe","x2HHBMrSzvi","B2jQzwn0u3q","Ag1YA3G","BwvZC2fNzq","v291ChO","ywXSB2nvBNm","vM1RwNy","DKXrsM0","wg96Dfi","BMrWB2LUDfq","DvvRv0S","zeP2rMS","zgDty0K","u0v6BuW","zMLN","B2nRzxrgywK","BwvZC2fNzv8","CgjICdi","D2Tzzve","CMvJzwL2zwq","re1oCNK","vuTsu04","CeLSu2q","vfnmvg0","zxjYtM8","z01urwe","sMf1sxG","C2nVwNy","Dxrjza","AwfnreG","tLz3uxy","C3vIyxjYyxK","r3Pgvuq","C2vYDMLJzs0","zNjVBujPDhm","sKX5t2u","BgLUzq","Aw1NAM0","zLLWA1K","A29WD20","vxbKyxrLq28","B3jL","BwvZC2fNztO","y01nswK","B2zMBgLUzq","zgvMAw5Luhi","rhLszKm","EvjLy29UBMu","tNbVAhy","q3vUwMu","x2n1CNnVCKy","y3vYC29Yx24","x29UrxjYB3i","z0Tit28","CMLLC0nVDw4","C2v0","te9MDfy","DhjHBNnHy3q","yuTvCeO","svnSq24","uxPPq28","r0D3zK4","q29Kzq","BLjzrxC","zhnADgu","DgzgCMi","De9rCfa","v0rMEfK","C3jJ","B25tDg9Wsw0","x2nVBM5Ly3q","rMvtDey","ywrKrxzLBNq","zNDZxZeUmc4","vwLjB3i","C0TIBey","ywDLu2HVDW","CYbPBNn0yw4","yvD3vfK","Aw5PDcbrB1m","u2ruzxG","y3vYC29YlNm","y3jLyxrLq2W","thbJu2i","Dg9tyui","C3nHz2vfDMu","Bwf4tg9ZC0m","zMzMzG","wvH3uNe","EKjZrhu","D1DVz0y","Aw9Ul2PZB24","vwDnvMm","DwjOsM8","vg9Uru8","EvnKufC","EgTTv0C","Bgjhr0u","AwXLx25HBwu","y3vYDMfSDwu","t2HRu0G","Cu5cEwi","qKnHA1y","EurpB2G","BgvUz3rO","m3WWFdr8mxW","uNbXvMC","C3bSAxq","wwTov20","AxDWEg0","z2v0t3DUuhi","zxjYtxnN","vgLwwuu","vKvKAMC","svjpDuq","yKLLtgy","C29Tzq","B2fK","rNfzqMG","rNPSEfC","EKnkBxG","BvPwELi","B0zmz0e","ENjVzuq","ChrXtfa","zw50zwqGDhK","ywDL","Aw5KzxG","s2HPDK4","Bgfzz2K","x3nLBMrby2S","D1Diy1u","zuHVChC","CgfYC2u","vKveug8","y2HnyxHdB3u","AhnZvxu","tg9NsurozxC","CMXTtu0","uwjgDe8","Buz0vxG","zxjYB3i","q2X6r0K","uufnr2q","Aenuvwi","DMfSDwu","rfDgBem","x2LUAxrqCM8","ugfzzLa","y3vYCMvUDeK","v29JAfK","x29Uq2XVC2u","sKfwB3m","zw5JB2rPBMC","B3vUDa","mdaWmdaWmda","tvPvsKO","vfLNrwG","BM5Ly3q","x2rPC2nVBM4","rwreBxK","y0jfvMW","BhPKuKC","zfHdqK0","BgHcvg8","uuLntuq","r3zcsMy","z2v0qwXS","wNLWq1y","ugH5tuG","uLnjBgy","yvDXDuu","sxDcCwO","qw1VDw50","rgvKAwnHDgu","v2vADK4","zw5fDMvUDa","Cw9Zx18","sfH5rMm","yxjAB2O","yu9Yuui","tKHQAMu","wg5nsK4","mhW0Fdj8nq","Dg9cExrLC0i","D3zsEvq","D3jPDgvvAw4","uhvqy0K","x3bHDgHlzxK","t1nmqu4","rxHpENe","D2Dbq28","Eev2CvG","Bwu6ia","ExDNuKu","zMLSzw5HBwu","yM9L","rfzIrem","x2rPC3bHDgm","ENLNDva","vePHCxy","sxDPzfK","Bg9Nsurhzw4","A2TjDxy","we5evuy","DNbUyLy","v2nzvMy","Dgjcy1G","Awrsr2K","CgH0CxG","x3bPBMDmB3m","z0LptKu","BfH4BMm","u3rYyxrLz3K","AKrwt1i","wwLgvLK","swLcv20","C2P3Aey","CMvJB25Uzwm","BgLTAxq","DwDHBui","yunNz3u","wKz0r3a","Bhb0z0i","Bg9IywXty28","CuDAqNy","y3vZDg9Tshq","x21PBMLoyxy","CunqB1C","tuzyuhy","DNncC0C","v0Dwyum","ChrVCG","rMPSA0e","C0DKEwS","zgf0yq","C2vUza","uMHque4","x2jPBMfYEvq","mxWZFdr8mNW","zxjFAxnFywm","u2j1vKK","zxbJBeS","Bhbzr20","rK1tCKi","B25mAw5L","BhHzsNi","tvrQELK","A1bnC3C","x3DHAxq","wxz6yvu","yxv0B21HDgK","yxnZAwDU","te9RuhC","BMCGB3iGyw4","ExrOvxm","D3jPDgu","q0nbwLO","C2HPzNq","v3jAvLy","ugDkruC","uev3EwW","zw5JB2rLrNi","AfrnAgW","wwHpruS","veTmA1m","qKHhu2K","tKvfvLe","Dg9tDhjPBMC","Dgnpv0e","wNLfqM8","sMjzvfO","zw1PDa","Cgf5Bg9Hzfq","CMvZzxrdB3u","vhjmzNK","DxjPwue","CNjVCK1LC3m","BKXPBMu","yNPXsvK","q291BNq","FdD8mhW5","zcbLCNjVCI4","zgvSzxrL","B25TzxnZywC","ywXPzcb1CMW","wgfkDuK","B1HZthy","vfnVAvu","AKDQy3m","B1rdB3i","rw9ly24","zfbxvhO","y3jLyxrLt3a","Dw5RBM93BIa","DerhwLK","EvPnuxy","rxjnA3u","ywnOzwq","sLfHq3a","AMXNtgS","C0nVDw50zxi","CIb0DhDjra","ntu1ndm4mxb5vLDHra","y29UBMvJDeu","Aw5L","zNjHBwvuExa","DhjPzxmGCMu","B3vyAgK","zcWGDw5RBM8","y29UBMvJDca","AxnbCNjHEq","wg9nuvu","BMnLq2XVC2u","wKvAy3i","r0vOEey","Aw5JBhvKzxm","x29Ut3bLBG","vNLyDLy","CMvWBgfJzui","BMvLzf9Hy2S","ugrRz0W","BNvIDeq","v1rpsMq","B1brzNi","yMLUyxj5vhK","BwX1v0e","uvzQBxe","q09otKvdveK","CgLUz0LUDgu","DM9Orw0","Aw5N","z2v0qwXSs2u","tKv5ANi","vKreuvO","qNrqBLq","vfj2rwe","u21UCeK","yw51Ce1LC3m","r0XWrwW","Ec1TC2CTy3u","C0f0Cxy","Cg93","rgjJs2S","wxPOyMW","yxbWBhK","AMvJDfn0B3i","DKXrwLe","x2LUAxq","CxPvC0O","uxvLDwu","ywDLsgLKzq","uLLSzxe","rxjYB3jdB2q","mhW1","DxbNCMfKzw4","B2zMC2v0","wxLly0O","C0riAKW","CMvHzfvjBNq","vw5Oyw5KBgu","r0zbBKC","Bg9NsurozxC","AwXSihvZzsa","z3nkthu","y2HnyxHuCMK","ANnst2C","zxjFBxnNAwq","igzHAwWSig0","q3veA0O","AwrI","x3nLCuLK","y2XVC2veqG","y29UBMvJDgK","yNL0zxm","Bwv0Ag9K","tMXqCNa","uKX1B1i","x25HDMLNyxq","CgXLyxnLiha","uwLnAMK","wuvev08","DMfS","AgT2Ewy","Bwf4uMv0CMK","C2XPy2u","tuL4r3y","Dg9Y","BgLUzw5V","wLnOsvy","wfbowMm","yvLxrMq","y29SBM8","DMvY","q0rZENK","EuroC2G","vLL5C1e","Bg9N","tLvrA1y","BMvJDa","D2jrvvm","z2v0q3vYCMu","CxP4CMu","z2vtEw5J","zLvxuui","veDjvNe","Au50yvO","Bg93","BM93","B25pCgvU","z25bvLi","qvHAu0O","CNnVCKzPBgu","BxrqBM8","EMHTzK0","BK1vwhy","t1bftL9fuLi","CfbMtwi","vMXIwNO","r2PWCfO","DcbVzIbYyw4","BNLYt3K","lcbTyxGGCMu","yw5Hz2vY","zNfezKm","BMv3vMvYC2K","CxD6zhe","x2TLEvbHDgG","zhDAzhO","y2XVC2uSihC","y2XVC2u","wMrLz1q","A3jvuLe","Ahvot2W","AxnrB1nnzxm","yxfYthO","DxL1u3K","rvves1C","wfDKqwO","sLnptLa","zKrcvLi","DvjhvwO","zNzXDfq","Fdv8oxW3FdG","sNHsz2i","x2zVCM1HDeu","zeXcyM0","CgLUz19VBMm","vuDICg8","AhjgAhO","wM9mvwy","yMLUyxj5","wuDkD0y","DMvYC2LVBG","uKzywey","Dvb4ruG","uNncy2G","lcbOB3n0BMe","t054AfO","z2vrDwv1zuW","CxPTrhK","werMr0K","vvLMEhy","sMLqwva","EfbyrLe","tLDAvhG","BwvY","A1fwrKO","yMX4Bve","z2LIruW","yuPhvMC","Bg5luxy","pxv0zI04","wgjYvvC","ihn1y2nLC3m","twLZC2LUzYa","CMvZB2X2zq","CefZshG","CfLmvLG","B25nzxnZywC","zef5DhO","zxj2AwnL","wgHVDhC","EePjD1e","EMz1BwW","BezSDxnO","yM1Jtxi","A3v6vxC","CMvHzhLtDge","DNrsDei","DhLWzq","zNjVBunOyxi","DNDsq1C","EunNu1K","uKTssMO","quvtEuC","AenSB3nLrxy","A1zdD2e","ruDUCgW","Bg9XBNO","CNnVCL9Uyw0","zMLSDgvY","A2LKuM8","DNPqvLy","C2vYDMLJzq","mxWW","rNjVBNrPzxi","EuzyDxe","rxzLBNq","ywnRtxnNswq","v0fZyxy","ChbL","rg1Yqxa","Ef9MCM9UDgK","rK9Tz1a","CM9YrxzLBNq","x2nYzwf0zvm","AfvACKG","u2vXsuq","zsbHihn0CMK","B25szwnLAxy","teneqKm","zg5oBva","zxjFCw9Z","yuP3sLG","vvLIuva","EMTnz3G","ywnRx2nVzgu","BNrLCG","mtb8nxW4Fdy","DKfYA3q","Eevxzhq","zgTLvgq","yKrTqKe","B0HdvfG","EKjSweK","twzPuMK","u2Pkv1G","B25LCNjVCG","vu5KC2e","D0jWqMO","wgPxAwW","CgvYC2LZDgu","ywHTuhm","m3W0Fdj8nxW","C2v0q3vYC28","su5tvefova","vw5PBxbSzw0","ExnLDM8","A2LUrw4","BwrPtLm","y29Uy2f0","BwLUzW","DePdyM4","uePHrva","C0zgDNi","BuXky1a","x2LUDgvYDMe","thrdrLy","Dg9oDw1Izxi","DuTmtuC","tM5QBeC","rvfTEwK","q3vZDg9Tq2W","Bu9qvfG","EfvZtKm","tvrishe","x2fKzfDZtgK","EwrmvuW","BLbltxq","B2zM","wwzWCvu","Dhr3Awq","CuTOshi","wujbrMm","Efrurw52","B25VCgvU","wLDsreC","thDvBw8","DMfSDwvZ","yxv0BW","thnHuhy","EejXEeK","ywnR","ywnRpwzYB24","x3jLywr5q2W","zw5HyMXLvhi","yNvMzMvYzwq","CMvUDevUzha","vfD2z1G","x0rctMfTzq","EgPer0G","z29cuxO","rLzUD2S","qujAtxC","A0L3Au8","zMPAwwe","x2vUzhbVAw4","B09JD3y","DwTzyvu","CxrKr1u","yvjwyxa","twncD1a","AwHqCeW","uLbTy3i","zxDgAKO","zxnxvNq","t3bLBKv2zw4","wxrizfu","vfbWy2u","yLfeCeO","tMvZrfq","x2rLyNvN","zgLZywjSzue","CMTLCKDSB2i","mJy1ndqYtwLABhv4","ihjLy29UBMu","EufnsKi","uMvHzcbWyxm","DgLTzw91DcW","EwTQsha","B25Uzwn0Aw4","twLPAM0","rMfkyKq","ENndq2C","AgLNAa","CMvJzxzPzwq","DhjPBq","qNfZvLm","B3bLBG","Dg9mB3DLCKm","v2fVuvi","z2vY","zfrHshK","yuTlvwC","DgjHzhO","x2LZsw5PDa","sNHyvwq","z3rQr1a","Egf3BNG","BgLZDgvUtMu","Cgf5Bg9Hzeu","zMvY","q0vQENe","zuncz2u","CMv0CNLdB3u","BhrPCgXLihq","z0HrqLu","t0PuCvG","Dg9cExrLCW","sLf4wuq","y29UDgv4Da","CYbHBhjLywq","uurnt1q","B09Is00","r3rSs3G","ign1CNnVCIa","uMj4ugG","r1bVzxK","ExbL","ChjVDg9JB2W","Ae1LC3nHz2u","r0TiEgS","BMnVzgLUzW","rfj0uvK","zLvlBuW","t3HwsMO","zNzvwLK","B2XKvMvYC2K","A1n0yxr1C0m","CM92AwrLigi","DhDVCMTdAge","yunTsNy","zeTlvNa","y29Kzq","FdeWFdn8nNW","BfHxtg8","CNjjzgW","y3jLyxrLrxi","ihrYEsbYzwm","C051B0O","y1LkEK0","BNvTyMvY","AgnsyMW","vfzcDwu","Dw50","igfYCMf5yNu","EMrku3O","tuvIzLC","x2nSzwfYugK","CMvHC29U","CMHjCvC","zxn1Bxi","wfL4zxC","v0LLvwO","yuDrrMK","DgHLBG","A0DYwfe","uLnergq","tMPlzwi","uLb4s3i","vhLYDKO","EgzntKC","q1Dlsu0","y3zzvM0","AwrJt2S","tKnpAum","z2u6ia","CMvKDwnL","zgvS","AxnFywnR","DgLTzw91Da","Dhz3qMG","CgfNzwHPzgu","qwfvtgO","ugXOrLe","x2HHBMrSzva","C2v0sxrLBq","wKvyz0W","y3jLyxrLrwW","sxPJve8","x0vysvnu","Dg1ss2G","DenureS","rLjptLrjrvi","zw1LBNq","C2v0zgi","yMf1vxq","x2rLC3rYB3K","C21zD1q","ALPuuNm","mJG1ntiYmZb0EwPUtLy","AfnxDMO","qwjVCNrfCNi","DKvdsKC","tu5SCLa","x3jLy29UBMu","zMzXzeK","AxjLza","ofrvtgLVsa","DfbRwuq","BxLRsxm","y29UC3rYDwm","BIWGAg9ZDg4","x2LZv29YA2u","D2f2sNi","BhPUDKK","ALfmsfu","yMXVy2TLza","zNjVBuj5Dgu","qwDxCgK","zxHWB3j0CW","DuzRr00","AgfZ","r2HqANi","yLLsEMu","rgvgDfm","DfPZDgG","EK5yDKy","z2nzEfe","DxbKyxrLq3u","sg5zBfe","ww5Otwy","zgTxvM8","tLD1D1K","thLtyLq","DuTqqNy","yNL0zuXLBMC","rvPQCM8","ANjNsNm","v0Xmqwu","qK9ct3C","D2DAsNG","zKTiyxy","zfPYzNC","yM9YtvK","yxnL","C3rLBMvYCW","v2LyEfa","x3vYBa","Dw5ZAwDUzwq","C3bSAwnL","uePpsNe","zw9Ny0i","t29ytgi","ihrPBwvVDxq","o2nOyxjZzxq","DxjS","ChvZAa","CgLUz0XVC3m","q09oveLovuu","BxnNsuq","qMDrEhi","r1LdBw8","mteYntCXmtLHse5dtLG","qMPtuKu","rwT3s1y","EKjRuha","thruvhO","tuvtu0fhrv8","wgngyNy","D2LSBfjLy28","CwjtzeS","u2TPCcbWyxm","ueXkBfK","C0jf","uffpDLC","z1PLteK","uxDPrha","CgfNzxnOB3C","vMHiqui","sLPKCfy","uwzfEKK","rgfxveO","vfjtAgC","EvbZu1O","DhjPzxm","suvtx0vsuK8","vKXksKW","wvDlsMu","zKHAwLq","ihrVihjLDhi","yw5Nzq","C29YDa","D0fhsMG","A2v5CW","yw53Cgi","CMXUzKK","yKPZwvm","B2LUDfjLywm","vxrlEKu","twzYrNa","uurdBMG","ChvnELe","u3jUzKW","zfDVCMTLCKC","vwPJreC","DgvZDa","tNHYtKW","C2vUDa","z1rPBwvVDxq","yNLL","BLjZzeW","u2Prugq","B25dBg9Zzq","CM92AwrLihC","EuzRv0u","EeXPAfu","DxnezM4","DvHQBuO","qKfJv3K","CMvZzxrfBMq","rM1hDMu","tu5sD1m","Dgv4DfbHEwW","rgDIr24","tez2Cvy","vM5Lt08","uLvnrMq","D24GCMvHC28","BfvUqvG","tNnns2u","B25JBg9Zzq","B3LxquC","yvnMu0G","BMCGzMfPBgu","s0TuwLa","CwXOtLq","zw9St08","EKXwu08","sLvzt2W","CNzHBa","vufdCxy","swzewuC","C3vJy2vZCW","v3Dbruy","DMLJzuLeig8","Dw5KzwzPBMu","zv90Aw1LB3u","zufJAW","uxrzq2m","zvrPvu0","CwH1yMm","q1HOswy","BMrLEa","wevkChy","rvjst1i","CwHXsKu","zgv2AwnLx2K","B1L1EhC","AuLJvvC","DeLUDgvYy2u","ug52v1a","q3vZDg9Trxi","wwTLseC","DLHqsve","D2X1tgy","AgXAsfm","q0Xpu0ve","v1PXuKm","AwXK","uMLhqvq","yMfJA3vWigu","CvrPyxa","s3Hyzvi","tKfusvzfx0u","zK5ssMi","tvvbsNq","ueTlwLC","t2jMCLi","t0nPD0C","AgvHzgvY","tfv4Exi","ENvZtMe","y3vYCMvUDeu","r2rPAfe","BwLUAvbYB2C","tM1jt0K","t0Hzse4","DhbizwfKzxi","y3zTwfq","BM5Hrgm","zxH0zw5ZAw8","zxvUDNu","B3bLCNr5","y3vYC29Y","t2TYvem","B3jRig9MzMW","DhryD20","sM5bAwq","DcbSAw1PDa","x3nVy2TLDa","CMvZDwX0","zwLOzvi","thrfBeK","BNruCMLLC0m","rwj3Cu4","tgLZDgvUzxi","zhvlsMe","zLL1q1G","ELzSzgq","yMTmDgq","C0Xf","AgvHzgvYCW","Dev2zw50","ChjVy2vZCW","t3btBgS","ywnNt1i","Dg9hzw5LCMe","EvbRBgu","B0rXvNy","yMfSrxzLBNq","vxjsA0W","rvH2v00","yxbWzw5Kq2G","CM92AwrLige","CgzOreu","Bg5TAhO","BMrWB2LUDca","s2Xms28","vgfN","EeDPwgK","EgrtCLa","AgfZt3DUuhi","x2rItMfTzq","EgXKDNe","yxnJCMLWDa","D0fNtuq","CMfTzq","AK9NC1C","Ahr0Chm6","x3bYzwzPEa","r1ngEuu","x1fVu01HBMe","C2vYDMvYvgK","Ae9utuK","C2r4CKK","t2jQzwn0","CvPvreu","wxnbzeu","ELnTq3O","DhDqCwe","wwvgC20","zxrxB3jRq2G","z2f5yxe","igzPzwXKoIa","ywPHCK0","CMfTugfYyw0","BeTpD1K","DgLUzYbZzxi","B2nRzxrtDwm","qwX1wuS","u0PXEgi","Awj2DfK","zuzeBMK","vgLTzw91Da","DMzlANa","DhDIzNO","CYbWyxjHBxm","sMDyv00","EM1VCvq","B1L0Aue","uhjPBwfYEuS","zNjVBu51Bwi","t3bzCfq","ihzHBgLKigq","wLHJBK4","y2fSBa","BLDtsM4","BKrKwfG","CMvTB3zLq2G","q29UzMLN","B3jpBMXPBMu","EM5VsKW","vMHKtLi","ze95s24","yMLUza","A1DsrKS","EufNALC","Bxztre4","zxH0ugf5Bg8","zxq9DxrMltG","suvNuNi","Ee9nt00","x29UtwvZC2e","y2XLyxi","CMvHzg9UBhK","q1Heq3m","y1fvEuu","yKTjqxy","vNrNvhq","AxnAzxjV","v2vIu29JA2u","C2vUzf9Hy2S","x3DZ","zg9Uzq","y0zcvNG","DffNBNu","BM9Uzv9UB24","shrLEwO","x29UvgLTzw8","ywTXA2e","qxrHr24","yw1LoIa","t01xBLG","wwvlCgG","A2ncrLC","DgfYz2v0","zxf1ywXZ","ywnOzwqSihC","EM5Orve","BgvY","tKDFrvjst1i","y29UBMvJDfm","rujnzNu","t0nYvxu","zMzZwNy","BLn2wNm","r3HXq3i","DgLLCKPtt04","v2zfwem","y2XLyxjtDg8","r1rXDMm","vKTtwNu","revVu2S","wMH1z2C","Aw5Lza","A0XTwhi","vgLSyxy","D3jVsei","y29TCgXLDgu","x2LZtM9Kzq","sK9QA0i","y1D6q1K","B3nLza","tufyx1jfvfi","C3rYAw5NAwy","mJK1nJu4mg5btLziwa","CK9Qu3G","A2vdtvq","vuD5rgS","EvbgCgi","y2HLy2TdDxi","sffIrfC","tw9KDwXL","wNfLBLG","zw5HyMXLuw8","AvbVrKS","zvn6ug4","AuPPDeq","x2XPC3rLBMu","t2T5wKe","l3DZl3yY","mhWZFdf8nhW","AwDHDg9Yt24","CgLUz09Uy2u","r1bOwLC","DNjkuMS","C2zbqwS","yuDbBvu","vezQswq","y2HHCKnVzgu","DvLYBui","y09Wzw4","tg9JAW","zgLZCgf0y2G","BNrfBMrWB2K","Fdf8nhWZFdi","y1bKwLK","thjsvhm","z29PBMCGyxC","BxzUA3m","rgjrDfq","txjVAxi","q3Hvufi","DgHmsNm","B3nLrxzLBNq","AKfKEfG","yxL4Cfq","AwXLtMfTzq","zMX1C2HfEha","sg12zK0","rhfzy0S","yNL0zu9MzNm","Cg9PBNrdB24","DxrVuMvJB24","C0XPC3rLBMu","B25tDgfYDfi","qNnVte0","y3LhDLC","x2nSzwfYvgK","yxbWBgLJyxq","sgDWC1u","rer1BhC","uM94CeC","B3nusgi","sND6EhK","ywr2yw5Jzq","DNHrANG","sgvisuK","Cgu6ia","sLnYtLu","igXHCMDLCIa","DxnLCKLW","twvZC2fNzuu","Au1hzLu","y2uGBM90igK","EvjdqNC","C3zWqxi","BMCGDxjSoIa","Aw5KzxHpzG","yvPxCxq","B29LDwG","C3vIC3rYAw4","AefJA01LC3m","r2fjuge","AevYCM9Yrxy","B3bLBIa","wvv1Bu4","Agz2zNm","Dgv2C24","De1HBMfNzxi","C2LnthC","v2PeCuu","C3rVCMu","zNjVBNrPzxi","we5dD0W","BvnIyxG","B2DnzvK","z2v0sxrLBq","C2PYrxm","tg9Nsuq","AuHfD3O","s29qqMK","z2v0","qNDPq2q","C01gwuO","lcbxzwjtB2m","ugv5Cfy","C2v0u3rVCMe","q2vOAvu","ExHTqLq","ywXty29Wzq","zxjHDg9Y","AMvrEe0","whbluxm","Bwzouxy","EhDuwei","uLjpuG","ywnRDxbfBMq","DuTXAfC","m3WYFdr8mhW","zvzbwKC","y3r4","BwLZzq","wvbYzeW","x29WDgLVBNm","D3nZoI8V","ALLTB20","AeXvt0O","BffNsw8","q09ftKm","CMfUCvG","DuXiwgi","y29UBMvJDa","CLzHBhvLCW","tenrtu0","zM9Yy2u","t3jVD3u","icSG","zgvJB2rLzey","t0HNsuW","r3H4BMq","B2nRzxq","uu12vMe","zenvBeS","DfPHzem","CgfZwey","x2DLBMvYyxq","y291BNq","uxDSDw8","CMvTB3zLrxy","zwn0","DxrMofDYAxq","tgzjyxq","vKvWz0S","zNnkELO","DNroAw4","CvDnrfC","Cgnfr3G","y2vZC0HHBMq","C0TABui","DejjDhu","DNDPyuq","Dgv4Dc9WBge","yxGGCMv0CMK","yw1Quee","CNnVCL92ywW","ihbYB3rVy28","BNjcuxe","D2zswfq","ywrKt25L","qNjIAxi","B25fCNjVCG","x3DZsw5ZDge","Dg9cExrLC0W","BxbXDve","BMv4DcGPigm","z09Kvfq","CM92AwrLihy","wKrtBgS","rNzSv1G","EMTTELm","DMvUDa","wgLpCKK","Ec11C2uT","DgvmB2Djre4","rKXkqMS","zezVwvK","CK9tyu8","q3v3v0e","zMLUza","CgLUz1rPBwu","rfvtCvC","uLjezgm","t2Pnwfe","Ewj3uvC","x2LZtwLUAvC","x2LZqNjVD3m","EgvgvuK","D1nkEuu","mtjdD3fPrK4","u1H1veq","sfD6zNK","BxbJyMS","sMrzsMO","AgfUz2u","z2v5y3i","yxrLq291BNq","tNzXreW","zgrjrcWGzgu","Cgf5Bg9Hza","C2fNzq","zgvSzxrLrge","BwfW","vwPQs0O","rfbYsLm","y3jLyxrLuMu","DwD2wuK","zLv3ExG","y2f0y2G","y1H0z1q","x2LUAxrhBg8","rLDt","ywjVCNq","y2HLy2Tszwe","EhvPquG","ihzHBgLKihm","zxmGCMvHy2G","BfrPBwvVDxq","CwT1Bu8","B25SAw5L","DgP0v0e","Aw9UvgLTzw8","zw5SBve","q09lDhG","t3vkBhm","ywXSzwqGBxu","D2TXBgC","zNvUy3rPB24","z2jVsfa","AxPIBei","C2PIDfu","yM9KEq","yw1Lu3bHy2u","s1nQqvy","ANrJyLi","CKnlv28","u2HHCMvKv28","BhPHCM0","v2LUzg93","x3bYB3rVy28","u292A08","CMfUzg9T","BM1WyMy","terStve","Aw47y2HHCNm","B2zAvLe","zw5KCg9PBNq","BMH1qM4","ywWGy3vYC28","D2jZtMe","aaaaaaaaaaa","yNvMzMvY","D3rwEwS"];return Do=function(){return t},Do()}function ee(t,e){t=t-462;let r=Do(),i=r[t];if(ee.yMJJlw===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let A=0,y,b,I=0;b=x.charAt(I++);~b&&(y=A%4?y*64+b:b,A++%4)?m+=String.fromCharCode(255&y>>(-2*A&6)):0)b=h.indexOf(b);for(let A=0,y=m.length;A<y;A++)E+="%"+("00"+m.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(E)};ee.uRbyLE=o,ee.CNrqGh={},ee.yMJJlw=!0}let c=r[0],l=t+c,f=ee.CNrqGh[l];return f?i=f:(i=ee.uRbyLE(i),ee.CNrqGh[l]=i),i}function Fu(t,e){let r=M,i={tBItu:r(1468),LsaPv:function(x,h){return x instanceof h},KxXeR:function(x,h){return x in h},QIMMD:r(1884),ythUs:function(x,h){return x!==h}};if(!(i[r(1023)](t,IDBDatabase)&&!i[r(1346)](e,t)&&typeof e===i[r(607)]))return;if(So[r(1616)](e))return So[r(1616)](e);let o=e[r(1825)](/FromIndex$/,""),c=i[r(697)](e,o),l=Wu.includes(o);if(!i[r(1346)](o,(c?IDBIndex:IDBObjectStore)[r(1895)+"e"])||!(l||Hu.includes(o)))return;let f=async function(x,...h){let m=r,E=this["transact"+m(1778)](x,l?"readwrite":i[m(1674)]),A=E[m(1606)];return c&&(A=A[m(569)](h[m(700)]())),(await Promise.all([A[o](...h),l&&E[m(1477)]]))[0]};return So.set(e,f),f}var Hu,Wu,So,TE=qu({"node_modules/idb/build/index.js"(){let t=M,e={mtPno:function(o,c){return o(c)},cosIr:t(1616),VEdjg:t(1901),vDQbb:t(774)+"ys",amhsm:t(1661),YtHdU:function(o){return o()},gupfL:t(1831),YyKcJ:"add",WISLG:t(725),ErMku:t(1467)},r=(t(986)+t(947)).split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(855)](bE,o=>({...o,get:(c,l,f)=>Fu(c,l)||o[t(1616)](c,l,f),has:(c,l)=>!!Fu(c,l)||o[t(1195)](c,l)}));continue;case"1":So=new Map;continue;case"2":Hu=[e[t(1841)],e[t(555)],"getAll",e.vDQbb,e.amhsm];continue;case"3":e[t(1050)](zu);continue;case"4":e[t(1050)](zu);continue;case"5":Wu=[e.gupfL,e[t(799)],e[t(1891)],e[t(739)]];continue}break}}}),DE={idb:function(t){let e=M;t[e(1193)]=Promise[e(918)]()[e(1138)](()=>(TE(),ju))[e(1138)](function(r){return r})}},Uu={};function Bt(t){let e=M,r={CbIiU:"0|4|1|2|3",xGiXi:function(f,x){return f!==x}},i=r.CbIiU[e(549)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=Uu[t];continue;case"1":var l=Uu[t]={exports:{}};continue;case"2":DE[t](l,l[e(1193)],Bt);continue;case"3":return l[e(1193)];case"4":if(r[e(1403)](void 0,c))return c[e(1193)];continue}break}}Bt.d=(t,e)=>{let r=ee;for(var i in e)Bt.o(e,i)&&!Bt.o(t,i)&&Object[r(487)+r(1366)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Bt.o=(e,r)=>Object[t(1895)+"e"][t(1405)+"operty"][t(1449)](e,r)})(),(()=>{let t=M,e={AaULj:function(r,i){return r!=i},lnmhz:t(1319)+"d",YnFZU:t(1526)};Bt.r=r=>{let i=t;e[i(1156)](e[i(1399)],typeof Symbol)&&Symbol[i(710)+i(1402)]&&Object[i(487)+i(1366)](r,Symbol[i(710)+i(1402)],{value:e.YnFZU}),Object["definePr"+i(1366)](r,i(1845)+"le",{value:!0})}})();var Pe={};(()=>{let t=M,e={COKtx:function(a,n){return a===n},CxUPR:t(1302),keCMT:t(1226),nRYEw:function(a,n){return a(n)},TVqwQ:function(a,n){return a+n},xEvqX:function(a,n){return a+n},hfvfs:function(a,n){return a*n},iwpxm:function(a,n){return a(n)},tZsth:function(a,n,s){return a(n,s)},zCJmx:t(1064),NVwQv:t(1036),XYxew:function(a,n,s){return a(n,s)},qhqJE:function(a,n){return a===n},azhXY:"jSRhT",bKIAv:t(1842),TFjId:function(a,n){return a+n},yxmBT:t(1856),JOjkB:t(529),NWuwY:function(a,n){return a===n},UNdsa:t(481),YUumN:function(a,n){return a(n)},eCBge:function(a,n){return a(n)},ZoLUf:t(597)+t(597)+t(597)+t(597),wavJr:function(a,n){return a instanceof n},pEcmm:t(1676)+"in;chars"+t(1463),vzPVV:t(1480)+"e",SbuVI:t(893),FvlWX:function(a,n,s,d){return a(n,s,d)},RbxPh:function(a,n){return a<<n},imgjm:function(a,n){return a<<n},kpwES:function(a,n){return a!=n},vFcBE:t(1884),GxqCr:function(a,n){return a instanceof n},JKixh:"applicat"+t(533),cyGvW:function(a,n){return a==n},pcEGx:function(a,n){return a>n},arZoj:function(a,n){return a<n},BgQxr:t(1114),JQxYD:t(1325),vfKjp:function(a,n){return a!==n},TKLkS:"UtVyW",BjSRE:function(a,n){return a<n},kAYtL:function(a,n){return a!==n},ugvYI:t(1359),ZyEBo:function(a,n){return a-n},DqYcK:function(a,n){return a<n},eTiUM:function(a,n){return a<n},pIlSd:function(a,n){return a!==n},sKblF:"sFOeb",oOcwv:"PEHCn",mykIs:function(a,n,s){return a(n,s)},OjVgw:function(a,n,s){return a(n,s)},QfEzI:function(a,n){return a(n)},FqYBh:function(a,n){return a>>>n},ZypCV:function(a,n,s){return a(n,s)},Xhotw:function(a,n){return a(n)},mOPTX:function(a,n){return a&n},oyWAG:function(a,n){return a===n},bIIpH:t(917)+t(1883)+t(1427)+"key",yDOoh:function(a,n){return a===n},oFLgA:t(917)+t(1883)+t(1427)+"value",UYfxv:function(a){return a()},oYuxw:function(a,n){return a(n)},fqDfC:function(a){return a()},vLQZQ:function(a,n){return a(n)},pasXF:function(a,n){return a!==n},MyByN:function(a,n,s){return a(n,s)},kidRo:function(a,n,s){return a(n,s)},YvzaU:function(a,n,s){return a(n,s)},oObKM:function(a,n){return a(n)},UgMVc:t(1617),BCakV:t(1702),XnpvE:function(a,n,s){return a(n,s)},tZadC:function(a,n,s){return a(n,s)},TRvEa:t(1759),gIONE:function(a,n,s){return a(n,s)},IzcTO:function(a,n){return a!==n},xUsNC:function(a,n,s){return a(n,s)},znhEQ:function(a,n,s){return a(n,s)},nMUXv:function(a,n){return a!==n},RTIzi:function(a,n,s){return a(n,s)},TaeLE:function(a,n,s){return a(n,s)},ahxIu:function(a,n,s){return a(n,s)},ZEXgL:function(a,n){return a!==n},WfEXC:function(a,n){return a(n)},mLJcP:function(a,n){return a>>>n},XaJuI:function(a,n,s){return a(n,s)},kEduw:function(a,n,s){return a(n,s)},bjSgy:function(a,n){return a(n)},WaoQR:function(a,n,s){return a(n,s)},zBsDu:function(a,n){return a(n)},YkeHG:function(a,n,s){return a(n,s)},JbYTZ:function(a,n){return a(n)},wWogF:function(a,n){return a(n)},vXPIQ:function(a,n,s){return a(n,s)},FzlxW:function(a,n){return a(n)},aWwTY:function(a,n,s){return a(n,s)},YkSVG:function(a,n){return a===n},lnKQv:t(917)+t(1883)+t(1427)+"SeqID",ACgXY:t(917)+t(1883)+" field: LogID",HnYlQ:t(917)+t(1883)+t(1427)+t(946),tvwBh:function(a,n){return a(n)},eogcB:function(a,n){return a+n},kIwiO:function(a,n){return a&n},XjWil:function(a,n,s){return a(n,s)},oQVVh:function(a,n){return a+n},UTGNH:t(1865),fYuCX:"hNVMv",GzFUD:t(1245)+t(1372),GvBJf:function(a,n){return a+n},YfpqU:t(1060)+t(1372),kzqEd:function(a,n,s){return a(n,s)},ahmPs:t(671),rNIjY:function(a,n,s){return a(n,s)},eunvu:function(a,n){return a+n},dKKVp:function(a,n){return a+n},osTHb:t(1651),JQaCp:" > ",WZqRC:function(a,n){return a+n},xdSrP:function(a,n){return a(n)},OSLAN:function(a,n){return a===n},PJaEP:function(a,n){return a+n},lXWLo:function(a,n){return a+n},QzuiM:function(a,n){return a+n},CWCZD:function(a,n){return a&n},JiPYP:function(a,n){return a|n},bkLtd:function(a,n){return a&n},MmdAq:function(a,n){return a>=n},vwiaD:function(a,n){return a+n},sfAAk:function(a,n){return a+n},MZUJJ:function(a,n){return a&n},wZdbk:function(a,n){return a<<n},vxQjx:function(a,n){return a|n},VlbZz:function(a,n){return a<n},TJaqv:function(a,n){return a>=n},sDHjL:function(a,n){return a!==n},ogMeY:t(1812),YTfqZ:function(a,n){return a(n)},JdYJj:function(a,n){return a&n},QwiDp:function(a,n){return a>=n},wtVyk:function(a,n){return a+n},bpYpB:function(a,n){return a+n},Qwluo:function(a,n){return a+n},wkYeQ:function(a,n){return a+n},dOyKn:function(a,n){return a+n},bDmBA:function(a,n){return a!==n},FMSrB:function(a,n){return a|n},LDlMQ:function(a,n){return a<<n},ydLUL:function(a,n){return a|n},KsveI:function(a,n){return a|n},eFDni:function(a,n){return a&n},gOdTT:function(a,n){return a&n},QiMji:function(a,n,s){return a(n,s)},YWKJe:function(a,n){return a>>n},aSnBz:function(a,n){return a&n},cYJzM:function(a,n){return a<n},QziCo:function(a,n){return a<=n},Yzhbl:function(a,n){return a<n},UOIVU:function(a,n){return a<<n},ONxhZ:function(a,n,s){return a(n,s)},cWzCY:function(a,n){return a+n},fjZYa:function(a,n){return a<<n},TZtsG:function(a,n){return a<n},OxVJj:function(a,n){return a&n},YeFsm:t(838),RpqVg:t(468),oXsLv:function(a,n){return a&n},RhPPN:function(a,n){return a|n},ofZVQ:function(a,n){return a&n},ZShIV:function(a,n){return a|n},RYleq:function(a,n){return a&n},AESyG:function(a,n){return a<n},RUMFd:function(a,n){return a>=n},EBMfu:function(a,n){return a===n},uKLMG:t(1477),ZdegT:"objectStoreNames",qzmDy:function(a,n){return a===n},ysevo:function(a,n){return a&n},NEEVQ:function(a,n){return a<<n},cQUyE:function(a,n){return a&n},JZdpV:function(a,n){return a(n)},LCDBC:function(a,n){return a&n},nrBQq:function(a,n){return a&n},nhuBn:function(a,n){return a(n)},anwpb:function(a,n){return a&n},EbwqN:function(a,n){return a<<n},LOftV:function(a,n){return a&n},YhOEK:function(a,n){return a&n},kPMsw:function(a,n){return a&n},iXQqO:t(1800),jZoGq:function(a,n){return a&n},NEyjr:function(a,n){return a<<n},GSFyE:function(a,n){return a|n},rhIqW:function(a,n){return a<<n},mfNQv:function(a,n){return a|n},nRsdL:function(a,n){return a>>>n},uYrmB:function(a,n){return a|n},OjMXQ:function(a,n){return a<<n},UjcDG:function(a,n){return a>>>n},fUKmL:function(a,n){return a===n},Npohv:function(a,n){return a<n},ewFjJ:function(a,n){return a<n},xwTXB:function(a,n){return a<n},InqXk:function(a,n){return a+n},bYRze:function(a,n){return a+n},akqka:function(a,n){return a+n},DgbGn:function(a,n){return a>>>n},UGbpo:function(a,n){return a&n},AluYK:function(a,n){return a>>>n},ThTlK:function(a,n){return a+n},sjwhF:function(a,n){return a&n},dkWVo:function(a,n){return a>>>n},WiXxP:function(a,n){return a+n},dviaB:function(a,n){return a|n},pAsHx:function(a,n){return a&n},uFkGM:function(a,n){return a|n},aKKUg:function(a,n){return a>>>n},aZWqt:function(a,n){return a|n},svpAr:function(a,n){return a>>>n},mZVzR:function(a,n){return a>>>n},okjxg:function(a,n){return a!==n},WAsav:function(a,n){return a&n},Gxxnd:function(a,n){return a===n},XOJTR:t(1890),MTHHq:"RdMPV",iHEwz:function(a,n){return a|n},SjJWX:function(a,n){return a|n},xuiAH:function(a,n){return a===n},yBSGe:t(1371),bmcMr:function(a,n){return a|n},JxXUd:function(a,n){return a<<n},jlgLk:function(a,n){return a|n},ybwQW:function(a,n){return a<<n},aRVap:function(a,n){return a<<n},siMLw:function(a,n){return a|n},vECJG:function(a,n){return a|n},Wesse:function(a,n){return a|n},UGyDk:function(a,n){return a<<n},aCggu:function(a,n){return a<<n},OMJnM:function(a,n){return a|n},dwZdz:function(a,n){return a|n},YBAFc:function(a,n){return a|n},wWHcU:function(a,n){return a<<n},WLLAe:function(a,n){return a(n)},MfrFp:t(1478),twbfz:t(1643),QbzIP:function(a,n){return a|n},YeKph:function(a,n){return a|n},sGdyk:function(a,n){return a<<n},ooeuh:function(a,n){return a<<n},wgACo:function(a,n){return a>>>n},goBQz:function(a,n){return a|n},xfMNG:function(a,n){return a|n},lzarm:function(a,n){return a&n},rlnfI:function(a,n){return a>>>n},YsAdE:function(a,n){return a>>>n},tCTDK:function(a,n){return a&n},oUFkv:function(a,n){return a(n)},puMzQ:function(a,n){return a>=n},fYpkY:function(a,n){return a+n},qTiap:function(a,n){return a%n},wtWSr:function(a,n){return a/n},TSLTm:function(a,n){return a===n},ykjHp:function(a,n){return a===n},Zhugg:function(a,n){return a>>>n},RFXXF:function(a,n){return a>>>n},NCOiC:function(a,n){return a+n},zPfPY:function(a,n){return a>>>n},oLOqA:function(a,n){return a<<n},gtjGP:function(a,n){return a===n},ffqdI:t(501),TFCww:t(500),dgScI:function(a,n){return a===n},tevsn:function(a,n){return a===n},BsoLM:function(a,n){return a>>>n},fDBVR:function(a,n){return a===n},yCtMH:function(a,n,s){return a(n,s)},oUogT:function(a,n){return a+n},bbwTH:t(1461),zsCCg:function(a,n){return a>>>n},hlZHS:function(a,n){return a>>>n},tPkYD:function(a,n){return a>>>n},UACqv:function(a,n){return a&n},duKJa:function(a,n){return a&n},xXVXQ:function(a,n){return a&n},MEbfW:function(a,n){return a>>>n},TGIVq:function(a,n){return a>>>n},Syqcu:function(a,n){return a&n},EXvWM:t(1347)+t(1630),VEDPo:"MESSAGE_"+t(1328),amjPA:"MAX_RETR"+t(1259)+"R",loqnz:function(a,n){return a<n},amphU:function(a,n){return a===n},uUkWK:function(a,n){return a+n},xeFUI:t(462),CehiU:t(1071),RSIlf:function(a,n){return a!==n},pYLVX:t(1848),gibEL:t(547)+"2",zhmfM:t(1319)+"d",ffsZv:"Module",sjbtU:t(1845)+"le",wAgMD:"vufqJ",AXZSJ:t(1089),UrRkL:function(a,n){return a&n},ZDSlk:function(a,n){return a>>n},blxmQ:function(a,n){return a&n},TEzzk:function(a,n){return a!==n},wbQUS:t(685),PlhFQ:t(624),lbGGE:function(a,n){return a|n},Vtfne:function(a,n){return a|n},xlvBf:function(a,n){return a<<n},aGQFi:function(a,n){return a|n},OCrUu:t(836),ClzGI:function(a,n){return a!==n},FaJbD:t(878),OJTqX:function(a,n){return a>=n},EUDKW:function(a,n){return a-n},EdDmy:function(a,n){return a(n)},PuPcI:t(1316),XNCwL:t(889)+t(1819)+"s",GDREs:t(889)+t(1320)+"t",bQDpJ:"VBCzH",OuJls:t(926),sKZmB:t(583),JgXWM:function(a,n){return a instanceof n},NlPrp:t(802)+t(724),jtcbR:function(a,n){return a+n},WwAEF:function(a,n){return a===n},KODJv:function(a,n,s){return a(n,s)},EoKcn:"qos",RSDDd:function(a,n){return a===n},uXjmJ:t(650),eiheR:t(872),UKRSN:function(a,n,s){return a(n,s)},TPpce:function(a,n){return a===n},yRCBw:t(1003),znoJL:t(1958),tQgnu:"YjaqZ",iPoFK:function(a,n){return a instanceof n},iNtaZ:function(a,n){return a+n},GjppZ:"UipOt",aJGVg:t(1506),WIeUj:function(a,n){return a||n},gYEEi:function(a,n){return a!=n},xPXFQ:t(1811)+"3",dkoNX:t(1689)+t(1749)+t(1088)+t(1940)+t(1387),uPxEH:"Whjdk",qWMDW:t(1020),aWquE:function(a,n){return a<n},PLJlY:function(a,n){return a<n},wuOgP:function(a,n){return a-n},oyEaX:function(a,n){return a<n},borMY:function(a,n){return a<=n},RRDdc:function(a,n){return a<n},zyguP:function(a,n){return a>=n},IEgRr:function(a,n){return a<<n},mAEYq:function(a,n){return a<<n},JTmtr:function(a,n){return a&n},NsMKe:function(a,n){return a>=n},DUSqW:function(a,n){return a-n},GtlKx:function(a,n){return a|n},tzmFo:function(a,n){return a|n},epclK:function(a,n){return a|n},MfiRi:function(a,n){return a<<n},YDKCz:function(a,n){return a<<n},zTqsp:function(a,n){return a&n},zkMgx:function(a,n){return a<<n},jkisc:function(a,n){return a+n},yCgSY:function(a,n){return a&n},nHpSd:function(a,n){return a<n},xLihU:function(a,n){return a>>n},ywgRE:function(a,n){return a|n},IfDYG:function(a,n){return a===n},hrFhz:function(a,n){return a+n},ySdPW:function(a,n){return a+n},JxRgb:function(a,n){return a<<n},fKHav:function(a,n){return a&n},EQmyi:function(a,n){return a&n},kinEn:function(a,n){return a|n},WTOJd:function(a,n){return a>>n},nmpbf:function(a,n){return a>>n},tfFrb:function(a,n,s,d){return a(n,s,d)},FjlkA:function(a,n){return a!=n},OHYHN:t(1146),Jwzxy:t(638),yPFpb:t(953),QDCnh:function(a,n){return a===n},SmnpI:t(769),hTMhl:"DeaXe",HWzfy:function(a,n){return a!==n},PdkgL:function(a,n){return a-n},tORrg:t(662),HXyFc:function(a,n){return a(n)},vohEm:t(736)+"reason",KlLKo:t(1791),DyRfC:"text/jav"+t(1408),lXxnc:"http",IwidY:"dZYiH",IROuD:t(812),AgWpi:function(a,n){return a===n},ErmCj:function(a,n){return a+n},mseRd:function(a,n){return a+n},nFaip:function(a,n){return a===n},kNdrJ:t(757),NvXWw:function(a,n){return a!==n},fvqtT:t(907),WochY:t(1418),xHxHY:function(a,n){return a===n},Brbir:t(1634),WGVaC:function(a,n){return a===n},KSjAV:function(a,n){return a!==n},Tilav:"IkyoX",fHZZT:function(a,n){return a||n},rlmMM:function(a,n){return a||n},fUwyx:function(a,n){return a!==n},JLyOe:t(1389),wroHB:function(a,n){return a|n},xEWdt:function(a,n){return a|n},smYwT:function(a,n){return a!==n},nHnvo:t(1109),GFAnG:t(1832),YnhMf:function(a,n){return a||n},enlmQ:function(a,n){return a||n},xkmWG:t(495),hmrkx:t(1352),uLHXb:function(a,n){return a||n},MNRwS:function(a,n,s){return a(n,s)},oENVC:t(1971)+"id",PnvWP:t(1196),jDVOR:t(557),ZQzvT:"CApDA",QDMOT:function(a,n,s,d){return a(n,s,d)},jYmom:t(955)+t(965),AOIVm:t(955)+t(1870)+"ck",oDqVv:function(a,n,s,d){return a(n,s,d)},zkmzS:t(955)+t(682)+"k",lptgB:t(955)+"er_ack_m"+t(1783),qwzdq:function(a,n){return a&&n},RiGAT:t(1152),sAtqv:t(1930),QMvVa:t(969),hLUOJ:t(1974),sNuoJ:function(a){return a()},LGknW:function(a,n){return a(n)},jeQxM:function(a,n){return a(n)},Hteyj:function(a,n){return a instanceof n},SHJye:function(a,n){return a instanceof n},DPrJS:t(1573)+"ion/json"+t(1228)+t(914),OpSlk:function(a,n){return a>n},zBkPp:function(a,n){return a(n)},jAdxX:function(a,n){return a||n},RoxpG:function(a,n){return a===n},vLQJm:"noVaa",zJpWO:function(a,n){return a+n},gZeLI:function(a,n){return a+n},SFZrq:function(a,n){return a+n},PQOvW:"index ou"+t(862)+t(1149),nRXqc:"integer too large",vQmKJ:function(a,n){return a+n},tdbjW:function(a,n){return a<n},rsipp:function(a,n){return a>>>n},LySbT:function(a,n){return a<<n},PwzhN:"3|0|2|4|1",HFkxS:function(a,n){return a+n},orqhg:function(a,n){return a+n},jQLHU:function(a,n){return a+n},SrnfL:function(a,n){return a<<n},KKTZP:function(a,n){return a+n},xNFUt:function(a,n){return a+n},uCaOm:function(a,n){return a|n},ResTd:function(a,n){return a<<n},qxkSP:function(a,n){return a<<n},YiFVY:function(a,n){return a<<n},eHopw:function(a,n){return a+n},SjQPd:function(a,n){return a+n},mxGJw:function(a,n){return a+n},CCAZZ:function(a,n){return a+n},DRtQY:function(a,n){return a>>>n},dsZte:function(a,n){return a&n},sjrEs:function(a,n){return a>>>n},fXjWJ:function(a,n){return a+n},vlmoq:function(a,n){return a>>>n},TVBue:t(903),VDDQZ:function(a,n){return a+n},vHFeb:function(a,n){return a&n},GLUHI:t(571),mVgUB:"OvLVJ",vrJRk:function(a,n){return a&n},qzxre:function(a,n){return a+n},CDQXU:function(a,n){return a===n},qWjlg:t(718),XEJpv:function(a,n){return a<<n},GPhZW:function(a,n){return a&n},NamLB:function(a,n){return a<<n},dkeTd:function(a,n){return a<n},yZMQv:function(a,n){return a<n},VsWBH:t(971)+t(1549)+t(723),BAcWy:function(a,n,s,d){return a(n,s,d)},WDfxY:t(946),QFjQr:function(a,n,s,d){return a(n,s,d)},gnAVR:function(a,n,s,d){return a(n,s,d)},pShjf:t(1885),XpKQs:t(1353),NfkAi:t(541),kuzUw:t(1035),TWvgX:"cursor_f"+t(540),PgrhQ:function(a,n){return a<n},GHSfv:function(a,n,s){return a(n,s)},izblB:t(1782)+t(1163),IwnrM:t(493)+t(1788),qIZaf:t(1820)+t(1647),xEQmS:"ALL",tlsME:t(988),msYuD:t(1232),lzdRG:t(1168),nubtD:function(a,n){return a(n)},CQZzW:"setcursor",jOgsW:t(486),aOrQB:function(a,n){return a instanceof n},scoZv:t(1752),qNByb:t(1417),hssUu:t(1257),XiOrI:function(a,n){return a-n},qhubc:function(a,n){return a<n},xBqxI:function(a,n){return a>=n},rEPQQ:function(a,n){return a|n},EIRfS:function(a,n){return a<<n},vwtBT:function(a,n){return a|n},UiIor:function(a,n){return a&n},uNKsH:function(a,n){return a|n},xJIwQ:function(a,n){return a|n},PhfbD:function(a,n){return a&n},bJsYS:function(a,n){return a&n},aSfSH:function(a,n){return a<<n},oPQfr:function(a,n){return a+n},tOQpP:function(a,n){return a+n},XWdAj:"rnORD",fAGlB:t(1554),cQQwh:"code",rviGY:function(a,n,s,d){return a(n,s,d)},TlEhG:"x_fronti"+t(809),vsBsG:function(a,n){return a(n)},GAOTF:"x-msg-qos",QAMGd:"x-msg-cu"+t(1679)+"ue",nMGud:function(a,n){return a<n},PsXwo:t(995),idcOk:t(1145),mFtUx:function(a){return a()},tmRKh:function(a){return a()},vtNin:"0|1|2|3|4",qKhHr:function(a,n){return a!=n},ExOzq:t(894),VhHAB:t(526),ukYaU:function(a,n,s){return a(n,s)},lejwj:function(a){return a()},gJSwx:function(a){return a()},yFkWE:function(a,n){return a<n},ObfrR:function(a){return a()},XbrUW:function(a){return a()},iaMDH:t(523)+t(923),qCPoW:function(a,n,s,d){return a(n,s,d)},ljDxy:t(658),nnaDc:t(1022),usDfn:function(a,n){return a===n},qkumO:t(1280),YkNWm:function(a,n,s){return a(n,s)},wBpBj:t(1283),HqKEt:function(a,n){return a!==n},fVUCu:function(a,n){return a(n)},fUWQB:t(1733),Jpclg:t(1190),UtKzE:function(a,n){return a(n)},hSWvj:t(1349),YEDWO:"arraybuf"+t(1084),mpcbk:function(a,n){return a/n},qZUDE:t(821)+t(1691)+t(727),tYhtP:"please p"+t(1287)+t(1440)+t(1619)+"ket cons"+t(1857)+"is undef"+t(1508),YuxIi:function(a,n){return a instanceof n},IwBqj:function(a,n){return a+n},eSzPn:t(1814),kDcUb:"yLyyU",dCSAO:function(a,n,s){return a(n,s)},yDNsh:"reconnect",EJAzM:t(1743),esumr:t(1155),hcRbl:t(1251),kLmXr:t(1412),NvqDL:t(1639),VmJoe:t(1869),oPtzP:function(a,n){return a!==n},CJQWz:t(717),jFuty:"bd_did",xKtdI:t(1014),lGGWS:t(1330)+"d",yFXuq:t(821)+t(1112)+t(1722)+t(1318)+t(744),zVldd:function(a,n){return a==n},XNDUF:"function",FLJBk:function(a){return a()},dFoYY:function(a,n,s){return a(n,s)},dnNmP:t(1944),ihPpL:t(515)+"0",ZVhhx:"start",Woupz:function(a,n,s){return a(n,s)},OhkSH:function(a,n){return a(n)},dPWTz:t(1682),RsBch:function(a,n){return a*n},huNOl:function(a,n,s){return a(n,s)},GdihQ:"KZRLu",ZNmqa:t(1153),YXwRq:"going away, try "+t(660)+t(1431)+t(835),WYKBH:t(1061)+t(1121)+t(1063)+"g",MTjzY:t(1475),XZqpS:t(1426),OkrTC:t(877),nWSJn:t(1552)+"ay, netw"+t(1369)+"ine",BqsVS:"Rskps",qlhNT:t(708),cfHuz:function(a,n){return a|n},dNdoW:t(1484),GGwfN:t(1897),nyrOy:"1|3|7|6|"+t(625),LOkPw:t(871)+t(1094)+"y closed",FeStF:function(a,n){return a+n},JAVos:t(1124),dLBbm:function(a,n){return a!=n},sMFYJ:function(a,n){return a instanceof n},LtElI:function(a,n){return a||n},mdiNS:t(821)+t(1397)+t(1739)+"ervice",fsJzZ:function(a,n){return a(n)},NjKeb:function(a,n){return a===n},oTCor:"hAsXS",nPKMt:t(1281),QtYCc:"enqueue",bzqIY:t(1139),lhBTo:function(a,n){return a==n},YtoQI:"manual r"+t(1892)+t(773),EdphB:function(a){return a()},oHCTX:t(1653),dYIBM:t(956),cPgSx:t(1797),NXDKw:function(a,n){return a(n)},JUYOl:t(1774),BtPnT:function(a,n){return a!=n},ibvtY:t(1762),DeFtS:function(a,n){return a!=n},dTaHy:function(a,n){return a!=n},dJvFk:function(a,n){return a===n},YvPIR:t(616)+t(1277)+t(666)+"pe",nSvZs:function(a,n){return a!=n},xOMOM:"Object",MIxGv:function(a,n){return a!=n},HQbDW:function(a,n){return a===n},kcBFW:function(a,n){return a===n},wvRyT:function(a,n){return a===n},VKSZu:function(a,n){return a!=n},yPkle:function(a,n,s){return a(n,s)}};Bt.r(Pe),Bt.d(Pe,{FWS:()=>Cp,CustomErrorEvent:()=>Fd,createCloseEvent:()=>gt,ReconnectEvent:()=>zd,createErrorEvent:()=>dt,decodedFrame:()=>en,createOpenEvent:()=>Wd,CustomCloseEvent:()=>Ud,createReconnectEvent:()=>aa,FrontierMessageEvent:()=>Gd,encodeFrame:()=>Ut,createMessageEvent:()=>Hd,OpenEvent:()=>jd,ErrorCode:()=>nn,Event:()=>Qn,MessageEvent:()=>qd});let r="";function i(a=""){let n=t;if(e[n(1747)](e[n(1556)],e[n(1521)]))this[n(1875)+"T"]||this._isMiniWX?this[n(1935)+"etWorkCh"+n(1264)]():this[n(1710)+"er"]&&this[n(1734)+n(1393)+n(1379)]();else{let d=""+Date[n(850)](),u=r||(r=e.nRYEw(x,a)),p=Math[n(1765)]()[n(710)](16)[n(827)](-6);return e[n(1938)](e[n(1938)](e[n(634)]("02",d),u),p)}}function o(){let a=t;return 1e4*Date.now()+Math.floor(e[a(1601)](1e4,Math[a(1765)]()))}function c(a){let n=t;return(e[n(551)](Array,8)[n(1928)]("0")+e[n(1199)](parseInt,a,10)[n(710)](2))[n(827)](-8)}function l(a){let n=t;return e[n(562)]!==e[n(472)]?e[n(634)](e[n(551)](Array,4).join("0"),e.XYxew(parseInt,a,2).toString(16))[n(827)](-4):this[n(1924)].clearStorageSync()}function f(a){let n=t;if(e[n(1329)](e.azhXY,e[n(1471)]))this[n(1924)]?.[n(872)](),this[n(1924)]=void 0;else{let s=a[n(549)](/\./)[n(1726)](p=>c(p)),d=[];return d[0]=e[n(505)](l,e[n(1542)](s[0],s[1])),d[1]=l(e[n(1938)](s[2],s[3])),[e[n(1623)],n(1856),n(1856),e[n(1623)],e[n(1623)],e[n(1514)],d[0],d[1]].join("")}}function x(a){let n=t;if(e[n(1206)](e.UNdsa,e[n(981)])){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(1279)](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(1600)](f,a):d?e[n(1086)](h,a):e[n(892)]}else _0x8df7e7.d=(s,d)=>{let u=n;for(var p in d)_0x38255c.o(d,p)&&!_0x1e2ab0.o(s,p)&&_0x255d9d[u(487)+u(1366)](s,p,{enumerable:!0,get:d[p]})}}function h(a){let n=t,s={uRGUj:function(D,L){return e[ee(1206)](D,L)},mSbax:function(D,L){return D|L},wgZJx:function(D,L){return D|L},LtTTz:function(D,L){return e.RbxPh(D,L)},aGAmU:function(D,L){return e[ee(479)](D,L)},QhBUU:function(D,L){return D>>>L},XlxGR:function(D,L){return e[ee(1099)](D,L)},VHWeo:function(D,L){return e[ee(1947)](D,L)},LfIat:e[n(1888)],jrgJs:function(D,L){return e[n(1500)](D,L)},PeypV:e[n(1830)],lznvI:function(D,L){return e.cyGvW(D,L)}},d="",u=[],p=0,_=0,v=!0,g=n(1856);if(e[n(1671)](a[n(1592)]("::"),-1)){let D=a[n(549)]("::");for(let N=0;e[n(621)](N,D[n(546)]);N++){if(e[n(1234)]===e[n(1092)])return s[n(883)](_0x3acad7,_0x5ad743)?_0x5a74a3:new _0x1a8e07(s[n(1609)](s[n(1609)](s[n(1214)](_0x3b32f3[n(1449)](_0x2eaa12,0),s[n(1240)](_0x45f494[n(1449)](_0x142ec9,1),8)),s[n(1240)](_0x776f7e.call(_0x2b4205,2),16)),s[n(1541)](_0x52a4c8[n(1449)](_0x82811,3),24))>>>0,s.QhBUU(s.mSbax(s[n(1609)](_0xe569a2[n(1449)](_0x47f34f,4),_0x76ff2a.call(_0x5d605e,5)<<8),s[n(1867)](_0x415fb1[n(1449)](_0x3ea7c3,6),16))|_0x1b9a5a[n(1449)](_0x39239c,7)<<24,0),!0);{let j=D[N];if(j.indexOf(":")>0)if(e[n(1438)](e[n(707)],e[n(707)]))if(_0x22887a.payload instanceof _0x436c99){let U=e[n(1187)](this._options[n(1083)+n(1105)],_0x20d1b3)?{force:!!this[n(1638)][n(1083)+n(1105)].force,encoding:this[n(1638)]["payloadE"+n(1105)].encoding?this[n(1638)][n(1083)+n(1105)][n(595)][n(1825)](/\s/g,"")[n(1072)+"ase"]():""}:{force:!1,encoding:this._options[n(1083)+n(1105)]?this._options[n(1083)+n(1105)].replace(/\s/g,"")[n(1072)+n(1218)]():""},W=_0x356990[n(1083)+n(1105)]?_0x2f2ab8[n(1083)+n(1105)][n(1825)](/\s/g,"")[n(1072)+n(1218)]():"",$=e[n(1187)](this[n(1638)][n(715)+"ype"],_0x5c4f95)?{force:!!this[n(1638)]["payloadT"+n(1101)][n(1649)],type:this[n(1638)]["payloadT"+n(1101)][n(932)]?this[n(1638)]["payloadT"+n(1101)].type[n(1825)](/\s/g,"")[n(1072)+n(1218)]():""}:{force:!1,type:this[n(1638)][n(715)+"ype"]?this[n(1638)][n(715)+n(1101)][n(1825)](/\s/g,"")[n(1072)+n(1218)]():""},ie=_0x224b17[n(715)+n(1101)]?_0x5ee545["payloadT"+n(1101)].replace(/\s/g,"")[n(1072)+n(1218)]():"",Z=$[n(1649)]?$[n(932)]:ie||$[n(932)],Ce=U[n(1649)]?U.encoding:W||U.encoding,Ue=[e[n(1795)],"applicat"+n(533),n(1573)+n(533)+n(1228)+n(914),"string"],Dn=[e[n(945)],e[n(683)]];this[n(1638)][n(1028)+"ansformT"+n(1462)+"ad"]&&Ue[n(758)](Z)&&(!Ce||Dn.includes(Ce))?_0x3a2825.textPayload=e.FvlWX(_0x199a83,_0x596902[n(1723)],0,_0x4ebe94.payload[n(1209)+"th"]):_0x11226f[n(1296)+"oad"]=""}else _0x3d4df4[n(1296)+n(559)]="";else{let U=j[n(549)](":");v&&(p=U[n(546)]),_+=U[n(546)];for(let W=0;e[n(1237)](W,U.length);W++)if(e[n(1438)](4,U[W][n(546)])){let $=g.substring(0,4-U[W][n(546)]),ie=$[n(993)](U[W]);u[n(1230)](ie)}else u[n(1230)](U[W]);v=!1}else{if(e[n(1915)](4,j[n(546)]))if(n(939)===e[n(1730)])try{return s.VHWeo(s[n(1666)],typeof _0x5ef69e)&&(_0x2f4cf5 instanceof _0x44422e||_0x461705[n(1775)]&&s[n(1211)](_0x1bbf97[n(1775)],_0x295baf))||s.VHWeo(s[n(1666)],typeof _0x1275a0)?"":(_0x520e0f[n(575)](_0x48b649),s[n(1620)])}catch{return s[n(1188)](n(1884),typeof _0x2d30f6)?n(1676)+n(1768)+n(1463):""}else{let U=g[n(1595)+"g"](0,e[n(712)](4,j.length)),W=U[n(993)](j);u.push(W)}else u[n(1230)](j);v&&(p+=1),_+=1,v=!1}}}let L="";for(let N=0;e[n(1564)](N,e[n(712)](8,_));N++)L=L[n(993)](g);for(let N=0;e.eTiUM(N,u[n(546)]);N++)N===p&&(d=d[n(993)](L)),d=d[n(993)](u[N]);return d}{let D=a.split(":");for(let L=0;e[n(621)](L,D.length);L++){let N=D[L];if(e.pIlSd(4,D[L][n(546)])){let j=g[n(1595)+"g"](0,e[n(712)](4,D[L][n(546)])),U=j.concat(N);d=d[n(993)](U)}else d=d.concat(N)}return d}}function m(a,n){let s=t,d={QrwFO:function(u,p){return u(p)}};if(e.COKtx(e[s(517)],e[s(1040)]))return d[s(1903)](_0x58de51,_0x188a49);{let u=a[s(1934)];e.kAYtL(void 0,u)&&(e[s(1183)](he,n,10),G(n,u));let p=a[s(587)];e[s(464)](void 0,p)&&(e.OjVgw(he,n,18),e[s(1183)](G,n,p))}}function E(a){let n=t,s={};e:for(;!e[n(505)](Y,a);){let d=e[n(1254)](xe,a);switch(e[n(560)](d,3)){case 0:break e;case 1:s.key=e[n(610)](P,a,xe(a));break;case 2:s[n(587)]=P(a,e[n(924)](xe,a));break;default:e[n(1199)](C,a,e[n(1006)](7,d))}}if(e.oyWAG(void 0,s[n(1934)]))throw new Error(e.bIIpH);if(e[n(545)](void 0,s[n(587)]))throw new Error(e[n(564)]);return s}function A(a){let n=t,s=e.UYfxv(R);return e[n(1135)](y,a,s),e.oYuxw(z,s)}function y(a,n){let s=t,d={nDdXX:function(ie){return e.fqDfC(ie)},UjjKJ:function(ie,Z){return e[ee(789)](ie,Z)},mizcL:"success"},u=a[s(960)];e.pasXF(void 0,u)&&(e[s(1135)](he,n,8),e[s(1902)](pt,n,u));let p=a[s(1613)];e[s(464)](void 0,p)&&(e.kidRo(he,n,16),e.YvzaU(pt,n,p));let _=a[s(946)];_!==void 0&&(e.OjVgw(he,n,24),e[s(1183)](pt,n,e[s(789)](O,_)));let v=a[s(817)];e[s(464)](void 0,v)&&(e[s(1135)](he,n,32),e[s(1920)](pt,n,e[s(1096)](O,v)));let g=a.headers;if(e[s(464)](void 0,g))for(let ie of g)if(e[s(1329)](e[s(534)],e[s(544)])){let Z={DDulw:s(583),ZqenX:function(Se,Cn){return Se(Cn)},VEpgK:function(Se){let Cn=s;return VVmfZs[Cn(1451)](Se)},DwuJh:function(Se,Cn){let Jr=s;return VVmfZs[Jr(1727)](Se,Cn)}},Ce=()=>{let Se=s;_0x3edbb6[Se(1663)+Se(1834)+Se(1792)](Se(1316),Ue),_0x16e7bb["removeEv"+Se(1834)+"ner"](Z[Se(1575)],Dn)},Ue=()=>{let Se=s;_0x301259(Z[Se(1527)](_0x18a6ee,_0x446e75[Se(1374)])),Z.VEpgK(Ce)},Dn=()=>{let Se=s;Z.DwuJh(_0xa6a65e,_0x516bc5[Se(583)]),Z[Se(1667)](Ce)};_0x29fa26[s(514)+s(1379)](VVmfZs[s(1871)],Ue),_0x2008e1[s(514)+s(1379)]("error",Dn)}else{he(n,42);let Z=R();m(ie,Z),e.XnpvE(he,n,Z[s(661)]),e[s(1658)](K,n,Z),e[s(1331)](k,Z)}let D=a[s(1083)+"ncoding"];e[s(464)](void 0,D)&&(e[s(1206)]("PMUFn",e[s(778)])?_0x45e8a6[s(1755)][s(1396)+s(1342)](_0x3345f2):(e.ZypCV(he,n,50),e[s(653)](G,n,D)));let L=a[s(715)+s(1101)];e[s(1162)](void 0,L)&&(e[s(1199)](he,n,58),e.xUsNC(G,n,L));let N=a[s(1723)];N!==void 0&&(e[s(1920)](he,n,66),e.gIONE(he,n,N[s(546)]),e[s(1492)](ge,n,N));let j=a[s(579)];e[s(857)](void 0,j)&&(e[s(1827)](he,n,74),e.TaeLE(G,n,j));let U=a[s(1416)+s(994)];e[s(1438)](void 0,U)&&(e[s(1492)](he,n,82),e[s(1135)](G,n,U));let W=a[s(1233)];W!==void 0&&(e.ahxIu(he,n,90),G(n,W));let $=a[s(748)+"e"];e[s(1160)](void 0,$)&&(he(n,96),e[s(944)](pt,n,e[s(924)](O,$)))}function b(a){return I(e.oYuxw(B,a))}function I(a){let n=t,s={};e:for(;!e[n(1600)](Y,a);){let d=e[n(1502)](xe,a);switch(e[n(998)](d,3)){case 0:break e;case 1:s.SeqID=e[n(728)](At,a,!0);break;case 2:s.LogID=e.kEduw(At,a,!0);break;case 3:s.service=e[n(551)](xe,a);break;case 4:s[n(817)]=e.bjSgy(xe,a);break;case 5:{let u=S(a);(s[n(1385)]||(s[n(1385)]=[])).push(e[n(1502)](E,a)),a[n(661)]=u;break}case 6:s["payloadE"+n(1105)]=P(a,e[n(789)](xe,a));break;case 7:s[n(715)+"ype"]=e[n(1073)](P,a,e[n(531)](xe,a));break;case 8:s[n(1723)]=e[n(1336)](ve,a,e[n(713)](xe,a));break;case 9:s[n(579)]=P(a,e[n(532)](xe,a));break;case 10:s[n(1416)+"ming"]=P(a,e[n(531)](xe,a));break;case 11:s[n(1233)]=e[n(1337)](P,a,e[n(561)](xe,a));break;case 12:s.frameType=e[n(505)](xe,a);break;default:e[n(520)](C,a,e[n(1006)](7,d))}}if(e.YkSVG(void 0,s[n(960)]))throw new Error(e[n(913)]);if(s[n(1613)]===void 0)throw new Error(e.ACgXY);if(e[n(1305)](void 0,s.service))throw new Error(e[n(1203)]);if(e[n(1329)](void 0,s[n(817)]))throw new Error(n(917)+"required"+n(1427)+n(817));return s}function S(a){let n=t,s=e[n(1154)](xe,a),d=a.limit;return a[n(661)]=e[n(1225)](a[n(798)],s),d}function C(a,n){let s=t;switch(n){case 0:for(;e[s(1037)](128,ae(a)););break;case 2:e[s(983)](V,a,xe(a));break;case 5:V(a,4);break;case 1:V(a,8);break;default:throw new Error(e[s(1914)](s(989)+s(567)+s(1582),n))}}function O(a){let n=t,s={IKyHA:function(d,u,p){return d(u,p)}};if(e[n(1206)](e.UTGNH,e[n(1381)])){this[n(1131)+n(1813)](),this["_pingPon"+n(1282)+"Id"]=s.IKyHA(_0x3a6d6d,this[n(1822)].bind(this),this[n(1638)]["pingInte"+n(1313)]);return}else return a|=0,{low:a,high:a>>31,unsigned:a>=0}}let w=[];function R(){let a=t,n=w.pop();return n?(n[a(798)]=n[a(661)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(a){w[t(1230)](a)}function B(a){return{bytes:a,offset:0,limit:a[t(546)]}}function z(a){let n=t,s=a[n(816)],d=a[n(661)];return e[n(1747)](s[n(546)],d)?s:s[n(473)](0,d)}function V(a,n){let s=t;if(e[s(1671)](a[s(798)]+n,a[s(661)]))throw new Error(e[s(474)]);a.offset+=n}function Y(a){let n=t;return a[n(798)]>=a[n(661)]}function re(a,n){let s=t,d=a.bytes,u=a[s(798)],p=a[s(661)],_=e.GvBJf(u,n);if(e.pcEGx(_,d[s(546)])){let v=new Uint8Array(e[s(1601)](2,_));v[s(497)](d),a[s(816)]=v}return a[s(798)]=_,e[s(1671)](_,p)&&(a[s(661)]=_),u}function te(a,n){let s=t,d=a[s(798)];if(e[s(608)](d,n)>a[s(661)])throw new Error(e[s(1013)]);return a.offset+=n,d}function ve(a,n){let s=te(a,n);return a.bytes.subarray(s,s+n)}function ge(a,n){let s=t,d={jsROg:function(u,p,_){return e[ee(1900)](u,p,_)}};if(e[s(1438)](s(581),e[s(985)])){let u=e.rNIjY(re,a,n[s(546)]);a.bytes.set(n,u)}else this[s(714)](s(1958),d[s(808)](_0x393b11,"message",{..._0x1740eb}))}function P(a,n){let s=t,d={vpnbV:function(D,L){return e[ee(1365)](D,L)},VmkZv:function(D,L){return e.dKKVp(D,L)},zroeD:e[s(1577)],mpquQ:function(D,L){return D||L},DmrAp:e[s(741)]},u=e[s(944)](te,a,n),p=String[s(933)+s(504)],_=a[s(816)],v="\uFFFD",g="";for(let D=0;e.DqYcK(D,n);D++){let L=_[e[s(1341)](D,u)],N,j,U,W;if(e[s(1305)](e[s(1037)](128,L),0))g+=e[s(1404)](p,L);else if(e.OSLAN(224&L,192))e[s(996)](D,1)>=n?g+=v:(N=_[e[s(1118)](e.QzuiM(D,u),1)],e[s(1162)](e.CWCZD(192,N),128)?g+=v:(W=e[s(905)]((31&L)<<6,e.bkLtd(63,N)),e[s(1323)](W,128)?g+=v:(g+=e.bjSgy(p,W),D++)));else if(e[s(1571)](240&L,224))if(e[s(1838)](e.vwiaD(D,2),n))g+=v;else if(N=_[e.dKKVp(D+u,1)],j=_[e.dKKVp(e[s(1540)](D,u),2)],e[s(598)](e[s(905)](N,e[s(1882)](j,8)),49344)!==32896)g+=v;else if(W=e[s(1580)](e.vxQjx(e[s(1882)](15&L,12),e[s(1882)](e[s(1383)](63,N),6)),e[s(598)](63,j)),e[s(860)](W,2048)||e[s(642)](W,55296)&&W<=57343)g+=v;else{if(e[s(800)](e.ogMeY,e[s(1610)]))return _0x4e5a9d(d.vpnbV(d.VmkZv(d[s(647)](d[s(1961)]("index ou"+s(862)+s(1149),_0x1172ae),d[s(565)]),d[s(1688)](_0x7f3c5d,1)),d[s(954)])+_0x5e7d16);g+=e[s(1899)](p,W),D+=2}else if(e[s(1571)](e.JdYJj(248,L),240))if(e[s(1250)](D+3,n))g+=v;else if(N=_[e[s(1776)](e[s(1341)](D,u),1)],j=_[e.bpYpB(e[s(1662)](D,u),2)],U=_[e[s(1973)](e[s(1457)](D,u),3)],e.bDmBA((e[s(686)](N,e[s(1767)](j,8))|e[s(1767)](U,16))&12632256,8421504))g+=v;else if(W=e[s(686)](e[s(1010)](e[s(1793)]((7&L)<<18,e[s(1436)](63,N)<<12),e[s(1099)](63&j,6)),e.gOdTT(63,U)),W<65536||W>1114111)g+=v;else if(s(819)!==s(1238))W-=65536,g+=e[s(822)](p,e[s(1973)](e.YWKJe(W,10),55296),e[s(634)](e.aSnBz(1023,W),56320)),D+=3;else return _0x574282?this[s(1687)+"E"]():this[s(626)+"E"]();else g+=v}return g}function G(a,n){let s=t,d=n[s(546)],u=0;for(let v=0;e[s(1123)](v,d);v++){let g=n.charCodeAt(v);g>=55296&&e.QziCo(g,56319)&&e[s(786)](e.wkYeQ(v,1),d)&&(g=e[s(1115)](e[s(1925)](g,10),n[s(1543)+"At"](++v))-56613888),u+=e[s(1323)](g,128)?1:e.Yzhbl(g,2048)?2:g<65536?3:4}e[s(900)](he,a,u);let p=e.ZypCV(re,a,u),_=a[s(816)];for(let v=0;e[s(1237)](v,d);v++){let g=n.charCodeAt(v);e.TJaqv(g,55296)&&e.QziCo(g,56319)&&v+1<d&&(g=e[s(712)](e[s(1515)](e[s(1038)](g,10),n[s(1543)+"At"](++v)),56613888)),e[s(1123)](g,128)?_[p++]=g:(e[s(1798)](g,2048)?_[p++]=e.OxVJj(e[s(1261)](g,6),31)|192:e[s(1424)]===e[s(548)]?this.on(_0x1f3054,_0x19d163):(e[s(1123)](g,65536)?_[p++]=e[s(729)](g>>12,15)|224:(_[p++]=e[s(679)](g>>18&7,240),_[p++]=e[s(1769)](g>>12,63)|128),_[p++]=e[s(831)](e.eFDni(g>>6,63),128)),_[p++]=e[s(794)](63,g)|128)}}function K(a,n){let s=t,d=e[s(610)](re,a,n[s(661)]),u=a[s(816)],p=n[s(816)];for(let _=0,v=n[s(661)];e[s(937)](_,v);_++)u[_+d]=p[_]}function ae(a){let n=t;return a[n(816)][e[n(1183)](te,a,1)]}function Xe(a,n){let s=re(a,1);a.bytes[s]=n}function xe(a){let n=t,s=0,d=0,u;do u=ae(a),e[n(1798)](s,32)&&(d|=e[n(1925)](127&u,s)),s+=7;while(e[n(1108)](128,u));return d}function he(a,n){let s=t;for(n>>>=0;e[s(1300)](n,128);)e[s(653)](Xe,a,e.ydLUL(e.MZUJJ(127,n),128)),n>>>=7;e[s(1135)](Xe,a,n)}function At(a,n){let s=t,d=0,u=0,p=0,_;if(_=e.JbYTZ(ae,a),d=e[s(990)](127,_),e.OxVJj(128,_)&&(_=e[s(713)](ae,a),d|=e[s(1038)](e[s(1037)](127,_),7),e[s(1006)](128,_)&&(_=ae(a),d|=e[s(709)](e[s(1717)](127,_),14),e.cQUyE(128,_)&&(_=e.JZdpV(ae,a),d|=e.imgjm(e[s(963)](127,_),21),e[s(1681)](128,_)&&(_=e[s(1771)](ae,a),u=e.aSnBz(127,_),e[s(1268)](128,_)&&(_=e.vLQZQ(ae,a),u|=(127&_)<<7,128&_&&(_=ae(a),u|=e[s(1378)](e.bkLtd(127,_),14),e[s(498)](128,_)&&(_=e[s(1154)](ae,a),u|=e[s(706)](127,_)<<21,e.kPMsw(128,_)))))))))if(e.bDmBA(s(1948),e[s(1880)]))_=e.oYuxw(ae,a),p=e[s(1826)](127,_),128&_&&(_=ae(a),p|=e[s(775)](127&_,7));else{if(_0x5b9f7b instanceof _0x50e848){if(llJBDI[s(1496)](_0x486367,llJBDI[s(1002)]))return _0x336898[s(1616)](_0x49e966);if(_0xa1e72e===llJBDI[s(873)])return _0x2ab9cf[s(1956)+s(1863)]||_0x28adff[s(1616)](_0x421b3f);if(llJBDI[s(902)](_0x34a889,"store"))return _0xd06bdf[s(1956)+s(1863)][1]?void 0:_0x22c82e[s(1956)+"ore"](_0x307794[s(1956)+"oreNames"][0])}return _0x26c24d(_0x1e071b[_0x256c04])}return{low:e[s(1414)](d,e[s(1133)](u,28)),high:e[s(1628)](e[s(560)](u,4),p<<24),unsigned:n}}function pt(a,n){let s=t,d=e[s(1284)](n.low,0),u=e[s(1544)](e[s(560)](n[s(849)],28),e.OjMXQ(n[s(1067)],4))>>>0,p=e[s(1278)](n[s(1067)],24),_=e[s(1107)](0,p)?e.YkSVG(0,u)?e[s(490)](d,16384)?e.ewFjJ(d,128)?1:2:d<2097152?3:4:e.cYJzM(u,16384)?u<128?5:6:u<2097152?7:8:e[s(1629)](p,128)?9:10,v=e[s(610)](re,a,_),g=a[s(816)];switch(_){case 10:g[e.InqXk(v,9)]=e.anwpb(e.UjcDG(p,7),1);case 9:g[e[s(1197)](v,8)]=_!==9?e[s(1628)](128,p):127&p;case 8:g[e[s(1483)](v,7)]=e[s(1659)](8,_)?e[s(1793)](e[s(1297)](u,21),128):e[s(890)](e[s(1433)](u,21),127);case 7:g[e[s(1921)](v,6)]=e[s(800)](7,_)?e[s(560)](u,14)|128:e[s(659)](e[s(1205)](u,14),127);case 6:g[e[s(1220)](v,5)]=_!==6?e[s(1817)](u>>>7,128):e.pAsHx(u>>>7,127);case 5:g[e[s(1365)](v,4)]=e.pasXF(5,_)?e[s(1194)](128,u):e[s(990)](127,u);case 4:g[v+3]=_!==4?d>>>21|128:e[s(598)](e.aKKUg(d,21),127);case 3:g[e.QzuiM(v,2)]=e.pIlSd(3,_)?e[s(1593)](e[s(1590)](d,14),128):e[s(563)](d,14)&127;case 2:g[e[s(1844)](v,1)]=e[s(1162)](2,_)?d>>>7|128:d>>>7&127;case 1:g[v]=e.okjxg(1,_)?128|d:e.LCDBC(127,d)}}function en(a){return e[t(1253)](b,a)}function Ut(a){let n=t;if(e[n(1654)](e.XOJTR,e[n(1008)]))_0x4c8729=e[n(1331)](_0x31fcf3,_0x2377b5),e[n(860)](_0x455168,32)&&(_0x1e5e53|=e[n(1378)](e[n(952)](127,_0x1d000b),_0x5903d9)),_0x284574+=7;else return e.iwpxm(A,a)}let tn=65536,Wr=e[t(1312)],_e=e[t(1601)](tn,tn),De=e[t(1601)](_e,_e),Xn=e.wtWSr(De,2),Le=String[t(1895)+"e"][t(1543)+"At"];class fe{constructor(n,s,d){let u=t;this[u(1815)]=!0,this.low=e[u(1614)](0,n),this[u(1067)]=e.SjJWX(0,s),this[u(1222)]=!!d}static[t(1815)](n){return n&&e[t(1738)](!0,n.isLong)}static[t(476)](n,s,d){let u=t;return e[u(975)](e[u(1854)],u(1764))?new fe(n,s,d):this[u(1875)+"T"]||this[u(1709)+"X"]?this[u(669)+u(1536)+"line"]:(this[u(1710)+"er"]||this[u(1186)+"r"])&&this[u(1638)][u(1082)+"tworkCha"+u(1893)]?_0x266b78[u(687)]:!0}static[t(1191)+"s"](n,s,d){let u=t;return d?fe[u(1191)+u(1384)](n,s):fe["fromByte"+u(1247)](n,s)}static[t(1191)+t(1384)](n,s){let d=t;return new fe(e[d(686)](e[d(928)](n[0]|e.UOIVU(n[1],8),e[d(1079)](n[2],16)),e[d(1099)](n[3],24)),e[d(742)](e[d(979)](n[4],e[d(1708)](n[5],8))|n[6]<<16,e[d(1043)](n[7],24)),s)}static[t(1191)+t(1247)](n,s){let d=t;return new fe(e[d(1604)](e[d(1176)](e.Wesse(e[d(1522)](n[4],24),e[d(663)](n[5],16)),n[6]<<8),n[7]),e.OMJnM(e[d(870)](e[d(1016)](n[0]<<24,e[d(573)](n[1],16)),e[d(1043)](n[2],8)),n[3]),s)}static fromHash(n){let s=t;return e[s(1273)]===e[s(1439)]?(_0x41a59a&&(_0x11d383=(0,_0xf0a9ba[llJBDI[s(1212)](_0x371057,_0x2c6cac)[0]])(_0x1a00f0=0)),_0x2188e4):n===Wr?Bd:new fe(e[s(1278)](e[s(1580)](e.QbzIP(e[s(1487)](Le.call(n,0),e.fjZYa(Le[s(1449)](n,1),8)),e[s(676)](Le.call(n,2),16)),e[s(1594)](Le[s(1449)](n,3),24)),0),e[s(633)](e[s(1034)](e[s(1144)](Le[s(1449)](n,4),Le[s(1449)](n,5)<<8),e.OjMXQ(Le.call(n,6),16))|Le.call(n,7)<<24,0),!0)}toHash(){let n=t;return String[n(933)+n(504)](e[n(1761)](255,this[n(849)]),e[n(1717)](e[n(1590)](this[n(849)],8),255),e[n(1037)](e.rlnfI(this.low,16),255),e[n(1421)](this[n(849)],24),e[n(1165)](255,this[n(1067)]),this.high>>>8&255,e[n(1470)](e[n(998)](this[n(1067)],16),255),e[n(1076)](this[n(1067)],24))}static[t(1445)+"er"](n,s=!0){let d=t;if(e[d(1894)](isNaN,n))return s?qh:Bd;if(s){if(e[d(642)](n,De))return jh}else{if(e[d(502)](n,-Xn))return Hh;if(e[d(1275)](e.fYpkY(n,1),Xn))return Gh}return fe[d(476)](e[d(1487)](e[d(1345)](n,_e),0),e.iHEwz(e[d(1829)](n,_e),0),s)}toNumber(){let n=t;return this[n(1222)]?e[n(480)](e[n(633)](this[n(1067)],0)*_e,this.low>>>0):this.high*_e+e[n(1421)](this.low,0)}[t(1473)](){let n=t;return e[n(465)](0,this.high)&&e[n(1062)](0,this[n(849)])}add(n){let s=t;fe[s(1815)](n)||(n=fe[s(1445)+"er"](n));let d=e.FqYBh(this.high,16),u=65535&this[s(1067)],p=e[s(1269)](this[s(849)],16),_=e[s(659)](65535,this[s(849)]),v=e[s(1507)](n[s(1067)],16),g=e.ysevo(65535,n[s(1067)]),D=n[s(849)]>>>16,L=e[s(1436)](65535,n[s(849)]),N=0,j=0,U=0,W=0;return W+=e[s(1844)](_,L),U+=e[s(896)](W,16),W&=65535,U+=e[s(1148)](p,D),j+=e[s(1837)](U,16),U&=65535,j+=e[s(996)](u,g),N+=j>>>16,j&=65535,N+=e[s(1365)](d,v),N&=65535,fe[s(476)](e.oLOqA(U,16)|W,N<<16|j,this[s(1222)])}[t(1490)](n){let s=t,d={ayxpT:function(u,p){return e[ee(1601)](u,p)}};if(e[s(1080)](e[s(1179)],e.TFCww)){let u=_0x31d226.bytes,p=_0x2a78ba[s(798)],_=_0x2b18a4.limit,v=p+_0x2e445d;if(v>u.length){let g=new _0x4fe702(PQuJph[s(1560)](2,v));g[s(497)](u),_0x456976[s(816)]=g}return _0x12f4b1[s(798)]=v,v>_&&(_0xe57546.limit=v),p}else return fe.isLong(n)||(n=fe[s(1445)+"er"](n)),this[s(1222)]!==n[s(1222)]&&e[s(1967)](e[s(1278)](this.high,31),1)&&e[s(1602)](e[s(1570)](n[s(1067)],31),1)?!1:this.high===n[s(1067)]&&this.low===n[s(849)]}[t(1683)](){let n=t;return this[n(849)]===-1&&e.EBMfu(-1,this[n(1067)])?fe[n(476)](0,0,this[n(1222)]):e[n(882)](-1,this[n(849)])?fe.fromBits(0,this[n(1067)]+1,this.unsigned):fe[n(476)](e[n(1148)](this[n(849)],1),this[n(1067)],this.unsigned)}[t(1091)](n){let s=t;if(s(588)===e.bbwTH){let{offset:d}=e[s(1902)](_0x5046dc,_0x1c76d3,_0x2ae22a);_0x238844=d;let u={cursor_name:"",cursor:0,service:0},{value:p,offset:_}=e[s(1941)](_0x4052cb,_0x3d7f17,_0x2e6656);u[s(946)]=p,_0x22452f=_;let{value:v,offset:g}=_0x3c4690(_0xac4b5d,_0x4b2a11);_0x229e0a=g,u[s(493)+"ame"]=e[s(1693)](_0x51ee4a,_0x5ad7b5,_0x11a536,e.oUogT(_0x26d6b0,v)),_0x5eed41+=v;let{value:D,offset:L}=e.xUsNC(_0x116c90,_0x7adbe1,_0x44aa40);u[s(1367)]=D[s(1001)](),_0x24b1f3=L,_0x4ddfca.push(u)}else return n?this.toBytesLE():this.toBytesBE()}[t(1687)+"E"](){let n=t,s=this[n(1067)],d=this[n(849)];return[e[n(1268)](255,d),e.zsCCg(d,8)&255,e[n(1339)](d,16)&255,e[n(1297)](d,24),e[n(1006)](255,s),e[n(1182)](s,8)&255,e[n(1165)](s>>>16,255),e[n(1182)](s,24)]}toBytesBE(){let n=t,s=this[n(1067)],d=this[n(849)];return[e[n(1066)](s,24),e[n(1314)](s>>>16,255),e[n(1380)](s>>>8,255),e.xXVXQ(255,s),e[n(1130)](d,24),e.tCTDK(e[n(1284)](d,16),255),e[n(1383)](e[n(847)](d,8),255),e.Syqcu(255,d)]}}let Bd=new fe(0,0,!1),qh=new fe(0,0,!0),Gh=fe[t(476)](-1,2147483647,!1),jh=fe[t(476)](-1,-1,!0),Hh=fe[t(476)](0,-2147483648,!1);var nn=(function(a){let n=t,s=(n(681)+n(796))[n(549)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[n(858)+"OR"]=5005]=n(858)+"OR";continue;case"1":a[a[e[n(1395)]]=5001]=e[n(1395)];continue;case"2":a[a[e[n(576)]]=5004]=e.VEDPo;continue;case"3":a[a[n(770)+n(1494)]=5002]=n(770)+n(1494);continue;case"4":a[a[e[n(1678)]]=5003]=e[n(1678)];continue;case"5":return a}break}})({});class Qn{constructor(n){let s=t;e[s(1496)](e[s(1711)],s(462))?(this[s(932)]=n,this[s(1489)]=null):(_0x561449=_0x3b8c24[s(1543)+"At"](_0xbfed2),e.loqnz(_0x6dc4bd,128)?_0x1ddfbe+=1:e[s(941)](_0x59a430,2048)?_0x482c75+=2:e[s(1654)](e[s(919)](64512,_0x3d1277),55296)&&e.amphU(e.aSnBz(64512,_0x420021[s(1543)+"At"](e[s(1965)](_0x17af6b,1))),56320)?(++_0x4de297,_0x56905e+=4):_0x24d450+=3)}}class zd extends Qn{constructor(n,s){let d=t;super(n),this[d(1958)]=s&&s[d(1958)]||null}}class Fd extends Qn{constructor(n,s){let d=t;e[d(612)](e[d(920)],d(1848))?(this.emit(e[d(1622)],_0x39abfb),this.onopen&&this[d(1018)](_0x47202d)):(super(n),this[d(583)]=s&&s[d(583)]||null,this[d(834)]=s&&s[d(834)]||0,this[d(637)]=s&&s[d(637)]||"",this[d(830)]=s&&s.lineno||0,this[d(1958)]=s&&s.message||"",this[d(1116)]=s&&s[d(1116)]||5001)}}class Ud extends Qn{constructor(n,s){let d=t,u=e[d(911)][d(549)]("|"),p=0;for(;;){switch(u[p++]){case"0":this[d(1116)]=s&&s.code||0;continue;case"1":this.wasClean=s&&s.wasClean||!1;continue;case"2":this[d(1243)+"nnect"]=s&&s[d(1243)+d(600)]||!1;continue;case"3":super(n);continue;case"4":this[d(1132)]=s&&s[d(1132)]||"";continue}break}}}class qd extends Qn{constructor(n,s){let d=t;super(n),this[d(677)]=s&&s.data||null}}class Gd extends qd{constructor(n,s){let d=t;super(n),this[d(677)]=s&&s.data||null,this.message=s&&s[d(1958)]||null}}class jd extends Qn{constructor(n,s){super(n),this.data=s&&s.data||null}}function dt(a,{message:n,code:s,error:d}){return new Fd(a,{message:n,code:s,error:d})}function gt(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new Ud(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function Hd(a,{data:n,message:s}){return new Gd(a,{data:n,message:s})}function Wd(a,{data:n}){let s=t;if(e[s(1409)]===e[s(853)])llJBDI.kpwES(llJBDI.zhmfM,typeof _0x306421)&&_0xf72a38[s(710)+s(1402)]&&_0x1a9882[s(487)+"operty"](_0xfdc85c,_0x4b0d4c["toString"+s(1402)],{value:llJBDI[s(1498)]}),_0x38dbe2[s(487)+"operty"](_0x5a5c9e,llJBDI[s(1754)],{value:!0});else return new jd(a,{data:n})}function aa(a,{message:n}){let s=t;if(e.TEzzk(e[s(842)],e[s(1157)]))return new zd(a,{message:n});_0x504eb1[_0x29b2c0++]=e[s(1394)](e[s(1692)](_0x387db3,18),7)|240,_0x5b0060[_0x5a07b4++]=e[s(910)](_0x4093e6>>12,63)|128}class Kd{constructor(n,s){let d=t;this[d(1770)+"s"]=n,this[d(826)+"es"]=s,this[d(591)+d(1326)]=0,this[d(1356)+d(1964)+d(496)+"t"]=0}[t(1293)+"pointCon"+t(1969)](){let n=t;this[n(591)+"ndex"]=0,this[n(1356)+"ndpointT"+n(496)+"t"]=0}resetTries(){let n=t;this[n(1356)+n(1964)+n(496)+"t"]=0}getCurrentEndpoint(){let n=t;return this.endpoints[this["currentI"+n(1326)]]}[t(843)+t(1548)+t(1377)+t(596)](){let n=t;return e[n(1497)]==="QdQwe"?new _0x191af2(e[n(1793)](e[n(539)](e.Vtfne(e.xlvBf(_0x3482bc[4],24),e[n(663)](_0x5bf56f[5],16)),e.UOIVU(_0x4cef41[6],8)),_0x38a752[7]),e[n(1604)](e[n(1137)](_0x8ef27[0]<<24|e[n(1707)](_0x473e80[1],16),e[n(663)](_0x12005f[2],8)),_0x14d49e[3]),_0x2c3ff5):this[n(1356)+n(1964)+n(496)+"t"]}["checkRea"+t(807)+"es"](){let n=t;if(e[n(584)](e[n(1065)],n(878)))throw this[n(512)+n(1546)]=!1,_0x60b5a7;return!!(e[n(1090)](this[n(591)+"ndex"],this.endpoints.length)||e[n(465)](this[n(591)+"ndex"],e[n(879)](this[n(1770)+"s"][n(546)],1))&&e[n(465)](this[n(1356)+n(1964)+n(496)+"t"],this[n(826)+"es"]))}["checkCur"+t(1030)+"ointReac"+t(1887)+t(1258)](){let n=t,s={RPmcr:e[n(1881)]};if(e[n(857)](e[n(1052)],e.bQDpJ)){let d={zusNa:function(u,p){return e[n(602)](u,p)},FmGve:e.PuPcI,dbGDz:e[n(1608)],TSoiU:n(1153)};return new _0x13a050((u,p)=>{let _=n;this["_clearPi"+_(1813)](),this["_pingPon"+_(1282)+"Id"]=_0xa7ceb(this[_(1822)][_(1458)](this),this[_(1638)][_(771)+_(1313)]);let v=()=>{let D=_;d.zusNa(u,d[D(1294)]),this[D(1012)](d.dbGDz,v),this.off("ping_once_timeout",g)},g=()=>{let D=_;d[D(1355)](p,d[D(730)]),this[D(1012)](d.dbGDz,v),this[D(1012)](D(889)+D(1320)+"t",g)};this.on(_(889)+_(1819)+"s",v),this.on(s[_(1046)],g),this._ping()})}else return e.cyGvW(this[n(591)+n(1326)],this[n(1770)+"s"][n(546)])?!0:this[n(1356)+n(1964)+"riesCount"]>this.maxRetries}[t(761)+t(1631)+"pointAndUpdateCo"+t(1127)](){let n=t,s={wbsNa:function(d,u){return d>>>u},SXuTD:function(d,u){return e[ee(1826)](d,u)}};if(e.dgScI(e[n(1748)],e[n(1748)]))return this["currentE"+n(1964)+n(496)+"t"]=1,this[n(591)+n(1326)]++,this.endpoints[this[n(591)+n(1326)]];{let d=this.high,u=this[n(849)];return[d>>>24,CANhZv.wbsNa(d,16)&255,d>>>8&255,CANhZv[n(1714)](255,d),CANhZv[n(1773)](u,24),CANhZv[n(1714)](CANhZv[n(1773)](u,16),255),CANhZv.SXuTD(u>>>8,255),255&u]}}[t(843)+t(1548)+t(1777)+t(1720)](){let n=t;return this[n(1356)+n(1964)+n(496)+"t"]++,this[n(843)+n(1548)+"nt"]()}}let er=(e.dLBbm(e.zhmfM,typeof globalThis)&&e.NjKeb("Window",globalThis[t(1184)+t(829)][t(1885)])||e[t(777)](t(1319)+"d",typeof window)&&e[t(1192)](e[t(1435)],window[t(1184)+t(829)][t(1885)]))&&e[t(1198)](e[t(856)],typeof document),Tn=e[t(1075)](e[t(856)],typeof globalThis)&&(e[t(1654)]("Object",globalThis[t(1184)+t(829)][t(1885)])||e.dJvFk(e.YvPIR,globalThis[t(1184)+t(829)][t(1885)]))&&e[t(1499)](e[t(856)],typeof tt),Kr=(e.kpwES("undefined",typeof globalThis)&&e[t(1315)](e[t(1465)],globalThis["construc"+t(829)][t(1885)])||e[t(856)]==typeof globalThis||e[t(1075)](e.zhmfM,typeof globalThis)&&!!globalThis.WeixinJSBridge)&&e[t(888)](e.zhmfM,typeof wx),$r=e.MIxGv(e[t(856)],typeof globalThis)&&(e[t(1966)]("DedicatedWorkerG"+t(666)+"pe",globalThis["construc"+t(829)].name)||e[t(1525)](t(1760)+t(1056)+t(1624),globalThis[t(1184)+t(829)][t(1885)])||e[t(1488)](t(1786)+"orkerGlobalScope",globalThis[t(1184)+t(829)].name))&&e[t(777)](e[t(856)],typeof self),Wh=e[t(675)](e[t(856)],typeof globalThis)&&e[t(631)](e.xOMOM,globalThis[t(1184)+t(829)][t(1885)])&&e[t(828)](e[t(856)],typeof global)&&e[t(627)](t(1419),global[t(1184)+t(829)].name)&&e.kpwES(e[t(856)],typeof process)&&!!process[t(895)];class ca{constructor(){let n=t;this[n(1532)+"rs"]={}}[t(714)](n,...s){let d=t,u=this[d(1532)+"rs"][n];if(u)u[d(827)]()[d(1868)](p=>p.fn.apply(p[d(1635)],s));else if(e[d(1329)](e[d(1673)],n)&&!this[d(980)]){let p=s[d(546)]&&s[0];if(e[d(1441)](p,Error))throw p;let _=new Error(e[d(1197)](e[d(818)],p?e[d(1341)](e[d(1758)](" (",p[d(1958)]),")"):""));throw _[d(1093)]=p,p}return this}[t(1012)](n,s){let d=t;if(e[d(1654)](void 0,n))this[d(1532)+"rs"]={};else if(e.WwAEF(void 0,s))this[d(1532)+"rs"][n]=null;else{let u=this[d(1532)+"rs"][n];if(u)for(let p=0;e[d(1629)](p,u[d(546)]);)e.WwAEF(u[p].fn,s)?u[d(1223)](p,1):++p}return this}on(n,s,d){let u=t,p={FRtjT:function(_,v,g){return e[ee(1803)](_,v,g)},YPrdL:e.EoKcn};if(e[u(1140)](e[u(1291)],e[u(1291)]))return(this._listeners[n]||(this[u(1532)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this;this["_interva"+u(1741)+"Id"]=null,this[u(999)+"l"]=36e5,this._qosDB=p.FRtjT(_0x6f6563,p[u(1637)],u(1971)+"id")}}class Kh extends ca{["_formatE"+t(719)+t(568)](n){let s=t;return n[s(553)]||n[s(466)]?(s(484)+" "+(n[s(553)]||"")+" code: "+(n.errNo||""))[s(1069)]():JSON[s(1518)+"y"](n)}constructor(n,s,d){let u=t;super(),this[u(1373)]=null,Kr&&wx[u(1495)+u(1655)]&&(this[u(1373)]=wx[u(1495)+"ocket"]({url:n,protocols:s,header:d,fail:this[u(958)+"ocketFai"+u(1913)][u(1458)](this),success:this["_createS"+u(1432)+u(1672)+"ler"][u(1458)](this)})),Tn&&tt[u(1495)+u(1655)]&&(this[u(1373)]=tt[u(1495)+u(1655)]({url:n,protocols:s,header:d,fail:this[u(958)+u(1970)+u(1913)][u(1458)](this),success:this[u(958)+u(1432)+u(1672)+u(1493)][u(1458)](this)}))}[t(958)+t(1432)+t(1672)+t(1493)](){let n=t;Promise[n(918)]()[n(1138)](()=>{let s=n;this[s(1009)+s(1219)]()})}[t(958)+t(1970)+t(1913)](n){let s=t,d={gsJLu:e.sKZmB,iIcUW:function(u,p,_){return e[ee(822)](u,p,_)},yBPkw:e[s(1375)]};Promise[s(918)]()[s(1138)](()=>{let u=s,p=dt(d[u(806)],{message:this[u(887)+u(719)+u(568)](n)});this[u(714)](d[u(806)],p);let _=d[u(1332)](gt,d.yBPkw,{reason:this[u(887)+u(719)+"age"](n)});this.emit("close",_)})}[t(1009)+"steners"](){let n=t,s={SEzmL:n(583),WrZVV:function(d,u,p){return e[n(1073)](d,u,p)}};this._socket[n(851)](d=>{let u=n;this.emit("open",Wd(e.CehiU,{...d,data:d[u(553)]||""}))}),this[n(1373)][n(1286)](d=>{let u=n;this[u(714)](e[u(1375)],e[u(463)](gt,e[u(1375)],{...d}))}),this._socket[n(921)+"e"](d=>{let u=n;if(e[u(1051)](u(1003),e[u(1589)]))this.emit(e[u(1455)],e[u(1183)](Hd,e[u(1455)],{...d}));else return _0x5d5bf0[_0x1062e8]=_0x31c4db,!0}),this[n(1373)][n(1685)](d=>{let u=n;this[u(714)](s[u(1968)],s[u(701)](dt,s.SEzmL,{...d,message:d[u(553)]||""}))})}[t(678)](n){let s=t,d={uKqhW:e.sKZmB,zLVSO:"timeout",jZTRs:e[s(1881)],ymDKs:function(u,p){return e[s(561)](u,p)},kWRFK:e[s(1608)],iJitD:function(u,p,_){return e.ZypCV(u,p,_)}};if(s(1428)!==e[s(1479)])if(e[s(1529)](n,Uint8Array)){let u=n[s(1775)][s(827)](n[s(1565)+"et"],e[s(848)](n.byteLength,n.byteOffset));this._socket&&this[s(1373)][s(678)]({data:u,fail:p=>{let _=s;this.emit(d[_(1632)],dt(d[_(1632)],{message:this[_(887)+_(719)+_(568)](p)}))}})}else this[s(1373)]&&this._socket[s(678)]({data:n,fail:u=>{let p=s;this[p(714)](d[p(1632)],dt(d[p(1632)],{message:this[p(887)+p(719)+p(568)](u)}))}});else{let u={wAGJh:function(v,g){return d[s(1794)](v,g)},mlDzB:d[s(1459)]};this._clearPingTimer(),this[s(1945)+s(1282)+"Id"]=d[s(1531)](_0x4cf4a9,this[s(1822)][s(1458)](this),this[s(1638)][s(771)+s(1313)]);let p=()=>{let v=s;u[v(1266)](_0xe6e3c5,v(1316)),this[v(1012)](u.mlDzB,p),this[v(1012)](v(889)+v(1320)+"t",_)},_=()=>{let v=s;_0x1898b7(d[v(1311)]),this[v(1012)](v(889)+v(1819)+"s",p),this[v(1012)](d[v(1172)],_)};this.on(d.kWRFK,p),this.on(d[s(1172)],_),this[s(1822)]()}}[t(872)](n,s){let d=t;this[d(1373)]&&this[d(1373)][d(872)]({code:n,reason:s})}[t(514)+t(1379)](n,s){this.on(n,s)}[t(1663)+t(1834)+t(1792)](n,s){this[t(1012)](n,s)}get[t(930)+"te"](){let n=t;return this._socket[n(930)+"te"]}get[t(767)+"pe"](){let n=t;return this[n(1373)][n(767)+"pe"]}set[t(767)+"pe"](n){}get url(){let n=t;if(e[n(465)](n(1177),e[n(861)]))this[n(1078)]=!0,this[n(512)]();else return this[n(1373)].url}get[t(1102)](){let n=t;return e[n(912)]===e[n(912)]?this[n(1373)].protocol:(_0x595e99+=_0x15f0c3&&_0x5a80dd.byteLength||0,_0x20e8e7)}get[t(1364)+"ns"](){return this[t(1373)].extensions}get[t(1029)+t(615)](){return 0}}function $h(a,n){let s=t;if(n)return new n(a.url,a.protocol);if(e.WIeUj(Kr,Tn))return new Kh(a.url,a[s(1102)],a.headers);if(e[s(1136)](er,$r)&&e[s(1936)](s(1319)+"d",typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1102)+"s"])}function Jh(a){let n=t,s=e[n(906)].split("|"),d=0;for(;;){switch(s[d++]){case"0":if(Tn&&tt["connectS"+n(1655)])return!0;continue;case"1":if(a)return!0;continue;case"2":if((er||$r)&&e[n(1947)](n(1319)+"d",typeof WebSocket)&&WebSocket)return!0;continue;case"3":return!1;case"4":if(Kr&&wx[n(1495)+"ocket"])return!0;continue}break}}function $d(a,n,s){let d=t;if(e.qhqJE(d(1362),"cvmXT")){let u=-1;async function p(_){let v=d;return e[v(502)](_,u)?Promise[v(1927)](new Error(e.dkoNX)):(u=_,e[v(1747)](_,s.length)?Promise.resolve():s[_][v(1458)](a)(n,p[v(1458)](null,e[v(1675)](_,1))))}e[d(602)](p,0)}else{let u=this._qosDB[d(1954)+d(845)](this._prefix),p=_0x30ad40.parse(u||"{}");return p[_0x41ae7f]=void 0,this[d(1924)][d(1621)+d(845)](this[d(1413)],_0x4ee964[d(1518)+"y"](p))}}function Jd(a){let n=t,s={OpYpT:function(d,u,p){return d(u,p)}};if(e[n(1160)](e[n(897)],e[n(1670)])){let d=0,u=0;for(let p=0;e.Yzhbl(p,a[n(546)]);++p)u=a.charCodeAt(p),e[n(613)](u,128)?d+=1:e.PLJlY(u,2048)?d+=2:e.amphU(64512&u,55296)&&e[n(1305)](e[n(1165)](64512,a.charCodeAt(e[n(848)](p,1))),56320)?(++p,d+=4):d+=3;return d}else{let d=this[n(1039)+n(1603)]?.["getCurre"+n(1548)+"nt"]();this[n(640)+n(938)+n(1789)](s[n(1446)](_0x3735c7,n(872),{code:_0x5aabea[n(1116)],reason:n(815)+"ng faile"+n(751)+"wn reaso"+n(1185)+n(1485)+d})),this[n(1039)+n(1603)]?.[n(1293)+n(1566)+"fig"](),this._pingLossCounter?.resetCounter();return}}function Vd(a,n,s){let d=t;if(e[d(941)](e.wuOgP(s,n),1))return"";let u="";for(let p=n;e.oyEaX(p,s);){let _=a[p++];if(e[d(1217)](_,127))u+=String[d(933)+d(504)](_);else if(e[d(1090)](_,192)&&e[d(1706)](_,224))u+=String[d(933)+d(504)](e[d(742)](e[d(709)](31&_,6),63&a[p++]));else if(e[d(641)](_,224)&&_<240)u+=String[d(933)+"Code"](e[d(1194)](e[d(1817)](e[d(1464)](15&_,12),e.mAEYq(e.JTmtr(63,a[p++]),6)),e[d(1006)](63,a[p++])));else if(e[d(1303)](_,240)){let v=e[d(1705)](e[d(1097)](e[d(1931)](e[d(684)](e[d(978)](7&_,18),e.YDKCz(e[d(1898)](63,a[p++]),12)),e[d(968)](63&a[p++],6)),63&a[p++]),65536);u+=String[d(933)+d(504)](e.jkisc(55296,e[d(1692)](v,10))),u+=String[d(933)+d(504)](e[d(1844)](56320,e[d(935)](1023,v)))}}return u}function da(a,n,s){let d=t,u=s,p,_;for(let v=0;e[d(1246)](v,a[d(546)]);++v)p=a.charCodeAt(v),p<128?n[s++]=p:e.nHpSd(p,2048)?(n[s++]=e[d(1614)](e[d(1289)](p,6),192),n[s++]=e[d(636)](63&p,128)):e[d(1037)](64512,p)===55296&&e[d(1315)](e[d(598)](64512,_=a[d(1543)+"At"](e[d(891)](v,1))),56320)?(p=e[d(1515)](e[d(537)](65536,e[d(886)](e[d(690)](1023,p),10)),e[d(1215)](1023,_)),++v,n[s++]=e[d(831)](p>>18,240),n[s++]=e[d(1016)](e[d(1004)](e[d(1692)](p,12),63),128),n[s++]=e.kinEn(e[d(765)](p,6)&63,128),n[s++]=e[d(1108)](63,p)|128):(n[s++]=p>>12|224,n[s++]=e.xXVXQ(e[d(1766)](p,6),63)|128,n[s++]=e[d(831)](63&p,128));return e[d(879)](s,u)}async function Yd(a){let n=t;if(e[n(1888)]==typeof a){let s=new Uint8Array(e[n(1254)](Jd,a));return e.tfFrb(da,a,s,0),s}return e.wavJr(a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1775)],a.byteOffset,a[n(1209)+"th"])}function Vh(a){let n=t;try{return e[n(1888)]!=typeof a&&(e[n(1441)](a,ArrayBuffer)||a[n(1775)]&&e[n(1529)](a[n(1775)],ArrayBuffer))||e[n(675)](n(1884),typeof a)?"":(JSON.parse(a),n(1573)+n(533))}catch{if(e[n(1360)]==="wmupm"){let s=this[n(1924)][n(1611)](this[n(1413)]),d=_0x30da46[n(575)](e[n(1136)](s,"{}"));return d[_0x24b95d]=void 0,this[n(1924)][n(1159)](this[n(1413)],_0x219bcd.stringify(d))}else return e[n(1888)]==typeof a?"text/pla"+n(1768)+n(1463):""}}let Yh=(a,n)=>{let s=t;switch(a){case e[s(1578)]:case e[s(1523)]:return{[s(1697)+a]:1,"x-tt-env":n};default:return{}}};class Zh{constructor(n){let s=t;this.maxLossCount=n,this[s(1661)]=0}[t(1926)](){let n=t;this[n(1661)]++}["checkRea"+t(577)+"nt"](){let n=t;return e[n(1274)](e[n(779)],e[n(705)])?new _0x341398(_0x597677,{data:_0x46fe98}):e[n(1838)](this[n(1661)],this["maxLossC"+n(596)])}["resetCou"+t(970)](n=0){let s=t;if(e.tORrg==="mJxKM"){if(e.HWzfy(4,_0xe7f3d7[s(546)])){let d=_0x7136e7[s(1595)+"g"](0,e[s(763)](4,_0x57f52d[s(546)])),u=d[s(993)](_0x11fe4f);_0x18eca5.push(u)}else _0x28857b[s(1230)](_0x20a88b);_0x3733f1&&(_0x316bae+=1),_0x26ffd8+=1,_0x2a36c8=!1}else this[s(528)+s(596)]=n,this.count=0}}async function Xh(a){let n=t,s={jGjcs:function(d,u){return e[ee(620)](d,u)},rOSaO:e[n(772)],mluWA:function(d,u){return e.loqnz(d,u)},ZDqwL:function(d,u){return d+u},aJwJX:e[n(1401)],VyXvV:e[n(488)],rOjSx:e[n(654)],VhsQP:function(d,u){return e[n(1274)](d,u)},zuKxE:"wUHuz",vArkt:function(d,u){return e[n(1600)](d,u)}};return new Promise(d=>{let u=n,p={PgJEG:function(_,v){return s[ee(768)](_,v)},uKPBv:function(_,v){return s.ZDqwL(_,v)}};if(!er)return d(u(736)+u(1132));try{let _=document[u(1161)+u(1167)](s[u(966)]);window[u(1607)+u(881)]=v=>{let g=u;document[g(1755)][g(1452)+g(1342)](_),window[g(1607)+g(881)]=void 0,s[g(731)](d,v&&v[g(1785)]||s.rOSaO)},_[u(932)]=s[u(760)],_.src=a[u(1825)](/^ws/,s[u(1520)])+(u(1896)+u(1026)+"tierJSONP");try{document.body[u(1396)+u(1342)](_)}catch{document[u(1755)][u(1452)+u(1342)](_)}}catch{if(s.VhsQP(s.zuKxE,s.zuKxE))window[u(1607)+"JSONP"]=void 0,s[u(972)](d,s[u(1701)]);else{let _=_0x520287(_0xc0c04b,_0x2574d2.limit),v=_0x169230[u(816)],g=_0x3dc8ad[u(816)];for(let D=0,L=_0x4241d4[u(661)];TVvHQC[u(702)](D,L);D++)v[TVvHQC[u(1208)](D,_)]=g[D]}}})}function rn(a,n,s){let d=t;return!!a?.[d(1703)](u=>u[d(1934)]===n&&u[d(587)]===s)}function tr(a,n){let s=t;return a?.[s(1703)](d=>d[s(1934)]===n)?.value}let la=null;async function Qh(){let a=t;return e[a(643)]!==e[a(643)]?this[a(1356)+a(1964)+a(496)+"t"]:(la||(la=Promise.resolve()[a(1138)](Bt[a(1458)](Bt,e[a(556)]))),la)}class ep extends ca{constructor(n,s){let d=t;super(),this[d(1406)]=n,this[d(869)]=s,this._qosDB=void 0,this[d(589)+"mise"]=null}async[t(1874)](){await this._init()}async[t(790)](){let n=t,s={MonXm:function(d){return e.UYfxv(d)},LzkRK:function(d,u,p,_){return e[ee(1693)](d,u,p,_)}};if(!this._qosDB){if(this[n(589)+n(1636)])return this[n(589)+n(1636)];try{if(e[n(1929)]("GEhxF",e[n(1889)])){let d=this._dbName,u=this[n(869)];this[n(589)+n(1636)]=(async()=>{let p=n,{openDB:_}=await s.MonXm(Qh);this[p(1924)]=await s[p(1943)](_,p(1607)+"_"+d,1,{upgrade(v){v["createOb"+p(788)+"e"](d,{keyPath:u})}})})(),await this[n(589)+n(1636)]}else return e[n(1192)](-1,this[n(849)])&&e[n(1192)](-1,this[n(1067)])?_0x2d7f24.fromBits(0,0,this[n(1222)]):e[n(465)](-1,this.low)?_0xc7789d.fromBits(0,e.ErmCj(this[n(1067)],1),this[n(1222)]):_0x47bf03[n(476)](e.mseRd(this[n(849)],1),this[n(1067)],this[n(1222)])}catch(d){console[n(839)](d)}finally{this[n(589)+n(1636)]=null}}}async[t(1616)](n){let s=t;try{return await this[s(790)](),this._qosDB?.[s(1616)](this[s(1406)],n)}catch(d){console[s(839)](d)}}async[t(497)](n,s){let d=t;return await this[d(790)](),this[d(1924)]?.[d(1831)](this._dbName,n)}async[t(1151)](n){let s=t;try{if(e.NvXWw(e[s(884)],e[s(884)]))this[s(1032)]=_0x2c78d7,this[s(630)]=_0x532d5a,this[s(1924)]=_0x453349;else return await this[s(790)](),this[s(1924)]?.[s(725)](this[s(1406)],n)}catch(d){console[s(839)](d)}}async[t(1467)](){let n=t,s={oEJXj:e[n(1673)],QxNjI:function(d,u,p){return d(u,p)}};try{if(e.HWzfy(e[n(592)],n(1712)))return await this[n(790)](),this[n(1924)]?.[n(1467)](this[n(1406)]);{let d=_0x5f320c[n(1775)][n(827)](_0x1f840c[n(1565)+"et"],_0x3fb83b[n(1209)+"th"]+_0x2fcc3e[n(1565)+"et"]);this[n(1373)]&&this._socket[n(678)]({data:d,fail:u=>{let p=n;this.emit(wvlOtP[p(1833)],wvlOtP[p(1907)](_0x2898a4,wvlOtP[p(1833)],{message:this[p(887)+p(719)+"age"](u)}))}})}}catch(d){console[n(839)](d)}}async keys(){let n=t;return await this._init(),this[n(1924)]?.[n(774)+"ys"](this[n(1406)])}async[t(609)](){let n=t;return await this[n(790)](),this[n(1924)]?.[n(609)](this[n(1406)])}async[t(814)](){let n=t;try{this[n(1924)]?.[n(872)](),this[n(1924)]=void 0}catch(s){console[n(839)](s)}}get[t(1816)](){let n=t;try{return!!this[n(1924)]}catch(s){return console[n(839)](s),!1}}}class tp{constructor(n,s){let d=t;this._DBName=n,this[d(630)]=s,this._qosDB=localStorage}async[t(1874)](){}get _prefix(){let n=t;return n(1607)+"_"+this[n(1032)]}async[t(1616)](n){let s=t;if(e[s(1806)](e[s(1684)],"GuEWj"))return this._qosDB.clear();{let d=this[s(1924)][s(1611)](this[s(1413)]);return JSON[s(575)](e.WIeUj(d,"{}"))[n]}}async[t(497)](n,s){let d=t,u=this._qosDB[d(1611)](this[d(1413)]),p=JSON[d(575)](u||"{}");return p[s||n[this[d(630)]]]=n,this._qosDB[d(1159)](this._prefix,JSON.stringify(p)),s||n[this[d(630)]]}async[t(1151)](n){let s=t,d=this[s(1924)][s(1611)](this._prefix),u=JSON[s(575)](e[s(1136)](d,"{}"));return u[n]=void 0,this[s(1924)][s(1159)](this._prefix,JSON[s(1518)+"y"](u))}async clear(){let n=t;if(e[n(1757)](e[n(1510)],e[n(1510)])){if(e.NWuwY(void 0,_0x56ce59))this._listeners={};else if(e[n(673)](void 0,_0x389a0f))this._listeners[_0x19330a]=null;else{let s=this._listeners[_0x1be89f];if(s)for(let d=0;e[n(490)](d,s[n(546)]);)e.fDBVR(s[d].fn,_0x22a229)?s[n(1223)](d,1):++d}return this}else return this._qosDB[n(1467)]()}async[t(1267)](){let n=t,s=this[n(1924)].getItem(this[n(1413)]),d=JSON.parse(e[n(1262)](s,"{}"));return Object[n(1267)](d)}async[t(609)](){let n=t,s=this[n(1924)][n(1611)](this._prefix),d=JSON[n(575)](e.rlmMM(s,"{}"));return Object[n(1021)](d)}[t(814)](){let n=t,s={ymHPB:e.Jwzxy};if(e[n(1731)](e[n(477)],n(1389)))switch(_0x47b95a){case GnDDor.ymHPB:case n(953):return{[n(1697)+_0x190935]:1,"x-tt-env":_0x414397};default:return{}}else return Promise[n(918)]()}get[t(1816)](){return!!this._qosDB}}class np{constructor(n,s){let d=t;this[d(1032)]=n,this[d(630)]=s,this[d(1924)]=Tn?tt:Kr?wx:null}async[t(1874)](){}get[t(1413)](){let n=t;return n(1607)+"_"+this[n(1032)]}async[t(1616)](n){let s=t,d={geycr:function(u,p){return u|p},LrRTs:function(u,p){return e[ee(1511)](u,p)},ZFtGp:function(u,p){return e[ee(973)](u,p)},zdJSz:function(u,p){return u+p},kQVFJ:function(u,p){return e.wZdbk(u,p)},sFFvr:function(u,p){return e.wkYeQ(u,p)},tcOWA:function(u,p){return e.fYpkY(u,p)},rrIdl:function(u,p){return u+p}};if(e.smYwT(e.nHnvo,e[s(803)])){let u=this[s(1924)][s(1954)+s(845)](this._prefix);return JSON.parse(e[s(1136)](u,"{}"))[n]}else{let u=new _0x566c40(d[s(1719)](d[s(1551)](d[s(664)](_0x7a2e55[_0x500fce+4]<<24,_0x5159f0[d[s(1129)](_0x5047a0,5)]<<16),d[s(909)](_0x4e2613[d[s(997)](_0x436868,6)],8)),_0x14d621[d[s(711)](_0x27e64a,7)]),d.LrRTs(_0x4d9dd2[d[s(1129)](_0x4ec823,0)]<<24|d[s(909)](_0x4c7bb6[d.sFFvr(_0x1b3844,1)],16),d.kQVFJ(_0x27905e[d[s(1129)](_0xca6f72,2)],8))|_0x4ab11e[_0x139117+3],!0);return _0x4352a1+=8,{value:u,offset:d[s(1119)](_0x4be91f,8)}}}async[t(497)](n,s){let d=t,u=this[d(1924)][d(1954)+d(845)](this[d(1413)]),p=JSON.parse(e[d(1136)](u,"{}"));return p[s||n[this[d(630)]]]=n,this[d(1924)][d(1621)+d(845)](this._prefix,JSON[d(1518)+"y"](p)),s||n[this._pathKey]}async[t(1151)](n){let s=t,d=this._qosDB[s(1954)+"geSync"](this[s(1413)]),u=JSON[s(575)](e[s(1204)](d,"{}"));return u[n]=void 0,this[s(1924)][s(1621)+s(845)](this[s(1413)],JSON[s(1518)+"y"](u))}async[t(1467)](){let n=t;return this._qosDB[n(1503)+"rageSync"]()}async keys(){let n=t,s=this._qosDB[n(1954)+"geInfoSync"](this[n(1413)]),d=JSON[n(575)](e[n(1746)](s,"{}"));return Object[n(1267)](d)}async[t(609)](){let n=t,s=this[n(1924)]["getStora"+n(1823)+"nc"](this[n(1413)]),d=JSON[n(575)](e.fHZZT(s,"{}"));return Object[n(1021)](d)}[t(814)](){let n=t;return e[n(1602)](e[n(538)],e[n(1957)])?this[n(1373)][n(767)+"pe"]:Promise[n(918)]()}get isReady(){return!!this._qosDB}}function Zd(a,n){let s=t;if(Tn||Tn)return new np(a,n);if(e[s(1645)](er,$r)&&e.zhmfM!=typeof indexedDB)return new ep(a,n);if(e[s(580)](er,$r)&&e[s(856)]!=typeof localStorage)return new tp(a,n);throw new Error(s(521)+"DB failed")}class rp{constructor(){let n=t;this[n(999)+n(1741)+"Id"]=null,this._interval=36e5,this._qosDB=e[n(1295)](Zd,e[n(733)],e.oENVC)}async["_interva"+t(927)](){let n=t;clearInterval(this[n(999)+n(1741)+"Id"]),this[n(999)+"lTimeoutId"]=setInterval(()=>{this[n(1562)+"ired"]()},this._interval)}async[t(1874)](){let n=t,s={pfhDE:function(d,u){return d-u}};await this[n(1924)][n(1874)]().then(()=>{let d=n;if(e[d(1107)]("hcbWQ",e[d(1334)])){let u=_0x3ff7b7[d(1595)+"g"](0,WjiSrk[d(1398)](4,_0x2e0cbc[d(546)])),p=u[d(993)](_0x4851f1);_0x2565b3[d(1230)](p)}else this[d(999)+d(927)]()})}async[t(1562)+t(1180)](){let n=t;(await this._qosDB?.[n(609)]()||[])[n(943)](({timestamp:u})=>u<Date[n(850)]())[n(1868)](u=>{let p=n;this[p(1924)]?.[p(1151)](u[p(1971)+"id"])})}async[t(1151)](n){let s=t,d={iMGfU:function(u,p,_){return e[ee(692)](u,p,_)}};if(e[s(1438)](e[s(656)],e.ZQzvT))return this[s(1924)]?.[s(1151)](n);_0x3211b9(_0x2293bb,90),Vcgmrg[s(1587)](_0x356892,_0x42be84,_0x4252ff)}async set(n,s){let d=t;return this._qosDB?.[d(497)]({message_id:n,timestamp:s})}async[t(1616)](n){let s=t;return this[s(1924)]?.[s(1616)](n)}async[t(814)](){clearInterval(this["_interva"+t(1741)+"Id"]),await this._qosDB?.closeDB()}get[t(1816)](){let n=t;return this._qosDB?.[n(1816)]}}function fa(a){let n=t,s=!!this[n(1638)][n(1528)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e.QDMOT(rn,a[n(1958)][n(1385)],e[n(1640)],"2"),u=d&&rn(a[n(1958)].headers,e.AOIVm,"1"),p=d&&e[n(1392)](rn,a[n(1958)][n(1385)],e[n(1694)],"1"),_=p?tr(a[n(1958)][n(1385)],e[n(665)])?.[n(549)](",")[n(943)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:_}}async function Xd(){let a=t;return this[a(1415)+"ger"]||(this._QoSManager=new rp),this[a(1415)+"ger"].isReady||await this[a(1415)+a(1074)].openDB(),this[a(1415)+a(1074)]}async function ip(a,n){let s=t,{enableAutoAck:d}=this._options,u=rn(a[s(1958)][s(1385)],s(762),"1"),p=e[s(1392)](rn,a[s(1958)].headers,s(1152),"1"),_=fa.call(this,a);if(e[s(868)](d,u)){let{SeqID:v,LogID:g,service:D,LogIDNew:L,method:N}=a[s(1958)];this[s(572)]({SeqID:v,LogID:g,LogIDNew:L,service:D,method:N,headers:[{key:e.RiGAT,value:"1"},{key:e[s(783)],value:e[s(1645)](L,"")},{key:e[s(1656)],value:"0"}]})}p&&!_[s(1836)]&&this["_dispatchAckMess"+s(1949)](a),e[s(904)](n)}async function sp(a,n){let s=t;this._debug(e[s(1641)],a[s(1958)]),e[s(1122)](n)}async function op(a,n){let s=t,d=e[s(1866)](en,await e[s(1626)](Yd,a[s(677)]));try{if(d.payload instanceof Uint8Array){let u=e[s(1481)](this[s(1638)][s(1083)+s(1105)],Object)?{force:!!this[s(1638)][s(1083)+s(1105)].force,encoding:this[s(1638)][s(1083)+s(1105)][s(595)]?this[s(1638)][s(1083)+"ncoding"][s(595)][s(1825)](/\s/g,"")[s(1072)+s(1218)]():""}:{force:!1,encoding:this._options[s(1083)+"ncoding"]?this[s(1638)][s(1083)+"ncoding"][s(1825)](/\s/g,"")["toLowerC"+s(1218)]():""},p=d["payloadE"+s(1105)]?d[s(1083)+"ncoding"][s(1825)](/\s/g,"")["toLowerC"+s(1218)]():"",_=e[s(1877)](this[s(1638)]["payloadT"+s(1101)],Object)?{force:!!this[s(1638)].payloadType[s(1649)],type:this[s(1638)][s(715)+s(1101)][s(932)]?this[s(1638)][s(715)+s(1101)][s(932)].replace(/\s/g,"")[s(1072)+"ase"]():""}:{force:!1,type:this[s(1638)].payloadType?this[s(1638)][s(715)+"ype"][s(1825)](/\s/g,"")[s(1072)+"ase"]():""},v=d[s(715)+s(1101)]?d[s(715)+s(1101)][s(1825)](/\s/g,"")["toLowerC"+s(1218)]():"",g=_[s(1649)]?_.type:v||_[s(932)],D=u.force?u[s(595)]:p||u[s(595)],L=[e[s(1795)],"applicat"+s(533),e[s(1728)],e[s(1888)]],N=[e[s(945)],e[s(683)]];this[s(1638)][s(1028)+s(1939)+"extPayload"]&&L[s(758)](g)&&(!D||N[s(758)](D))?d[s(1296)+s(559)]=Vd(d[s(1723)],0,d.payload[s(1209)+"th"]):d[s(1296)+s(559)]=""}else d[s(1296)+s(559)]=""}catch(u){d[s(1296)+s(559)]="",console[s(839)](u)}a[s(1958)]=d,n()}function ap(a,n,s){let d=t,u=e[d(1559)](s,8192),p=u>>>1,_=null,v=u;return function(g){let D=d;if(e[D(1047)](g,1)||e.OpSlk(g,p))return e[D(1239)](a,g);e[D(1388)](e[D(891)](v,g),u)&&(_=a(u),v=0);let L=n[D(1449)](_,v,v+=g);return 7&v&&(v=e[D(991)](7,v)+1),L}}let cp=4294967295;function dp(a,n,s){let d=t,u={ZXcnN:e[d(1455)]};if(e[d(1576)](e[d(1962)],e[d(1962)]))return e.xdSrP(RangeError,e[d(1876)](e[d(1249)](e.ErmCj(e.SFZrq(e[d(1248)]+a,e.osTHb),e[d(580)](n,1)),e[d(741)]),s));this[d(714)](u[d(1448)],_0x1db18d),this[d(726)+"e"]&&this[d(726)+"e"](_0x1fa9ca)}function lp(a,n,s){let d=t;if(e[d(1388)](s,cp))throw new Error(e.nRXqc);let u=3;for(;e.puMzQ(u,0);){let p=255&s;e[d(1392)](xa,p,a,e[d(1801)](n,u)),s>>>=8,u--}return n+4}function fp(a,n){let s=t,d=0,u=n,p=n+4;for(;e.tdbjW(u,p);){let{value:_,offset:v}=ua(a,u);u=v,d=e.rsipp(e[s(1207)](d,8),0),d+=_}return{value:d,offset:p}}function up(a,n,s){let d=t,u=e.PwzhN[d(549)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(e[d(937)](a[d(546)],40))return e.HFkxS(da(a,n,s),s);continue;case"1":return e[d(1938)](e[d(1693)](da,a,n,s),s);case"2":if(n.utf8Write)return e[d(1840)](n[d(1665)+"e"](a,s),s);continue;case"3":if(!a)return s;continue;case"4":if(n[d(698)])return e[d(1189)](n.write(a,s),s);continue}break}}function xp(a,n){let s=t,d=new fe(e[s(1010)](a[n+4]<<24,e[s(1276)](a[e.uUkWK(n,5)],16))|a[e[s(1308)](n,6)]<<8|a[e[s(1916)](n,7)],e.jlgLk(e[s(742)](e.uCaOm(e.ResTd(a[e.sfAAk(n,0)],24),e.qxkSP(a[e[s(1776)](n,1)],16)),e[s(657)](a[e[s(574)](n,2)],8)),a[e.akqka(n,3)]),!0);return n+=8,{value:d,offset:e[s(1285)](n,8)}}function hp(a,n,s){let d=t,u=a[d(849)],p=a.high;return n[s]=p>>>24,n[e[d(1118)](s,1)]=e[d(1394)](p>>>16,255),n[e.mxGJw(s,2)]=e.oXsLv(p>>>8,255),n[e[d(699)](s,3)]=255&p,n[e[d(537)](s,4)]=e[d(1106)](u,24),n[s+5]=e[d(506)](e[d(1612)](u,16),255),n[e.fXjWJ(s,6)]=e.UrRkL(e.vlmoq(u,8),255),n[s+7]=e.lzarm(255,u),s+=8,s}function ua(a,n){let s=t;if(e[s(1126)]===s(491)){let d=_0x119aeb[s(1872)]();return d?(d.offset=d[s(661)]=0,d):{bytes:new _0x121af0(64),offset:0,limit:0}}else return a.readUInt8?{value:a[s(801)+"8"](n),offset:e[s(776)](n,1)}:{value:e.vHFeb(255,a[n]),offset:e[s(1457)](n,1)}}function xa(a,n,s){let d=t;if(e[d(1274)](e[d(1804)],e.mVgUB))this[d(1532)+"rs"]={};else return n[d(628)+"t8"]?n[d(628)+"t8"](a,s):n[s]=e[d(1539)](255,a),e[d(844)](s,1)}let pp=function(a){let n=t;return e.CDQXU(n(703),e.qWjlg)?new _0x4218da(_0x42330c,{code:_0x5ed532,reason:_0xd89817,wasClean:_0x4732b3,willReconnect:_0x5cbe6e}):new Uint8Array(a)},gp=e[t(1505)](t(1319)+"d",typeof Buffer)?Buffer[t(1960)+"afe"]:e[t(1391)](ap,pp,Uint8Array[t(1895)+"e"][t(473)]);(()=>{let a=t,n={hCTUb:"11|2|0|1"+a(885)+a(1117)+"4",rOkdj:function(d,u){return e.DgbGn(d,u)},LCQMM:function(d,u){return e[a(1016)](d,u)},aSDsx:function(d,u){return e[a(1327)](d,u)},oBISE:function(d,u){return d<u},EGnpl:function(d,u){return d<u},McBwP:function(d,u){return d|u},zYLCl:function(d,u){return e[a(1942)](d,u)},xawnx:function(d,u){return e[a(1269)](d,u)},GLpEl:function(d,u){return e[a(1538)](d,u)},HgpsU:function(d,u,p,_){return e[a(507)](d,u,p,_)},TonEO:function(d,u){return e[a(1421)](d,u)},NHjje:function(d,u){return e.NamLB(d,u)},fHJvl:function(d,u){return e[a(974)](d,u)},VneOO:function(d,u){return d<<u},mzAXr:function(d,u){return e[a(847)](d,u)},bhDiP:function(d,u){return d&u}},s=4294967295;return function(d,u,p=!0){let _=a,v=n[_(586)][_(549)]("|"),g=0;for(;;){switch(v[g++]){case"0":s=n.rOkdj(n[_(1648)](s,n.aSDsx(127&d[u],7)),0);continue;case"1":if(n[_(1824)](d[u++],128))return{value:p?s:0|s,offset:u};continue;case"2":if(n[_(940)](d[u++],128))return{value:p?s:n[_(1044)](0,s),offset:u};continue;case"3":if(n.zYLCl(d[u++],128))return{value:p?s:0|s,offset:u};continue;case"4":return{value:p?s:n.McBwP(0,s),offset:u};case"5":s=n[_(1081)](n[_(1648)](s,n.aSDsx(n[_(781)](127,d[u]),14)),0);continue;case"6":if((u+=5)>d.length)throw u=d[_(546)],n[_(1574)](dp,u,10,d[_(546)]);continue;case"7":s=n[_(536)](n[_(1044)](s,n[_(623)](127&d[u],21)),0);continue;case"8":if(n[_(1824)](d[u++],128))return{value:p?s:0|s,offset:u};continue;case"9":if(n.fHJvl(d[u++],128))return{value:p?s:0|s,offset:u};continue;case"10":s=n.xawnx(n.LCQMM(s,n[_(1299)](n[_(781)](15,d[u]),28)),0);continue;case"11":s=n[_(1779)](n[_(1818)](127,d[u]),0);continue}break}}})();let mp=16,ha=32;function wp(a){let n=t,s=0,d={};for(let u=0;e[n(738)](u,a.length);u++)d[a[u][n(493)+n(1788)]]=Jd(a[u][n(493)+"ame"]),s+=14+d[a[u][n(493)+"ame"]];return[s,d]}function Qd(a,n,s){let d=t;if(e[d(929)]!==d(1035))return this[d(1373)][d(1102)];{let[u,p]=wp(a),_=gp(u),v=0;return a[d(1868)](g=>{let D=d,L=e.VsWBH[D(549)]("|"),N=0;for(;;){switch(L[N++]){case"0":v=e[D(1292)](hp,fe[D(1445)+"er"](g[D(1367)]||n),_,v);continue;case"1":console[D(839)](e[D(509)],v);continue;case"2":v=e.QFjQr(up,g[D(493)+D(1788)],_,v);continue;case"3":console[D(839)](D(475)+"name",v);continue;case"4":v=e[D(1095)](xa,p[g[D(493)+D(1788)]],_,v);continue;case"5":v=xa(0,_,v);continue;case"6":v=e[D(852)](lp,_,v,g[D(946)]||0);continue;case"7":console[D(839)](e[D(1849)],v);continue;case"8":console[D(839)](e[D(1627)],v);continue;case"9":console[D(839)](e[D(1919)],v);continue;case"10":console[D(839)](D(523)+D(923),g,g.service);continue}break}}),{frameType:ha,headers:[{key:e.TWvgX,value:s}],payload:_}}}function _p(a){let n=t,s=0,d=[];for(;e.PgrhQ(s,a.byteLength);){let{offset:u}=ua(a,s);s=u;let p={cursor_name:"",cursor:0,service:0},{value:_,offset:v}=e[n(520)](fp,a,s);p[n(946)]=_,s=v;let{value:g,offset:D}=e[n(1879)](ua,a,s);s=D,p[n(493)+n(1788)]=e[n(1292)](Vd,a,s,s+g),s+=g;let{value:L,offset:N}=xp(a,s);p[n(1367)]=L[n(1001)](),s=N,d.push(p)}return d}function yp(){let a=t;return{frameType:ha,headers:[{key:e[a(1031)],value:e[a(1753)]}],payload:void 0}}class Ep{constructor(n,s,d){let u=t;this["_cursorN"+u(1756)]=n,this[u(492)+u(1561)]=s,this["_message"+u(655)]=d,this[u(1924)]=e[u(1007)](Zd,this["_cursorN"+u(1756)],e.IwnrM)}async[t(1874)](){let n=t;await this[n(1924)][n(1874)]()}async[t(1835)+"rs"](){let n=t;if(!this[n(1924)][n(1816)])return;let s=this._messageStrategy,d=await this[n(1924)][n(609)]();switch(console.log(e[n(1850)],d),s){case e.xEQmS:return d&&d.length?Qd(d,0,this[n(492)+"ileName"]):void 0;case e.tlsME:return;case e[n(1807)]:return d&&d.length?e[n(1693)](Qd,d,0,this[n(492)+n(1561)]):e[n(866)](yp)}}async[t(497)](n,s,d){let u=t;return console.log(e[u(604)],n,s,d),this[u(1924)].set({cursor_name:n,cursor:s,service:d})}async[t(987)+"rs"](n){let s=t,d=e[s(764)](_p,n);for(let u of d)console[s(839)](e.CQZzW,d),await this[s(1924)][s(497)](u)}async[t(1616)](n){let s=t;return(await this[s(1924)][s(1616)](n))?.[s(1367)]}async[t(814)](){let n=t,s={uTHUT:n(1743),GaIPa:e[n(1411)],KhivN:n(1251)};n(554)!==n(754)?await this[n(1924)][n(814)]():(this[n(1710)+"er"]&&_0x373f7b[n(1663)+n(1834)+n(1792)](s.uTHUT,this["_handleO"+n(720)]),this[n(1710)+"er"]&&_0x2ab4db[n(1663)+n(1834)+"ner"](s[n(1597)],this["_handleO"+n(1909)]),this[n(1710)+"er"]&&_0x264ff5[n(1663)+n(1834)+n(1792)]("pagehide",this["_handleP"+n(793)]),this[n(1710)+"er"]&&_0x2ea7b8[n(1663)+n(1834)+n(1792)](s[n(570)],this[n(1158)+n(518)]))}[t(1202)+t(854)+t(1796)](n){let s=t;this[s(492)+"ileName"]=n}get[t(1816)](){return this[t(1924)].isReady}}let bp="__x_msg_"+t(619);async function el(a){let n=t;if(e[n(1160)](e[n(469)],e[n(543)])){if(!this._options[n(1528)+"S"])return null;let{aID:s,fpID:d,messageStrategy:u}=this[n(1638)],p=e[n(580)](a,bp);try{if(e[n(578)]!=="mnGMS")return this[n(1846)+n(865)]?a&&this[n(1846)+n(865)][n(1202)+n(854)+"Name"](a):this["_cursorM"+n(865)]=new Ep(d+"_"+s+"_"+p,p,u),this[n(1846)+n(865)][n(1816)]||await this[n(1846)+n(865)][n(1874)](),this[n(1846)+n(865)];{let _=e.wavJr(this._options[n(1083)+n(1105)],_0x1cc82e)?{force:!!this[n(1638)][n(1083)+n(1105)][n(1649)],encoding:this[n(1638)][n(1083)+n(1105)][n(595)]?this[n(1638)]["payloadE"+n(1105)][n(595)][n(1825)](/\s/g,"")[n(1072)+n(1218)]():""}:{force:!1,encoding:this[n(1638)][n(1083)+"ncoding"]?this[n(1638)][n(1083)+n(1105)][n(1825)](/\s/g,"")[n(1072)+n(1218)]():""},v=_0x1d8616[n(1083)+n(1105)]?_0x4b208d.payloadEncoding[n(1825)](/\s/g,"")[n(1072)+"ase"]():"",g=e[n(622)](this[n(1638)][n(715)+n(1101)],_0x4f9cd8)?{force:!!this[n(1638)].payloadType[n(1649)],type:this._options["payloadT"+n(1101)][n(932)]?this[n(1638)]["payloadT"+n(1101)][n(932)][n(1825)](/\s/g,"")[n(1072)+n(1218)]():""}:{force:!1,type:this[n(1638)]["payloadT"+n(1101)]?this[n(1638)][n(715)+n(1101)].replace(/\s/g,"")[n(1072)+n(1218)]():""},D=_0x309626.payloadType?_0x3e38ac[n(715)+n(1101)].replace(/\s/g,"")[n(1072)+"ase"]():"",L=g[n(1649)]?g[n(932)]:D||g[n(932)],N=_.force?_[n(595)]:v||_[n(595)],j=[n(1676)+n(1768)+"et=utf-8","applicat"+n(533),e[n(1728)],"string"],U=[e[n(945)],e.SbuVI];this[n(1638)]["enableTr"+n(1939)+n(1462)+"ad"]&&j[n(758)](L)&&(!N||U[n(758)](N))?_0x44e6a0[n(1296)+n(559)]=e[n(1292)](_0x447f2e,_0xcbc03c[n(1723)],0,_0x7abb0e[n(1723)][n(1209)+"th"]):_0x25893d[n(1296)+n(559)]=""}}catch{return null}}else return _0x30f7c5?_0x4e1808[n(1191)+n(1384)](_0x10a3fe,_0x81b23b):_0x285a8a[n(1191)+n(1247)](_0x4bdae7,_0x243666)}async function vp(a,n){let s=t,d={KClil:function(u,p){return e.KSjAV(u,p)},esWVt:function(u,p){return e[ee(584)](u,p)},Dozhd:s(1743)};if(e.NWuwY(e[s(880)],e[s(1821)]))this[s(820)+s(1454)]()&&(!this._ws||d.KClil(this[s(1476)].readyState,this[s(1781)])||d[s(1048)](this[s(1476)][s(930)+"te"],this.CONNECTING))&&this[s(1878)+"nLine"](),this[s(1710)+"er"]&&_0x546ac0[s(514)+"Listener"](d.Dozhd,this["_handleO"+s(720)]),this[s(1710)+"er"]&&_0x364b05["addEvent"+s(1379)]("offline",this[s(1878)+s(1909)]);else{let u=e[s(507)](rn,a.message[s(1385)],e.cQQwh,"-1"),p=e.rviGY(rn,a.message[s(1385)],e[s(1343)],"1"),_=tr(a[s(1958)][s(1385)],e.TlEhG),v=e[s(672)](Number,tr(a[s(1958)].headers,s(955)+s(1810)))||0,g=fa[s(1449)](this,a),D=rn(a.message.headers,e.GAOTF,"2"),L=tr(a[s(1958)].headers,s(782)+s(942)+"e"),N=e[s(672)](Number,e[s(1827)](tr,a[s(1958)][s(1385)],e[s(585)]));if(g[s(1836)])return n();let j=g[s(876)+s(1724)]?await Xd[s(1449)](this):null;if(a[s(1958)][s(946)]>0&&p&&!u||a[s(1958)][s(946)]>0){if(_&&g[s(876)+s(1724)]&&j)return!!!await j.get(_)&&(this[s(640)+s(1103)+s(950)](a),await j[s(497)](_,Date[s(850)]()+v)),e.UYfxv(n);if(D){let U=await el.call(this);if(!U)return this[s(640)+s(1103)+s(950)](a),e[s(904)](n);let W=await U[s(1616)](L)??-1;if(e[s(1952)](W,N))if(e[s(1715)](e.PsXwo,e[s(1147)]))this[s(640)+s(1103)+s(950)](a),U.set(L,N,a[s(1958)][s(946)]);else{if(e[s(1629)](e[s(1696)](_0x2c2b85,_0x11de43),1))return"";let $="";for(let ie=_0x421003;e[s(1324)](ie,_0x29a101);){let Z=_0x4e8c98[ie++];if(e[s(1217)](Z,127))$+=_0x2e2b5c[s(933)+s(504)](Z);else if(e[s(1024)](Z,192)&&Z<224)$+=_0x11be38.fromCharCode(e.rEPQQ(e.EIRfS(e[s(990)](31,Z),6),63&_0x242007[ie++]));else if(e[s(642)](Z,224)&&Z<240)$+=_0x4c2fc9[s(933)+s(504)](e[s(1780)](e[s(1594)](e[s(516)](15,Z),12)|e[s(1594)](e[s(1717)](63,_0x236246[ie++]),6),e[s(1006)](63,_0x5339f4[ie++])));else if(Z>=240){let Ce=e.uNKsH(e[s(925)](e[s(1953)](7,Z)<<18,e[s(1767)](e[s(1270)](63,_0x5b2dc1[ie++]),12))|e[s(1306)](63&_0x33571c[ie++],6),63&_0x4f5924[ie++])-65536;$+=_0x2bc75c[s(933)+s(504)](e[s(766)](55296,e.xLihU(Ce,10))),$+=_0x124bc3[s(933)+"Code"](e[s(508)](56320,e[s(1690)](1023,Ce)))}}return $}else throw new Error(s(1068)+" message"+s(1098)+N+(s(1584)+"than loc"+s(1772)+"r ")+W);return e.sNuoJ(n)}return this["_dispatc"+s(1103)+s(950)](a),e[s(582)](n)}}}async function Sp(a,n){let s=t,d=fa.call(this,a);if(!d["isQoSMes"+s(1724)])return n();let u=await Xd.call(this);if(d[s(1860)+s(780)+s(568)]&&d.ackMsgIds.length)for(let p of d[s(951)+"s"])await u[s(1151)](p);e[s(1164)](n)}async function Ip(a,n){let s=t,d={dCUlK:e[s(1669)],Hoqfe:function(u,p){return e[s(1015)](u,p)},GPoey:s(1319)+"d"};if(e.RoxpG(e[s(632)],e[s(1252)])){let u=d[s(1657)][s(549)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(_0x2db5cc)return!0;continue;case"1":if(_0x5a5fc5&&_0x4cc900[s(1495)+"ocket"])return!0;continue;case"2":if(_0x35a922&&_0xc7d2f2[s(1495)+s(1655)])return!0;continue;case"3":if((_0x1855e7||_0x478e5c)&&kvuHYa.Hoqfe(kvuHYa[s(1100)],typeof _0x28e320)&&_0x303905)return!0;continue;case"4":return!1}break}}else{let u=a[s(1958)][s(748)+"e"]===mp,p=e[s(1602)](a[s(1958)][s(748)+"e"],ha);if(e[s(868)](!u,!p))return e[s(582)](n);let _=e[s(1041)](tr,a[s(1958)][s(1385)],e[s(1031)]);if(!_)return e[s(1923)](n);let v=await el[s(1449)](this,_);if(!v)return e[s(1923)](n);if(u){let g=await v[s(1835)+"rs"](),D={frameType:g?.["frameType"],SeqID:fe[s(1445)+"er"](this[s(813)]++),LogID:fe.fromNumber(this[s(1638)][s(644)+s(1625)]()),service:9e3,method:5,headers:g?.[s(1385)],payload:g?.payload},L=e.vLQZQ(A,D);this._ws&&this._ws.readyState&&this[s(1476)][s(678)](L)}if(p){let g=a[s(1958)][s(1723)];g&&v[s(987)+"rs"](g)}}}let Ap=async function(a,n){let s=t;this._isInit=!1,e[s(531)](clearTimeout,this[s(512)+s(1745)+s(470)]),e.gJSwx(n)},Tp=async function(a,n){let s=t;if(!this._ws||this._ws[s(930)+"te"]!==this[s(1781)])return n();let{pingInterval:d}=this[s(1638)];this[s(1039)+s(1603)]?.[s(1293)+s(1566)+s(1969)]();for(let p=0;e[s(1288)](p,this["_message"+s(792)].length);p++){let _=this[s(1904)+"Queue"][p];if(this[s(1476)].readyState===this[s(1781)]&&e[s(1715)](null,_))this._ws&&this[s(1476)][s(678)](_),this["_message"+s(792)][p]=null;else break}this._messageQueue=this["_message"+s(792)].filter(p=>!!p),this[s(1945)+s(1282)+"Id"]=e.YkeHG(setTimeout,()=>this._ping(),d),this[s(640)+s(1864)+"nt"](a),this[s(1710)+"er"]&&this[s(1476)]&&(this[s(1476)][s(767)+"pe"]=this[s(680)+s(1101)]);let u=this[s(1039)+"tManager"]?.[s(843)+s(1548)+"nt"]();this[s(1054)](s(1599)+u+s(916)),e[s(1351)](n)},Dp=async function(a,n){let s=t,d=this[s(1039)+s(1603)]?.[s(843)+"ntEndpoint"]();this[s(1054)](s(1599)+d),e[s(915)](n)};class Cp extends ca{constructor(n){let s=t,d={tbBcX:function(u,p){return e[ee(1171)](u,p)},ARcQF:e[s(1742)],dXCBM:function(u,p,_,v){return e[s(1292)](u,p,_,v)},RKRJj:function(u,p,_){return e[s(550)](u,p,_)},Mroir:function(u,p,_){return u(p,_)},PJOJq:function(u,p,_){return e[s(1007)](u,p,_)},zNXvF:e.eiheR,DbcKk:e[s(982)],XoztR:function(u,p){return e.HqKEt(u,p)},XlhFd:function(u,p){return e.Gxxnd(u,p)},Orowu:s(1504),OUAPM:function(u,p){return e.fVUCu(u,p)},twPqa:e[s(1673)],NYQaW:e[s(846)],vAdFM:function(u,p,_){return e[s(1905)](u,p,_)},zBlXI:e.Jpclg,KoPBi:function(u,p){return e[s(1272)](u,p)}};if(e[s(1174)]==="MUAJt"){super(),this["_miniNav"+s(1536)+"line"]=!0,this[s(1710)+"er"]=er,this[s(1513)]=Wh,this[s(1875)+"T"]=Tn,this._isMiniWX=Kr,this._isWorker=$r,this[s(1904)+s(792)]=[],this[s(1039)+s(1603)]=null,this["_readyCl"+s(1516)]=!1,this._binaryType=e[s(823)],this[s(512)+s(1546)]=!1,this["_connect"+s(1745)+s(470)]=null,this[s(1178)+s(1843)+s(1799)]=null,this[s(1945)+s(1282)+"Id"]=null,this._seqId=0,this[s(1078)]=!1,this[s(1221)]="",this[s(1415)+s(1074)]=null,this[s(1846)+s(865)]=null,this[s(652)+s(743)]=null,this[s(1763)+"ls"]=s(1972),this[s(1340)]=3,this[s(770)+"NG"]=0,this[s(1781)]=1,this.CLOSING=2,this[s(759)]=v=>{let g=s;try{d[g(649)](d[g(1933)],d[g(1933)])?(this[g(1770)+"s"]=_0xad7699,this[g(826)+"es"]=_0x533c55,this[g(591)+g(1326)]=0,this[g(1356)+g(1964)+g(496)+"t"]=0):d[g(605)]($d,this,v,[Ap,Tp,Dp])}catch(D){let L=d[g(936)](dt,g(583),{message:D.message,code:nn[g(858)+"OR"],error:D});this[g(640)+"hErrorEv"+g(1789)](L)}},this._onMessage=async v=>{let g=s,D={lQgIo:e[g(471)],krURQ:function(L,N,j,U){return e[g(670)](L,N,j,U)},dyJPF:function(L,N,j,U){return L(N,j,U)},PKKZW:"service",aYWFd:function(L,N,j,U){return L(N,j,U)},NtEAZ:function(L,N,j,U){return L(N,j,U)},BOBOw:e[g(1849)],xiVtR:g(541),zSmCz:function(L,N){return e.iwpxm(L,N)},ubhJo:e[g(1031)]};if(g(658)!==e.ljDxy){let[L,N]=_0x51e3b1(_0x1f82dc),j=nTKgim[g(1422)](_0x5bb0b9,L),U=0;return _0x177a82.forEach(W=>{let $=g;_0x2a542c.log(nTKgim[$(1642)],W,W[$(946)]),U=nTKgim[$(874)](_0x5ef30d,0,j,U),_0xceff88[$(839)]($(1353),U),U=nTKgim[$(1906)](_0x2e3775,j,U,W[$(946)]||0),_0x4dbae9[$(839)](nTKgim[$(1350)],U),U=nTKgim[$(833)](_0xb31c07,N[W[$(493)+$(1788)]],j,U),_0x2983c8[$(839)]($(475)+"name",U),U=nTKgim[$(1790)](_0x4d6050,W["cursor_n"+$(1788)],j,U),_0x315b4a.log(nTKgim[$(1213)],U),U=_0x203f81(_0x6cd06c[$(1445)+"er"](W.cursor||_0x2c21ee),j,U),_0x35ca15[$(839)](nTKgim.xiVtR,U)}),{frameType:_0x1951a3,headers:[{key:nTKgim[g(535)],value:_0x4999d8}],payload:j}}else{let{pingInterval:L,pingFrequency:N}=this[g(1638)];if((e[g(673)]("hi",v[g(677)])&&e[g(1329)]("always",N)||e[g(1363)]===N)&&(this[g(1131)+g(1813)](),this[g(714)](e[g(1608)],e[g(629)]),this[g(1945)+g(1282)+"Id"]=e[g(1073)](setTimeout,this[g(1822)][g(1458)](this),L)),e.usDfn("hi",v.data))return;try{$d(this,v,[op,ip,Sp,Ip,vp,sp])}catch(j){let U=dt(e[g(1673)],{message:j.message,code:nn[g(1241)+"ERROR"],error:j});this[g(640)+"hErrorEv"+g(1789)](U)}}},this[s(494)]=v=>{let g=s,D=this[g(1039)+"tManager"]?.[g(1737)+g(807)+"es"](),L=this[g(1039)+"tManager"]?.["getCurre"+g(1548)+"nt"]();if(D&&!v[g(1958)]){let N="connect "+L+(g(810)+g(1677)+g(1740)+"ed");this[g(640)+"hErrorEvent"](e.XaJuI(dt,e[g(1673)],{message:N,code:nn[g(1517)+g(1259)+"R"],error:v}));return}this[g(1476)]&&e.fDBVR(this._ws[g(930)+"te"],this[g(1781)])&&this["_disconn"+g(1664)](),this[g(640)+g(1598)+g(1789)](e.RTIzi(dt,e[g(1673)],{message:v[g(1958)],code:nn[g(1347)+"RROR"],error:v}))},this._onClose=async v=>{let g=s;this[g(1572)+"mer"](),this["_clearPi"+g(1813)](),this._removeWsListeners(),this[g(1476)]=null,this["_connect"+g(1546)]=!1;let D=this[g(1039)+g(1603)]?.["checkRea"+g(807)+"es"]();if(!D&&this[g(820)+g(1454)]()&&!this._readyClosed){let L=this[g(1039)+"tManager"]?.[g(843)+g(1548)+"nt"](),N=this[g(1638)]["reconnec"+g(1333)+g(674)](v.code,v[g(1132)]);this[g(640)+g(938)+"ent"](d[g(1224)](gt,d.zNXvF,{code:1006,reason:v[g(1132)]||g(815)+"ng faile"+g(751)+g(1301)+g(1185)+g(1485)+L,willReconnect:N})),N&&this._connect();return}if(v[g(1116)]!==1e3&&this[g(1027)+g(1516)]){this["_dispatchCloseEv"+g(1789)](gt(d[g(1200)],{code:1e3,reason:d[g(785)]})),this["_endpoin"+g(1603)]?.[g(1293)+g(1566)+g(1969)](),this._pingLossCounter?.[g(716)+g(970)]();return}if(d[g(1963)](1e3,v[g(1116)])&&D)if(d.XlhFd(g(1504),d[g(1650)])){let L=this[g(1039)+g(1603)]?.[g(843)+g(1548)+"nt"](),N=v[g(1132)];N||(N=await d.OUAPM(Xh,this[g(1221)])),N=g(815)+g(1307)+"d, "+N+(g(899)+g(635))+L+(", max retries re"+g(740)),this[g(640)+g(938)+"ent"](d[g(936)](gt,d.zNXvF,{code:v[g(1116)],reason:N}));let j=g(752)+L+(" fail, m"+g(1677)+g(1740)+"ed");this[g(640)+g(1598)+g(1789)](dt(d[g(1423)],{message:j,code:nn[g(1517)+g(1259)+"R"]})),this[g(1039)+g(1603)]?.[g(1293)+g(1566)+g(1969)](),this[g(652)+g(743)]?.["resetCou"+g(970)]();return}else return this[g(1476)]?this._ws[g(767)+"pe"]:this[g(680)+"ype"];if(v[g(1116)]!==1e3&&!v[g(1132)])if(d[g(1950)]!==d.NYQaW)d[g(1555)](_0x1752a9,_0x1a330a,this[g(1886)+g(1859)+"e"](_0x4c4871));else{let L=this[g(1039)+"tManager"]?.["getCurre"+g(1548)+"nt"]();this["_dispatc"+g(938)+g(1789)](d.vAdFM(gt,d[g(1200)],{code:v[g(1116)],reason:g(815)+"ng faile"+g(751)+"wn reason, hostn"+g(1485)+L})),this[g(1039)+g(1603)]?.["resetEnd"+g(1566)+"fig"](),this[g(652)+g(743)]?.[g(716)+"nter"]();return}this[g(640)+g(938)+g(1789)](v),this[g(1039)+g(1603)]?.[g(1293)+g(1566)+"fig"](),this[g(652)+g(743)]?.[g(716)+g(970)]()},this[s(1304)]=null,this[s(980)]=null,this[s(726)+"e"]=null,this.onopen=null,this[s(1569)+s(1892)]=null,this["onReceiv"+s(1321)]=null,this[s(511)+s(1951)+s(489)+"ct"]=null,this["_handleO"+s(720)]=this[s(1878)+s(720)][s(1458)](this),this["_handleO"+s(1909)]=this[s(1878)+s(1909)].bind(this),this["_handleP"+s(793)]=this[s(1158)+s(793)][s(1458)](this),this[s(1158)+"ageShow"]=this[s(1158)+s(518)][s(1458)](this),this[s(1638)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1716)](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(1363)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1807)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,_=Array.isArray(u)?u:e[s(1571)](e[s(1888)],typeof u)?[u]:[];if(!_||e[s(631)](0,_.length))throw new Error(e[s(1420)]);if(!e[s(620)](Jh,p))throw new Error(e[s(1853)]);Object[s(694)](this[s(1638)],n),this[s(1039)+s(1603)]=new Kd(_,this._options[s(826)+"es"]),this[s(652)+s(743)]=new Zh(this[s(1638)][s(1231)+s(722)]),this[s(1638)][s(693)+s(1545)]&&(this._isInit=!0,this[s(512)]()),this._options["listenNetworkCha"+s(1893)]&&(this._isMiniTT||this[s(1709)+"X"]?this["_onPageN"+s(1425)+s(1264)]():this[s(1710)+"er"]&&this[s(1734)+s(1393)+s(1379)]())}else{let u=_0xd0d1fd[s(1725)+s(1808)](_0x2e26c4);return _0x2acfb7&&u[s(514)+s(1379)](VjMDFE[s(977)],()=>_0x180493()),VjMDFE[s(1615)](_0x1ae953,u)[s(1138)](()=>{})}}[t(1878)+t(720)](){let n=t;this._options[n(1055)+n(1567)+n(841)]||this[n(1027)+n(1516)]||this[n(1955)+n(1892)]()}[t(1878)+t(1909)](){let n=t,s={cPdZY:function(d,u){return e.YuxIi(d,u)},ouXhi:function(d,u){return e[ee(848)](d,u)},nlVbf:e[n(818)],szTMC:function(d,u){return e[n(614)](d,u)}};if(e[n(673)](e[n(1530)],e.kDcUb)){let d=_0x560c04[n(546)]&&_0x1d5657[0];if(BEKevL[n(1550)](d,_0x2b2067))throw d;let u=new _0x201d2c(BEKevL[n(750)](BEKevL.nlVbf,d?BEKevL[n(1851)](" ("+d[n(1958)],")"):""));throw u[n(1093)]=d,d}else{this[n(1170)+n(1474)+"t"]();let d=e[n(1912)](aa,e[n(837)],{message:"stop immediately"+n(1058)+"ct"});this[n(511)+n(1951)+n(489)+"ct"]&&this["onStopIm"+n(1951)+n(489)+"ct"](d)}}[t(1734)+"balEvent"+t(1379)](){let n=t;this[n(1710)+"er"]&&window[n(514)+n(1379)](e[n(1852)],this[n(1878)+n(720)]),this[n(1710)+"er"]&&window.addEventListener(e[n(1411)],this[n(1878)+"ffLine"]),this[n(1710)+"er"]&&window[n(514)+n(1379)](e[n(1134)],this[n(1158)+n(793)]),this._isBrowser&&window["addEvent"+n(1379)](e[n(1125)],this[n(1158)+"ageShow"])}[t(1911)+t(1393)+"Listener"](){let n=t;this[n(1710)+"er"]&&window["removeEv"+n(1834)+n(1792)](e[n(1852)],this[n(1878)+n(720)]),this[n(1710)+"er"]&&window[n(1663)+n(1834)+"ner"](e[n(1411)],this[n(1878)+n(1909)]),this[n(1710)+"er"]&&window["removeEv"+n(1834)+n(1792)](e[n(1134)],this["_handleP"+n(793)]),this[n(1710)+"er"]&&window[n(1663)+n(1834)+n(1792)](e[n(1125)],this["_handleP"+n(518)])}[t(1158)+t(793)](n){let s=t;!n[s(984)+"d"]&&(this[s(1710)+"er"]&&window["removeEv"+s(1834)+s(1792)](e[s(1134)],this["_handleP"+s(793)]),this[s(1710)+"er"]&&window[s(1663)+s(1834)+s(1792)](e[s(1125)],this._handlePageShow),this[s(872)]()),this[s(1710)+"er"]&&window["removeEv"+s(1834)+"ner"](e[s(1852)],this._handleOnLine),this[s(1710)+"er"]&&window[s(1663)+s(1834)+"ner"](e[s(1411)],this["_handleO"+s(1909)])}[t(1158)+t(518)](n){let s=t;n[s(984)+"d"]&&(this[s(820)+s(1454)]()&&(!this._ws||this[s(1476)][s(930)+"te"]!==this[s(1781)]||e[s(464)](this[s(1476)][s(930)+"te"],this[s(770)+"NG"]))&&this["_handleO"+s(720)](),this[s(1710)+"er"]&&window[s(514)+"Listener"](e[s(1852)],this["_handleO"+s(720)]),this._isBrowser&&window[s(514)+s(1379)](s(486),this["_handleO"+s(1909)]))}async[t(1660)+t(1787)](n){let s=t,{fpID:d,deviceID:u,bddID:p,ttwID:_,accessKey:v,aID:g,customParams:D={},enableAutoAck:L,enableQoS:N,QoSLevel:j,env:U}=this[s(1638)],W,$,ie;this[s(1710)+"er"]||this[s(1709)+"X"]||this[s(1875)+"T"]?(W=location&&e[s(1571)](e[s(1509)],location[s(1102)])?e[s(1721)]:e[s(1809)],$=n[s(1825)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),ie=/^wss(.*:\/\/)/[s(1279)](n)?n:""+W+$):e.oPtzP(e.CJQWz,s(717))?_0x408742[s(1755)][s(1452)+"ild"](_0x5a2295):(W=e[s(1721)],$=n.replace(/(^http)((?:[s]*:\/\/))/,""),ie=/(^ws)((?:[s]*:\/\/))/[s(1279)]($)?$:""+W+$);let Z=p?e.jFuty:_?e.xKtdI:e.lGGWS,Ce=p||_||u;if(e.WIeUj(!Ce,!Z))throw new Error(e[s(949)]);let Ue=e[s(1382)](e[s(646)],typeof D)?await e[s(1699)](D):D,Dn=U?e.dFoYY(Yh,U.xUseEnv,U[s(1017)]):{},Se=Object[s(694)]({device_platform:e[s(964)],version_code:e[s(1045)],access_key:v,fpid:d,aid:g,[Z]:Ce,xsack:L?1:0,xaack:L?1:0,xsqos:N?1:0,qos_level:N?j:void 0,qos_sdk_version:2,...Dn},Ue),Cn=Object[s(1267)](Se)[s(1150)]((Jr,pa)=>Se[pa]!==void 0?""+Jr+(Jr?"&":"?")+pa+"="+Se[pa]:Jr,"");return ie+s(1534)+Cn}async[t(512)](){let n=t;if(!(this[n(512)+n(1546)]||this[n(1027)+n(1516)])){this[n(512)+n(1546)]=!0;try{let s=this[n(1039)+n(1603)]?.[n(1524)+"rentEndp"+n(1271)+"hedMaxRe"+n(1258)](),{timeoutInterval:d}=this._options;if(s){let p=this["_endpoin"+n(1603)]?.[n(843)+n(1548)+"nt"](),_=this[n(1039)+n(1603)]?.[n(761)+n(1631)+"pointAnd"+n(482)+n(1127)](),v=this["_endpoin"+n(1603)]?.[n(843)+"ntEndpoi"+n(1377)+n(596)]();if(_){let g=n(752)+p+(n(1227)+", max retries re"+n(1491)+n(805)+n(1344)+n(1400))+_+(n(1263)+"y"),D=dt(e[n(1673)],{message:g,code:nn[n(1517)+"IES_ERROR"]});this[n(1054)](g),this[n(640)+n(1598)+n(1789)](D),this[n(1221)]=await this[n(1660)+"eUrl"](_),this[n(1054)](n(752)+_+" "+v+" times"),this[n(1847)+n(1568)+"rs"]()}else{let g=n(752)+p+(n(1227)+n(864)+n(749)+n(740));this[n(1054)](g),this[n(640)+n(1598)+n(1789)](e[n(1900)](dt,e.sKZmB,{message:g,code:nn[n(1517)+"IES_ERROR"]}));return}}else{let p=this[n(1039)+n(1603)]?.[n(843)+"ntEndpointAndUpd"+n(1720)](),_=this["_endpoin"+n(1603)]?.["getCurre"+n(1548)+n(1377)+n(596)]();this[n(1221)]=await this[n(1660)+n(1787)](p||""),this._debug(n(752)+p+" "+_+" times"),this[n(1847)+"sListeners"]()}if(this[n(1078)])this[n(1078)]=!1;else{let p=e[n(1007)](aa,n(660)+"t",{message:e.ZVhhx});this[n(1569)+n(1892)]&&this["onStartR"+n(1892)](p)}let u=this[n(1039)+n(1603)]?.["getCurre"+n(1548)+"ntTriesCount"]()||0;e[n(1388)](u,1)&&await this[n(691)](e[n(763)](u,1)),this._debug(n(815)+n(1591)+this[n(1221)]+(n(1680)+"ls: ")+this[n(1763)+"ls"]),this._ws=e[n(1959)]($h,{url:this[n(1221)],protocols:[this[n(1763)+"ls"]],headers:this[n(1638)][n(1358)+n(1429)+"s"][n(668)+n(1361)]},this[n(1638)].ws),(this._isBrowser||this._isWorker)&&this[n(1476)]&&(this[n(1476)][n(767)+"pe"]=this[n(680)+n(1101)]),this[n(1009)+n(1219)](),this[n(512)+n(1745)+n(470)]=e[n(1902)](setTimeout,this[n(1482)+"ut"][n(1458)](this),d)}catch(s){throw this._connectLock=!1,s}}}[t(1572)+t(908)](){let n=t;e[n(620)](clearTimeout,this["_connect"+n(1745)+n(470)]),this[n(512)+"ionTimeo"+n(470)]=null}[t(1131)+t(1813)](){let n=t;e[n(542)](clearTimeout,this[n(1945)+n(1282)+"Id"]),e[n(1212)](clearTimeout,this["_reconne"+n(1843)+n(1799)]),this[n(1945)+"gTimeoutId"]=null,this[n(1178)+n(1843)+n(1799)]=null}[t(1054)](...n){let s=t;this[s(1638)][s(1908)]&&console[s(839)][s(787)](console,[s(1166)+">",...n])}[t(1886)+"rvalValue"](n){let s=t,d={VtgTt:function(u,p,_){return e[ee(1337)](u,p,_)}};if(s(1682)===e[s(734)]){let{initReconnectInterval:u,maxReconnectInterval:p,reconnectIntervalGrowFactor:_}=this[s(1638)],v=e[s(898)](u,Math[s(784)](_,n-1));return e.pcEGx(v,p)?p:v}else xrauIB[s(1472)](_0x5e939e,_0x57cc67,74),xrauIB[s(1472)](_0x380216,_0x1d4b55,_0x31c5be)}[t(1822)](){let n=t;if(this[n(1476)]&&e[n(465)](this[n(1476)][n(930)+"te"],this[n(770)+"NG"])){this[n(1131)+n(1813)](),this[n(1945)+"gTimeoutId"]=e[n(1900)](setTimeout,this[n(1822)][n(1458)](this),this[n(1638)][n(771)+n(1313)]);return}if(!this._ws||e[n(1160)](this[n(1476)][n(930)+"te"],this.OPEN))return void this[n(1955)+n(1892)]();this[n(1476)]&&this._ws[n(678)]("hi"),this["_reconne"+n(1843)+"tId"]=e[n(875)](setTimeout,this[n(1955)+n(1892)+"Timeout"][n(1458)](this),this[n(1638)][n(1704)+"outInter"+n(824)])}["_handleR"+t(1892)+t(1437)](){let n=t;e.GdihQ===e[n(1357)]?(this[n(652)+n(743)]?.[n(1926)](),this[n(714)](e[n(1881)],e.ZNmqa),this._pingLossCounter?.[n(1737)+n(577)+"nt"]()?this[n(1955)+n(1892)]():this._ping()):this[n(999)+n(927)]()}[t(820)+t(1454)](){let n=t;return this[n(1875)+"T"]||this[n(1709)+"X"]?this["_miniNav"+n(1536)+"line"]:(this[n(1710)+"er"]||this[n(1186)+"r"])&&this[n(1638)][n(1082)+n(1113)+"nged"]?navigator.onLine:!0}[t(1955)+t(1892)](){let n=t;!this[n(820)+n(1454)]()||this[n(1027)+n(1516)]||(this[n(1039)+n(1603)]?.["resetEnd"+n(1566)+n(1969)](),this[n(652)+"sCounter"]?.[n(716)+n(970)](),this._ws?this["_disconn"+n(1664)](1001,e[n(530)],!0):this._connect())}[t(1935)+t(1425)+t(1264)](){let n=t;this[n(1875)+"T"]?tt["onNetwor"+n(1111)+n(1718)](({isConnected:s})=>{let d=n;this[d(669)+"igatorOn"+d(478)]=s,s?this[d(1878)+"nLine"]():this[d(1878)+d(1909)]()}):this[n(1709)+"X"]&&wx[n(1828)+n(1111)+n(1718)](({isConnected:s})=>{let d=n;this[d(669)+d(1536)+d(478)]=s,s?this[d(1878)+d(720)]():this[d(1878)+"ffLine"]()})}_wait(n){let s={KzSxZ:function(d,u,p){return d(u,p)}};return new Promise(d=>{let u=ee;s.KzSxZ(setTimeout,d,this["_getInte"+u(1859)+"e"](n))})}[t(601)+t(1664)](n=1e3,s="",d=!1){let u=t;this._ws&&this[u(1170)+u(1474)+"t"](n,s,d)}[t(1482)+"ut"](){let n=t,s=this[n(1039)+"tManager"]?.[n(843)+n(1548)+"nt"]();this._debug(n(752)+s+n(1227)),this[n(601)+n(1664)](1001,e.WYKBH,!0)}_sendAck(n){let s=t,d=Ut(n);this._ws&&e[s(1290)](this[s(1476)][s(930)+"te"],this[s(1781)])&&(this[s(1476)]&&this[s(1476)][s(678)](d),this[s(1054)](e[s(689)],n))}[t(1847)+t(1568)+"rs"](){let n=t,s=(n(1535)+"2")[n(549)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this[n(1476)])return;continue;case"1":this[n(1476)][n(1663)+n(1834)+"ner"](e[n(1375)],this[n(593)]);continue;case"2":this._ws["removeEventListe"+n(1792)](n(583),this[n(494)]);continue;case"3":this[n(1476)][n(1663)+n(1834)+n(1792)](e[n(1622)],this._onOpen);continue;case"4":this[n(1476)][n(1663)+"entListener"](e.znoJL,this._onMessage);continue}break}}[t(1009)+t(1219)](){let n=t,s=(n(1633)+"1").split("|"),d=0;for(;;){switch(s[d++]){case"0":this._ws[n(514)+n(1379)](e[n(1455)],this[n(1466)+"ge"]);continue;case"1":this[n(1476)][n(514)+n(1379)](e[n(1673)],this._onError);continue;case"2":this[n(1476)][n(514)+n(1379)](e[n(1622)],this[n(759)]);continue;case"3":if(!this._ws)return;continue;case"4":this._ws[n(514)+"Listener"](e[n(1375)],this[n(593)]);continue}break}}[t(1686)+t(755)](n=1e3,s=""){let d=t;try{this[d(1476)]&&this[d(1476)][d(872)](n,s)}catch{}}[t(1170)+t(1474)+"t"](n=1e3,s="",d=!1){let u=t;if(e.oPtzP(e.XZqpS,u(1426)))_0x19ea3a[u(839)](_0x301e87);else{if(this[u(1131)+u(1813)](),this["_clearTi"+u(908)](),this["_removeW"+u(1568)+"rs"](),this["_wsInsta"+u(755)](1e3,s),this[u(512)+"Lock"]=!1,d&&this[u(820)+u(1454)]()&&!this[u(1027)+u(1516)]){if(this["_endpoin"+u(1603)]?.[u(1737)+u(807)+"es"]()){if(e[u(1171)](e[u(1368)],e[u(1368)]))return this[u(1924)].isReady;{let _=this[u(1039)+"tManager"]?.["getCurre"+u(1548)+"nt"]();this[u(640)+u(938)+"ent"](gt(e[u(1375)],{code:1006,reason:u(752)+_+(u(1227)+", max re"+u(749)+"ached"),wasClean:!0}))}}else{let _=this[u(1638)][u(660)+u(1333)+u(674)](n,s);this[u(640)+"hCloseEv"+u(1789)](e[u(1700)](gt,e[u(1375)],{code:n,reason:s,wasClean:!0,willReconnect:_})),_&&this[u(512)]()}return}this._navigatorOnline()||this[u(1027)+"osed"]?this["_dispatchCloseEv"+u(1789)](gt(e.eiheR,{code:n,reason:u(1283)})):this[u(640)+u(938)+u(1789)](e[u(1920)](gt,e[u(1375)],{code:1006,reason:e[u(1450)]})),this[u(1476)]=null,this["_endpoin"+u(1603)]?.[u(1293)+u(1566)+u(1969)](),this[u(652)+u(743)]?.["resetCou"+u(970)]()}}[t(640)+"hOpenEvent"](n){let s=t;e[s(1070)]===e.BqsVS?(this[s(714)](e.CehiU,n),this.onopen&&this[s(1018)](n)):_0xd4d40.set(_0x2e8dab,_0x343b43)}[t(640)+t(1103)+t(950)](n){let s=t;this[s(714)](s(1958),n),this[s(726)+"e"]&&this[s(726)+"e"](n)}["_dispatc"+t(1596)+t(1949)](n){let s=t;this[s(714)](s(1025),n),this[s(962)+s(1321)]&&this[s(962)+s(1321)](n)}[t(640)+t(1598)+t(1789)](n){let s=t;this.emit(e[s(1673)],n),this[s(980)]&&this.onerror(n)}[t(640)+"hCloseEv"+t(1789)](n){let s=t;e[s(1438)](e[s(1309)],e.qlhNT)?_0x109716&&this._cursorManager[s(1202)+s(854)+s(1796)](_0x3bb27c):(this[s(714)](e.eiheR,n),this[s(1304)]&&this[s(1304)](n))}get[t(767)+"pe"](){let n=t;return this[n(1476)]?this[n(1476)][n(767)+"pe"]:this[n(680)+"ype"]}set[t(767)+"pe"](n){let s=t;e[s(1140)](e.dNdoW,e[s(503)])?(this[s(1815)]=!0,this[s(849)]=0|_0x368cd8,this.high=e.cfHuz(0,_0x4c2459),this[s(1222)]=!!_0xef3340):(this[s(680)+s(1101)]=n,this[s(1476)]&&(this._ws[s(767)+"pe"]=n))}get[t(1087)+"nt"](){let n=t;return this["_endpoin"+n(1603)]?.["getCurre"+n(1548)+n(1377)+n(596)]()||0}get[t(1029)+t(615)](){let n=t,s=this["_message"+n(792)].reduce((d,u)=>(d+=u&&u[n(1209)+"th"]||0,d),0);return e[n(1916)](s,this[n(1476)]?this[n(1476)][n(1029)+n(615)]:0)}get extensions(){let n=t;return this._ws?this[n(1476)][n(1364)+"ns"]:""}get[t(1102)](){return this._ws?this._ws.protocol:""}get[t(930)+"te"](){let n=t;return this._ws?this[n(1476)].readyState:this[n(1638)][n(693)+"cOpen"]?this.CONNECTING:this[n(1340)]}get url(){let n=t;return this[n(1476)]?this._ws[n(1229)]:this[n(1221)]}[t(872)](n=1e3,s){let d=t,u=e[d(863)][d(549)]("|"),p=0;for(;;){switch(u[p++]){case"0":this[d(1415)+d(1074)]?.[d(814)]();continue;case"1":this[d(1027)+d(1516)]=!0;continue;case"2":if(e[d(1806)](this[d(1476)][d(930)+"te"],this[d(1340)])||e[d(1206)](this[d(1476)][d(930)+"te"],this[d(1855)]))return void this[d(1054)](e[d(695)]);continue;case"3":this[d(1572)+d(908)]();continue;case"4":if(!this[d(1476)])return void this[d(1054)]("close, w"+d(519)+d(1588)+"nitialized");continue;case"5":this["_destroy"+d(1474)+"t"](n,s);continue;case"6":this[d(1911)+d(1393)+d(1379)]();continue;case"7":this[d(1131)+d(1813)]();continue}break}}async[t(678)](n,s){let d=t,u={XPNZc:function(ie,Z){return ie<Z},ranqX:function(ie,Z){return ie+Z},tDGZY:function(ie,Z,Ce,Ue){return ie(Z,Ce,Ue)},MbfWE:function(ie,Z){return e[ee(513)](ie,Z)}};if(e[d(1571)](null,n))throw new Error(d(821)+"rovide a"+d(1447)+"ata, data must b"+d(961)+d(696)+d(1128)+"ffer");e[d(594)]==typeof n&&(n=JSON[d(1518)+"y"](n)),e.dLBbm(e[d(1888)],typeof n)&&!e[d(1618)](n,ArrayBuffer)&&!(n[d(1775)]&&e[d(1618)](n[d(1775)],ArrayBuffer))&&(n=JSON[d(1518)+"y"](n));let p=await Yd(n),_=e[d(1254)](Vh,n),{method:v=0,service:g=this[d(1638)][d(946)],logID:D=this._options["logIDGen"+d(1625)](),headers:L=this._options.headers,payloadEncoding:N=this._options[d(1083)+d(1105)],payloadType:j=this[d(1638)]["payloadT"+d(1101)],logIDNew:U=this[d(1638)][d(804)+d(1453)]["enableAu"+d(1390)+d(1698)+"ew"]?e[d(620)](i,this[d(1638)][d(804)+"Config"][d(1585)]):""}=e[d(1376)](s,{});if(!g)throw new Error(e[d(992)]);let W={SeqID:fe[d(1445)+"er"](this[d(813)]++),LogID:fe.fromNumber(D),service:g,method:v,headers:L,payloadEncoding:N instanceof Object?N[d(595)]?N.encoding:"":N,payloadType:j instanceof Object?j[d(932)]?j[d(932)]:_:j||_,payload:p,LogIDNew:U},$=e[d(1668)](Ut,W);if(this[d(1476)]&&e.NjKeb(this[d(1476)][d(930)+"te"],this[d(1781)]))if(e[d(1274)](e[d(732)],d(1932)))this[d(1476)]&&this[d(1476)][d(678)]($),this._debug(e[d(1011)],W);else return _0x430cc1?byGXgA[d(832)](_0x31f363.length,40)?byGXgA[d(1644)](byGXgA[d(737)](_0x2fe4fa,_0x25a224,_0x5f167b,_0x3327ad),_0x28bb70):_0x3677ac[d(1665)+"e"]?byGXgA[d(1644)](_0x58b7c3.utf8Write(_0x98d71f,_0x2ac673),_0x3e1383):_0x38c320[d(698)]?byGXgA[d(1644)](_0x4ebbf7.write(_0x11eece,_0x92ff0a),_0x724fd9):byGXgA.MbfWE(_0x124dd9(_0x108368,_0xe2dd18,_0x9cb36f),_0x4451af):_0x1ca18f;else if(this["_message"+d(792)][d(546)]<this[d(1638)]["maxMessa"+d(901)+d(1917)])this["_message"+d(792)].push($),this._debug(e[d(1322)],W);else if(e[d(1141)](e[d(721)],d(1139)))this["_message"+d(792)][d(700)](),this[d(1904)+"Queue"][d(1230)]($);else{let ie={AYjRo:function(Ce,Ue){return e[d(1866)](Ce,Ue)},cBEVl:e[d(772)]},Z=_0x173457[d(1161)+d(1167)](e[d(1401)]);_0x4e2a6b[d(1607)+"JSONP"]=Ce=>{let Ue=d;_0x2d0538[Ue(1755)][Ue(1452)+Ue(1342)](Z),_0x3ccc2b[Ue(1607)+Ue(881)]=void 0,ie.AYjRo(_0x1b934b,Ce&&Ce[Ue(1785)]||ie[Ue(603)])},Z[d(932)]=e[d(488)],Z[d(510)]=e.oQVVh(_0xda54f7[d(1825)](/^ws/,e[d(654)]),d(1896)+d(1026)+d(1501)+"P");try{_0x2e51ae.body[d(1396)+"ild"](Z)}catch{_0x12d1bf[d(1755)][d(1452)+d(1342)](Z)}}return{seqID:this[d(813)],logID:D,logIDNew:U}}async reconnect(n){let s=t,{url:d}=n||{},u=Array[s(753)](d)?d:e[s(606)](e.vFcBE,typeof d)?[d]:[];n&&Object.assign(this[s(1638)],n),u&&u[s(546)]?this["_endpoin"+s(1603)]=new Kd(u,this[s(1638)][s(826)+"es"]):this[s(1039)+s(1603)]?.[s(1293)+s(1566)+s(1969)](),this[s(652)+s(743)]?.[s(716)+s(970)](this[s(1638)][s(1231)+"Count"]),this[s(1027)+"osed"]=!1,this[s(1476)]&&e[s(1438)](this[s(1476)][s(930)+"te"],this[s(1340)])?this[s(601)+"ect"](1e3,e.YtoQI,!0):(this._isInit=!0,this[s(512)]())}async[t(1646)](){let n=t;!this[n(512)+n(1546)]&&(this[n(1039)+n(1603)]?.[n(1293)+n(1566)+n(1969)](),this[n(652)+"sCounter"]?.[n(716)+n(970)](),this[n(1027)+"osed"]=!1,this._isInit=!0,this[n(512)]())}[t(514)+t(1379)](n,s){this.on(n,s)}[t(1547)+"Event"](n){let s=t,d={CuDkJ:function(u,p){return u(p)},XcFbv:function(u){return e.EdphB(u)}};if(e[s(1317)](e[s(976)],e[s(1805)]))this[s(1078)]=!1,DMAhgG[s(811)](_0x4b1522,this[s(512)+s(1745)+s(470)]),DMAhgG[s(1242)](_0x1fcb3e);else{let{type:u}=n;this.emit(u,n)}}["removeEv"+t(1834)+t(1792)](n,s){this[t(1012)](n,s)}[t(1537)](){let n=t,s={NUQkV:function(d,u){return e[ee(545)](d,u)},bauUt:e.cPgSx,NesDT:n(1033),dLUfc:function(d,u){return e.NXDKw(d,u)},WjDqE:e[n(1608)],thLJs:e[n(1881)]};return new Promise((d,u)=>{let p=n,_={dcGCd:p(1153)};this["_clearPi"+p(1813)](),this[p(1945)+p(1282)+"Id"]=setTimeout(this[p(1822)].bind(this),this[p(1638)][p(771)+p(1313)]);let v=()=>{let D=p;if(s[D(840)](s[D(1169)],s[D(1053)]))return _0x4efb1e["objectSt"+D(1863)]||_0x230e39.get(_0x591750);s.dLUfc(d,"success"),this[D(1012)](s[D(1605)],v),this[D(1012)](s.thLJs,g)},g=()=>{let D=p;u(_.dcGCd),this.off("ping_onc"+D(1819)+"s",v),this.off("ping_onc"+D(1320)+"t",g)};this.on(s[p(1605)],v),this.on(s[p(1557)],g),this[p(1822)]()})}}})(),Fe["CustomCl"+M(1558)]=Pe[M(1005)+M(1558)],Fe[M(1335)+M(957)]=Pe[M(1335)+M(957)],Fe[M(795)+"e"]=Pe.ErrorCode,Fe[M(950)]=Pe.Event,Fe[M(1735)]=Pe[M(1735)],Fe[M(948)+"MessageE"+M(1695)]=Pe[M(948)+"MessageE"+M(1695)],Fe["MessageE"+M(1695)]=Pe["MessageE"+M(1695)],Fe.OpenEvent=Pe[M(1049)+"t"],Fe[M(1937)+"tEvent"]=Pe[M(1937)+"tEvent"],Fe[M(524)+M(1558)]=Pe["createCl"+M(1558)],Fe[M(1120)+"rorEvent"]=Pe[M(1120)+"rorEvent"],Fe[M(1862)+"ssageEvent"]=Pe[M(1862)+M(527)+"nt"],Fe["createOp"+M(618)]=Pe[M(735)+M(618)],Fe[M(1729)+M(746)+M(1695)]=Pe[M(1729)+M(746)+M(1695)],Fe[M(1652)+"rame"]=Pe["decodedF"+M(1410)],Fe[M(704)+M(1788)]=Pe[M(704)+M(1788)];for(bo in Pe)["CustomCl"+M(1558),M(1335)+M(957),M(795)+"e","Event",M(1735),"Frontier"+M(1586)+M(1695),M(1586)+"vent",M(1049)+"t","Reconnec"+M(1386),M(524)+"oseEvent",M(1120)+M(957),M(1862)+"ssageEvent",M(735)+M(618),M(1729)+M(746)+M(1695),M(1652)+M(1410),M(704)+M(1788)][M(1592)](bo)===-1&&(Fe[bo]=Pe[bo]);var bo;Object[M(487)+M(1366)](Fe,"__esModule",{value:!0})});var Vt=ce((L3,Vu)=>{"use strict";var $u=["nodebuffer","arraybuffer","fragments"],Ju=typeof Blob<"u";Ju&&$u.push("blob");Vu.exports={BINARY_TYPES:$u,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Ju,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ji=ce((N3,Co)=>{"use strict";var{EMPTY_BUFFER:CE}=Vt(),nd=Buffer[Symbol.species];function RE(t,e){if(t.length===0)return CE;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new nd(r.buffer,r.byteOffset,i):r}function Yu(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Zu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function kE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function rd(t){if(rd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new nd(t):ArrayBuffer.isView(t)?e=new nd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),rd.readOnly=!1),e}Co.exports={concat:RE,mask:Yu,toArrayBuffer:kE,toBuffer:rd,unmask:Zu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");Co.exports.mask=function(e,r,i,o,c){c<48?Yu(e,r,i,o,c):t.mask(e,r,i,o,c)},Co.exports.unmask=function(e,r){e.length<32?Zu(e,r):t.unmask(e,r)}}catch{}});var ex=ce((M3,Qu)=>{"use strict";var Xu=Symbol("kDone"),id=Symbol("kRun"),sd=class{constructor(e){this[Xu]=()=>{this.pending--,this[id]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[id]()}[id](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Xu])}}};Qu.exports=sd});var Lr=ce((B3,ix)=>{"use strict";var Hi=ue("zlib"),tx=ji(),PE=ex(),{kStatusCode:nx}=Vt(),OE=Buffer[Symbol.species],LE=Buffer.from([0,0,255,255]),ko=Symbol("permessage-deflate"),Yt=Symbol("total-length"),Pr=Symbol("callback"),Sn=Symbol("buffers"),Or=Symbol("error"),Ro,od=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 PE(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Pr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Ro.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Ro.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[ko]=this,this._inflate[Yt]=0,this._inflate[Sn]=[],this._inflate.on("error",ME),this._inflate.on("data",rx)}this._inflate[Pr]=i,this._inflate.write(e),r&&this._inflate.write(LE),this._inflate.flush(()=>{let c=this._inflate[Or];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=tx.concat(this._inflate[Sn],this._inflate[Yt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Yt]=0,this._inflate[Sn]=[],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[Yt]=0,this._deflate[Sn]=[],this._deflate.on("data",NE)}this._deflate[Pr]=i,this._deflate.write(e),this._deflate.flush(Hi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=tx.concat(this._deflate[Sn],this._deflate[Yt]);r&&(c=new OE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Pr]=null,this._deflate[Yt]=0,this._deflate[Sn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};ix.exports=od;function NE(t){this[Sn].push(t),this[Yt]+=t.length}function rx(t){if(this[Yt]+=t.length,this[ko]._maxPayload<1||this[Yt]<=this[ko]._maxPayload){this[Sn].push(t);return}this[Or]=new RangeError("Max payload size exceeded"),this[Or].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Or][nx]=1009,this.removeListener("data",rx),this.reset()}function ME(t){if(this[ko]._inflate=null,this[Or]){this[Pr](this[Or]);return}t[nx]=1007,this[Pr](t)}});var Nr=ce((z3,Po)=>{"use strict";var{isUtf8:sx}=ue("buffer"),{hasBlob:BE}=Vt(),zE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function FE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ad(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function UE(t){return BE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Po.exports={isBlob:UE,isValidStatusCode:FE,isValidUTF8:ad,tokenChars:zE};if(sx)Po.exports.isValidUTF8=function(t){return t.length<24?ad(t):sx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");Po.exports.isValidUTF8=function(e){return e.length<32?ad(e):t(e)}}catch{}});var ud=ce((F3,ux)=>{"use strict";var{Writable:qE}=ue("stream"),ox=Lr(),{BINARY_TYPES:GE,EMPTY_BUFFER:ax,kStatusCode:jE,kWebSocket:HE}=Vt(),{concat:cd,toArrayBuffer:WE,unmask:KE}=ji(),{isValidStatusCode:$E,isValidUTF8:cx}=Nr(),Oo=Buffer[Symbol.species],xt=0,dx=1,lx=2,fx=3,dd=4,ld=5,Lo=6,fd=class extends qE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||GE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[HE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=xt}_write(e,r,i){if(this._opcode===8&&this._state==xt)return i();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 Oo(i.buffer,i.byteOffset+e,i.length-e),new Oo(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 Oo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case xt:this.getInfo(e);break;case dx:this.getPayloadLength16(e);break;case lx:this.getPayloadLength64(e);break;case fx:this.getMask();break;case dd:this.getData(e);break;case ld:case Lo: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[ox.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=dx:this._payloadLength===127?this._state=lx: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=fx:this._state=dd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=dd}getData(e){let r=ax;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&KE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ld,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[ox.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===xt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=xt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=cd(i,r):this._binaryType==="arraybuffer"?o=WE(cd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=xt):(this._state=Lo,setImmediate(()=>{this.emit("message",o,!0),this._state=xt,this.startLoop(e)}))}else{let o=cd(i,r);if(!this._skipUTF8Validation&&!cx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ld||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=xt):(this._state=Lo,setImmediate(()=>{this.emit("message",o,!1),this._state=xt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ax),this.end();else{let i=e.readUInt16BE(0);if(!$E(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Oo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!cx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=xt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=xt):(this._state=Lo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=xt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[jE]=o,l}};ux.exports=fd});var pd=ce((q3,px)=>{"use strict";var{Duplex:U3}=ue("stream"),{randomFillSync:JE}=ue("crypto"),xx=Lr(),{EMPTY_BUFFER:VE,kWebSocket:YE,NOOP:ZE}=Vt(),{isBlob:Mr,isValidStatusCode:XE}=Nr(),{mask:hx,toBuffer:Kn}=ji(),ht=Symbol("kByteLength"),QE=Buffer.alloc(4),No=8*1024,$n,Br=No,It=0,eb=1,tb=2,xd=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=It,this.onerror=ZE,this[YE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||QE,r.generateMask?r.generateMask(i):(Br===No&&($n===void 0&&($n=Buffer.alloc(No)),JE($n,0,No),Br=0),i[0]=$n[Br++],i[1]=$n[Br++],i[2]=$n[Br++],i[3]=$n[Br++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||l)&&r[ht]!==void 0?f=r[ht]:(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?(hx(e,i,h,c,f),[h]):(hx(e,i,e,0,f),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=VE;else{if(typeof e!="number"||!XE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let 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={[ht]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==It?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Mr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Mr(e)?this._state!==It?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==It?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Mr(e)?(o=e.size,c=!1):(e=Kn(e),o=e.length,c=Kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Mr(e)?this._state!==It?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==It?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[xx.extensionName],c=r.binary?2:1,l=r.compress,f,x;typeof e=="string"?(f=Buffer.byteLength(e),x=!1):Mr(e)?(f=e.size,x=!1):(e=Kn(e),f=e.length,x=Kn.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={[ht]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Mr(e)?this._state!==It?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==It?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ht],this._state=tb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(hd,this,f,o);return}this._bufferedBytes-=i[ht];let l=Kn(c);r?this.dispatch(l,r,i,o):(this._state=It,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(nb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[xx.extensionName];this._bufferedBytes+=i[ht],this._state=eb,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");hd(this,x,o);return}this._bufferedBytes-=i[ht],this._state=It,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===It&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ht],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ht],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};px.exports=xd;function hd(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function nb(t,e,r){hd(t,e,r),t.onerror(e)}});var Ix=ce((G3,Sx)=>{"use strict";var{kForOnEventAttribute:Wi,kListener:gd}=Vt(),gx=Symbol("kCode"),mx=Symbol("kData"),_x=Symbol("kError"),yx=Symbol("kMessage"),Ex=Symbol("kReason"),zr=Symbol("kTarget"),bx=Symbol("kType"),vx=Symbol("kWasClean"),Zt=class{constructor(e){this[zr]=null,this[bx]=e}get target(){return this[zr]}get type(){return this[bx]}};Object.defineProperty(Zt.prototype,"target",{enumerable:!0});Object.defineProperty(Zt.prototype,"type",{enumerable:!0});var Jn=class extends Zt{constructor(e,r={}){super(e),this[gx]=r.code===void 0?0:r.code,this[Ex]=r.reason===void 0?"":r.reason,this[vx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[gx]}get reason(){return this[Ex]}get wasClean(){return this[vx]}};Object.defineProperty(Jn.prototype,"code",{enumerable:!0});Object.defineProperty(Jn.prototype,"reason",{enumerable:!0});Object.defineProperty(Jn.prototype,"wasClean",{enumerable:!0});var Fr=class extends Zt{constructor(e,r={}){super(e),this[_x]=r.error===void 0?null:r.error,this[yx]=r.message===void 0?"":r.message}get error(){return this[_x]}get message(){return this[yx]}};Object.defineProperty(Fr.prototype,"error",{enumerable:!0});Object.defineProperty(Fr.prototype,"message",{enumerable:!0});var Ki=class extends Zt{constructor(e,r={}){super(e),this[mx]=r.data===void 0?null:r.data}get data(){return this[mx]}};Object.defineProperty(Ki.prototype,"data",{enumerable:!0});var rb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Wi]&&o[gd]===e&&!o[Wi])return;let i;if(t==="message")i=function(c,l){let f=new Ki("message",{data:l?c:c.toString()});f[zr]=this,Mo(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[zr]=this,Mo(e,this,f)};else if(t==="error")i=function(c){let l=new Fr("error",{error:c,message:c.message});l[zr]=this,Mo(e,this,l)};else if(t==="open")i=function(){let c=new Zt("open");c[zr]=this,Mo(e,this,c)};else return;i[Wi]=!!r[Wi],i[gd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[gd]===e&&!r[Wi]){this.removeListener(t,r);break}}};Sx.exports={CloseEvent:Jn,ErrorEvent:Fr,Event:Zt,EventTarget:rb,MessageEvent:Ki};function Mo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Bo=ce((j3,Ax)=>{"use strict";var{tokenChars:$i}=Nr();function Ft(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function ib(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,f,x=-1,h=-1,m=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),l===void 0)if(m===-1&&$i[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let y=t.slice(x,m);h===44?(Ft(e,y,r),r=Object.create(null)):l=y,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(f===void 0)if(m===-1&&$i[h]===1)x===-1&&(x=E);else if(h===32||h===9)m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Ft(r,t.slice(x,m),!0),h===44&&(Ft(e,l,r),r=Object.create(null),l=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)f=t.slice(x,E),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if($i[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:i||(i=!0),o=!1}else if(c)if($i[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,m=E;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&$i[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))m===-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let y=t.slice(x,m);i&&(y=y.replace(/\\/g,""),i=!1),Ft(r,f,y),h===44&&(Ft(e,l,r),r=Object.create(null),l=void 0),f=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let A=t.slice(x,m);return l===void 0?Ft(e,A,r):(f===void 0?Ft(r,A,!0):i?Ft(r,f,A.replace(/\\/g,"")):Ft(r,f,A),Ft(e,l,r)),e}function sb(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ax.exports={format:sb,parse:ib}});var qo=ce((K3,zx)=>{"use strict";var ob=ue("events"),ab=ue("https"),cb=ue("http"),Cx=ue("net"),db=ue("tls"),{randomBytes:lb,createHash:fb}=ue("crypto"),{Duplex:H3,Readable:W3}=ue("stream"),{URL:md}=ue("url"),In=Lr(),ub=ud(),xb=pd(),{isBlob:hb}=Nr(),{BINARY_TYPES:Tx,CLOSE_TIMEOUT:pb,EMPTY_BUFFER:zo,GUID:gb,kForOnEventAttribute:wd,kListener:mb,kStatusCode:wb,kWebSocket:We,NOOP:Rx}=Vt(),{EventTarget:{addEventListener:_b,removeEventListener:yb}}=Ix(),{format:Eb,parse:bb}=Bo(),{toBuffer:vb}=ji(),kx=Symbol("kAborted"),_d=[8,13],Xt=["CONNECTING","OPEN","CLOSING","CLOSED"],Sb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,we=class t extends ob{constructor(e,r,i){super(),this._binaryType=Tx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=zo,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]),Px(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Tx.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new ub({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new xb(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[We]=this,c[We]=this,e[We]=this,o.on("conclude",Tb),o.on("drain",Db),o.on("error",Cb),o.on("message",Rb),o.on("ping",kb),o.on("pong",Pb),c.onerror=Ob,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Nx),e.on("data",Uo),e.on("end",Mx),e.on("error",Bx),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[In.extensionName]&&this._extensions[In.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){ct(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())}),Lx(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){yd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||zo,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){yd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||zo,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){yd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[In.extensionName]||(o.compress=!1),this._sender.send(e||zo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ct(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(we,"CONNECTING",{enumerable:!0,value:Xt.indexOf("CONNECTING")});Object.defineProperty(we.prototype,"CONNECTING",{enumerable:!0,value:Xt.indexOf("CONNECTING")});Object.defineProperty(we,"OPEN",{enumerable:!0,value:Xt.indexOf("OPEN")});Object.defineProperty(we.prototype,"OPEN",{enumerable:!0,value:Xt.indexOf("OPEN")});Object.defineProperty(we,"CLOSING",{enumerable:!0,value:Xt.indexOf("CLOSING")});Object.defineProperty(we.prototype,"CLOSING",{enumerable:!0,value:Xt.indexOf("CLOSING")});Object.defineProperty(we,"CLOSED",{enumerable:!0,value:Xt.indexOf("CLOSED")});Object.defineProperty(we.prototype,"CLOSED",{enumerable:!0,value:Xt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(we.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(we.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[wd])return e[mb];return null},set(e){for(let r of this.listeners(t))if(r[wd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[wd]:!0})}})});we.prototype.addEventListener=_b;we.prototype.removeEventListener=yb;zx.exports=we;function Px(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:pb,protocolVersion:_d[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,!_d.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${_d.join(", ")})`);let c;if(e instanceof md)c=e;else try{c=new md(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;Fo(t,I);return}let h=l?443:80,m=lb(16).toString("base64"),E=l?ab.request:cb.request,A=new Set,y;if(o.createConnection=o.createConnection||(l?Ab:Ib),o.defaultPort=o.defaultPort||h,o.port=c.port||h,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new In({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Eb({[In.extensionName]:y.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Sb.test(I)||A.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),f){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let b;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=l,t._originalHostOrSocketPath=f?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[S,C]of Object.entries(I))i.headers[S.toLowerCase()]=C}else if(t.listenerCount("redirect")===0){let I=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),b=t._req=E(o),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=E(o);o.timeout&&b.on("timeout",()=>{ct(t,b,"Opening handshake has timed out")}),b.on("error",I=>{b===null||b[kx]||(b=t._req=null,Fo(t,I))}),b.on("response",I=>{let S=I.headers.location,C=I.statusCode;if(S&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){ct(t,b,"Maximum redirects exceeded");return}b.abort();let O;try{O=new md(S,e)}catch{let R=new SyntaxError(`Invalid URL: ${S}`);Fo(t,R);return}Px(t,O,r,i)}else t.emit("unexpected-response",b,I)||ct(t,b,`Unexpected server response: ${I.statusCode}`)}),b.on("upgrade",(I,S,C)=>{if(t.emit("upgrade",I),t.readyState!==we.CONNECTING)return;b=t._req=null;let O=I.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){ct(t,S,"Invalid Upgrade header");return}let w=fb("sha1").update(m+gb).digest("base64");if(I.headers["sec-websocket-accept"]!==w){ct(t,S,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],k;if(R!==void 0?A.size?A.has(R)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":A.size&&(k="Server sent no subprotocol"),k){ct(t,S,k);return}R&&(t._protocol=R);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!y){ct(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=bb(B)}catch{ct(t,S,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(z);if(V.length!==1||V[0]!==In.extensionName){ct(t,S,"Server indicated an extension that was not requested");return}try{y.accept(z[In.extensionName])}catch{ct(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[In.extensionName]=y}t.setSocket(S,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(b,t):b.end()}function Fo(t,e){t._readyState=we.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ib(t){return t.path=t.socketPath,Cx.connect(t)}function Ab(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Cx.isIP(t.host)?"":t.host),db.connect(t)}function ct(t,e,r){t._readyState=we.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ct),e.setHeader?(e[kx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Fo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function yd(t,e,r){if(e){let i=hb(e)?e.size:vb(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Xt[t.readyState]})`);process.nextTick(r,i)}}function Tb(t,e){let r=this[We];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[We]!==void 0&&(r._socket.removeListener("data",Uo),process.nextTick(Ox,r._socket),t===1005?r.close():r.close(t,e))}function Db(){let t=this[We];t.isPaused||t._socket.resume()}function Cb(t){let e=this[We];e._socket[We]!==void 0&&(e._socket.removeListener("data",Uo),process.nextTick(Ox,e._socket),e.close(t[wb])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Dx(){this[We].emitClose()}function Rb(t,e){this[We].emit("message",t,e)}function kb(t){let e=this[We];e._autoPong&&e.pong(t,!this._isServer,Rx),e.emit("ping",t)}function Pb(t){this[We].emit("pong",t)}function Ox(t){t.resume()}function Ob(t){let e=this[We];e.readyState!==we.CLOSED&&(e.readyState===we.OPEN&&(e._readyState=we.CLOSING,Lx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Lx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Nx(){let t=this[We];if(this.removeListener("close",Nx),this.removeListener("data",Uo),this.removeListener("end",Mx),t._readyState=we.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[We]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Dx),t._receiver.on("finish",Dx))}function Uo(t){this[We]._receiver.write(t)||this.pause()}function Mx(){let t=this[We];t._readyState=we.CLOSING,t._receiver.end(),this.end()}function Bx(){let t=this[We];this.removeListener("error",Bx),this.on("error",Rx),t&&(t._readyState=we.CLOSING,this.destroy())}});var Gx=ce((J3,qx)=>{"use strict";var $3=qo(),{Duplex:Lb}=ue("stream");function Fx(t){t.emit("close")}function Nb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ux(t){this.removeListener("error",Ux),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Mb(t,e){let r=!0,i=new Lb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let 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(Fx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Fx,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",Nb),i.on("error",Ux),i}qx.exports=Mb});var Ed=ce((V3,jx)=>{"use strict";var{tokenChars:Bb}=Nr();function zb(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&Bb[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let 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:zb}});var Yx=ce((Z3,Vx)=>{"use strict";var Fb=ue("events"),Go=ue("http"),{Duplex:Y3}=ue("stream"),{createHash:Ub}=ue("crypto"),Hx=Bo(),Vn=Lr(),qb=Ed(),Gb=qo(),{CLOSE_TIMEOUT:jb,GUID:Hb,kWebSocket:Wb}=Vt(),Kb=/^[+/0-9A-Za-z]{22}==$/,Wx=0,Kx=1,Jx=2,bd=class extends Fb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:jb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Gb,...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=Go.createServer((i,o)=>{let c=Go.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=$b(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Wx}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===Jx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ji,this);return}if(e&&this.once("close",e),this._state!==Kx)if(this._state=Kx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ji,this):process.nextTick(Ji,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ji(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",$x);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Yn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Yn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Kb.test(c)){Yn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){Yn(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=qb.parse(x)}catch{Yn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let A=new Vn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Hx.parse(m);y[Vn.extensionName]&&(A.accept(y[Vn.extensionName]),E[Vn.extensionName]=A)}catch{Yn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(y,b,I,S)=>{if(!y)return Vi(r,b||401,I,S);this.completeUpgrade(E,c,h,e,r,i,o)});return}if(!this.options.verifyClient(A))return Vi(r,401)}this.completeUpgrade(E,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[Wb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wx)return Vi(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ub("sha1").update(r+Hb).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[Vn.extensionName]){let E=e[Vn.extensionName].params,A=Hx.format({[Vn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${A}`),m._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
15
15
  `).join(`\r
16
- `)),c.removeListener("error",jh),m.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ji,this)})),u(m,o)}};Wh.exports=_d;function $b(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function ji(t){t._state=Gh,t.emit("close")}function jh(){this.destroy()}function Gi(t,e,r,i){r=r||Bo.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Bo.STATUS_CODES[e]}\r
16
+ `)),c.removeListener("error",$x),m.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ji,this)})),f(m,o)}};Vx.exports=bd;function $b(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function Ji(t){t._state=Jx,t.emit("close")}function $x(){this.destroy()}function Vi(t,e,r,i){r=r||Go.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} ${Go.STATUS_CODES[e]}\r
17
17
  `+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
18
18
  `)+`\r
19
19
  \r
20
- `+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else Gi(r,i,o,c)}});import{existsSync as mv,openSync as wv}from"node:fs";import{mkdir as _v}from"node:fs/promises";import{dirname as yv}from"node:path";import{fileURLToPath as Ev}from"node:url";function vv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function vd(t=Z()){return mv(t.libEntry)?t.libEntry:Ev(new URL("../index.ts",import.meta.url))}async function ox(t={}){let e=t.paths??Z(),r=t.entryOverride??vd(e),i=vv(e,process.env.COZE_BRIDGE_LOG_MODE);await _v(yv(i),{recursive:!0});let o=wv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=lt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[$i]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return bv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var bv,$i,jo=Ze(()=>{"use strict";yn();te();Ne();bv=U("spawn-daemon"),$i="COZE_BRIDGE_DAEMON"});import{spawn as uS}from"node:child_process";import{mkdir as fS,unlink as hS,writeFile as xS}from"node:fs/promises";import{dirname as pS,join as gS}from"node:path";function Fr(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function mS(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Fr(r)}</key>
21
- <string>${Fr(i)}</string>`).join(`
20
+ `+r)}function Yn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Yn),t.emit("wsClientError",l,r,e)}else Vi(r,i,o,c)}});import{existsSync as mv,openSync as wv}from"node:fs";import{mkdir as _v}from"node:fs/promises";import{dirname as yv}from"node:path";import{fileURLToPath as Ev}from"node:url";function vv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ad(t=Q()){return mv(t.libEntry)?t.libEntry:Ev(new URL("../index.ts",import.meta.url))}async function lh(t={}){let e=t.paths??Q(),r=t.entryOverride??Ad(e),i=vv(e,process.env.COZE_BRIDGE_LOG_MODE);await _v(yv(i),{recursive:!0});let o=wv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=ut(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Xi]:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return bv.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var bv,Xi,Jo=Qe(()=>{"use strict";bn();se();Ne();bv=q("spawn-daemon"),Xi="COZE_BRIDGE_DAEMON"});import{spawn as f2}from"node:child_process";import{mkdir as u2,unlink as x2,writeFile as h2}from"node:fs/promises";import{dirname as p2,join as g2}from"node:path";function jr(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function m2(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${jr(r)}</key>
21
+ <string>${jr(i)}</string>`).join(`
22
22
  `);return e?`
23
23
  <key>EnvironmentVariables</key>
24
24
  <dict>
25
25
  ${e}
26
- </dict>`:""}function wS(t,e){return new Promise((r,i)=>{let o=uS(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var zr,Vi,Yo,Dd,Sx=Ze(()=>{"use strict";te();zr=U("supervisor.launchd"),Vi="ai.coze.bridge",Yo=wS,Dd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
26
+ </dict>`:""}function w2(t,e){return new Promise((r,i)=>{let o=f2(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 Gr,es,ta,Od,Th=Qe(()=>{"use strict";se();Gr=q("supervisor.launchd"),es="ai.coze.bridge",ta=w2,Od={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
27
27
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
28
28
  <plist version="1.0">
29
29
  <dict>
30
30
  <key>Label</key>
31
- <string>${Vi}</string>
31
+ <string>${es}</string>
32
32
  <key>ProgramArguments</key>
33
33
  <array>
34
- <string>${Fr(t.nodeBin)}</string>
35
- <string>${Fr(t.entry)}</string>
34
+ <string>${jr(t.nodeBin)}</string>
35
+ <string>${jr(t.entry)}</string>
36
36
  <string>--daemon</string>
37
37
  </array>
38
38
  <key>RunAtLoad</key>
@@ -42,13 +42,13 @@ ${e}
42
42
  <key>ThrottleInterval</key>
43
43
  <integer>10</integer>
44
44
  <key>StandardOutPath</key>
45
- <string>${Fr(t.logFile)}</string>
45
+ <string>${jr(t.logFile)}</string>
46
46
  <key>StandardErrorPath</key>
47
- <string>${Fr(t.logFile)}</string>${mS(t.env)}
47
+ <string>${jr(t.logFile)}</string>${m2(t.env)}
48
48
  </dict>
49
49
  </plist>
50
- `},configPath(t){return gS(t.homeDir,"Library","LaunchAgents",`${Vi}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await fS(pS(i),{recursive:!0}),await xS(i,this.renderConfig(t),"utf8"),zr.info("plist written",{plistPath:i,activate:r}),!r)return;await Yo("launchctl",["unload","-w",i]).catch(c=>zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await Yo("launchctl",["load","-w",i]),zr.info("launchd job loaded",{label:Vi});let o=process.getuid?.()??0;await Yo("launchctl",["kickstart","-k",`gui/${o}/${Vi}`]),zr.info("launchd job kickstarted",{label:Vi,uid:o})},async uninstall(t){let e=this.configPath(t);await Yo("launchctl",["unload","-w",e]).catch(r=>zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await hS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),zr.info("launchd job removed",{plistPath:e})}}});import{spawn as _S}from"node:child_process";import{mkdir as yS,unlink as ES,writeFile as bS}from"node:fs/promises";import{dirname as vS,join as Ix}from"node:path";function Xo(t,e){return t.isRoot?e:["--user",...e]}function IS(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
51
- `):""}function Qo(t,e){return new Promise((r,i)=>{let o=_S(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Zo,Ur,SS,kd,Ax=Ze(()=>{"use strict";te();Zo=U("supervisor.systemd"),Ur="coze-bridge.service",SS="/etc/systemd/system";kd={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
50
+ `},configPath(t){return g2(t.homeDir,"Library","LaunchAgents",`${es}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await u2(p2(i),{recursive:!0}),await h2(i,this.renderConfig(t),"utf8"),Gr.info("plist written",{plistPath:i,activate:r}),!r)return;await ta("launchctl",["unload","-w",i]).catch(c=>Gr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ta("launchctl",["load","-w",i]),Gr.info("launchd job loaded",{label:es});let o=process.getuid?.()??0;await ta("launchctl",["kickstart","-k",`gui/${o}/${es}`]),Gr.info("launchd job kickstarted",{label:es,uid:o})},async uninstall(t){let e=this.configPath(t);await ta("launchctl",["unload","-w",e]).catch(r=>Gr.warn("launchctl unload failed (ignored)",{err:String(r)})),await x2(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Gr.info("launchd job removed",{plistPath:e})}}});import{spawn as _2}from"node:child_process";import{mkdir as y2,unlink as E2,writeFile as b2}from"node:fs/promises";import{dirname as v2,join as Dh}from"node:path";function ra(t,e){return t.isRoot?e:["--user",...e]}function I2(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
51
+ `):""}function ia(t,e){return new Promise((r,i)=>{let o=_2(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 na,Hr,S2,Ld,Ch=Qe(()=>{"use strict";se();na=q("supervisor.systemd"),Hr="coze-bridge.service",S2="/etc/systemd/system";Ld={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
- ${IS(t.env)}
62
+ ${I2(t.env)}
63
63
  [Install]
64
64
  WantedBy=${e}
65
- `},configPath(t){return t.isRoot?Ix(SS,Ur):Ix(t.homeDir,".config","systemd","user",Ur)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await yS(vS(i),{recursive:!0}),await bS(i,this.renderConfig(t),"utf8"),Zo.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await Qo("systemctl",Xo(t,["daemon-reload"])),await Qo("systemctl",Xo(t,r?["enable","--now",Ur]:["enable",Ur])),Zo.info("systemd unit enabled",{unitName:Ur,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await Qo("systemctl",Xo(t,["disable","--now",Ur])).catch(r=>Zo.warn("systemctl disable failed (ignored)",{err:String(r)})),await ES(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Qo("systemctl",Xo(t,["daemon-reload"])).catch(()=>{}),Zo.info("systemd unit removed",{unitPath:e})}}});import{spawn as AS}from"node:child_process";import{join as TS}from"node:path";function Tx(t,e){return new Promise((r,i)=>{let o=AS(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Od,ea,Pd,Rx=Ze(()=>{"use strict";te();Od=U("supervisor.taskscheduler"),ea="CozeBridge",Pd={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
65
+ `},configPath(t){return t.isRoot?Dh(S2,Hr):Dh(t.homeDir,".config","systemd","user",Hr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await y2(v2(i),{recursive:!0}),await b2(i,this.renderConfig(t),"utf8"),na.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await ia("systemctl",ra(t,["daemon-reload"])),await ia("systemctl",ra(t,r?["enable","--now",Hr]:["enable",Hr])),na.info("systemd unit enabled",{unitName:Hr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await ia("systemctl",ra(t,["disable","--now",Hr])).catch(r=>na.warn("systemctl disable failed (ignored)",{err:String(r)})),await E2(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ia("systemctl",ra(t,["daemon-reload"])).catch(()=>{}),na.info("systemd unit removed",{unitPath:e})}}});import{spawn as A2}from"node:child_process";import{join as T2}from"node:path";function Rh(t,e){return new Promise((r,i)=>{let o=A2(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 Nd,sa,Md,kh=Qe(()=>{"use strict";se();Nd=q("supervisor.taskscheduler"),sa="CozeBridge",Md={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
66
66
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
67
67
  <RegistrationInfo>
68
68
  <Description>Coze Bridge daemon</Description>
@@ -86,43 +86,43 @@ WantedBy=${e}
86
86
  </Exec>
87
87
  </Actions>
88
88
  </Task>
89
- `},configPath(t){return TS(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Tx("schtasks",["/Create","/SC","ONLOGON","/TN",ea,"/TR",r,"/RU",t.userName,"/F"]),Od.info("task scheduler entry created",{task:ea,logFile:t.logFile})},async uninstall(t){await Tx("schtasks",["/Delete","/TN",ea,"/F"]).catch(e=>Od.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Od.info("task scheduler entry removed",{task:ea})}}});var Cx={};xa(Cx,{buildContext:()=>PS,getSupervisor:()=>DS,launchdSupervisor:()=>Dd,systemdSupervisor:()=>kd,taskSchedulerSupervisor:()=>Pd});import{homedir as RS,userInfo as CS}from"node:os";function DS(t=process.platform){switch(t){case"darwin":return Dd;case"linux":return kd;case"win32":return Pd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function OS(){let t={};for(let e of kS){let r=process.env[e];r&&(t[e]=r)}return t}function PS(){let t=Z();return{nodeBin:process.execPath,entry:vd(t),logFile:t.logFile,homeDir:RS(),userName:CS().username,isRoot:process.getuid?.()===0,env:OS()}}var kS,Dx=Ze(()=>{"use strict";Ne();jo();Sx();Ax();Rx();kS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();nn();var dl=U("acp-installer-warmup"),ng=["claude-code","codex"];async function ll(t={}){let e=t.ensure??er,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);dl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&dl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();te();import{readdir as xg}from"node:fs/promises";import{mkdir as gl,writeFile as ml}from"node:fs/promises";import{join as Ea}from"node:path";var hg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await gl(t,{recursive:!0});let i=hg[e],o=Ea(t,i);return await ml(o,r??"","utf8"),o}async function wl(t){let e=Ea(t,".claude");await gl(e,{recursive:!0});let r=Ea(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await ml(r,i,"utf8"),r}var nt=U("agent-detail-sync"),pg=6e4,gg=5*6e4,as=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await xg(r)}catch(o){nt.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}nt.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ge(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){nt.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){nt.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),nt.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){nt.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){nt.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ge(e,this.opts.paths);if(!i){nt.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){nt.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let h=this.retryQueue.get(e),p=h?Math.min(h.currentDelay*2,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){nt.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&nt.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){nt.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),nt.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Lf=It(Zl(),1);import{lstat as Mc,mkdir as Bc,readFile as kf,readdir as jw,rm as Gw,stat as Ww,writeFile as zc}from"node:fs/promises";import{dirname as Kw,join as Ot,normalize as $w,relative as qc,resolve as Fc,sep as Of}from"node:path";import{Readable as Pf}from"node:stream";import{pipeline as Nf}from"node:stream/promises";import zg from"events";import et from"fs";import{EventEmitter as yc}from"node:events";import Ou from"node:stream";import{StringDecoder as Fg}from"node:string_decoder";import Lu from"node:path";import pr from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import tc from"assert";import{Buffer as Bn}from"buffer";import*as nu from"zlib";import cm from"zlib";import{posix as cr}from"node:path";import{basename as Lm}from"node:path";import Fs from"fs";import Ct from"fs";import du from"path";import{win32 as Km}from"node:path";import gu from"path";import Yu from"node:fs";import dw from"node:assert";import{randomBytes as Zu}from"node:crypto";import ne from"node:fs";import Me from"node:path";import Xu from"fs";import Js from"node:fs";import gi from"node:path";import st from"node:fs";import gw from"node:fs/promises";import Hs from"node:path";import{join as lf}from"node:path";import it from"node:fs";import hf from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},Xl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Ou||qg(t)||Hg(t)),qg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.pipe=="function"&&t.pipe!==Ou.Writable.prototype.pipe,Hg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),fs=Symbol("emittingEnd"),Qr=Symbol("emittedError"),hs=Symbol("closed"),Ql=Symbol("read"),xs=Symbol("flush"),eu=Symbol("flushChunk"),pt=Symbol("encoding"),ar=Symbol("decoder"),ze=Symbol("flowing"),ei=Symbol("paused"),fr=Symbol("resume"),Fe=Symbol("buffer"),Je=Symbol("pipes"),Ue=Symbol("bufferLength"),Ta=Symbol("bufferPush"),ps=Symbol("bufferShift"),Ke=Symbol("objectMode"),Ae=Symbol("destroyed"),Ra=Symbol("error"),Ca=Symbol("emitData"),tu=Symbol("emitEnd"),Da=Symbol("emitEnd2"),At=Symbol("async"),ka=Symbol("abort"),gs=Symbol("aborted"),ti=Symbol("signal"),Rn=Symbol("dataListeners"),rt=Symbol("discarded"),ni=t=>Promise.resolve().then(t),jg=t=>t(),Gg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Pu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[fr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},$g=class extends Pu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Jg=t=>!!t.objectMode,Vg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends yc{[ze]=!1;[ei]=!1;[Je]=[];[Fe]=[];[Ke];[pt];[At];[ar];[Ut]=!1;[on]=!1;[fs]=!1;[hs]=!1;[Qr]=null;[Ue]=0;[Ae]=!1;[ti];[gs]=!1;[Rn]=0;[rt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Jg(e)?(this[Ke]=!0,this[pt]=null):Vg(e)?(this[pt]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[pt]=null),this[At]=!!e.async,this[ar]=this[pt]?new Fg(this[pt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Fe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Je]});let{signal:r}=e;r&&(this[ti]=r,r.aborted?this[ka]():r.addEventListener("abort",()=>this[ka]()))}get bufferLength(){return this[Ue]}get encoding(){return this[pt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[At]}set async(t){this[At]=this[At]||!!t}[ka](){this[gs]=!0,this.emit("abort",this[ti]?.reason),this.destroy(this[ti]?.reason)}get aborted(){return this[gs]}set aborted(t){}write(t,e,r){if(this[gs])return!1;if(this[Ut])throw new Error("write after end");if(this[Ae])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[At]?ni:jg;if(!this[Ke]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ke]?(this[ze]&&this[Ue]!==0&&this[xs](!0),this[ze]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):t.length?(typeof t=="string"&&!(e===this[pt]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[pt]&&(t=this[ar].write(t)),this[ze]&&this[Ue]!==0&&this[xs](!0),this[ze]?this.emit("data",t):this[Ta](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze])}read(t){if(this[Ae])return null;if(this[rt]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[qt](),null;this[Ke]&&(t=null),this[Fe].length>1&&!this[Ke]&&(this[Fe]=[this[pt]?this[Fe].join(""):Buffer.concat(this[Fe],this[Ue])]);let e=this[Ql](t||null,this[Fe][0]);return this[qt](),e}[Ql](t,e){if(this[Ke])this[ps]();else{let r=e;t===r.length||t===null?this[ps]():typeof r=="string"?(this[Fe][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[Fe][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[Fe].length&&!this[Ut]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ut]=!0,this.writable=!1,(this[ze]||!this[ei])&&this[qt](),this}[fr](){this[Ae]||(!this[Rn]&&!this[Je].length&&(this[rt]=!0),this[ei]=!1,this[ze]=!0,this.emit("resume"),this[Fe].length?this[xs]():this[Ut]?this[qt]():this.emit("drain"))}resume(){return this[fr]()}pause(){this[ze]=!1,this[ei]=!0,this[rt]=!1}get destroyed(){return this[Ae]}get flowing(){return this[ze]}get paused(){return this[ei]}[Ta](t){this[Ke]?this[Ue]+=1:this[Ue]+=t.length,this[Fe].push(t)}[ps](){return this[Ke]?this[Ue]-=1:this[Ue]-=this[Fe][0].length,this[Fe].shift()}[xs](t=!1){do;while(this[eu](this[ps]())&&this[Fe].length);!t&&!this[Fe].length&&!this[Ut]&&this.emit("drain")}[eu](t){return this.emit("data",t),this[ze]}pipe(t,e){if(this[Ae])return t;this[rt]=!1;let r=this[on];return e=e||{},t===Xl.stdout||t===Xl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Je].push(e.proxyErrors?new $g(this,t,e):new Pu(this,t,e)),this[At]?ni(()=>this[fr]()):this[fr]()),t}unpipe(t){let e=this[Je].find(r=>r.dest===t);e&&(this[Je].length===1?(this[ze]&&this[Rn]===0&&(this[ze]=!1),this[Je]=[]):this[Je].splice(this[Je].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[rt]=!1,this[Rn]++,!this[Je].length&&!this[ze]&&this[fr]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(Gg(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Qr]){let i=e;this[At]?ni(()=>i.call(this,this[Qr])):i.call(this,this[Qr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Rn]=this.listeners("data").length,this[Rn]===0&&!this[rt]&&!this[Je].length&&(this[ze]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Rn]=0,!this[rt]&&!this[Je].length&&(this[ze]=!1)),e}get emittedEnd(){return this[on]}[qt](){!this[fs]&&!this[on]&&!this[Ae]&&this[Fe].length===0&&this[Ut]&&(this[fs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[hs]&&this.emit("close"),this[fs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ae&&this[Ae])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[At]?(ni(()=>this[Ca](r)),!0):this[Ca](r);if(t==="end")return this[tu]();if(t==="close"){if(this[hs]=!0,!this[on]&&!this[Ae])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Qr]=r,super.emit(Ra,r);let o=!this[ti]||this.listeners("error").length?super.emit("error",r):!1;return this[qt](),o}else if(t==="resume"){let o=super.emit("resume");return this[qt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[qt](),i}[Ca](t){for(let r of this[Je])r.dest.write(t)===!1&&this.pause();let e=this[rt]?!1:super.emit("data",t);return this[qt](),e}[tu](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(ni(()=>this[Da]()),!0):this[Da]())}[Da](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[Je])r.dest.write(e);this[rt]||super.emit("data",e)}}for(let e of this[Je])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ke]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ke]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ke])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[pt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ae,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[rt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(Ae,h),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(Ae,h),this.pause(),i({value:p,done:!!this[Ut]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ae,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((p,m)=>{o=m,i=p,this.once(Ae,h),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[rt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ra,e),this.off(Ae,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Ra,e),this.once(Ae,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ae])return t?this.emit("error",t):this.emit(Ae),this;this[Ae]=!0,this[rt]=!0,this[Fe].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[hs]&&e.close(),t?this.emit("error",t):this.emit(Ae),this}static get isStream(){return Ug}},Yg=et.writev,gn=Symbol("_autoClose"),_t=Symbol("_close"),ri=Symbol("_ended"),oe=Symbol("_fd"),Oa=Symbol("_finished"),Wt=Symbol("_flags"),Pa=Symbol("_flush"),Qa=Symbol("_handleChunk"),ec=Symbol("_makeBuf"),xi=Symbol("_mode"),ms=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Na=Symbol("_onread"),hr=Symbol("_onwrite"),mn=Symbol("_open"),wt=Symbol("_path"),un=Symbol("_pos"),Tt=Symbol("_queue"),xr=Symbol("_read"),La=Symbol("_readSize"),Gt=Symbol("_reading"),ii=Symbol("_remain"),Ma=Symbol("_size"),Ts=Symbol("_write"),Cn=Symbol("_writing"),Rs=Symbol("_defaultFlag"),Mn=Symbol("_errored"),Ec=class extends Un{[Mn]=!1;[oe];[wt];[La];[Gt]=!1;[Ma];[ii];[gn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Mn]=!1,this[oe]=typeof e.fd=="number"?e.fd:void 0,this[wt]=t,this[La]=e.readSize||16*1024*1024,this[Gt]=!1,this[Ma]=typeof e.size=="number"?e.size:1/0,this[ii]=this[Ma],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[oe]=="number"?this[xr]():this[mn]()}get fd(){return this[oe]}get path(){return this[wt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){et.open(this[wt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[oe]=e,this.emit("open",e),this[xr]())}[ec](){return Buffer.allocUnsafe(Math.min(this[La],this[ii]))}[xr](){if(!this[Gt]){this[Gt]=!0;let t=this[ec]();if(t.length===0)return process.nextTick(()=>this[Na](null,0,t));et.read(this[oe],t,0,t.length,null,(e,r,i)=>this[Na](e,r,i))}}[Na](t,e,r){this[Gt]=!1,t?this[mr](t):this[Qa](e,r)&&this[xr]()}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[Gt]=!0,this[_t](),this.emit("error",t)}[Qa](t,e){let r=!1;return this[ii]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ii]<=0)&&(r=!1,this[_t](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[oe]=="number"&&this[xr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Zg=class extends Ec{[mn](){let t=!0;try{this[wr](null,et.openSync(this[wt],"r")),t=!1}finally{t&&this[_t]()}}[xr](){let t=!0;try{if(!this[Gt]){this[Gt]=!0;do{let e=this[ec](),r=e.length===0?0:et.readSync(this[oe],e,0,e.length,null);if(!this[Qa](r,e))break}while(!0);this[Gt]=!1}t=!1}finally{t&&this[_t]()}}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.closeSync(t),this.emit("close")}}},js=class extends zg{readable=!1;writable=!0;[Mn]=!1;[Cn]=!1;[ri]=!1;[Tt]=[];[ms]=!1;[wt];[xi];[gn];[oe];[Rs];[Wt];[Oa]=!1;[un];constructor(t,e){e=e||{},super(e),this[wt]=t,this[oe]=typeof e.fd=="number"?e.fd:void 0,this[xi]=e.mode===void 0?438:e.mode,this[un]=typeof e.start=="number"?e.start:void 0,this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[un]!==void 0?"r+":"w";this[Rs]=e.flags===void 0,this[Wt]=e.flags===void 0?r:e.flags,this[oe]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[oe]}get path(){return this[wt]}[mr](t){this[_t](),this[Cn]=!0,this.emit("error",t)}[mn](){et.open(this[wt],this[Wt],this[xi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Rs]&&this[Wt]==="r+"&&t&&t.code==="ENOENT"?(this[Wt]="w",this[mn]()):t?this[mr](t):(this[oe]=e,this.emit("open",e),this[Cn]||this[Pa]())}end(t,e){return t&&this.write(t,e),this[ri]=!0,!this[Cn]&&!this[Tt].length&&typeof this[oe]=="number"&&this[hr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ri]?(this.emit("error",new Error("write() after end()")),!1):this[oe]===void 0||this[Cn]||this[Tt].length?(this[Tt].push(t),this[ms]=!0,!1):(this[Cn]=!0,this[Ts](t),!0)}[Ts](t){et.write(this[oe],t,0,t.length,this[un],(e,r)=>this[hr](e,r))}[hr](t,e){t?this[mr](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[Tt].length?this[Pa]():(this[Cn]=!1,this[ri]&&!this[Oa]?(this[Oa]=!0,this[_t](),this.emit("finish")):this[ms]&&(this[ms]=!1,this.emit("drain"))))}[Pa](){if(this[Tt].length===0)this[ri]&&this[hr](null,0);else if(this[Tt].length===1)this[Ts](this[Tt].pop());else{let t=this[Tt];this[Tt]=[],Yg(this[oe],t,this[un],(e,r)=>this[hr](e,r))}}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Nu=class extends js{[mn](){let t;if(this[Rs]&&this[Wt]==="r+")try{t=et.openSync(this[wt],this[Wt],this[xi])}catch(e){if(e?.code==="ENOENT")return this[Wt]="w",this[mn]();throw e}else t=et.openSync(this[wt],this[Wt],this[xi]);this[wr](null,t)}[_t](){if(this[gn]&&typeof this[oe]=="number"){let t=this[oe];this[oe]=void 0,et.closeSync(t),this.emit("close")}}[Ts](t){let e=!0;try{this[hr](null,et.writeSync(this[oe],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[_t]()}catch{}}}},em=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,bc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},vi=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let h=bc(c);if(o?.(h,l),tm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(nm(h)){let p=e(h,l);return u?p.then(()=>u(),u):p}else if(rm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(im(h)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(h,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),dm=cm.constants||{ZLIB_VERNUM:4736},kt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},dm)),lm=Bn.concat,ru=Object.getOwnPropertyDescriptor(Bn,"concat"),um=t=>t,Ba=ru?.writable===!0||ru?.set!==void 0?t=>{Bn.concat=t?um:lm}:t=>{},zn=Symbol("_superWrite"),ws=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},za=Symbol("flushFlag"),vc=class extends Un{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof nu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new nu[e](t)}catch(r){throw new ws(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ws(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return tc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[za]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[zn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;tc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ba(!0);let l;try{let h=typeof t[za]=="number"?t[za]:this.#r;l=this.#t._processChunk(t,h),Ba(!1)}catch(h){Ba(!1),this.#o(new ws(h,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",h=>this.#o(new ws(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[zn](Bn.from(h));for(let p=1;p<l.length;p++)u=this[zn](l[p])}else u=this[zn](Bn.from(l));return r&&r(),u}},Mu=class extends vc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||kt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||kt.Z_FINISH,t.fullFlushFlag=kt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(kt.Z_SYNC_FLUSH),tc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},fm=class extends Mu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[zn](t){return this.#e?(this.#e=!1,t[9]=255,super[zn](t)):super[zn](t)}},hm=class extends Mu{constructor(t){super(t,"Unzip")}},Bu=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||kt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=kt.BROTLI_OPERATION_FLUSH,super(t,e)}},xm=class extends Bu{constructor(t){super(t,"BrotliCompress")}},pm=class extends Bu{constructor(t){super(t,"BrotliDecompress")}},zu=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||kt.ZSTD_e_continue,t.finishFlush=t.finishFlush||kt.ZSTD_e_end,t.fullFlushFlag=kt.ZSTD_e_flush,super(t,e)}},gm=class extends zu{constructor(t){super(t,"ZstdCompress")}},mm=class extends zu{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Fu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Uu(o))}},Em=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?bm(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},bm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Fu(c):c===0?l=c:(i=!0,l=Uu(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Fu=t=>(255^t)&255,Uu=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>Sc,isCode:()=>Cs,isName:()=>Im,name:()=>Gs});var Cs=t=>Gs.has(t),Im=t=>Sc.has(t),Gs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Sc=new Map(Array.from(Gs).map(t=>[t[1],t[0]])),Fn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??fn(t,e+100,8),this.uid=r?.uid??i?.uid??fn(t,e+108,8),this.gid=r?.gid??i?.gid??fn(t,e+116,8),this.size=r?.size??i?.size??fn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Fa(t,e+136,12),this.cksum=fn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(Cs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??fn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??fn(t,e+337,8)??0,t[e+475]!==0){let l=Dn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Dn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Fa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Fa(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Am(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=hn(t,e+100,8,this.mode)||this.needPax,this.needPax=hn(t,e+108,8,this.uid)||this.needPax,this.needPax=hn(t,e+116,8,this.gid)||this.needPax,this.needPax=hn(t,e+124,12,this.size)||this.needPax,this.needPax=Ua(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=hn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=hn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(t,e+345,130,c)||this.needPax,this.needPax=Ua(t,e+476,12,this.atime)||this.needPax,this.needPax=Ua(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,hn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Gs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Sc.get(t));if(Cs(e)||e==="Unsupported")this.#e=e;else if(Cs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Am=(t,e)=>{let r=t,i="",o,c=cr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=cr.dirname(r),r=cr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=cr.join(cr.basename(i),r),i=cr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Dn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Fa=(t,e,r)=>Tm(fn(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?Em(t.subarray(e,e+r)):Cm(t,e,r),Rm=t=>isNaN(t)?void 0:t,Cm=(t,e,r)=>Rm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Dm={12:8589934591,8:2097151},hn=(t,e,r,i)=>i===void 0?!1:i>Dm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Om(i,r),e,r,"ascii"),Om=(t,e)=>Pm(Math.floor(t).toString(8),e),Pm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ua=(t,e,r,i)=>i===void 0?!1:hn(t,e,r,i.getTime()/1e3),Nm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Nm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),zs=class qu{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Fn({path:("PaxHeader/"+Lm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
90
- `,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new qu(Mm(Bm(e),r),i)}},Mm=(t,e)=>e?Object.assign({},e,t):t,Bm=t=>t.replace(/\n$/,"").split(`
91
- `).reduce(zm,Object.create(null)),zm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=Fm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Hu=class extends Un{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Y(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Y(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Y(t.path)),t.linkpath&&(t.linkpath=Y(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ws=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Um=1024*1024,nc=Buffer.from([31,139]),rc=Buffer.from([40,181,47,253]),qm=Math.max(nc.length,rc.length),ct=Symbol("state"),On=Symbol("writeEntry"),Ht=Symbol("readEntry"),qa=Symbol("nextEntry"),iu=Symbol("processEntry"),Rt=Symbol("extendedHeader"),si=Symbol("globalExtendedHeader"),an=Symbol("meta"),su=Symbol("emitMeta"),ue=Symbol("buffer"),jt=Symbol("queue"),cn=Symbol("ended"),Ha=Symbol("emittedEnd"),Pn=Symbol("emit"),Ce=Symbol("unzip"),_s=Symbol("consumeChunk"),ys=Symbol("consumeChunkSub"),ja=Symbol("consumeBody"),ou=Symbol("consumeMeta"),au=Symbol("consumeHeader"),oi=Symbol("consuming"),Ga=Symbol("bufferConcat"),Es=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),bs=Symbol("onDone"),Nn=Symbol("sawValidEntry"),vs=Symbol("sawNullBlock"),Ss=Symbol("sawEOF"),cu=Symbol("closeStream"),Hm=()=>!0,bi=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[jt]=[];[ue];[Ht];[On];[ct]="begin";[an]="";[Rt];[si];[cn]=!1;[Ce];[dn]=!1;[Nn];[vs]=!1;[Ss]=!1;[dr]=!1;[oi]=!1;[Ha]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(bs,()=>{(this[ct]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(bs,t.ondone):this.on(bs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:Hm;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[cu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ws(this,t,e,r)}[au](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new Fn(t,e,this[Rt],this[si])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[vs]?(this[Ss]=!0,this[ct]==="begin"&&(this[ct]="header"),this[Pn]("eof")):(this[vs]=!0,this[Pn]("nullBlock"));else if(this[vs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[On]=new Hu(r,this[Rt],this[si]);if(!this[Nn])if(o.remain){let c=()=>{o.invalid||(this[Nn]=!0)};o.on("end",c)}else this[Nn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Pn]("ignoredEntry",o),this[ct]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[ct]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Pn]("ignoredEntry",o),this[ct]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ct]="body":(this[ct]="header",o.end()),this[Ht]?this[jt].push(o):(this[jt].push(o),this[qa]())))}}}[cu](){queueMicrotask(()=>this.emit("close"))}[iu](t){let e=!0;if(!t)this[Ht]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ht]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[qa]()),e=!1);return e}[qa](){do;while(this[iu](this[jt].shift()));if(this[jt].length===0){let t=this[Ht];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[ja](t,e){let r=this[On];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[ct]="header",this[On]=void 0,r.end()),o.length}[ou](t,e){let r=this[On],i=this[ja](t,e);return!this[On]&&r&&this[su](r),i}[Pn](t,e,r){this[jt].length===0&&!this[Ht]?this.emit(t,e,r):this[jt].push([t,e,r])}[su](t){switch(this[Pn]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=zs.parse(this[an],this[Rt],!1);break;case"GlobalExtendedHeader":this[si]=zs.parse(this[an],this[si],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[dn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[ue]&&(t=Buffer.concat([this[ue],t]),this[ue]=void 0),t.length<qm)return this[ue]=t,r?.(),!0;for(let l=0;this[Ce]===void 0&&l<nc.length;l++)t[l]!==nc[l]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<rc.length;l++)if(t[l]!==rc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[ue]=t,r?.(),!0;else try{new Fn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Ce]=this[Ce]===void 0?new hm({}):o?new mm({}):new pm({}),this[Ce].on("data",h=>this[_s](h)),this[Ce].on("error",h=>this.abort(h)),this[Ce].on("end",()=>{this[cn]=!0,this[_s]()}),this[dr]=!0;let u=!!this[Ce][l?"end":"write"](t);return this[dr]=!1,r?.(),u}}this[dr]=!0,this[Ce]?this[Ce].write(t):this[_s](t),this[dr]=!1;let i=this[jt].length>0?!1:this[Ht]?this[Ht].flowing:!0;return!i&&this[jt].length===0&&this[Ht]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ga](t){t&&!this[dn]&&(this[ue]=this[ue]?Buffer.concat([this[ue],t]):t)}[Es](){if(this[cn]&&!this[Ha]&&!this[dn]&&!this[oi]){this[Ha]=!0;let t=this[On];if(t&&t.blockRemain){let e=this[ue]?this[ue].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ue]&&t.write(this[ue]),t.end()}this[Pn](bs)}}[_s](t){if(this[oi]&&t)this[Ga](t);else if(!t&&!this[ue])this[Es]();else if(t){if(this[oi]=!0,this[ue]){this[Ga](t);let e=this[ue];this[ue]=void 0,this[ys](e)}else this[ys](t);for(;this[ue]&&this[ue]?.length>=512&&!this[dn]&&!this[Ss];){let e=this[ue];this[ue]=void 0,this[ys](e)}this[oi]=!1}(!this[ue]||this[cn])&&this[Es]()}[ys](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ss];)switch(this[ct]){case"begin":case"header":this[au](t,e),e+=512;break;case"ignore":case"body":e+=this[ja](t,e);break;case"meta":e+=this[ou](t,e);break;default:throw new Error("invalid state: "+this[ct])}e<r&&(this[ue]=this[ue]?Buffer.concat([t.subarray(e),this[ue]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[dn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Es]())),this}},pi=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},jm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},ju=(t,e)=>{let r=new Map(e.map(c=>[pi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Qg(c).root||".",h;if(c===u)h=!1;else{let p=r.get(c);h=p!==void 0?p:o(Xg(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(pi(c)):c=>o(pi(c))},Gm=t=>{let e=new bi(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=pr.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let h=pr.readSync(i,u,0,c,l);if(h===0)break;l+=h,e.write(u.subarray(0,h))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},Wm=(t,e)=>{let r=new bi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ec(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},_r=vi(Gm,Wm,t=>new bi(t),t=>new bi(t),(t,e)=>{e?.length&&ju(t,e),t.noResume||jm(t)}),Gu=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:$m,parse:lu}=Km,Ic=t=>{let e="",r=lu(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=lu(t)}return[e,t]},Ks=["|","<",">","?",":"],Ac=Ks.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Jm=new Map(Ks.map((t,e)=>[t,Ac[e]])),Vm=new Map(Ac.map((t,e)=>[t,Ks[e]])),uu=t=>Ks.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),Ym=t=>Ac.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),Wu=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),pi(e)+"/"+t):Y(t),Zm=16*1024*1024,fu=Symbol("process"),hu=Symbol("file"),xu=Symbol("directory"),ic=Symbol("symlink"),pu=Symbol("hardlink"),ai=Symbol("header"),Ds=Symbol("read"),sc=Symbol("lstat"),ks=Symbol("onlstat"),oc=Symbol("onread"),ac=Symbol("onreadlink"),cc=Symbol("openfile"),dc=Symbol("onopenfile"),xn=Symbol("close"),Us=Symbol("mode"),lc=Symbol("awaitDrain"),Wa=Symbol("ondrain"),Dt=Symbol("prefix"),Ku=class extends Un{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=bc(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Zm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Y(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Y(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Ic(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Ym(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||du.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[ks](o):this[sc]()}warn(t,e,r={}){return Ws(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[sc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ks](e)})}[ks](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[fu]()}[fu](){switch(this.type){case"File":return this[hu]();case"Directory":return this[xu]();case"SymbolicLink":return this[ic]();default:return this.end()}}[Us](t){return Gu(t,this.type==="Directory",this.portable)}[Dt](t){return Wu(t,this.prefix)}[ai](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Fn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this[Us](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new zs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[xu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[ai](),this.end()}[ic](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ac](e)})}[ac](t){this.linkpath=Y(t),this[ai](),this.end()}[pu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(du.relative(this.cwd,t)),this.stat.size=0,this[ai](),this.end()}[hu](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[pu](e);this.linkCache.set(t,this.absolute)}if(this[ai](),this.stat.size===0)return this.end();this[cc]()}[cc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[dc](e)})}[dc](t){if(this.fd=t,this.#e)return this[xn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ds]()}[Ds](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,l)=>{if(c)return this[xn](()=>this.emit("error",c));this[oc](l)})}[xn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[oc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[xn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Wa]():this[lc](()=>this[Wa]())}[lc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Wa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[xn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ds]()}},Xm=class extends Ku{sync=!0;[sc](){this[ks](Ct.lstatSync(this.absolute))}[ic](){this[ac](Ct.readlinkSync(this.absolute))}[cc](){this[dc](Ct.openSync(this.absolute,"r"))}[Ds](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Ct.readSync(e,r,i,o,c);this[oc](l),t=!1}finally{if(t)try{this[xn](()=>{})}catch{}}}[lc](t){t()}[xn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},Qm=class extends Un{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Ws(this,t,e,r)}constructor(t,e={}){let r=bc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Y(t.path),this.mode=t.mode!==void 0?this[Us](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Ic(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Fn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new zs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Dt](t){return Wu(t,this.prefix)}[Us](t){return Gu(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=class gr{tail;head;length=0;static create(e=[]){return new gr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new gr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new gr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=nw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Tc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Tc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Tc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Tc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},mu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},wu=Buffer.alloc(1024),Os=Symbol("onStat"),ci=Symbol("ended"),gt=Symbol("queue"),di=Symbol("queue"),ln=Symbol("current"),Ln=Symbol("process"),li=Symbol("processing"),Is=Symbol("processJob"),mt=Symbol("jobs"),Ka=Symbol("jobDone"),Ps=Symbol("addFSEntry"),_u=Symbol("addTarEntry"),uc=Symbol("stat"),fc=Symbol("readdir"),Ns=Symbol("onreaddir"),Ls=Symbol("pipe"),yu=Symbol("entry"),$a=Symbol("entryOpt"),Ms=Symbol("writeEntryClass"),$u=Symbol("write"),Ja=Symbol("ondrain"),$s=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ms];onWriteEntry;[gt];[di]=new Map;[mt]=0;[li]=!1;[ci]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Y(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ms]=Ku,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new fm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new xm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[gt]=new tw,this[mt]=0,this.jobs=Number(t.jobs)||4,this[li]=!1,this[ci]=!1}[$u](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[ci]=!0,this[Ln](),r&&r(),this}write(t){if(this[ci])throw new Error("write after end");return t instanceof Hu?this[_u](t):this[Ps](t),this.flowing}[_u](t){let e=Y(gu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new mu(t.path,e);r.entry=new Qm(t,this[$a](r)),r.entry.on("end",()=>this[Ka](r)),this[mt]+=1,this[gt].push(r)}this[Ln]()}[Ps](t){let e=Y(gu.resolve(this.cwd,t));this[gt].push(new mu(t,e)),this[Ln]()}[uc](t){t.pending=!0,this[mt]+=1;let e=this.follow?"stat":"lstat";Fs[e](t.absolute,(r,i)=>{t.pending=!1,this[mt]-=1,r?this.emit("error",r):this[Os](t,i)})}[Os](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[Is](t);else{let r=`${e.dev}:${e.ino}`,i=this[di].get(r);i?i.push(t):this[di].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[fc](t){t.pending=!0,this[mt]+=1,Fs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[mt]-=1,e)return this.emit("error",e);this[Ns](t,r)})}[Ns](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[li]){this[li]=!0;for(let t=this[gt].head;t&&this[mt]<this.jobs;t=t.next)if(this[Is](t.value),t.value.ignore){let e=t.next;this[gt].removeNode(t),t.next=e}this[li]=!1,this[ci]&&this[gt].length===0&&this[mt]===0&&(this.zip?this.zip.end(wu):(super.write(wu),super.end()))}}get[ln](){return this[gt]&&this[gt].head&&this[gt].head.value}[Ka](t){this[gt].shift(),this[mt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[di].get(r);if(i){this[di].delete(r);for(let o of i)o.pending=!1,this[Is](o)}}this[Ln]()}[Is](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[Ls](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Os](t,e):this[uc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ns](t,e):this[fc](t),!t.readdir)return}if(t.entry=this[yu](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Ls](t)}}}[$a](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[yu](t){this[mt]+=1;try{return new this[Ms](t.path,this[$a](t)).on("end",()=>this[Ka](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Ls](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ps](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ws(this,t,e,r)}},Rc=class extends $s{sync=!0;constructor(t){super(t),this[Ms]=Xm}pause(){}resume(){}[uc](t){let e=this.follow?"statSync":"lstatSync";this[Os](t,Fs[e](t.absolute))}[fc](t){this[Ns](t,Fs.readdirSync(t.absolute))}[Ls](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ps](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[$u](i)})}},sw=(t,e)=>{let r=new Rc(t),i=new Nu(t.file,{mode:t.mode||438});r.pipe(i),Ju(r,e)},ow=(t,e)=>{let r=new $s(t),i=new js(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return Vu(r,e).catch(c=>r.emit("error",c)),o},Ju=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:Lu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Vu=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:Lu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new Rc(t);return Ju(r,e),r},cw=(t,e)=>{let r=new $s(t);return Vu(r,e).catch(i=>r.emit("error",i)),r},p2=vi(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,Qu=lw==="win32",{O_CREAT:ef,O_NOFOLLOW:Eu,O_TRUNC:tf,O_WRONLY:nf}=Xu.constants,rf=Number(process.env.__FAKE_FS_O_FILENAME__)||Xu.constants.UV_FS_O_FILEMAP||0,uw=Qu&&!!rf,fw=512*1024,hw=rf|tf|ef|nf,bu=!Qu&&typeof Eu=="number"?Eu|tf|ef|nf:null,sf=bu!==null?()=>bu:uw?t=>t<fw?hw:"w":()=>"w",hc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},qs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},xw=(t,e,r,i,o)=>{if(e.isDirectory())of(gi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=gi.resolve(t,e.name);qs(l,r,i,o)});else{let c=gi.resolve(t,e.name);qs(c,r,i,o)}},of=(t,e,r,i)=>{Js.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return qs(t,e,r,i);let l=c.length,u=null,h=p=>{if(!u){if(p)return i(u=p);if(--l===0)return qs(t,e,r,i)}};for(let p of c)xw(t,p,e,r,h)})},pw=(t,e,r,i)=>{e.isDirectory()&&af(gi.resolve(t,e.name),r,i),hc(gi.resolve(t,e.name),r,i)},af=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return hc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return hc(t,e,r)},cf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Vs=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{st.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new cf(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,h=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,m=e.unlink,E=Y(e.cwd),T=(v,I)=>{v?r(v):I&&h?of(I,l,u,S=>T(S)):c?st.chmod(t,o,r):r()};if(t===E)return mw(t,T);if(p)return gw.mkdir(t,{mode:o,recursive:!0}).then(v=>T(null,v??void 0),T);let _=Y(Hs.relative(E,t)).split("/");xc(E,_,o,m,E,void 0,T)},xc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=Y(Hs.resolve(t+"/"+u));st.mkdir(h,r,df(h,e,r,i,o,c,l))},df=(t,e,r,i,o,c,l)=>u=>{u?st.lstat(t,(h,p)=>{if(h)h.path=h.path&&Y(h.path),l(h);else if(p.isDirectory())xc(t,e,r,i,o,c,l);else if(i)st.unlink(t,m=>{if(m)return l(m);st.mkdir(t,r,df(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Vs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,xc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=st.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new cf(t,r??"ENOTDIR")}},yw=(t,e)=>{t=Y(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),h=e.preserve,p=e.unlink,m=Y(e.cwd),E=v=>{v&&u&&af(v,c,l),o&&st.chmodSync(t,i)};if(t===m)return _w(m),E();if(h)return E(st.mkdirSync(t,{mode:i,recursive:!0})??void 0);let T=Y(Hs.relative(m,t)).split("/"),_;for(let v=T.shift(),I=m;v&&(I+="/"+v);v=T.shift()){I=Y(Hs.resolve(I));try{st.mkdirSync(I,i),_=_||I}catch{let S=st.lstatSync(I);if(S.isDirectory())continue;if(p){st.unlinkSync(I),st.mkdirSync(I,i),_=_||I;continue}else if(S.isSymbolicLink())return new Vs(I,I+"/"+T.join("/"))}}return E(_)},Va=Object.create(null),vu=1e4,lr=new Set,Ew=t=>{lr.has(t)?lr.delete(t):Va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=Va[t],r=lr.size-vu;if(r>vu/10){for(let i of lr)if(lr.delete(i),delete Va[i],--r<=0)break}return e},bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=bw==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=lf(i,r)),e.push(r||"/"),e},[]),Iw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>pi(lf(Ew(i))));let r=new Set(t.map(i=>Sw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let h of u)o.add(h)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Aw=()=>process.umask(),Su=Symbol("onEntry"),pc=Symbol("checkFs"),Iu=Symbol("checkFs2"),gc=Symbol("isReusable"),dt=Symbol("makeFs"),mc=Symbol("file"),wc=Symbol("directory"),Bs=Symbol("link"),Au=Symbol("symlink"),Tu=Symbol("hardlink"),hi=Symbol("ensureNoSymlink"),Ru=Symbol("unsupported"),Cu=Symbol("checkPath"),Ya=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),qe=Symbol("onError"),As=Symbol("pending"),Du=Symbol("pend"),ur=Symbol("unpend"),Za=Symbol("ended"),Xa=Symbol("maybeClose"),_c=Symbol("skip"),mi=Symbol("doChown"),wi=Symbol("uid"),_i=Symbol("gid"),yi=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ei=Tw==="win32",Rw=1024,Cw=(t,e)=>{if(!Ei)return ne.unlink(t,e);let r=t+".DELETE."+Zu(16).toString("hex");ne.rename(t,r,i=>{if(i)return e(i);ne.unlink(r,e)})},Dw=t=>{if(!Ei)return ne.unlinkSync(t);let e=t+".DELETE."+Zu(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},ku=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Cc=class extends bi{[Za]=!1;[yi]=!1;[As]=0;reservations=new Iw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Za]=!0,this[Xa]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Rw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ei,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Aw():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Su](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Xa](){this[Za]&&this[As]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ya](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Ic(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ei&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Me.posix.dirname(t.path),h=Me.posix.normalize(Me.posix.join(u,l.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Cu](t){let e=Y(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Y(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Ya](t,"path")||!this[Ya](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Y(Me.resolve(t.path)):Y(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Y(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+uu(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+uu(t.path.slice(o.length))}return!0}[Su](t){if(!this[Cu](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[pc](t);default:return this[Ru](t)}}[qe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ur](),e.resume())}[pn](t,e,r){ww(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[mi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[wi](t){return ku(this.uid,t.uid,this.processUid)}[_i](t){return ku(this.gid,t.gid,this.processGid)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new js(String(t.absolute),{flags:sf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ne.close(i.fd,()=>{}),i.write=()=>!0,this[qe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ne.close(i.fd,()=>{}),this[qe](u,t),e();return}--o===0&&i.fd!==void 0&&ne.close(i.fd,h=>{h?this[qe](h,t):this[ur](),e()})};i.on("finish",()=>{let u=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,m=t.mtime;ne.futimes(h,p,m,E=>E?ne.utimes(u,p,m,T=>c(T&&E)):c())}if(typeof h=="number"&&this[mi](t)){o++;let p=this[wi](t),m=this[_i](t);typeof p=="number"&&typeof m=="number"&&ne.fchown(h,p,m,E=>E?ne.chown(u,p,m,T=>c(T&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[qe](u,t),e()}),t.pipe(l)),l.pipe(i)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[qe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[ur](),t.resume())};t.mtime&&!this.noMtime&&(o++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[mi](t)&&(o++,ne.chown(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)),c)),c()})}[Ru](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Au](t,e){let r=Y(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[hi](t,this.cwd,r,()=>this[Bs](t,String(t.linkpath),"symlink",e),i=>{this[qe](i,t),e()})}[Tu](t,e){let r=Y(Me.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[hi](t,this.cwd,i,()=>this[Bs](t,r,"link",e),o=>{this[qe](o,t),e()})}[hi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);ne.lstat(l,(u,h)=>{if(u)return i();if(h?.isSymbolicLink())return o(new Vs(l,Me.resolve(l,r.join("/"))));this[hi](t,l,r,i,o)})}[Du](){this[As]++}[ur](){this[As]--,this[Xa]()}[_c](t){this[ur](),t.resume()}[gc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ei}[pc](t){this[Du]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Iu](t,r))}[Iu](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[qe](l,t),r();return}this[yi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Y(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,u=>{if(u){this[qe](u,t),r();return}c()})}c()},c=()=>{ne.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[_c](t),r();return}if(l||this[gc](t,u))return this[dt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=m=>this[dt](m??null,t,r);return h?ne.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ne.rmdir(String(t.absolute),h=>this[dt](h??null,t,r))}if(t.absolute===this.cwd)return this[dt](null,t,r);Cw(String(t.absolute),h=>this[dt](h??null,t,r))})};this[yi]?o():i()}[dt](t,e,r){if(t){this[qe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[mc](e,r);case"Link":return this[Tu](e,r);case"SymbolicLink":return this[Au](e,r);case"Directory":case"GNUDumpDir":return this[wc](e,r)}}[Bs](t,e,r,i){ne[r](e,String(t.absolute),o=>{o?this[qe](o,t):(this[ur](),t.resume()),i()})}},ui=t=>{try{return[null,t()]}catch(e){return[e,null]}},uf=class extends Cc{sync=!0;[dt](t,e){return super[dt](t,e,()=>{})}[pc](t){if(!this[yi]){let o=this[pn](this.cwd,this.dmode);if(o)return this[qe](o,t);this[yi]=!0}if(t.absolute!==this.cwd){let o=Y(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[qe](c,t)}}let[e,r]=ui(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[_c](t);if(e||this[gc](t,r))return this[dt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?ui(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[dt](l,t)}let[o]=ui(()=>ne.rmdirSync(String(t.absolute)));this[dt](o,t)}let[i]=t.absolute===this.cwd?[]:ui(()=>Dw(String(t.absolute)));this[dt](i,t)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ne.closeSync(o)}catch(h){u=h}(l||u)&&this[qe](l||u,t),e()},o;try{o=ne.openSync(String(t.absolute),sf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[qe](l,t)),t.pipe(c)),c.on("data",l=>{try{ne.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,h=t.mtime;try{ne.futimesSync(o,u,h)}catch(p){try{ne.utimesSync(String(t.absolute),u,h)}catch{l=p}}}if(this[mi](t)){let u=this[wi](t),h=this[_i](t);try{ne.fchownSync(o,Number(u),Number(h))}catch(p){try{ne.chownSync(String(t.absolute),Number(u),Number(h))}catch{l=l||p}}}i(l)})}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[qe](i,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[mi](t))try{ne.chownSync(String(t.absolute),Number(this[wi](t)),Number(this[_i](t)))}catch{}e(),t.resume()}[pn](t,e){try{return yw(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[hi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Me.resolve(c,l);let[u,h]=ui(()=>ne.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new Vs(c,Me.resolve(e,r.join("/"))))}i()}[Bs](t,e,r,i){let o=`${r}Sync`;try{ne[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[qe](c,t)}}},kw=t=>{let e=new uf(t),r=t.file,i=Yu.statSync(r),o=t.maxReadSize||16*1024*1024;new Zg(r,{readSize:o,size:i.size}).pipe(e)},Ow=(t,e)=>{let r=new Cc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Yu.stat(o,(u,h)=>{if(u)l(u);else{let p=new Ec(o,{readSize:i,size:h.size});p.on("error",l),p.pipe(r)}})})},ff=vi(kw,Ow,t=>new uf(t),t=>new Cc(t),(t,e)=>{e?.length&&ju(t,e)}),Pw=(t,e)=>{let r=new Rc(t),i=!0,o,c;try{try{o=it.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=it.openSync(t.file,"w+");else throw h}let l=it.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=it.readSync(o,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let h=new Fn(u);if(!h.cksumValid)break;let p=512*Math.ceil((h.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,Nw(t,r,c,o,e)}finally{if(i)try{it.closeSync(o)}catch{}}},Nw=(t,e,r,i,o)=>{let c=new Nu(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Lw=(t,e)=>{e=Array.from(e);let r=new $s(t),i=(o,c,l)=>{let u=(T,_)=>{T?it.close(o,v=>l(T)):l(null,_)},h=0;if(c===0)return u(null,0);let p=0,m=Buffer.alloc(512),E=(T,_)=>{if(T||_===void 0)return u(T);if(p+=_,p<512&&_)return it.read(o,m,p,m.length-p,h+p,E);if(h===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,h);let v=new Fn(m);if(!v.cksumValid)return u(null,h);let I=512*Math.ceil((v.size??0)/512);if(h+I+512>c||(h+=I+512,h>=c))return u(null,h);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,it.read(o,m,0,512,h,E)};it.read(o,m,0,512,h,E)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(h,p)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",it.open(t.file,l,u);if(h||!p)return c(h);it.fstat(p,(m,E)=>{if(m)return it.close(p,()=>c(m));i(p,E.size,(T,_)=>{if(T)return c(T);let v=new js(t.file,{fd:p,start:_});r.pipe(v),v.on("error",c),v.on("close",o),Bw(r,e)})})};it.open(t.file,l,u)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},fi=vi(Pw,Lw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!sm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),D2=vi(fi.syncFile,fi.asyncFile,fi.syncNoFile,fi.asyncNoFile,(t,e=[])=>{fi.validate?.(t,e),zw(t)}),zw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var yt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Si(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function xf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Dc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function pf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function yr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}$e();te();Ne();$e();function Kt(t,e){if(Si(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ys(t){return t.startsWith("http://")||t.startsWith("https://")}function Zs(t){return t.endsWith("/")?t.slice(0,-1):t}$e();te();var Xs="1008033",gf="1289";var mf="pbbp2",wf="https://www.coze.cn",_f="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",qw="wss://frontier.coze.cn";function Qs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function yf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??qw}function Er(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Ai(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ii=U("handshake");async function kc(t){let e=Qs(t.endpoint),r=t.timeoutMs??1e4,i=`${Zs(e)}${_f}?aid=${encodeURIComponent(Xs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Er(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ii.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${v.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${h}`);let E=m.data??{},T=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!T||!_){let v=JSON.stringify(m).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${v}`)}return Ii.info("handshake ok",{remoteDeviceId:_,logid:h,traceId:p}),{accessKey:T,deviceId:_}}catch(u){if(u instanceof R)throw Ii.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ii.warn("handshake timeout",{base:e,timeoutMs:r}),new R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw Ii.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:h?.code,syscall:h?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Oc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto",Ef=2e5;function bf(t){return{model:Pc(t.model)??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function vf(t){return!t||t===Et}var Hw=new Set(["auto","\u81EA\u52A8"]);function Pc(t){let e=t?.trim();if(e)return Hw.has(e.toLowerCase())?Et:e}function Sf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Oc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||Et;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else vf(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function If(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||Et}"`):vf(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Oc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Ef;e.push("-c",`model_context_window=${r}`)}return e}function Af(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Nc(t,e){let{ttEnv:r,usePpe:i}=Ai(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Tf(t,e,r){if(!t.modelToken)return{};let i=Nc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
92
- `)}}function Lc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Rf(t,e,r){if(!t.modelToken)return null;let i=t.model||Et,o=Nc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Oc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Ef,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Cf(t,e,r){if(!t.modelToken)return[];let i=Nc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Be=U("agent-handlers"),Df=5*1024*1024,Jw=1,Vw=6,Yw=new Set(["node_modules",".git",".coze","dist","build",".next"]),eo=class{constructor(e){this.opts=e}opts;async listSkills(e){Kt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=Ot(o,u.relPath,"SKILL.md");await Ww(h).then(m=>m.isFile()).catch(()=>!1)&&l.push(t_(u))}return{skills:l}}async addSkills(e){Kt(e._meta,"_agent/addSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((h,p)=>[h.skillId,p])),u=[];for(let h of o){let p=await Hc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});jc(c,l,p),u.push(h)}return await ss(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Kt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let h=Ot(i.workspace,u.relPath);await Gw(h,{recursive:!0,force:!0}),Be.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ss(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Be.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let h=c.downstream;c.downstream=void 0,Be.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(p=>Be.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Be.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ge(r);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Be.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Be.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),Be.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ge(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Be.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(Be.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Kt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Pc(e.model)??Et,i=await Ge(e.agentId);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),Be.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Be.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Be.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let h=o.sessions.get(l);h?.downstream&&(await h.downstream.stop(`switchModel: ${r}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(c),Be.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Kt(e._meta,yt.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,yt.RESET),await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Be.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await Zr(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ge(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(Kt(e._meta,yt.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Be.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Be.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Be.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Kt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Mc(l).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Yr(l,o))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=f_(e.depth);return u.isDirectory()?{tree:await u_(o,l,c,h)}:{tree:[{name:h_(c),path:Bf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Kt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Mc(o).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Yr(o,i))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Df)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Df})`);let l=await kf(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ge(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Fc(e,r||"."),o=qc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Of}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ge(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function Zw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Xw(t){return t==="claude-code"?Ot(".claude","skills"):Ot(".agents","skills")}var Qw=3e4,e_=50*1024*1024,br=3e4;async function Hc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new R("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new R("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=Zw(o.skillName),h=Xw(i),p=Ot(h,u),m=Ot(r,p);if(await Bc(m,{recursive:!0}),c){let T=Buffer.from(o.content,"utf8");Ti(T.length),await zc(Ot(m,"SKILL.md"),T,"utf8")}else{let T=await n_(o.downloadUrl);i_(T)?await c_(T,m):s_(T)?await o_(T,m):await zc(Ot(m,"SKILL.md"),T.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Be.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),E}function jc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function t_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function n_(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ti(e);let r=r_(t);return Ti(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await kf(e);return Ti(r.length),r}if(Ys(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new R("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ti(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ti(t){if(t>e_)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(t){return t.length>=2&&t[0]===31&&t[1]===139}function s_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function Uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new Lf.default(t),i=r.getEntries()}catch(l){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Uc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=a_(i),c=Fc(e);for(let l of i){if(Uc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=Fc(e,u),p=qc(c,h);if(p.startsWith("..")||p==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Bc(h,{recursive:!0});continue}await Bc(Kw(h),{recursive:!0});let m;try{m=l.getData()}catch(E){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await zc(h,m)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||Uc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=ff({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`))},br);try{await Nf(Pf.from(t),r)}catch(c){throw c instanceof R?c:i?new R("IPC_BAD_REQUEST",`tar extract timeout (${br}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`))},br);try{await Nf(Pf.from(t),r)}catch(c){throw i?new R("IPC_BAD_REQUEST",`tar list timeout (${br}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var l_=5e3;async function u_(t,e,r,i){return Mf(t,e,r,i,{count:0})}async function Mf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await jw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(Yw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Ot(e,u.name),p=$w(Ot(r,u.name)),m=null;try{m=await Mc(h)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let E={name:u.name,path:Bf(qc(t,h)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(E.children=await Mf(t,h,p,i-1,o)),l.push(E)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function f_(t){return!t||t<=0?Jw:Math.min(t,Vw)}function h_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Bf(t){return t.split(Of).join("/")}te();import{readFileSync as UI}from"node:fs";import{dirname as HI,join as jI}from"node:path";import{fileURLToPath as WI}from"node:url";var vr="0.1.96-beta.2";var wn=U("agent-health-reporter"),x_=1e4,Ri=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??x_}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),wn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),wn.info("heartbeat stopped"))}async tick(){if(this.inFlight){wn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){wn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=p_(l);if(!u)continue;let h={agentId:l.agentId,status:u};l.patToken&&(h.patToken=l.patToken),l.accountId&&(h.accountId=l.accountId),r.push(h)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){wn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(wn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){wn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){wn.warn("onTickEnd hook failed",{err:String(r)})}}};function p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as ay,mkdir as lo,rm as cy,stat as dy,writeFile as ly}from"node:fs/promises";import{homedir as uy}from"node:os";import{join as i0}from"node:path";nn();import{spawnSync as O_}from"node:child_process";import{existsSync as P_}from"node:fs";import{release as N_}from"node:os";import{basename as L_,isAbsolute as M_}from"node:path";function Ci(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ir(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}$e();var to=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function zf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Ff(t){return"method"in t&&!("id"in t)}function no(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Q.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Q.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Q.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Di(t.message)}:typeof t=="string"?Di(t):typeof t=="object"?__(t):t}var w_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Di(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Di(i):e[r]=i;return e}function ki(t){if(t instanceof R){let e=m_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:g_[t.code]??Q.INTERNAL_ERROR,message:Di(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Di(t instanceof Error?t.message:String(t))}}function Uf(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...u}=e;c=u}return new R(r,o,{retriable:e?.retriable??!1,cause:c})}function Hf(t){return`${JSON.stringify(t)}
93
- `}var qf=10*1024*1024,ro=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>qf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${qf} bytes`)}),[]}let r=this.buffer.split(`
94
- `);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var Gf={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},nA=Object.fromEntries(Object.entries(Gf).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ar=class{seq=0;next(e,r){this.seq+=1;let i=Gf[e]??E_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>jf(r?.[h]??"")),u=b_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>jf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function E_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function jf(t){return t.replace(/[:_\s]+/g,"-")}function b_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Vr();import{readFileSync as v_}from"node:fs";var S_=384;async function Gc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:S_})}function Wc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Wf(t,e,r={},i=o=>o){return{...i({...t,...Wc(e)}),...r}}yn();Zi();$e();te();Ne();var k_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (claude ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function Vf(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=Ft("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),z_=200,F_=40,U_=Ft("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),q_=Ft("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),H_=Ft("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Yf=500;function j_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Yf?t:`${e.slice(0,Yf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Zf(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),O_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function Xf(t){try{return P_(t)}catch{return}}function G_(t,e){return{platform:process.platform,osRelease:N_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?Xf(e.command):void 0,cwd:e.cwd,cwdExists:Xf(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${L_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Pt=class{constructor(e){this.opts=e;this.log=U(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new ro({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ar;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Wf(process.env,this.opts.agentEnvFile??Z().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=lt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>z_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=G_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new R("AGENT_SPAWN_FAILED",W_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Zf(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Zf(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=U_,i=q_,o=H_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ir(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_n(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),u=Ci(l,e,r),h=(()=>{if(typeof r!="object"||r===null)return;let E=r.sessionId;return typeof E=="string"?E:void 0})(),p=i>0&&Number.isFinite(i),m=o>0&&Number.isFinite(o);return new Promise((E,T)=>{let _={resolve:E,reject:T,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},v=Date.now();if(p){let S=()=>{_.timer=setTimeout(()=>{let C=Date.now()-v;if(this.inflightAgentRequests.size>0&&C<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:C,approvalMaxMs:c,...h?{sessionId:h}:{}}),S();return}this.pending.delete(l),_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer);let N=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:N,...h?{sessionId:h}:{}}),T(N?new R("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=m?()=>{_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),_.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...h?{sessionId:h}:{}}),I?.();return}_.timer&&clearTimeout(_.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...h?{sessionId:h}:{}}),T(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;_.onFirstUpdate=m?()=>{_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),_.firstUpdateTimer=null,_.onFirstUpdate=null}:null,this.pending.set(l,_),I?.();try{this.writeFrame(u)}catch(S){_.timer&&clearTimeout(_.timer),_.firstUpdateTimer&&clearTimeout(_.firstUpdateTimer),this.pending.delete(l),T(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Hf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(no(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(Uf(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:j_(e.result)}),r.resolve(e.result));return}if(Ff(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(zf(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_n(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(_n(e.id,ki(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new R("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(F_).join(`
95
- `),o=Vf(this.framework,i);return o?new R(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new R("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var io=class extends Pt{framework="claude-code";constructor(e){let{command:r,args:i}=Jr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return K_(e)}};nn();import{mkdtempSync as $_,rmSync as J_}from"node:fs";import{tmpdir as V_}from"node:os";import{join as Y_}from"node:path";var so=class extends Pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Jr("codex",e.command,i),l=e.isolateCodexHome?$_(Y_(V_(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,h={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(h),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{J_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Z_=3e4,Tr=class extends Pt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Z_))}get acpSessionName(){return this.sessionName}};$e();te();Ne();function Kc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();var En=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var oo=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new En,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Oi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Oi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();te();import{constants as Qf}from"node:fs";import{access as X_}from"node:fs/promises";import{delimiter as Q_,join as ey}from"node:path";var bt=U("framework-detector"),e0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ty=[".exe",".cmd",".bat",".ps1"],qn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??lt,access:e.access??X_}}async detect(e){let r=e0[e],i=await this.which(r);if(!i)return bt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(e0).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(Q_).filter(Boolean),i=this.env.platform==="win32"?["",...ty]:[""];for(let o of r)for(let c of i){let l=ey(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Qf.F_OK:Qf.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return bt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return bt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return bt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return bt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(bt.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(bt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return bt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return bt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||bt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){bt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(ry(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),u(null)},15e3),h.stdout?.on("data",p=>{o+=p.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",p=>u({code:p,stdout:o}))}catch{u(null)}})}},ny=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ry(t){return t.replace(ny,"")}import{homedir as iy}from"node:os";import{join as sy}from"node:path";yn();$e();Vr();te();async function r0(){let t=sy(iy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var t0=U("openclaw.config"),oy=[0,5e3,5e3],n0="models.providers.",ao="agents.defaults.models",co=class{command;env;retryDelaysMs;queue=new En;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??oy}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,t0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=lt(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){t0.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${n0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${n0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ao}[${e}]`,()=>this.runCli(["config","set",ao,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ao}[${e}]`,`${ao}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var xe=U("agent-manager"),fy=(t,e,r,i,o,c,l,u,h)=>{switch(t){case"claude-code":{let p={...o?{...Sf(o),...Tf(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new io({cwd:r,env:p,agentId:i})}case"codex":{let m=[...o?[...If(o),...Cf(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...o?Af(o):{},...h??{}},T=!!o;return new so({cwd:r,agentId:i,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...T?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tr({command:e,cwd:r,agentId:i,...c?{sessionName:Kc(c)}:{}})}};function $c(t){return t==="claude-code"||t==="codex"}function hy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(xy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
89
+ `},configPath(t){return T2(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 Rh("schtasks",["/Create","/SC","ONLOGON","/TN",sa,"/TR",r,"/RU",t.userName,"/F"]),Nd.info("task scheduler entry created",{task:sa,logFile:t.logFile})},async uninstall(t){await Rh("schtasks",["/Delete","/TN",sa,"/F"]).catch(e=>Nd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Nd.info("task scheduler entry removed",{task:sa})}}});var Ph={};ma(Ph,{buildContext:()=>O2,getSupervisor:()=>R2,launchdSupervisor:()=>Od,systemdSupervisor:()=>Ld,taskSchedulerSupervisor:()=>Md});import{homedir as D2,userInfo as C2}from"node:os";function R2(t=process.platform){switch(t){case"darwin":return Od;case"linux":return Ld;case"win32":return Md;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function P2(){let t={};for(let e of k2){let r=process.env[e];r&&(t[e]=r)}return t}function O2(){let t=Q();return{nodeBin:process.execPath,entry:Ad(t),logFile:t.logFile,homeDir:D2(),userName:C2().username,isRoot:process.getuid?.()===0,env:P2()}}var k2,Oh=Qe(()=>{"use strict";Ne();Jo();Th();Ch();kh();k2=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});se();sn();var ul=q("acp-installer-warmup"),ng=["claude-code","codex"];async function xl(t={}){let e=t.ensure??ir,i=(await Promise.allSettled(ng.map(async o=>{let c=await e(o);ul.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&ul.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}on();se();import{readdir as hg}from"node:fs/promises";import{mkdir as _l,writeFile as yl}from"node:fs/promises";import{join as Sa}from"node:path";var xg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function ar(t,e,r){await _l(t,{recursive:!0});let i=xg[e],o=Sa(t,i);return await yl(o,r??"","utf8"),o}async function El(t){let e=Sa(t,".claude");await _l(e,{recursive:!0});let r=Sa(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await yl(r,i,"utf8"),r}var it=q("agent-detail-sync"),pg=6e4,gg=5*6e4,us=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await hg(r)}catch(o){it.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}it.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await $e(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){it.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){it.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),it.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){it.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){it.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await $e(e,this.opts.paths);if(!i){it.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){it.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,gg):pg;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(o.agentId&&o.agentId!==e){it.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&&it.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){it.debug("detail sync: no diff",{agentId:e});return}await nt(i,this.opts.paths),it.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await ar(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var zf=Tt(e0(),1);import{lstat as Fc,mkdir as Uc,readFile as Lf,readdir as jw,rm as Hw,stat as Ww,writeFile as qc}from"node:fs/promises";import{dirname as Kw,join as Lt,normalize as $w,relative as Hc,resolve as Gc,sep as Nf}from"node:path";import{Readable as Mf}from"node:stream";import{pipeline as Bf}from"node:stream/promises";import zg from"events";import rt from"fs";import{EventEmitter as vc}from"node:events";import N0 from"node:stream";import{StringDecoder as Fg}from"node:string_decoder";import z0 from"node:path";import _r from"node:fs";import{dirname as Xg,parse as Qg}from"path";import{EventEmitter as am}from"events";import ic from"assert";import{Buffer as qn}from"buffer";import*as s0 from"zlib";import cm from"zlib";import{posix as ur}from"node:path";import{basename as Nm}from"node:path";import Hs from"fs";import kt from"fs";import u0 from"path";import{win32 as Km}from"node:path";import _0 from"path";import Q0 from"node:fs";import dw from"node:assert";import{randomBytes as ef}from"node:crypto";import oe from"node:fs";import Be from"node:path";import tf from"fs";import Qs from"node:fs";import Ei from"node:path";import at from"node:fs";import gw from"node:fs/promises";import $s from"node:path";import{join as xf}from"node:path";import ot from"node:fs";import gf from"node:path";var Mg=Object.defineProperty,Bg=(t,e)=>{for(var r in e)Mg(t,r,{get:e[r],enumerable:!0})},t0=typeof process=="object"&&process?process:{stdout:null,stderr:null},Ug=t=>!!t&&typeof t=="object"&&(t instanceof Hn||t instanceof N0||qg(t)||Gg(t)),qg=t=>!!t&&typeof t=="object"&&t instanceof vc&&typeof t.pipe=="function"&&t.pipe!==N0.Writable.prototype.pipe,Gg=t=>!!t&&typeof t=="object"&&t instanceof vc&&typeof t.write=="function"&&typeof t.end=="function",Gt=Symbol("EOF"),jt=Symbol("maybeEmitEnd"),cn=Symbol("emittedEnd"),ms=Symbol("emittingEnd"),ii=Symbol("emittedError"),ws=Symbol("closed"),n0=Symbol("read"),_s=Symbol("flush"),r0=Symbol("flushChunk"),mt=Symbol("encoding"),fr=Symbol("decoder"),qe=Symbol("flowing"),si=Symbol("paused"),gr=Symbol("resume"),Ge=Symbol("buffer"),Ze=Symbol("pipes"),je=Symbol("bufferLength"),Ra=Symbol("bufferPush"),ys=Symbol("bufferShift"),Ve=Symbol("objectMode"),Te=Symbol("destroyed"),ka=Symbol("error"),Pa=Symbol("emitData"),i0=Symbol("emitEnd"),Oa=Symbol("emitEnd2"),Dt=Symbol("async"),La=Symbol("abort"),Es=Symbol("aborted"),oi=Symbol("signal"),Pn=Symbol("dataListeners"),st=Symbol("discarded"),ai=t=>Promise.resolve().then(t),jg=t=>t(),Hg=t=>t==="end"||t==="finish"||t==="prefinish",Wg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Kg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),M0=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[gr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},$g=class extends M0{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},Jg=t=>!!t.objectMode,Vg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Hn=class extends vc{[qe]=!1;[si]=!1;[Ze]=[];[Ge]=[];[Ve];[mt];[Dt];[fr];[Gt]=!1;[cn]=!1;[ms]=!1;[ws]=!1;[ii]=null;[je]=0;[Te]=!1;[oi];[Es]=!1;[Pn]=0;[st]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Jg(e)?(this[Ve]=!0,this[mt]=null):Vg(e)?(this[mt]=e.encoding,this[Ve]=!1):(this[Ve]=!1,this[mt]=null),this[Dt]=!!e.async,this[fr]=this[mt]?new Fg(this[mt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ge]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ze]});let{signal:r}=e;r&&(this[oi]=r,r.aborted?this[La]():r.addEventListener("abort",()=>this[La]()))}get bufferLength(){return this[je]}get encoding(){return this[mt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ve]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Dt]}set async(t){this[Dt]=this[Dt]||!!t}[La](){this[Es]=!0,this.emit("abort",this[oi]?.reason),this.destroy(this[oi]?.reason)}get aborted(){return this[Es]}set aborted(t){}write(t,e,r){if(this[Es])return!1;if(this[Gt])throw new Error("write after end");if(this[Te])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[Dt]?ai:jg;if(!this[Ve]&&!Buffer.isBuffer(t)){if(Kg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Wg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ve]?(this[qe]&&this[je]!==0&&this[_s](!0),this[qe]?this.emit("data",t):this[Ra](t),this[je]!==0&&this.emit("readable"),r&&i(r),this[qe]):t.length?(typeof t=="string"&&!(e===this[mt]&&!this[fr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[mt]&&(t=this[fr].write(t)),this[qe]&&this[je]!==0&&this[_s](!0),this[qe]?this.emit("data",t):this[Ra](t),this[je]!==0&&this.emit("readable"),r&&i(r),this[qe]):(this[je]!==0&&this.emit("readable"),r&&i(r),this[qe])}read(t){if(this[Te])return null;if(this[st]=!1,this[je]===0||t===0||t&&t>this[je])return this[jt](),null;this[Ve]&&(t=null),this[Ge].length>1&&!this[Ve]&&(this[Ge]=[this[mt]?this[Ge].join(""):Buffer.concat(this[Ge],this[je])]);let e=this[n0](t||null,this[Ge][0]);return this[jt](),e}[n0](t,e){if(this[Ve])this[ys]();else{let r=e;t===r.length||t===null?this[ys]():typeof r=="string"?(this[Ge][0]=r.slice(t),e=r.slice(0,t),this[je]-=t):(this[Ge][0]=r.subarray(t),e=r.subarray(0,t),this[je]-=t)}return this.emit("data",e),!this[Ge].length&&!this[Gt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Gt]=!0,this.writable=!1,(this[qe]||!this[si])&&this[jt](),this}[gr](){this[Te]||(!this[Pn]&&!this[Ze].length&&(this[st]=!0),this[si]=!1,this[qe]=!0,this.emit("resume"),this[Ge].length?this[_s]():this[Gt]?this[jt]():this.emit("drain"))}resume(){return this[gr]()}pause(){this[qe]=!1,this[si]=!0,this[st]=!1}get destroyed(){return this[Te]}get flowing(){return this[qe]}get paused(){return this[si]}[Ra](t){this[Ve]?this[je]+=1:this[je]+=t.length,this[Ge].push(t)}[ys](){return this[Ve]?this[je]-=1:this[je]-=this[Ge][0].length,this[Ge].shift()}[_s](t=!1){do;while(this[r0](this[ys]())&&this[Ge].length);!t&&!this[Ge].length&&!this[Gt]&&this.emit("drain")}[r0](t){return this.emit("data",t),this[qe]}pipe(t,e){if(this[Te])return t;this[st]=!1;let r=this[cn];return e=e||{},t===t0.stdout||t===t0.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ze].push(e.proxyErrors?new $g(this,t,e):new M0(this,t,e)),this[Dt]?ai(()=>this[gr]()):this[gr]()),t}unpipe(t){let e=this[Ze].find(r=>r.dest===t);e&&(this[Ze].length===1?(this[qe]&&this[Pn]===0&&(this[qe]=!1),this[Ze]=[]):this[Ze].splice(this[Ze].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[st]=!1,this[Pn]++,!this[Ze].length&&!this[qe]&&this[gr]();else if(t==="readable"&&this[je]!==0)super.emit("readable");else if(Hg(t)&&this[cn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ii]){let i=e;this[Dt]?ai(()=>i.call(this,this[ii])):i.call(this,this[ii])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Pn]=this.listeners("data").length,this[Pn]===0&&!this[st]&&!this[Ze].length&&(this[qe]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Pn]=0,!this[st]&&!this[Ze].length&&(this[qe]=!1)),e}get emittedEnd(){return this[cn]}[jt](){!this[ms]&&!this[cn]&&!this[Te]&&this[Ge].length===0&&this[Gt]&&(this[ms]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ws]&&this.emit("close"),this[ms]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Te&&this[Te])return!1;if(t==="data")return!this[Ve]&&!r?!1:this[Dt]?(ai(()=>this[Pa](r)),!0):this[Pa](r);if(t==="end")return this[i0]();if(t==="close"){if(this[ws]=!0,!this[cn]&&!this[Te])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ii]=r,super.emit(ka,r);let o=!this[oi]||this.listeners("error").length?super.emit("error",r):!1;return this[jt](),o}else if(t==="resume"){let o=super.emit("resume");return this[jt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[jt](),i}[Pa](t){for(let r of this[Ze])r.dest.write(t)===!1&&this.pause();let e=this[st]?!1:super.emit("data",t);return this[jt](),e}[i0](){return this[cn]?!1:(this[cn]=!0,this.readable=!1,this[Dt]?(ai(()=>this[Oa]()),!0):this[Oa]())}[Oa](){if(this[fr]){let e=this[fr].end();if(e){for(let r of this[Ze])r.dest.write(e);this[st]||super.emit("data",e)}}for(let e of this[Ze])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ve]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ve]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ve])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[mt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Te,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[st]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Gt])return e();let i,o,c=h=>{this.off("data",l),this.off("end",f),this.off(Te,x),e(),o(h)},l=h=>{this.off("error",c),this.off("end",f),this.off(Te,x),this.pause(),i({value:h,done:!!this[Gt]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Te,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{o=m,i=h,this.once(Te,x),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[st]=!1;let t=!1,e=()=>(this.pause(),this.off(ka,e),this.off(Te,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(ka,e),this.once(Te,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Te])return t?this.emit("error",t):this.emit(Te),this;this[Te]=!0,this[st]=!0,this[Ge].length=0,this[je]=0;let e=this;return typeof e.close=="function"&&!this[ws]&&e.close(),t?this.emit("error",t):this.emit(Te),this}static get isStream(){return Ug}},Yg=rt.writev,wn=Symbol("_autoClose"),Et=Symbol("_close"),ci=Symbol("_ended"),le=Symbol("_fd"),Na=Symbol("_finished"),$t=Symbol("_flags"),Ma=Symbol("_flush"),nc=Symbol("_handleChunk"),rc=Symbol("_makeBuf"),_i=Symbol("_mode"),bs=Symbol("_needDrain"),Er=Symbol("_onerror"),br=Symbol("_onopen"),Ba=Symbol("_onread"),mr=Symbol("_onwrite"),_n=Symbol("_open"),yt=Symbol("_path"),xn=Symbol("_pos"),Ct=Symbol("_queue"),wr=Symbol("_read"),za=Symbol("_readSize"),Kt=Symbol("_reading"),di=Symbol("_remain"),Fa=Symbol("_size"),Ps=Symbol("_write"),On=Symbol("_writing"),Os=Symbol("_defaultFlag"),Un=Symbol("_errored"),Sc=class extends Hn{[Un]=!1;[le];[yt];[za];[Kt]=!1;[Fa];[di];[wn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Un]=!1,this[le]=typeof e.fd=="number"?e.fd:void 0,this[yt]=t,this[za]=e.readSize||16*1024*1024,this[Kt]=!1,this[Fa]=typeof e.size=="number"?e.size:1/0,this[di]=this[Fa],this[wn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[le]=="number"?this[wr]():this[_n]()}get fd(){return this[le]}get path(){return this[yt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[_n](){rt.open(this[yt],"r",(t,e)=>this[br](t,e))}[br](t,e){t?this[Er](t):(this[le]=e,this.emit("open",e),this[wr]())}[rc](){return Buffer.allocUnsafe(Math.min(this[za],this[di]))}[wr](){if(!this[Kt]){this[Kt]=!0;let t=this[rc]();if(t.length===0)return process.nextTick(()=>this[Ba](null,0,t));rt.read(this[le],t,0,t.length,null,(e,r,i)=>this[Ba](e,r,i))}}[Ba](t,e,r){this[Kt]=!1,t?this[Er](t):this[nc](e,r)&&this[wr]()}[Et](){if(this[wn]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,rt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Er](t){this[Kt]=!0,this[Et](),this.emit("error",t)}[nc](t,e){let r=!1;return this[di]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[di]<=0)&&(r=!1,this[Et](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[le]=="number"&&this[wr](),!1;case"error":return this[Un]?!1:(this[Un]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},Zg=class extends Sc{[_n](){let t=!0;try{this[br](null,rt.openSync(this[yt],"r")),t=!1}finally{t&&this[Et]()}}[wr](){let t=!0;try{if(!this[Kt]){this[Kt]=!0;do{let e=this[rc](),r=e.length===0?0:rt.readSync(this[le],e,0,e.length,null);if(!this[nc](r,e))break}while(!0);this[Kt]=!1}t=!1}finally{t&&this[Et]()}}[Et](){if(this[wn]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,rt.closeSync(t),this.emit("close")}}},Js=class extends zg{readable=!1;writable=!0;[Un]=!1;[On]=!1;[ci]=!1;[Ct]=[];[bs]=!1;[yt];[_i];[wn];[le];[Os];[$t];[Na]=!1;[xn];constructor(t,e){e=e||{},super(e),this[yt]=t,this[le]=typeof e.fd=="number"?e.fd:void 0,this[_i]=e.mode===void 0?438:e.mode,this[xn]=typeof e.start=="number"?e.start:void 0,this[wn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[xn]!==void 0?"r+":"w";this[Os]=e.flags===void 0,this[$t]=e.flags===void 0?r:e.flags,this[le]===void 0&&this[_n]()}emit(t,...e){if(t==="error"){if(this[Un])return!1;this[Un]=!0}return super.emit(t,...e)}get fd(){return this[le]}get path(){return this[yt]}[Er](t){this[Et](),this[On]=!0,this.emit("error",t)}[_n](){rt.open(this[yt],this[$t],this[_i],(t,e)=>this[br](t,e))}[br](t,e){this[Os]&&this[$t]==="r+"&&t&&t.code==="ENOENT"?(this[$t]="w",this[_n]()):t?this[Er](t):(this[le]=e,this.emit("open",e),this[On]||this[Ma]())}end(t,e){return t&&this.write(t,e),this[ci]=!0,!this[On]&&!this[Ct].length&&typeof this[le]=="number"&&this[mr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ci]?(this.emit("error",new Error("write() after end()")),!1):this[le]===void 0||this[On]||this[Ct].length?(this[Ct].push(t),this[bs]=!0,!1):(this[On]=!0,this[Ps](t),!0)}[Ps](t){rt.write(this[le],t,0,t.length,this[xn],(e,r)=>this[mr](e,r))}[mr](t,e){t?this[Er](t):(this[xn]!==void 0&&typeof e=="number"&&(this[xn]+=e),this[Ct].length?this[Ma]():(this[On]=!1,this[ci]&&!this[Na]?(this[Na]=!0,this[Et](),this.emit("finish")):this[bs]&&(this[bs]=!1,this.emit("drain"))))}[Ma](){if(this[Ct].length===0)this[ci]&&this[mr](null,0);else if(this[Ct].length===1)this[Ps](this[Ct].pop());else{let t=this[Ct];this[Ct]=[],Yg(this[le],t,this[xn],(e,r)=>this[mr](e,r))}}[Et](){if(this[wn]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,rt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},B0=class extends Js{[_n](){let t;if(this[Os]&&this[$t]==="r+")try{t=rt.openSync(this[yt],this[$t],this[_i])}catch(e){if(e?.code==="ENOENT")return this[$t]="w",this[_n]();throw e}else t=rt.openSync(this[yt],this[$t],this[_i]);this[br](null,t)}[Et](){if(this[wn]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,rt.closeSync(t),this.emit("close")}}[Ps](t){let e=!0;try{this[mr](null,rt.writeSync(this[le],t,0,t.length,this[xn])),e=!1}finally{if(e)try{this[Et]()}catch{}}}},em=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),tm=t=>!!t.sync&&!!t.file,nm=t=>!t.sync&&!!t.file,rm=t=>!!t.sync&&!t.file,im=t=>!t.sync&&!t.file,sm=t=>!!t.file,om=t=>em.get(t)||t,Ic=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=om(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Di=(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=Ic(c);if(o?.(x,l),tm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(nm(x)){let h=e(x,l);return f?h.then(()=>f(),f):h}else if(rm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(im(x)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),dm=cm.constants||{ZLIB_VERNUM:4736},Ot=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},dm)),lm=qn.concat,o0=Object.getOwnPropertyDescriptor(qn,"concat"),fm=t=>t,Ua=o0?.writable===!0||o0?.set!==void 0?t=>{qn.concat=t?fm:lm}:t=>{},Gn=Symbol("_superWrite"),vs=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"}},qa=Symbol("flushFlag"),Ac=class extends Hn{#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 s0[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new s0[e](t)}catch(r){throw new vs(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 vs(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ic(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(qn.alloc(0),{[qa]: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}[Gn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=qn.from(t,e)),this.#e)return;ic(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ua(!0);let l;try{let x=typeof t[qa]=="number"?t[qa]:this.#r;l=this.#t._processChunk(t,x),Ua(!1)}catch(x){Ua(!1),this.#o(new vs(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 vs(x,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];f=this[Gn](qn.from(x));for(let h=1;h<l.length;h++)f=this[Gn](l[h])}else f=this[Gn](qn.from(l));return r&&r(),f}},F0=class extends Ac{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Ot.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ot.Z_FINISH,t.fullFlushFlag=Ot.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Ot.Z_SYNC_FLUSH),ic(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},um=class extends F0{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Gn](t){return this.#e?(this.#e=!1,t[9]=255,super[Gn](t)):super[Gn](t)}},xm=class extends F0{constructor(t){super(t,"Unzip")}},U0=class extends Ac{constructor(t,e){t=t||{},t.flush=t.flush||Ot.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ot.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ot.BROTLI_OPERATION_FLUSH,super(t,e)}},hm=class extends U0{constructor(t){super(t,"BrotliCompress")}},pm=class extends U0{constructor(t){super(t,"BrotliDecompress")}},q0=class extends Ac{constructor(t,e){t=t||{},t.flush=t.flush||Ot.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ot.ZSTD_e_end,t.fullFlushFlag=Ot.ZSTD_e_flush,super(t,e)}},gm=class extends q0{constructor(t){super(t,"ZstdCompress")}},mm=class extends q0{constructor(t){super(t,"ZstdDecompress")}},wm=(t,e)=>{if(Number.isSafeInteger(t))t<0?ym(t,e):_m(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},_m=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},ym=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=G0(o):o===0?e[i-1]=0:(r=!0,e[i-1]=j0(o))}},Em=t=>{let e=t[0],r=e===128?vm(t.subarray(1,t.length)):e===255?bm(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},bm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=G0(c):c===0?l=c:(i=!0,l=j0(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},vm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},G0=t=>(255^t)&255,j0=t=>(255^t)+1&255,Sm={};Bg(Sm,{code:()=>Tc,isCode:()=>Ls,isName:()=>Im,name:()=>Vs});var Ls=t=>Vs.has(t),Im=t=>Tc.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"]]),Tc=new Map(Array.from(Vs).map(t=>[t[1],t[0]])),jn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Ln(t,e,100),this.mode=r?.mode??i?.mode??hn(t,e+100,8),this.uid=r?.uid??i?.uid??hn(t,e+108,8),this.gid=r?.gid??i?.gid??hn(t,e+116,8),this.size=r?.size??i?.size??hn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ga(t,e+136,12),this.cksum=hn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Ln(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=Ln(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Ln(t,e+265,32),this.gname=r?.gname??i?.gname??Ln(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??hn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??hn(t,e+337,8)??0,t[e+475]!==0){let l=Ln(t,e+345,155);this.path=l+"/"+this.path}else{let l=Ln(t,e+345,130);l&&(this.path=l+"/"+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 l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Am(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Nn(t,e,100,o)||this.needPax,this.needPax=pn(t,e+100,8,this.mode)||this.needPax,this.needPax=pn(t,e+108,8,this.uid)||this.needPax,this.needPax=pn(t,e+116,8,this.gid)||this.needPax,this.needPax=pn(t,e+124,12,this.size)||this.needPax,this.needPax=ja(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Nn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Nn(t,e+265,32,this.uname)||this.needPax,this.needPax=Nn(t,e+297,32,this.gname)||this.needPax,this.needPax=pn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=pn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Nn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Nn(t,e+345,155,c)||this.needPax:(this.needPax=Nn(t,e+345,130,c)||this.needPax,this.needPax=ja(t,e+476,12,this.atime)||this.needPax,this.needPax=ja(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let 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,pn(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(Tc.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)}},Am=(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},Ln=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ga=(t,e,r)=>Tm(hn(t,e,r)),Tm=t=>t===void 0?void 0:new Date(t*1e3),hn=(t,e,r)=>Number(t[e])&128?Em(t.subarray(e,e+r)):Cm(t,e,r),Dm=t=>isNaN(t)?void 0:t,Cm=(t,e,r)=>Dm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Rm={12:8589934591,8:2097151},pn=(t,e,r,i)=>i===void 0?!1:i>Rm[r]||i<0?(wm(i,t.subarray(e,e+r)),!0):(km(t,e,r,i),!1),km=(t,e,r,i)=>t.write(Pm(i,r),e,r,"ascii"),Pm=(t,e)=>Om(Math.floor(t).toString(8),e),Om=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ja=(t,e,r,i)=>i===void 0?!1:pn(t,e,r,i.getTime()/1e3),Lm=new Array(156).join("\0"),Nn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Lm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),js=class H0{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new jn({path:("PaxHeader/"+Nm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
90
+ `,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new H0(Mm(Bm(e),r),i)}},Mm=(t,e)=>e?Object.assign({},e,t):t,Bm=t=>t.replace(/\n$/,"").split(`
91
+ `).reduce(zm,Object.create(null)),zm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,X=Fm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),W0=class extends Hn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=X(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?X(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=X(t.path)),t.linkpath&&(t.linkpath=X(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ys=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Um=1024*1024,sc=Buffer.from([31,139]),oc=Buffer.from([40,181,47,253]),qm=Math.max(sc.length,oc.length),lt=Symbol("state"),Mn=Symbol("writeEntry"),Ht=Symbol("readEntry"),Ha=Symbol("nextEntry"),a0=Symbol("processEntry"),Rt=Symbol("extendedHeader"),li=Symbol("globalExtendedHeader"),dn=Symbol("meta"),c0=Symbol("emitMeta"),pe=Symbol("buffer"),Wt=Symbol("queue"),ln=Symbol("ended"),Wa=Symbol("emittedEnd"),Bn=Symbol("emit"),ke=Symbol("unzip"),Ss=Symbol("consumeChunk"),Is=Symbol("consumeChunkSub"),Ka=Symbol("consumeBody"),d0=Symbol("consumeMeta"),l0=Symbol("consumeHeader"),fi=Symbol("consuming"),$a=Symbol("bufferConcat"),As=Symbol("maybeEnd"),xr=Symbol("writing"),fn=Symbol("aborted"),Ts=Symbol("onDone"),zn=Symbol("sawValidEntry"),Ds=Symbol("sawNullBlock"),Cs=Symbol("sawEOF"),f0=Symbol("closeStream"),Gm=()=>!0,Ti=class extends am{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[pe];[Ht];[Mn];[lt]="begin";[dn]="";[Rt];[li];[ln]=!1;[ke];[fn]=!1;[zn];[Ds]=!1;[Cs]=!1;[xr]=!1;[fi]=!1;[Wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ts,()=>{(this[lt]==="begin"||this[zn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Ts,t.ondone):this.on(Ts,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Um,this.filter=typeof t.filter=="function"?t.filter:Gm;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[f0]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ys(this,t,e,r)}[l0](t,e){this[zn]===void 0&&(this[zn]=!1);let r;try{r=new jn(t,e,this[Rt],this[li])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ds]?(this[Cs]=!0,this[lt]==="begin"&&(this[lt]="header"),this[Bn]("eof")):(this[Ds]=!0,this[Bn]("nullBlock"));else if(this[Ds]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[Mn]=new W0(r,this[Rt],this[li]);if(!this[zn])if(o.remain){let c=()=>{o.invalid||(this[zn]=!0)};o.on("end",c)}else this[zn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Bn]("ignoredEntry",o),this[lt]="ignore",o.resume()):o.size>0&&(this[dn]="",o.on("data",c=>this[dn]+=c),this[lt]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Bn]("ignoredEntry",o),this[lt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[lt]="body":(this[lt]="header",o.end()),this[Ht]?this[Wt].push(o):(this[Wt].push(o),this[Ha]())))}}}[f0](){queueMicrotask(()=>this.emit("close"))}[a0](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[Ha]()),e=!1);return e}[Ha](){do;while(this[a0](this[Wt].shift()));if(this[Wt].length===0){let t=this[Ht];!t||t.flowing||t.size===t.remain?this[xr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ka](t,e){let r=this[Mn];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[lt]="header",this[Mn]=void 0,r.end()),o.length}[d0](t,e){let r=this[Mn],i=this[Ka](t,e);return!this[Mn]&&r&&this[c0](r),i}[Bn](t,e,r){this[Wt].length===0&&!this[Ht]?this.emit(t,e,r):this[Wt].push([t,e,r])}[c0](t){switch(this[Bn]("meta",this[dn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=js.parse(this[dn],this[Rt],!1);break;case"GlobalExtendedHeader":this[li]=js.parse(this[dn],this[li],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[dn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[dn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[fn])return r?.(),!1;if((this[ke]===void 0||this.brotli===void 0&&this[ke]===!1)&&t){if(this[pe]&&(t=Buffer.concat([this[pe],t]),this[pe]=void 0),t.length<qm)return this[pe]=t,r?.(),!0;for(let l=0;this[ke]===void 0&&l<sc.length;l++)t[l]!==sc[l]&&(this[ke]=!1);let o=!1;if(this[ke]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<oc.length;l++)if(t[l]!==oc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[ke]===!1&&c)if(t.length<512)if(this[ln])this.brotli=!0;else return this[pe]=t,r?.(),!0;else try{new jn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ke]===void 0||this[ke]===!1&&(this.brotli||o)){let l=this[ln];this[ln]=!1,this[ke]=this[ke]===void 0?new xm({}):o?new mm({}):new pm({}),this[ke].on("data",x=>this[Ss](x)),this[ke].on("error",x=>this.abort(x)),this[ke].on("end",()=>{this[ln]=!0,this[Ss]()}),this[xr]=!0;let f=!!this[ke][l?"end":"write"](t);return this[xr]=!1,r?.(),f}}this[xr]=!0,this[ke]?this[ke].write(t):this[Ss](t),this[xr]=!1;let i=this[Wt].length>0?!1:this[Ht]?this[Ht].flowing:!0;return!i&&this[Wt].length===0&&this[Ht]?.once("drain",()=>this.emit("drain")),r?.(),i}[$a](t){t&&!this[fn]&&(this[pe]=this[pe]?Buffer.concat([this[pe],t]):t)}[As](){if(this[ln]&&!this[Wa]&&!this[fn]&&!this[fi]){this[Wa]=!0;let t=this[Mn];if(t&&t.blockRemain){let e=this[pe]?this[pe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[pe]&&t.write(this[pe]),t.end()}this[Bn](Ts)}}[Ss](t){if(this[fi]&&t)this[$a](t);else if(!t&&!this[pe])this[As]();else if(t){if(this[fi]=!0,this[pe]){this[$a](t);let e=this[pe];this[pe]=void 0,this[Is](e)}else this[Is](t);for(;this[pe]&&this[pe]?.length>=512&&!this[fn]&&!this[Cs];){let e=this[pe];this[pe]=void 0,this[Is](e)}this[fi]=!1}(!this[pe]||this[ln])&&this[As]()}[Is](t){let e=0,r=t.length;for(;e+512<=r&&!this[fn]&&!this[Cs];)switch(this[lt]){case"begin":case"header":this[l0](t,e),e+=512;break;case"ignore":case"body":e+=this[Ka](t,e);break;case"meta":e+=this[d0](t,e);break;default:throw new Error("invalid state: "+this[lt])}e<r&&(this[pe]=this[pe]?Buffer.concat([t.subarray(e),this[pe]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[fn]||(this[ke]?(t&&this[ke].write(t),this[ke].end()):(this[ln]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[As]())),this}},yi=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()},K0=(t,e)=>{let r=new Map(e.map(c=>[yi(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||Qg(c).root||".",x;if(c===f)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(Xg(c),f)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(yi(c)):c=>o(yi(c))},Hm=t=>{let e=new Ti(t),r=t.file,i;try{i=_r.openSync(r,"r");let o=_r.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),f=_r.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=_r.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{_r.closeSync(i)}catch{}}},Wm=(t,e)=>{let r=new Ti(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),_r.stat(o,(f,x)=>{if(f)l(f);else{let h=new Sc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},vr=Di(Hm,Wm,t=>new Ti(t),t=>new Ti(t),(t,e)=>{e?.length&&K0(t,e),t.noResume||jm(t)}),$0=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:$m,parse:x0}=Km,Dc=t=>{let e="",r=x0(t);for(;$m(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=x0(t)}return[e,t]},Zs=["|","<",">","?",":"],Cc=Zs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),Jm=new Map(Zs.map((t,e)=>[t,Cc[e]])),Vm=new Map(Cc.map((t,e)=>[t,Zs[e]])),h0=t=>Zs.reduce((e,r)=>e.split(r).join(Jm.get(r)),t),Ym=t=>Cc.reduce((e,r)=>e.split(r).join(Vm.get(r)),t),J0=(t,e)=>e?(t=X(t).replace(/^\.(\/|$)/,""),yi(e)+"/"+t):X(t),Zm=16*1024*1024,p0=Symbol("process"),g0=Symbol("file"),m0=Symbol("directory"),ac=Symbol("symlink"),w0=Symbol("hardlink"),ui=Symbol("header"),Ns=Symbol("read"),cc=Symbol("lstat"),Ms=Symbol("onlstat"),dc=Symbol("onread"),lc=Symbol("onreadlink"),fc=Symbol("openfile"),uc=Symbol("onopenfile"),gn=Symbol("close"),Ws=Symbol("mode"),xc=Symbol("awaitDrain"),Ja=Symbol("ondrain"),Pt=Symbol("prefix"),V0=class extends Hn{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=Ic(e);super(),this.path=X(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||Zm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=X(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?X(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Dc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Ym(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=X(r.absolute||u0.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ms](o):this[cc]()}warn(t,e,r={}){return Ys(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[cc](){kt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ms](e)})}[Ms](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=ew(t),this.emit("stat",t),this[p0]()}[p0](){switch(this.type){case"File":return this[g0]();case"Directory":return this[m0]();case"SymbolicLink":return this[ac]();default:return this.end()}}[Ws](t){return $0(t,this.type==="Directory",this.portable)}[Pt](t){return J0(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 jn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,mode:this[Ws](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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[m0](){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()}[ac](){kt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[lc](e)})}[lc](t){this.linkpath=X(t),this[ui](),this.end()}[w0](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=X(u0.relative(this.cwd,t)),this.stat.size=0,this[ui](),this.end()}[g0](){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[w0](e);this.linkCache.set(t,this.absolute)}if(this[ui](),this.stat.size===0)return this.end();this[fc]()}[fc](){kt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[uc](e)})}[uc](t){if(this.fd=t,this.#e)return this[gn]();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[Ns]()}[Ns](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");kt.read(t,e,r,i,o,(c,l)=>{if(c)return this[gn](()=>this.emit("error",c));this[dc](l)})}[gn](t=()=>{}){this.fd!==void 0&&kt.close(this.fd,t)}[dc](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[gn](()=>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[gn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Ja]():this[xc](()=>this[Ja]())}[xc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ja](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[gn](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[Ns]()}},Xm=class extends V0{sync=!0;[cc](){this[Ms](kt.lstatSync(this.absolute))}[ac](){this[lc](kt.readlinkSync(this.absolute))}[fc](){this[uc](kt.openSync(this.absolute,"r"))}[Ns](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=kt.readSync(e,r,i,o,c);this[dc](l),t=!1}finally{if(t)try{this[gn](()=>{})}catch{}}}[xc](t){t()}[gn](t=()=>{}){this.fd!==void 0&&kt.closeSync(this.fd),t()}},Qm=class extends Hn{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 Ys(this,t,e,r)}constructor(t,e={}){let r=Ic(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=X(t.path),this.mode=t.mode!==void 0?this[Ws](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?X(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=Dc(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 jn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new 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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Pt](t){return J0(t,this.prefix)}[Ws](t){return $0(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},ew=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",tw=class yr{tail;head;length=0;static create(e=[]){return new yr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)rw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)iw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new yr;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 yr;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 yr;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 yr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=nw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function nw(t,e,r){let i=e,o=e?e.next:t.head,c=new Rc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function rw(t,e){t.tail=new Rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function iw(t,e){t.head=new Rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Rc=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}},y0=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},E0=Buffer.alloc(1024),Bs=Symbol("onStat"),xi=Symbol("ended"),wt=Symbol("queue"),hi=Symbol("queue"),un=Symbol("current"),Fn=Symbol("process"),pi=Symbol("processing"),Rs=Symbol("processJob"),_t=Symbol("jobs"),Va=Symbol("jobDone"),zs=Symbol("addFSEntry"),b0=Symbol("addTarEntry"),hc=Symbol("stat"),pc=Symbol("readdir"),Fs=Symbol("onreaddir"),Us=Symbol("pipe"),v0=Symbol("entry"),Ya=Symbol("entryOpt"),qs=Symbol("writeEntryClass"),Y0=Symbol("write"),Za=Symbol("ondrain"),Xs=class extends Hn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[qs];onWriteEntry;[wt];[hi]=new Map;[_t]=0;[pi]=!1;[xi]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=X(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[qs]=V0,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new um(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new hm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new gm(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Za]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Za]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[wt]=new tw,this[_t]=0,this.jobs=Number(t.jobs)||4,this[pi]=!1,this[xi]=!1}[Y0](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[xi]=!0,this[Fn](),r&&r(),this}write(t){if(this[xi])throw new Error("write after end");return t instanceof W0?this[b0](t):this[zs](t),this.flowing}[b0](t){let e=X(_0.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new y0(t.path,e);r.entry=new Qm(t,this[Ya](r)),r.entry.on("end",()=>this[Va](r)),this[_t]+=1,this[wt].push(r)}this[Fn]()}[zs](t){let e=X(_0.resolve(this.cwd,t));this[wt].push(new y0(t,e)),this[Fn]()}[hc](t){t.pending=!0,this[_t]+=1;let e=this.follow?"stat":"lstat";Hs[e](t.absolute,(r,i)=>{t.pending=!1,this[_t]-=1,r?this.emit("error",r):this[Bs](t,i)})}[Bs](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[un])this[Rs](t);else{let r=`${e.dev}:${e.ino}`,i=this[hi].get(r);i?i.push(t):this[hi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Fn]()}[pc](t){t.pending=!0,this[_t]+=1,Hs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[_t]-=1,e)return this.emit("error",e);this[Fs](t,r)})}[Fs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Fn]()}[Fn](){if(!this[pi]){this[pi]=!0;for(let t=this[wt].head;t&&this[_t]<this.jobs;t=t.next)if(this[Rs](t.value),t.value.ignore){let e=t.next;this[wt].removeNode(t),t.next=e}this[pi]=!1,this[xi]&&this[wt].length===0&&this[_t]===0&&(this.zip?this.zip.end(E0):(super.write(E0),super.end()))}}get[un](){return this[wt]&&this[wt].head&&this[wt].head.value}[Va](t){this[wt].shift(),this[_t]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[hi].get(r);if(i){this[hi].delete(r);for(let o of i)o.pending=!1,this[Rs](o)}}this[Fn]()}[Rs](t){if(t.pending&&t.pendingLink&&t===this[un]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[un]&&!t.piped&&this[Us](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Bs](t,e):this[hc](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[pc](t),!t.readdir)return}if(t.entry=this[v0](t),!t.entry){t.ignore=!0;return}t===this[un]&&!t.piped&&this[Us](t)}}}[Ya](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}}[v0](t){this[_t]+=1;try{return new this[qs](t.path,this[Ya](t)).on("end",()=>this[Va](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Za](){this[un]&&this[un].entry&&this[un].entry.resume()}[Us](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={}){Ys(this,t,e,r)}},kc=class extends Xs{sync=!0;constructor(t){super(t),this[qs]=Xm}pause(){}resume(){}[hc](t){let e=this.follow?"statSync":"lstatSync";this[Bs](t,Hs[e](t.absolute))}[pc](t){this[Fs](t,Hs.readdirSync(t.absolute))}[Us](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[Y0](i)})}},sw=(t,e)=>{let r=new kc(t),i=new B0(t.file,{mode:t.mode||438});r.pipe(i),Z0(r,e)},ow=(t,e)=>{let r=new Xs(t),i=new Js(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return X0(r,e).catch(c=>r.emit("error",c)),o},Z0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?vr({file:z0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},X0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await vr({file:z0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},aw=(t,e)=>{let r=new kc(t);return Z0(r,e),r},cw=(t,e)=>{let r=new Xs(t);return X0(r,e).catch(i=>r.emit("error",i)),r},p1=Di(sw,ow,aw,cw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),lw=process.env.__FAKE_PLATFORM__||process.platform,nf=lw==="win32",{O_CREAT:rf,O_NOFOLLOW:S0,O_TRUNC:sf,O_WRONLY:of}=tf.constants,af=Number(process.env.__FAKE_FS_O_FILENAME__)||tf.constants.UV_FS_O_FILEMAP||0,fw=nf&&!!af,uw=512*1024,xw=af|sf|rf|of,I0=!nf&&typeof S0=="number"?S0|sf|rf|of:null,cf=I0!==null?()=>I0:fw?t=>t<uw?xw:"w":()=>"w",gc=(t,e,r)=>{try{return Qs.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Ks=(t,e,r,i)=>{Qs.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},hw=(t,e,r,i,o)=>{if(e.isDirectory())df(Ei.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=Ei.resolve(t,e.name);Ks(l,r,i,o)});else{let c=Ei.resolve(t,e.name);Ks(c,r,i,o)}},df=(t,e,r,i)=>{Qs.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 l=c.length,f=null,x=h=>{if(!f){if(h)return i(f=h);if(--l===0)return Ks(t,e,r,i)}};for(let h of c)hw(t,h,e,r,x)})},pw=(t,e,r,i)=>{e.isDirectory()&&lf(Ei.resolve(t,e.name),r,i),gc(Ei.resolve(t,e.name),r,i)},lf=(t,e,r)=>{let i;try{i=Qs.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return gc(t,e,r);throw c}for(let o of i)pw(t,o,e,r);return gc(t,e,r)},ff=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"}},eo=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},mw=(t,e)=>{at.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new ff(t,r?.code||"ENOTDIR")),e(r)})},ww=(t,e,r)=>{t=X(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,m=e.unlink,E=X(e.cwd),A=(b,I)=>{b?r(b):I&&x?df(I,l,f,S=>A(S)):c?at.chmod(t,o,r):r()};if(t===E)return mw(t,A);if(h)return gw.mkdir(t,{mode:o,recursive:!0}).then(b=>A(null,b??void 0),A);let y=X($s.relative(E,t)).split("/");mc(E,y,o,m,E,void 0,A)},mc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),x=X($s.resolve(t+"/"+f));at.mkdir(x,r,uf(x,e,r,i,o,c,l))},uf=(t,e,r,i,o,c,l)=>f=>{f?at.lstat(t,(x,h)=>{if(x)x.path=x.path&&X(x.path),l(x);else if(h.isDirectory())mc(t,e,r,i,o,c,l);else if(i)at.unlink(t,m=>{if(m)return l(m);at.mkdir(t,r,uf(t,e,r,i,o,c,l))});else{if(h.isSymbolicLink())return l(new eo(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,mc(t,e,r,i,o,c,l))},_w=t=>{let e=!1,r;try{e=at.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new ff(t,r??"ENOTDIR")}},yw=(t,e)=>{t=X(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,m=X(e.cwd),E=b=>{b&&f&&lf(b,c,l),o&&at.chmodSync(t,i)};if(t===m)return _w(m),E();if(x)return E(at.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=X($s.relative(m,t)).split("/"),y;for(let b=A.shift(),I=m;b&&(I+="/"+b);b=A.shift()){I=X($s.resolve(I));try{at.mkdirSync(I,i),y=y||I}catch{let S=at.lstatSync(I);if(S.isDirectory())continue;if(h){at.unlinkSync(I),at.mkdirSync(I,i),y=y||I;continue}else if(S.isSymbolicLink())return new eo(I,I+"/"+A.join("/"))}}return E(y)},Xa=Object.create(null),A0=1e4,hr=new Set,Ew=t=>{hr.has(t)?hr.delete(t):Xa[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),hr.add(t);let e=Xa[t],r=hr.size-A0;if(r>A0/10){for(let i of hr)if(hr.delete(i),delete Xa[i],--r<=0)break}return e},bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vw=bw==="win32",Sw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=xf(i,r)),e.push(r||"/"),e},[]),Iw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=vw?["win32 parallelization disabled"]:t.map(i=>yi(xf(Ew(i))));let r=new Set(t.map(i=>Sw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let f=l[1];if(!f){this.#e.delete(c);continue}if(l.shift(),typeof f=="function")o.add(f);else for(let x of f)o.add(x)}for(let c of i){let l=this.#e.get(c),f=l?.[0];if(!(!l||!(f instanceof Set)))if(f.size===1&&l.length===1){this.#e.delete(c);continue}else if(f.size===1){l.shift();let x=l[0];typeof x=="function"&&o.add(x)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Aw=()=>process.umask(),T0=Symbol("onEntry"),wc=Symbol("checkFs"),D0=Symbol("checkFs2"),_c=Symbol("isReusable"),ft=Symbol("makeFs"),yc=Symbol("file"),Ec=Symbol("directory"),Gs=Symbol("link"),C0=Symbol("symlink"),R0=Symbol("hardlink"),wi=Symbol("ensureNoSymlink"),k0=Symbol("unsupported"),P0=Symbol("checkPath"),Qa=Symbol("stripAbsolutePath"),mn=Symbol("mkdir"),He=Symbol("onError"),ks=Symbol("pending"),O0=Symbol("pend"),pr=Symbol("unpend"),ec=Symbol("ended"),tc=Symbol("maybeClose"),bc=Symbol("skip"),bi=Symbol("doChown"),vi=Symbol("uid"),Si=Symbol("gid"),Ii=Symbol("checkedCwd"),Tw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ai=Tw==="win32",Dw=1024,Cw=(t,e)=>{if(!Ai)return oe.unlink(t,e);let r=t+".DELETE."+ef(16).toString("hex");oe.rename(t,r,i=>{if(i)return e(i);oe.unlink(r,e)})},Rw=t=>{if(!Ai)return oe.unlinkSync(t);let e=t+".DELETE."+ef(16).toString("hex");oe.renameSync(t,e),oe.unlinkSync(e)},L0=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Pc=class extends Ti{[ec]=!1;[Ii]=!1;[ks]=0;reservations=new Iw;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[ec]=!0,this[tc]()},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:Dw,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=X(Be.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Aw():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[T0](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[tc](){this[ec]&&this[ks]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Qa](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Dc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||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=Be.posix.dirname(t.path),x=Be.posix.normalize(Be.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}[P0](t){let e=X(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=X(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Qa](t,"path")||!this[Qa](t,"linkpath"))return!1;if(t.absolute=Be.isAbsolute(t.path)?X(Be.resolve(t.path)):X(Be.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:X(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Be.win32.parse(String(t.absolute));t.absolute=i+h0(String(t.absolute).slice(i.length));let{root:o}=Be.win32.parse(t.path);t.path=o+h0(t.path.slice(o.length))}return!0}[T0](t){if(!this[P0](t))return t.resume();switch(dw.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[wc](t);default:return this[k0](t)}}[He](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[pr](),e.resume())}[mn](t,e,r){ww(X(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[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}[vi](t){return L0(this.uid,t.uid,this.processUid)}[Si](t){return L0(this.gid,t.gid,this.processGid)}[yc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Js(String(t.absolute),{flags:cf(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&oe.close(i.fd,()=>{}),i.write=()=>!0,this[He](f,t),e()});let o=1,c=f=>{if(f){i.fd&&oe.close(i.fd,()=>{}),this[He](f,t),e();return}--o===0&&i.fd!==void 0&&oe.close(i.fd,x=>{x?this[He](x,t):this[pr](),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,m=t.mtime;oe.futimes(x,h,m,E=>E?oe.utimes(f,h,m,A=>c(A&&E)):c())}if(typeof x=="number"&&this[bi](t)){o++;let h=this[vi](t),m=this[Si](t);typeof h=="number"&&typeof m=="number"&&oe.fchown(x,h,m,E=>E?oe.chown(f,h,m,A=>c(A&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[He](f,t),e()}),t.pipe(l)),l.pipe(i)}[Ec](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[mn](String(t.absolute),r,i=>{if(i){this[He](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[pr](),t.resume())};t.mtime&&!this.noMtime&&(o++,oe.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[bi](t)&&(o++,oe.chown(String(t.absolute),Number(this[vi](t)),Number(this[Si](t)),c)),c()})}[k0](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[C0](t,e){let r=X(Be.relative(this.cwd,Be.resolve(Be.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[wi](t,this.cwd,r,()=>this[Gs](t,String(t.linkpath),"symlink",e),i=>{this[He](i,t),e()})}[R0](t,e){let r=X(Be.resolve(this.cwd,String(t.linkpath))),i=X(String(t.linkpath)).split("/");this[wi](t,this.cwd,i,()=>this[Gs](t,r,"link",e),o=>{this[He](o,t),e()})}[wi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Be.resolve(e,c);oe.lstat(l,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new eo(l,Be.resolve(l,r.join("/"))));this[wi](t,l,r,i,o)})}[O0](){this[ks]++}[pr](){this[ks]--,this[tc]()}[bc](t){this[pr](),t.resume()}[_c](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ai}[wc](t){this[O0]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[D0](t,r))}[D0](t,e){let r=l=>{e(l)},i=()=>{this[mn](this.cwd,this.dmode,l=>{if(l){this[He](l,t),r();return}this[Ii]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=X(Be.dirname(String(t.absolute)));if(l!==this.cwd)return this[mn](l,this.dmode,f=>{if(f){this[He](f,t),r();return}c()})}c()},c=()=>{oe.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[bc](t),r();return}if(l||this[_c](t,f))return this[ft](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,h=m=>this[ft](m??null,t,r);return x?oe.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return oe.rmdir(String(t.absolute),x=>this[ft](x??null,t,r))}if(t.absolute===this.cwd)return this[ft](null,t,r);Cw(String(t.absolute),x=>this[ft](x??null,t,r))})};this[Ii]?o():i()}[ft](t,e,r){if(t){this[He](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[yc](e,r);case"Link":return this[R0](e,r);case"SymbolicLink":return this[C0](e,r);case"Directory":case"GNUDumpDir":return this[Ec](e,r)}}[Gs](t,e,r,i){oe[r](e,String(t.absolute),o=>{o?this[He](o,t):(this[pr](),t.resume()),i()})}},gi=t=>{try{return[null,t()]}catch(e){return[e,null]}},hf=class extends Pc{sync=!0;[ft](t,e){return super[ft](t,e,()=>{})}[wc](t){if(!this[Ii]){let o=this[mn](this.cwd,this.dmode);if(o)return this[He](o,t);this[Ii]=!0}if(t.absolute!==this.cwd){let o=X(Be.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[mn](o,this.dmode);if(c)return this[He](c,t)}}let[e,r]=gi(()=>oe.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[bc](t);if(e||this[_c](t,r))return this[ft](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?gi(()=>{oe.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ft](l,t)}let[o]=gi(()=>oe.rmdirSync(String(t.absolute)));this[ft](o,t)}let[i]=t.absolute===this.cwd?[]:gi(()=>Rw(String(t.absolute)));this[ft](i,t)}[yc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{oe.closeSync(o)}catch(x){f=x}(l||f)&&this[He](l||f,t),e()},o;try{o=oe.openSync(String(t.absolute),cf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[He](l,t)),t.pipe(c)),c.on("data",l=>{try{oe.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{oe.futimesSync(o,f,x)}catch(h){try{oe.utimesSync(String(t.absolute),f,x)}catch{l=h}}}if(this[bi](t)){let f=this[vi](t),x=this[Si](t);try{oe.fchownSync(o,Number(f),Number(x))}catch(h){try{oe.chownSync(String(t.absolute),Number(f),Number(x))}catch{l=l||h}}}i(l)})}[Ec](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[mn](String(t.absolute),r);if(i){this[He](i,t),e();return}if(t.mtime&&!this.noMtime)try{oe.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[bi](t))try{oe.chownSync(String(t.absolute),Number(this[vi](t)),Number(this[Si](t)))}catch{}e(),t.resume()}[mn](t,e){try{return yw(X(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[wi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Be.resolve(c,l);let[f,x]=gi(()=>oe.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new eo(c,Be.resolve(e,r.join("/"))))}i()}[Gs](t,e,r,i){let o=`${r}Sync`;try{oe[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[He](c,t)}}},kw=t=>{let e=new hf(t),r=t.file,i=Q0.statSync(r),o=t.maxReadSize||16*1024*1024;new Zg(r,{readSize:o,size:i.size}).pipe(e)},Pw=(t,e)=>{let r=new Pc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Q0.stat(o,(f,x)=>{if(f)l(f);else{let h=new Sc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},pf=Di(kw,Pw,t=>new hf(t),t=>new Pc(t),(t,e)=>{e?.length&&K0(t,e)}),Ow=(t,e)=>{let r=new kc(t),i=!0,o,c;try{try{o=ot.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=ot.openSync(t.file,"w+");else throw x}let l=ot.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=ot.readSync(o,f,m,f.length-m,c+m),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new jn(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,Lw(t,r,c,o,e)}finally{if(i)try{ot.closeSync(o)}catch{}}},Lw=(t,e,r,i,o)=>{let c=new B0(t.file,{fd:i,start:r});e.pipe(c),Mw(e,o)},Nw=(t,e)=>{e=Array.from(e);let r=new Xs(t),i=(o,c,l)=>{let f=(A,y)=>{A?ot.close(o,b=>l(A)):l(null,y)},x=0;if(c===0)return f(null,0);let h=0,m=Buffer.alloc(512),E=(A,y)=>{if(A||y===void 0)return f(A);if(h+=y,h<512&&y)return ot.read(o,m,h,m.length-h,x+h,E);if(x===0&&m[0]===31&&m[1]===139)return f(new Error("cannot append to compressed archives"));if(h<512)return f(null,x);let b=new jn(m);if(!b.cksumValid)return f(null,x);let I=512*Math.ceil((b.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return f(null,x);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),h=0,ot.read(o,m,0,512,x,E)};ot.read(o,m,0,512,x,E)};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+",ot.open(t.file,l,f);if(x||!h)return c(x);ot.fstat(h,(m,E)=>{if(m)return ot.close(h,()=>c(m));i(h,E.size,(A,y)=>{if(A)return c(A);let b=new Js(t.file,{fd:h,start:y});r.pipe(b),b.on("error",c),b.on("close",o),Bw(r,e)})})};ot.open(t.file,l,f)})},Mw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?vr({file:gf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Bw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await vr({file:gf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},mi=Di(Ow,Nw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!sm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),R1=Di(mi.syncFile,mi.asyncFile,mi.syncNoFile,mi.asyncNoFile,(t,e=[])=>{mi.validate?.(t,e),zw(t)}),zw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};on();var bt={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 mf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Oc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function wf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Sr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ye();se();Ne();Ye();function Jt(t,e){if(Ci(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function to(t){return t.startsWith("http://")||t.startsWith("https://")}function no(t){return t.endsWith("/")?t.slice(0,-1):t}Ye();se();var ro="1008033",_f="1289";var yf="pbbp2",Ef="https://www.coze.cn",bf="/api/coze_claw/resource/get_frontier_key",Uw="https://www.coze.cn",qw="wss://frontier.coze.cn";function io(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Uw}function vf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??qw}function Ir(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 ki(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ri=q("handshake");async function Lc(t){let e=io(t.endpoint),r=t.timeoutMs??1e4,i=`${no(e)}${bf}?aid=${encodeURIComponent(ro)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Ir(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 b=await f.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${b.slice(0,200)}`)}let m=await f.json();if(m.code!==void 0&&m.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let E=m.data??{},A=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(!A||!y){let b=JSON.stringify(m).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${b}`)}return Ri.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:h}),{accessKey:A,deviceId:y}}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 Nc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto",Sf=2e5;function If(t){return{model:Mc(t.model)??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function Af(t){return!t||t===vt}var Gw=new Set(["auto","\u81EA\u52A8"]);function Mc(t){let e=t?.trim();if(e)return Gw.has(e.toLowerCase())?vt:e}function Tf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Nc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||vt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Af(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Df(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||vt}"`):Af(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="${Nc}/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??Sf;e.push("-c",`model_context_window=${r}`)}return e}function Cf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Bc(t,e){let{ttEnv:r,usePpe:i}=ki(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Rf(t,e,r){if(!t.modelToken)return{};let i=Bc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
92
+ `)}}function zc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function kf(t,e,r){if(!t.modelToken)return null;let i=t.model||vt,o=Bc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Nc}/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??Sf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Pf(t,e,r){if(!t.modelToken)return[];let i=Bc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var ze=q("agent-handlers"),Of=5*1024*1024,Jw=1,Vw=6,Yw=new Set(["node_modules",".git",".coze","dist","build",".next"]),so=class{constructor(e){this.opts=e}opts;async listSkills(e){Jt(e._meta,"_agent/listSkills");let r=Sr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??et(r).workspace,c=i?.skills??[],l=[];for(let f of c){let x=Lt(o,f.relPath,"SKILL.md");await Ww(x).then(m=>m.isFile()).catch(()=>!1)&&l.push(t_(f))}return{skills:l}}async addSkills(e){Jt(e._meta,"_agent/addSkills");let r=Sr(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 Wc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Kc(c,l,h),f.push(x)}return await ls(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Jt(e._meta,"_agent/removeSkills");let r=Sr(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=Lt(i.workspace,f.relPath);await Hw(x,{recursive:!0,force:!0}),ze.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await ls(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,ze.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,ze.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(h=>ze.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 ze.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await $e(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return ze.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await ar(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw ze.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 nt(i),ze.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 $e(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await nt(i),ze.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}):(ze.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Jt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Mc(e.model)??vt,i=await $e(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 nt(i),ze.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return ze.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=>ze.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),ze.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(Jt(e._meta,bt.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${bt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,bt.RESET),await this.runDetailSync(e.agentId,bt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),ze.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 ni(e,o)}async clearPersistedAcpSessionIds(e){let r=await $e(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 nt(r)}async repairAgent(e){if(Jt(e._meta,bt.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${bt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${bt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){ze.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,bt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){ze.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){ze.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Jt(e._meta,"_agent/getFileTree");let r=e._meta,i=Sr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),f=await Fc(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 ti(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=u_(e.depth);return f.isDirectory()?{tree:await f_(o,l,c,x)}:{tree:[{name:x_(c),path:Uf(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Jt(e._meta,"_agent/getFileContent");let r=Sr(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 Fc(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 ti(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Of)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Of})`);let l=await Lf(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 $e(e).catch(()=>null))?.workspace??et(e).workspace}safeJoin(e,r){let i=Gc(e,r||"."),o=Hc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Nf}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return $e(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function Zw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Xw(t){return t==="claude-code"?Lt(".claude","skills"):Lt(".agents","skills")}var Qw=3e4,e_=50*1024*1024,Ar=3e4;async function Wc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=Zw(o.skillName),x=Xw(i),h=Lt(x,f),m=Lt(r,h);if(await Uc(m,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");Pi(A.length),await qc(Lt(m,"SKILL.md"),A,"utf8")}else{let A=await n_(o.downloadUrl);i_(A)?await c_(A,m):s_(A)?await o_(A,m):await qc(Lt(m,"SKILL.md"),A.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:h,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return ze.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function Kc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function t_(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function n_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Pi(e);let r=r_(t);return Pi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Lf(e);return Pi(r.length),r}if(to(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Qw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Pi(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 Pi(t){if(t>e_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function r_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function i_(t){return t.length>=2&&t[0]===31&&t[1]===139}function s_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function jc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function o_(t,e){let r,i;try{r=new zf.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let f=l.entryName;if(!f||jc(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=a_(i),c=Gc(e);for(let l of i){if(jc(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=Gc(e,f),h=Hc(c,x);if(h.startsWith("..")||h==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await Uc(x,{recursive:!0});continue}await Uc(Kw(x),{recursive:!0});let m;try{m=l.getData()}catch(E){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await qc(x,m)}}function a_(t){let e;for(let r of t){let i=r.entryName;if(!i||jc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function c_(t,e){await d_(t);let r=pf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Ar}ms)`))},Ar);try{await Bf(Mf.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Ar}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function d_(t){let e=[],r=vr({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 (${Ar}ms)`))},Ar);try{await Bf(Mf.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Ar}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var l_=5e3;async function f_(t,e,r,i){return Ff(t,e,r,i,{count:0})}async function Ff(t,e,r,i,o){if(i<=0)return[];let c;try{c=await jw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(Yw.has(f.name)||f.isSymbolicLink())continue;if(o.count>=l_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Lt(e,f.name),h=$w(Lt(r,f.name)),m=null;try{m=await Fc(x)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let E={name:f.name,path:Uf(Hc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(E.children=await Ff(t,x,h,i-1,o)),l.push(E)}return l.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),l}function u_(t){return!t||t<=0?Jw:Math.min(t,Vw)}function x_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Uf(t){return t.split(Nf).join("/")}se();import{readFileSync as UI}from"node:fs";import{dirname as GI,join as jI}from"node:path";import{fileURLToPath as WI}from"node:url";var Tr="0.1.96";var yn=q("agent-health-reporter"),h_=1e4,Oi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??h_}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),yn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),yn.info("heartbeat stopped"))}async tick(){if(this.inFlight){yn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){yn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let f=p_(l);if(!f)continue;let x={agentId:l.agentId,status:f};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:Tr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){yn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(yn.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){yn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){yn.warn("onTickEnd hook failed",{err:String(r)})}}};function p_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}on();import{chmod as ay,mkdir as po,rm as cy,stat as dy,writeFile as ly}from"node:fs/promises";import{homedir as fy}from"node:os";import{join as au}from"node:path";sn();import{spawnSync as P_}from"node:child_process";import{existsSync as O_}from"node:fs";import{release as L_}from"node:os";import{basename as N_,isAbsolute as M_}from"node:path";function Li(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Dr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Cr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function En(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ye();var oo=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ne={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function qf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Gf(t){return"method"in t&&!("id"in t)}function ao(t){return!("method"in t)&&"id"in t}var g_={AGENT_NOT_FOUND:ne.AGENT_NOT_FOUND,AGENT_BUSY:ne.AGENT_BUSY,AGENT_DISCONNECTED:ne.AGENT_DISCONNECTED,AGENT_TIMEOUT:ne.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ne.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ne.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ne.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ne.INTERNAL_ERROR,BRIDGE_INTERNAL:ne.INTERNAL_ERROR,IPC_AUTH_FAILED:ne.INTERNAL_ERROR,IPC_BAD_REQUEST:ne.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ne.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ne.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ne.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ne.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ne.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ne.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ne.FILE_TOO_LARGE,UNSUPPORTED_MIME:ne.UNSUPPORTED_MIME,UPLOAD_FAILED:ne.UPLOAD_FAILED,UPSTREAM_NOT_READY:ne.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ne.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ne.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ne.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ne.AGENT_ENV_NOT_READY};function m_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ni(t.message)}:typeof t=="string"?Ni(t):typeof t=="object"?__(t):t}var w_=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Ni(t){let e=t;for(let[r,i]of w_)e=e.replace(r,i);return e}function __(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ni(i):e[r]=i;return e}function Mi(t){if(t instanceof T){let e=m_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:g_[t.code]??ne.INTERNAL_ERROR,message:Ni(t.message),data:r}}return{code:ne.INTERNAL_ERROR,message:Ni(t instanceof Error?t.message:String(t))}}function jf(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 Wf(t){return`${JSON.stringify(t)}
93
+ `}var Hf=10*1024*1024,co=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>Hf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${Hf} 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 $f={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},nA=Object.fromEntries(Object.entries($f).map(([t,e])=>[e,t])),y_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Rr=class{seq=0;next(e,r){this.seq+=1;let i=$f[e]??E_(e),o=y_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>Kf(r?.[x]??"")),f=b_(l).join(":");f&&c.push(f)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>Kf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function E_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Kf(t){return t.replace(/[:_\s]+/g,"-")}function b_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}ei();import{readFileSync as v_}from"node:fs";var S_=384;async function $c(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await or(t.agentEnvFile,r,{mode:S_})}function Jc(t){try{let e=JSON.parse(v_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Jf(t,e,r={},i=o=>o){return{...i({...t,...Jc(e)}),...r}}bn();ns();Ye();se();Ne();var k_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed/i,message:"openclaw gateway \u672A\u8FD0\u884C (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (claude ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function Xf(t,e){if(!e)return null;for(let r of k_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}var B_=qt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),z_=200,F_=40,U_=qt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),q_=qt("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),G_=qt("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Qf=500;function j_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Qf?t:`${e.slice(0,Qf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function eu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),P_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function tu(t){try{return O_(t)}catch{return}}function H_(t,e){return{platform:process.platform,osRelease:L_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:M_(e.command)?tu(e.command):void 0,cwd:e.cwd,cwdExists:tu(e.cwd),envKeys:e.envKeys}}function W_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${N_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Nt=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new co({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Rr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Jf(process.env,this.opts.agentEnvFile??Q().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=ut(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>z_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let 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=H_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",W_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));eu(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||eu(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=U_,i=q_,o=G_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Dr("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(Cr(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(En(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=B_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),f=Li(l,e,r),x=(()=>{if(typeof r!="object"||r===null)return;let E=r.sessionId;return typeof E=="string"?E:void 0})(),h=i>0&&Number.isFinite(i),m=o>0&&Number.isFinite(o);return new Promise((E,A)=>{let y={resolve:E,reject:A,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},b=Date.now();if(h){let S=()=>{y.timer=setTimeout(()=>{let C=Date.now()-b;if(this.inflightAgentRequests.size>0&&C<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:C,approvalMaxMs:c,...x?{sessionId:x}:{}}),S();return}this.pending.delete(l),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer);let O=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:O,...x?{sessionId:x}:{}}),A(O?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};S()}let I=m?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),I?.();return}y.timer&&clearTimeout(y.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),A(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;y.onFirstUpdate=m?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=null,y.onFirstUpdate=null}:null,this.pending.set(l,y),I?.();try{this.writeFrame(f)}catch(S){y.timer&&clearTimeout(y.timer),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),this.pending.delete(l),A(S)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Wf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(ao(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),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(jf(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:j_(e.result)}),r.resolve(e.result));return}if(Gf(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(qf(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(En(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(En(e.id,Mi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(F_).join(`
95
+ `),o=Xf(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function K_(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var lo=class extends Nt{framework="claude-code";constructor(e){let{command:r,args:i}=Qr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return K_(e)}};sn();import{mkdtempSync as $_,rmSync as J_}from"node:fs";import{tmpdir as V_}from"node:os";import{join as Y_}from"node:path";var fo=class extends Nt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Qr("codex",e.command,i),l=e.isolateCodexHome?$_(Y_(V_(),"coze-bridge-codex-home-")):void 0,f=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...f?{env:f}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{J_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Z_=3e4,kr=class extends Nt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Z_))}get acpSessionName(){return this.sessionName}};Ye();se();Ne();function Vc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}sn();var vn=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 uo=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 vn,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Bi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Bi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}bn();se();import{constants as nu}from"node:fs";import{access as X_}from"node:fs/promises";import{delimiter as Q_,join as ey}from"node:path";var St=q("framework-detector"),ru={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},ty=[".exe",".cmd",".bat",".ps1"],Wn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??ut,access:e.access??X_}}async detect(e){let r=ru[e],i=await this.which(r);if(!i)return St.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return l&&(f.defaultAgent=l),f}async detectAll(){let e=await Promise.all(Object.keys(ru).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(Q_).filter(Boolean),i=this.env.platform==="win32"?["",...ty]:[""];for(let o of r)for(let c of i){let l=ey(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?nu.F_OK:nu.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return St.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return St.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return St.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return St.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(St.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(St.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return St.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return St.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||St.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){St.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(ry(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,f=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),f(null)},15e3),x.stdout?.on("data",h=>{o+=h.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",h=>f({code:h,stdout:o}))}catch{f(null)}})}},ny=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ry(t){return t.replace(ny,"")}import{homedir as iy}from"node:os";import{join as sy}from"node:path";bn();Ye();ei();se();async function ou(){let t=sy(iy(),".openclaw/openclaw.json");return(await sr(t))?.gateway?.auth?.token??""}var iu=q("openclaw.config"),oy=[0,5e3,5e3],su="models.providers.",xo="agents.defaults.models",ho=class{command;env;retryDelaysMs;queue=new vn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??oy}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,iu.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=ut(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){iu.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",`${su}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${su}${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 me=q("agent-manager"),uy=(t,e,r,i,o,c,l,f,x)=>{switch(t){case"claude-code":{let h={...o?{...Tf(o),...Rf(o,l,f)}:{},...x??{},IS_SANDBOX:"1"};return new lo({cwd:r,env:h,agentId:i})}case"codex":{let m=[...o?[...Df(o),...Pf(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...o?Cf(o):{},...x??{}},A=!!o;return new fo({cwd:r,agentId:i,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new kr({command:e,cwd:r,agentId:i,...c?{sessionName:Vc(c)}:{}})}};function Yc(t){return t==="claude-code"||t==="codex"}function xy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(hy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
96
96
  `)}
97
- `}function xy(t){if(t.includes(`
98
- `)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var py={path:"",version:"cloud-deployed"},s0="openclaw_gateway_unavailable",gy="openclaw_default_agent_missing";function o0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var my={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},wy=6e4,uo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fy,this.createTimeoutMs=e.createTimeoutMs??wy,this.detectorFactory=e.detectorFactory??(()=>new qn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new co({command:r})),this.openclawConfigDir=e.openclawConfigDir??i0(uy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{xe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=i0(e,".env");if(await dy(r).then(c=>c.isFile()).catch(()=>!1)){xe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await lo(e,{recursive:!0});let o=hy({...process.env,...Wc(this.paths.agentEnvFile)});if(await ly(r,o,"utf8"),process.platform!=="win32")try{await ay(r,384)}catch(c){xe.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}xe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),xe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let i=Si(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")xe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>xe.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){xe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await Ge(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Qe(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){xe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await Ge(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Qe(S,this.paths))}return xe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=Xe(e.agentId,this.paths),u=Si(e._meta),h=e.framework==="openclaw"&&u==="local",p;h&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let m=p??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),E=e.workspace??m??l.workspace,T=new AbortController,_=setTimeout(()=>T.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&$c(e.framework)&&await er(e.framework,T.signal);let S=()=>{if(T.signal.aborted)throw T.signal.reason instanceof Error?T.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await lo(l.root,{recursive:!0}),await lo(E,{recursive:!0}),await lo(l.logs,{recursive:!0}),S(),h||await rr(E,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await wl(E),S();let C=await Ge(e.agentId,this.paths).catch(()=>null),N=bf({model:e.model??C?.model}),y=xf(e._meta)??C?.accountId,D=e.patToken??C?.patToken,k=u==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new oo({agentId:e.agentId,framework:e.framework,workspace:E,model:N.model??Et,deployType:u,...y?{accountId:y}:{},...D?{patToken:D}:{},...k?{modelInfo:k}:{}}),v.status="ok",C?.sessions){for(let[V,ee]of Object.entries(C.sessions))v.sessions.set(V,{acpSessionId:ee.acpSessionId,modelToken:ee.modelToken,tokenGeneratedAt:ee.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let J=Object.keys(C.sessions).length;J>0&&xe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:J})}this.registry.register(v),I=!0;let M={agentId:e.agentId,framework:e.framework,workspace:E,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:N.model};u==="cloud"&&(M.deployType="cloud"),y&&(M.accountId=y),D&&(M.patToken=D),k&&(M.modelInfo=k),C?.skills&&(M.skills=C.skills),C?.agentName&&(M.agentName=C.agentName),C?.description&&(M.description=C.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,E)):xe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let J=[...M.skills??[]],V=new Map(J.map((ye,fe)=>[ye.skillId,fe])),ee=await Promise.allSettled(B.map(ye=>Hc({agentId:e.agentId,workspace:E,framework:e.framework,skill:ye}))),X=0;for(let[ye,fe]of ee.entries()){let P=B[ye];P&&(fe.status==="fulfilled"?(jc(J,V,fe.value),X++):xe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:P.skillId,skillName:P.skillName,err:String(fe.reason)}))}X>0&&(M.skills=J,xe.info("initialSkills installed",{agentId:e.agentId,installed:X,requested:B.length}))}return await Qe(M,this.paths),xe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:E,framework:e.framework}}catch(S){throw xe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await cy(l.root,{recursive:!0,force:!0}).catch(C=>xe.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof R?S:new R("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&$c(e.framework))u=py;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);$c(e.framework)&&!ns(e.framework)&&(xe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(my),p}catch(m){let E=p instanceof Pt?p.getStderrTail():[];throw E.length>0&&xe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof R?m.code:"unknown",recentStderr:E}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,m)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new R("AGENT_ENV_NOT_READY",o0(o),{cause:{reason:s0}})}catch(o){xe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof R?new R(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new R("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};xe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return xe.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new R("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:gy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new R("AGENT_ENV_NOT_READY",o0(r),{cause:{reason:s0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=Kc(o);if(r.deployType==="local"){let T=await this.ensureOpenclawDefaultAgent();return new Tr({command:u,cwd:T.workspace,agentId:T.id,sessionName:h})}let p=await r0(),m=i?Rf(i,c,l):null,E;if(m){let T=Lc(o),v=m.models[0]?.id??Et,I=`${T}/${v}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(T,m),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}E=I}return new Tr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...p?{gatewayToken:p}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Lc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,xe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,xe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as u0}from"node:crypto";import{promises as Ay}from"node:fs";import{basename as f0}from"node:path";$e();te();import{promises as yy}from"node:fs";import{basename as Ey}from"node:path";var a0=U("file-upload"),by="/api/coze_claw/file/agent_upload",vy=6e4;async function c0(t,e={}){let i=`${Zs(Qs(e.handshakeBase))}${by}`,o=e.timeoutMs??vy,c=await yy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Er(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,p=setTimeout(()=>h.abort(),o);a0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:u,body:l,signal:h.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let v=await m.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${v.slice(0,200)}`)}let T=await m.json();if(T.code!==void 0&&T.code!==0)throw new R("UPLOAD_FAILED",`upload code=${T.code} msg=${T.msg??"-"} logid=${E}`);let _=T.data?.file?.file_url;if(!_)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(T).slice(0,200)}`);return a0.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof R?m:m.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Ey(t.path)}`):new R("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(p)}}$e();te();import{extname as Sy}from"node:path";var Iy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function d0(t){let e=Sy(t).toLowerCase();return Iy[e]??"application/octet-stream"}Ne();var fo=U("agent-send"),l0=50*1024*1024;function h0(t,e,r){let i=t.get(e);if(!i)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function x0(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,h<2&&(fo.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(p)}),await new Promise(m=>setTimeout(m,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function p0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!await Yr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ay.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>l0)throw new R("FILE_TOO_LARGE",`${o.size} bytes > limit ${l0}`);let c=await d0(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??f0(t.path),u;try{u=await c0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw fo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof R?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let h={sessionUpdate:"agent_file",messageId:u0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),fo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function g0(t,e){let{session:r,runtime:i}=h0(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??f0(t.path),c={sessionUpdate:"group_file",messageId:u0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await x0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),fo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function m0(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}nn();yn();te();var Nt=U("coze-cli-installer"),w0="@coze/cli@latest",Ty="coze",_0="0.1.8",Ry=5e3,Cy=5e3,Dy=9e4,y0=1e4,Pi=null,ho=!1;async function Jc(t,e={}){if(ho)return;if(Pi)return Pi;let r=e.exec??Jf;return Pi=(async()=>{try{let i=await ky(Ty,r),o=!1;if(i){let l=await Oy(r);if(l===void 0)Nt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(m0(l,_0))Nt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:_0}),o=!0;else{Nt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),ho=!0;return}}let c=o?"upgrade-only":"full";Nt.info("coze-cli install start",{package:w0,mode:c});try{await r("npm",["i","-g","--prefer-online",w0],{timeout:Dy,maxBuffer:10*1024*1024}),Nt.info("coze-cli install ok")}catch(l){Nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){ho=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:y0}),Nt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Nt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:y0}),Nt.info("coze auth login ok")}catch(l){Nt.warn("coze auth login failed",{err:String(l)});return}ho=!0}finally{Pi=null}})(),Pi}async function ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Ry});return ya(i)}catch{return}}async function Oy(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Cy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Vr();Ne();var Py=10*6e4;function E0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Py:e}function xo(t){return tr(t??Z().configFile)}function Ni(t,e){return nr(e??Z().configFile,t)}import{randomBytes as Qy}from"node:crypto";Zi();$e();te();import{createReadStream as Ny}from"node:fs";import{mkdir as Ly,readFile as My,realpath as By,stat as zy,writeFile as Fy}from"node:fs/promises";import{basename as Uy,dirname as Vc,isAbsolute as qy,join as Hy,relative as jy,resolve as b0,sep as Gy}from"node:path";import{createInterface as Wy}from"node:readline";var S0=U("fs-rpc"),Li=Ft("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function I0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Li)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Li} bytes`);let i=await T0(t.path,e);return await Ly(Vc(i),{recursive:!0}),await Fy(i,t.content,"utf8"),S0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function A0(t,e){let r=await T0(t.path,e),i=await zy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Li&&!o)throw new R("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Li} bytes`);let c;if(o&&i.size>Li)c=await Ky(r,t.line??1,t.limit);else{let l=await My(r,"utf8");if(o){let u=l.split(`
99
- `),h=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?h+t.limit:void 0;c=u.slice(h,p).join(`
100
- `)}else c=l}return S0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Ky(t,e,r){let i=Wy({input:Ny(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],u=0;try{for await(let h of i)if(u>=o&&u<c&&l.push(h),u++,u>=c)break}finally{i.close()}return l.join(`
101
- `)}async function T0(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([v0(b0(e)),v0(b0(t))]),o=jy(r,i);if($y(o,Gy,qy(o)))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function $y(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function v0(t){let e=[],r=t;for(;r!==Vc(r);)try{let i=await By(r);return e.length?Hy(i,...e.reverse()):i}catch{e.push(Uy(r)),r=Vc(r)}return t}te();var R0=U("prompt-multimodal"),C0=10*1024*1024,Jy=15e3,Vy=6;async function D0(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await Yy(l))}}let o=Array.from({length:Math.min(Vy,t.length)},()=>i());return await Promise.all(o),e}function k0(t){return t.some(e=>e.type==="image")}async function Yy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ys(e.uri))return t;try{let{buf:r,contentType:i}=await Xy(e.uri),o=e.mimeType||Zy(i)||"application/octet-stream";return R0.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return R0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Zy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Xy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Jy);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>C0)throw new Error(`image too large: ${o.byteLength} bytes (max ${C0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();$e();te();var $=U("core"),eE=3e4,tE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",rE="\u5BA1\u6279\u5DF2\u8D85\u65F6",iE=3e4,po=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ar;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=E0(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Oi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(_n(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>$.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new R("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(no(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&tE.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ir(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ir(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ir(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,ki(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new R("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new R("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let h=o.sessions.get(c);if(h?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,m=Dc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,h,c,nE,p,m)}}let l=Date.now(),u=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,h}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=pf(i);switch(r){case"session/new":{let c=sE();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(u.acpSessionId,h):e.activeTriggers.delete(u.acpSessionId);let p=Dc(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&k0(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await D0(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:m});return u.lastActiveAt=Date.now(),E}catch(E){if(E instanceof R&&E.code==="AGENT_APPROVAL_TIMEOUT"){let T=u.pendingPermission;T&&(T.downstream.respondAgentRequest(T.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(T.upstreamId),u.pendingPermission=void 0);let _=u.acpSessionId,v=_?e.activeTriggers.get(_):void 0,I=_?e.activeGroupIds.get(_):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,rE,v,I)}throw E}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let E=u.downstream;E&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(T=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(T)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(yt.GEN_MODEL_TOKEN,i,iE);if(!o?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof R&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new R("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Oi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new R("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let m=await h.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await h.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Oi(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(h=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(h)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(aE(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(p=>$.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await I0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await A0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,ki(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,h=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};h&&(p.cozeTriggerMsgId=h);let m=u?e.activeGroupIds.get(u):void 0;m&&(p.cozeGroupId=m);let E=u?this.reverseSessionId(e,u):void 0,T=E?e.sessions.get(E):void 0;T&&(T.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...E?{sessionId:E}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Ci(o,"session/request_permission",_)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&oE(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new to(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=eE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Ci(o,e,r)).catch(h=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Zr(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(_n(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function sE(){return Qy(16).toString("hex")}function oE(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function aE(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}te();Ne();import{randomBytes as cE}from"node:crypto";import{chmod as dE,mkdir as lE,writeFile as O0}from"node:fs/promises";import{createServer as uE}from"node:http";import{dirname as fE}from"node:path";var hE=1e6,Yc=U("ipc"),go=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??Z()}async start(){this.token=cE(32).toString("hex");let e=uE((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Yc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await lE(fE(this.paths.portFile),{recursive:!0}),await O0(this.paths.portFile,String(this.port),"utf8"),await O0(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await dE(this.paths.tokenFile,384)}catch(e){Yc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Mi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Mi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await xE(e)}catch(u){Mi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Mi(r,200,u??{ok:!0})}catch(u){Yc.error("IPC handler failed",{key:o,err:String(u)}),Mi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Mi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function xE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>hE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ex=It(j0(),1);var Jb=It(zh(),1),Vb=It(Oo(),1),Yb=It(Dr(),1),Zb=It(dd(),1),Xb=It(fd(),1),Qb=It(wd(),1),$h=It(Mo(),1),ev=It(Kh(),1);var Jh=$h.default;$e();te();var Oe=U("upstream.frontier"),Yh="application/json",Zh="none",nv=15e3;function rv(t){class e extends Jh{constructor(i){super(i,mf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Oe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(nl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Oe.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Oe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Wi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Oe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:wf,...Er(this.opts.ppeOverride)},r=rv(e),i=yf(this.opts.urlOverride),o={url:i,ws:r,fpID:gf,aID:Xs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Yh,force:!0},payloadEncoding:{encoding:Zh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ex.FWS(o),l=!1,u=null,h,p,m=new Promise((_,v)=>{h=_,p=v}),E=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?p(_):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Oe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:_})).catch(I=>Oe.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,Oe.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Oe.warn("frontier error",{code:_.code,msg:_.message}),E(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let T=this.opts.openTimeoutMs??nv;u=setTimeout(()=>{E(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${T}ms (handshake or upgrade slow)`))},T),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(v){Oe.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Oe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Oe.warn("frontier send refused: upstream not started",{method:i}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Oe.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Xh(c)||Oe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Yh,payloadEncoding:Zh})}catch(u){throw Oe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Oe.debug("drop non-adapter frontier frame",{service:r});return}let i=ov(e);if(!i){Oe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Oe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Oe.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Xh(c)||Oe.info("frontier frame in",{logid:sv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:iv(i)}),Promise.resolve(this.handler(o)).catch(l=>Oe.warn("frontier frame handler threw",{err:String(l)}))}};function Xh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Qh=2e3;function iv(t){return t.length<=Qh?t:`${t.slice(0,Qh)}...<truncated, total ${t.length} chars>`}function sv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function ov(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}te();var yd=U("upstream.switchable"),zo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;yd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw yd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>yd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};te();var Ed=U("upstream"),Mr=class{handler=null;async start(){Ed.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ed.info("NoopUpstream stopped",{reason:e})}async send(e){Ed.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};$e();te();te();Ne();import{promises as bd}from"node:fs";import{dirname as av}from"node:path";var cv=U("pat-token-store");async function Fo(t=Z()){try{let r=(await bd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&cv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ki(t,e=Z()){if(!t)throw new Error("writePatToken: empty patToken");await bd.mkdir(av(e.patTokenFile),{recursive:!0}),await bd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Ne();Ne();import{promises as Uo}from"node:fs";import{join as dv}from"node:path";function lv(t,e){return`#!/bin/sh
97
+ `}function hy(t){if(t.includes(`
98
+ `)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var py={path:"",version:"cloud-deployed"},cu="openclaw_gateway_unavailable",gy="openclaw_default_agent_missing";function du(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var my={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},wy=6e4,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??uy,this.createTimeoutMs=e.createTimeoutMs??wy,this.detectorFactory=e.detectorFactory??(()=>new Wn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new ho({command:r})),this.openclawConfigDir=e.openclawConfigDir??au(fy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{me.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=au(e,".env");if(await dy(r).then(c=>c.isFile()).catch(()=>!1)){me.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await po(e,{recursive:!0});let o=xy({...process.env,...Jc(this.paths.agentEnvFile)});if(await ly(r,o,"utf8"),process.platform!=="win32")try{await ay(r,384)}catch(c){me.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}me.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),me.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=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")me.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>me.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){me.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await $e(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await nt(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){me.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await $e(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await nt(S,this.paths))}return me.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let l=et(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 m=h??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),E=e.workspace??m??l.workspace,A=new AbortController,y=setTimeout(()=>A.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),b,I=!1;try{i&&Yc(e.framework)&&await ir(e.framework,A.signal);let S=()=>{if(A.signal.aborted)throw A.signal.reason instanceof Error?A.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await po(l.root,{recursive:!0}),await po(E,{recursive:!0}),await po(l.logs,{recursive:!0}),S(),x||await ar(E,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await El(E),S();let C=await $e(e.agentId,this.paths).catch(()=>null),O=If({model:e.model??C?.model}),w=mf(e._meta)??C?.accountId,R=e.patToken??C?.patToken,k=f==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(b=new uo({agentId:e.agentId,framework:e.framework,workspace:E,model:O.model??vt,deployType:f,...w?{accountId:w}:{},...R?{patToken:R}:{},...k?{modelInfo:k}:{}}),b.status="ok",C?.sessions){for(let[Y,re]of Object.entries(C.sessions))b.sessions.set(Y,{acpSessionId:re.acpSessionId,modelToken:re.modelToken,tokenGeneratedAt:re.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let V=Object.keys(C.sessions).length;V>0&&me.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:V})}this.registry.register(b),I=!0;let B={agentId:e.agentId,framework:e.framework,workspace:E,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:O.model};f==="cloud"&&(B.deployType="cloud"),w&&(B.accountId=w),R&&(B.patToken=R),k&&(B.modelInfo=k),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,E)):me.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let z=e.initialSkills??[];if(z.length>0){let V=[...B.skills??[]],Y=new Map(V.map((ve,ge)=>[ve.skillId,ge])),re=await Promise.allSettled(z.map(ve=>Wc({agentId:e.agentId,workspace:E,framework:e.framework,skill:ve}))),te=0;for(let[ve,ge]of re.entries()){let P=z[ve];P&&(ge.status==="fulfilled"?(Kc(V,Y,ge.value),te++):me.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:P.skillId,skillName:P.skillName,err:String(ge.reason)}))}te>0&&(B.skills=V,me.info("initialSkills installed",{agentId:e.agentId,installed:te,requested:z.length}))}return await nt(B,this.paths),me.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:E,framework:e.framework}}catch(S){throw me.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),I&&b&&(await b.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await cy(l.root,{recursive:!0,force:!0}).catch(C=>me.warn("rm agent dir failed (ignored)",{err:String(C)})),S instanceof T?S:new T("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Yc(e.framework))f=py;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);Yc(e.framework)&&!as(e.framework)&&(me.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await ir(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(my),h}catch(m){let E=h instanceof Nt?h.getStderrTail():[];throw E.length>0&&me.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof T?m.code:"unknown",recentStderr:E}),await h.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,f.path,m)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",du(o),{cause:{reason:cu}})}catch(o){me.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};me.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return me.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:gy}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",du(r),{cause:{reason:cu}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,x=Vc(o);if(r.deployType==="local"){let A=await this.ensureOpenclawDefaultAgent();return new kr({command:f,cwd:A.workspace,agentId:A.id,sessionName:x})}let h=await ou(),m=i?kf(i,c,l):null,E;if(m){let A=zc(o),b=m.models[0]?.id??vt,I=`${A}/${b}`;if(!this.ensuredProviders.has(I)){let S=this.getOpenclawConfig();await S.ensureProvider(A,m),await S.addModelToAllowlist(I),this.ensuredProviders.add(I)}E=I}return new kr({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=zc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(f){l=!1,me.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){l=!1,me.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as hu}from"node:crypto";import{promises as Ay}from"node:fs";import{basename as pu}from"node:path";Ye();se();import{promises as yy}from"node:fs";import{basename as Ey}from"node:path";var lu=q("file-upload"),by="/api/coze_claw/file/agent_upload",vy=6e4;async function fu(t,e={}){let i=`${no(io(e.handshakeBase))}${by}`,o=e.timeoutMs??vy,c=await yy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Ir(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);lu.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:f,body:l,signal:x.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let b=await m.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${b.slice(0,200)}`)}let A=await m.json();if(A.code!==void 0&&A.code!==0)throw new T("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${E}`);let y=A.data?.file?.file_url;if(!y)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(A).slice(0,200)}`);return lu.info("file upload ok",{uri:y,logid:E}),{uri:y}}catch(m){throw m instanceof T?m:m.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Ey(t.path)}`):new T("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}Ye();se();import{extname as Sy}from"node:path";var Iy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function uu(t){let e=Sy(t).toLowerCase();return Iy[e]??"application/octet-stream"}Ne();var mo=q("agent-send"),xu=50*1024*1024;function gu(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 mu(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&&(mo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function wu(t,e){let{session:r,runtime:i}=gu(e.core,t.agentId,t.sessionId);if(!await ti(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Ay.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>xu)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${xu}`);let c=await uu(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??pu(t.path),f;try{f=await fu({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 mo.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:hu(),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 mu(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: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 _u(t,e){let{session:r,runtime:i}=gu(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??pu(t.path),c={sessionUpdate:"group_file",messageId:hu(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await mu(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 yu(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}sn();bn();se();var Mt=q("coze-cli-installer"),Eu="@coze/cli@latest",Ty="coze",bu="0.1.8",Dy=5e3,Cy=5e3,Ry=9e4,vu=1e4,zi=null,wo=!1;async function Zc(t,e={}){if(wo)return;if(zi)return zi;let r=e.exec??Zf;return zi=(async()=>{try{let i=await ky(Ty,r),o=!1;if(i){let l=await Py(r);if(l===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(yu(l,bu))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:bu}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),wo=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:Eu,mode:c});try{await r("npm",["i","-g","--prefer-online",Eu],{timeout:Ry,maxBuffer:10*1024*1024}),Mt.info("coze-cli install ok")}catch(l){Mt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){wo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:vu}),Mt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Mt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:vu}),Mt.info("coze auth login ok")}catch(l){Mt.warn("coze auth login failed",{err:String(l)});return}wo=!0}finally{zi=null}})(),zi}async function ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Dy});return va(i)}catch{return}}async function Py(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Cy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}ei();Ne();var Oy=10*6e4;function Su(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Oy:e}function _o(t){return sr(t??Q().configFile)}function Fi(t,e){return or(e??Q().configFile,t)}import{randomBytes as Qy}from"node:crypto";ns();Ye();se();import{createReadStream as Ly}from"node:fs";import{mkdir as Ny,readFile as My,realpath as By,stat as zy,writeFile as Fy}from"node:fs/promises";import{basename as Uy,dirname as Xc,isAbsolute as qy,join as Gy,relative as jy,resolve as Iu,sep as Hy}from"node:path";import{createInterface as Wy}from"node:readline";var Tu=q("fs-rpc"),Ui=qt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Du(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ui)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ui} bytes`);let i=await Ru(t.path,e);return await Ny(Xc(i),{recursive:!0}),await Fy(i,t.content,"utf8"),Tu.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Cu(t,e){let r=await Ru(t.path,e),i=await zy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ui&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ui} bytes`);let c;if(o&&i.size>Ui)c=await Ky(r,t.line??1,t.limit);else{let l=await My(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 Tu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Ky(t,e,r){let i=Wy({input:Ly(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 Ru(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([Au(Iu(e)),Au(Iu(t))]),o=jy(r,i);if($y(o,Hy,qy(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function $y(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Au(t){let e=[],r=t;for(;r!==Xc(r);)try{let i=await By(r);return e.length?Gy(i,...e.reverse()):i}catch{e.push(Uy(r)),r=Xc(r)}return t}se();var ku=q("prompt-multimodal"),Pu=10*1024*1024,Jy=15e3,Vy=6;async function Ou(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await Yy(l))}}let o=Array.from({length:Math.min(Vy,t.length)},()=>i());return await Promise.all(o),e}function Lu(t){return t.some(e=>e.type==="image")}async function Yy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!to(e.uri))return t;try{let{buf:r,contentType:i}=await Xy(e.uri),o=e.mimeType||Zy(i)||"application/octet-stream";return ku.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 ku.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Zy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Xy(t){let e=new AbortController,r=setTimeout(()=>e.abort(),Jy);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Pu)throw new Error(`image too large: ${o.byteLength} bytes (max ${Pu})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}on();Ye();se();var J=q("core"),eE=3e4,tE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",rE="\u5BA1\u6279\u5DF2\u8D85\u65F6",iE=3e4,yo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Rr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Su(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(),J.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){J.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),J.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){J.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)&&J.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)=>{J.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Bi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){J.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(En(o,{code:ne.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>J.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ne.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){J.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ne.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(ao(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&tE.test(i)?this.currentCozeEnv=i:i&&J.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,ne.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):J.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Cr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Cr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Cr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ne.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):J.warn("drop unknown notification",{method:e.method})}catch(o){J.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(En(r,Mi(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,m=Oc(r._meta);return J.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,nE,h,m)}}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{J.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}=wf(i);switch(r){case"session/new":{let c=sE();return J.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return J.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=Oc(i._meta);if(h?e.activeGroupIds.set(f.acpSessionId,h):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Lu(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ou(c.prompt);try{let E=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:m});return f.lastActiveAt=Date.now(),E}catch(E){if(E instanceof T&&E.code==="AGENT_APPROVAL_TIMEOUT"){let A=f.pendingPermission;A&&(A.downstream.respondAgentRequest(A.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(A.upstreamId),f.pendingPermission=void 0);let y=f.acpSessionId,b=y?e.activeTriggers.get(y):void 0,I=y?e.activeGroupIds.get(y):void 0;return J.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,rE,b,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,J.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),E.stop("reload-after-turn").catch(A=>J.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(A)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(J.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(bt.GEN_MODEL_TOKEN,i,iE);if(!o?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof T&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new T("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Bi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,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&&(J.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),h}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}),J.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){J.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Bi(i),this.isRuntimeBusy(e,i)){J.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)){J.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}J.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=>J.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(Dr("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(Dr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:f})).catch(x=>J.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){J.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){J.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(aE(r)){J.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Dr("session/update",{...r,sessionId:o,_meta:l})).catch(h=>J.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}J.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:ne.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await Du(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Cu(c,o);r.respondAgentRequest(i.id,l)}}catch(o){J.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Mi(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 m=f?e.activeGroupIds.get(f):void 0;m&&(h.cozeGroupId=m);let E=f?this.reverseSessionId(e,f):void 0,A=E?e.sessions.get(E):void 0;A&&(A.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),J.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(Li(o,"session/request_permission",y)).catch(b=>{this.pendingUpstream.delete(o),J.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),r.respondAgentRequestError(i.id,{code:ne.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(J.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&oE(e.result,o),J.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new oo(e.error)):i.value.resolve(e.result);return}J.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 J.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=eE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let 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(Li(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 ni(e.agentId,r,this.paths)}catch(r){J.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(En(e,{code:r,message:i,data:{bridgeVersion:Tr}}))}};function sE(){return Qy(16).toString("hex")}function oE(t,e){if(!t||typeof t!="object"){J.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){J.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"){J.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")&&J.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function aE(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}se();Ne();import{randomBytes as cE}from"node:crypto";import{chmod as dE,mkdir as lE,writeFile as Nu}from"node:fs/promises";import{createServer as fE}from"node:http";import{dirname as uE}from"node:path";var xE=1e6,Qc=q("ipc"),Eo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??Q()}async start(){this.token=cE(32).toString("hex");let e=fE((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Qc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await lE(uE(this.paths.portFile),{recursive:!0}),await Nu(this.paths.portFile,String(this.port),"utf8"),await Nu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await dE(this.paths.tokenFile,384)}catch(e){Qc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){qi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){qi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await hE(e)}catch(f){qi(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);qi(r,200,f??{ok:!0})}catch(f){Qc.error("IPC handler failed",{key:o,err:String(f)}),qi(r,500,{error:f instanceof Error?f.message:String(f)})}}};function qi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function hE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>xE)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ih=Tt(Ku(),1);var Jb=Tt(Gx(),1),Vb=Tt(Bo(),1),Yb=Tt(Lr(),1),Zb=Tt(ud(),1),Xb=Tt(pd(),1),Qb=Tt(Ed(),1),Zx=Tt(qo(),1),ev=Tt(Yx(),1);var Xx=Zx.default;Ye();se();var Oe=q("upstream.frontier"),eh="application/json",th="none",nv=15e3;function rv(t){class e extends Xx{constructor(i){super(i,yf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Oe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(sl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Oe.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Oe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var 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){Oe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Ef,...Ir(this.opts.ppeOverride)},r=rv(e),i=vf(this.opts.urlOverride),o={url:i,ws:r,fpID:_f,aID:ro,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:eh,force:!0},payloadEncoding:{encoding:th,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ih.FWS(o),l=!1,f=null,x,h,m=new Promise((y,b)=>{x=y,h=b}),E=y=>{l||(l=!0,f&&(clearTimeout(f),f=null),y?h(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Oe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&E();for(let b of this.connectHandlers)Promise.resolve(b({initial:y})).catch(I=>Oe.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=y=>{this.opened=!1,Oe.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Oe.warn("frontier error",{code:y.code,msg:y.message}),E(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let A=this.opts.openTimeoutMs??nv;f=setTimeout(()=>{E(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await m}catch(y){try{c.close(1e3,"open failed")}catch(b){Oe.warn("fws close during start failure threw (ignored)",{err:String(b)})}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){Oe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Oe.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Oe.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=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;nh(c)||Oe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:eh,payloadEncoding:th})}catch(f){throw Oe.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){Oe.debug("drop non-adapter frontier frame",{service:r});return}let i=ov(e);if(!i){Oe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Oe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Oe.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;nh(c)||Oe.info("frontier frame in",{logid:sv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:iv(i)}),Promise.resolve(this.handler(o)).catch(l=>Oe.warn("frontier frame handler threw",{err:String(l)}))}};function nh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var rh=2e3;function iv(t){return t.length<=rh?t:`${t.slice(0,rh)}...<truncated, total ${t.length} chars>`}function sv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function ov(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}se();var vd=q("upstream.switchable"),jo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;vd.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 vd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>vd.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()}};se();var Sd=q("upstream"),Ur=class{handler=null;async start(){Sd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Sd.info("NoopUpstream stopped",{reason:e})}async send(e){Sd.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)}};Ye();se();se();Ne();import{promises as Id}from"node:fs";import{dirname as av}from"node:path";var cv=q("pat-token-store");async function Ho(t=Q()){try{let r=(await Id.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&cv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Zi(t,e=Q()){if(!t)throw new Error("writePatToken: empty patToken");await Id.mkdir(av(e.patTokenFile),{recursive:!0}),await Id.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Ne();Ne();import{promises as Wo}from"node:fs";import{join as dv}from"node:path";function lv(t,e){return`#!/bin/sh
102
102
  exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
103
- `}function uv(t,e){return`@echo off\r
103
+ `}function fv(t,e){return`@echo off\r
104
104
  "${e}" "${t}" %*\r
105
- `}async function tx(t,e=Z()){let r=e.binDir;await Uo.mkdir(r,{recursive:!0});let i=dv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?uv(t,o):lv(t,o);return await Uo.readFile(i,"utf8").catch(()=>null)===c||(await Uo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Uo.chmod(i,493)),r}te();Ne();import{execSync as nx}from"node:child_process";import{readFileSync as rx,unlinkSync as fv}from"node:fs";import{mkdir as hv,readFile as ix,unlink as sx,writeFile as xv}from"node:fs/promises";import{dirname as pv}from"node:path";function qo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var gv=U("single-instance"),Ho=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Z().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(gv.warn("removing stale pid file",{stalePid:e}),await sx(this.pidFile).catch(()=>{})),await hv(pv(this.pidFile),{recursive:!0}),await xv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await ix(this.pidFile,"utf8")).trim()===String(process.pid)&&await sx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await ix(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return qo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=rx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=nx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=nx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{rx(this.pidFile,"utf8").trim()===String(process.pid)&&fv(this.pidFile)}catch{}})}};jo();te();var $n=U("daemon.upstream-watchdog"),Sv=12e4,Iv=9e5,Av=3e4;function Sd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Go=class{constructor(e){this.opts=e;this.softMs=e.softMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Sv),this.hardMs=e.hardMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Iv),this.intervalMs=e.intervalMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Av),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=U("daemon"),Tv="coze-bridge-daemon";async function cx(){let t=Z();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&el({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:P=>Xe(P,t).logs,listAgentIds:()=>rs(t)});let e=new Ho({processTitle:Tv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await xo(),o=i??{};ts({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");try{let P=new qn;o.frameworksCache=await P.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){j.warn("framework detection failed",{err:String(P)})}await Ni(o);let c=new zo(new Mr),l=null,u=new po({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(P,q,W,re)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,q,W,re)}});await Cv(t,u);let h=new uo({paths:t,config:o,registry:u});l=h;let p,m,E=null,T={},_,v=null,I=null,S=null,C=new En;function N(P,q){return C.enqueue(()=>D(P,q))}function y(){I||(I=new Go({isConnected:()=>c.isConnected(),forceReconnect:()=>S?N(S,{force:!0}):void 0,onFatal:P=>{if(process.env[$i]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:P});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:P}),process.exit(1)}})),I.start()}async function D(P,q){let W=P,re=W?.privatecode;if(!re)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Ai(W.env),de=W.handshake_url,le=W.frontier_url,St=ax(W.env,de,le);if(S=W,!q?.force&&p===re&&m===St){let ge=await Rv(t);return u.agents.size===0&&ge?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ko(t,h).catch(Te=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Te)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ht=!!p&&p!==re,Xt=m!==void 0&&m!==St,zt=ht||Xt,Qt=await kc({privatecode:re,...de?{endpoint:de}:{},ppeOverride:Ve});if(zt){j.warn("connect config switched, resetting agents",{pcChanged:ht,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(re)});for(let ge of[...u.agents.values()])await ge.dispose("connect config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"connect switch").catch(()=>{})}E=Qt.deviceId,ts({deviceId:E,pid:process.pid}),Jc({patToken:re,env:W.env}).catch(ge=>j.warn("coze-cli setup error (ignored)",{err:String(ge)}));let qr=new Wi({handshake:Qt,privatecode:re,...le?{urlOverride:le}:{},ppeOverride:Ve,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});return await c.swap(qr,"connect"),p=re,m=St,T=Ve,_=de,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new Ri({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(ge=>j.warn("detailSync.retryPending failed (ignored)",{err:String(ge)})),onAuthFailures:J})),v.start(),y(),zt&&Ko(t,h).catch(ge=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(ge)})),Ki(re,t).catch(ge=>j.warn("writePatToken after /connect failed (ignored)",{err:String(ge)})),j.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async P=>h.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let k={},M=new eo({agents:u.agents,disposeAndMarkDisconnected:async(P,q)=>{let W=u.agents.get(P);if(W){await h.cleanupOpenclawSessionProviders(W).catch(Ve=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(Ve)}));let re=!0;try{await W.dispose(`disconnect: ${q}`)}catch(Ve){re=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(Ve)}),W.status="error"}re&&(W.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await h.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,q)=>{await h.openclawRepair(P,q)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>M.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>M.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>M.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>M.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>M.getFileContent(P.params)),u.registerExtension("_agent/update",P=>M.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>M.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>M.switchModel(P.params)),u.registerExtension("_agent/reset",P=>M.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>M.repairAgent(P.params));let B=new as({paths:t,handlers:M,sendDetail:P=>u.sendRequest("_agent/detail",P)});k.ref=B;let J=async P=>{await Promise.allSettled(P.map(async q=>{try{await M.disconnectAgent({agentId:q.agentId,reason:`auth_failure: code=${q.code} ${q.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:q.agentId,code:q.code,message:q.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:q.agentId,err:String(W)})}}))};c.onConnect(({initial:P})=>{j.info("frontier upstream connected, triggering detail sync",{initial:P}),B.syncAll(P?"initial-connect":"reconnect").catch(q=>j.warn("detail sync top-level error (ignored)",{err:String(q)}))});let V=new go({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[$i]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let q=P,W=q?.privatecode,re=q?.pairing_code;if(!W||!re)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Ai(q.env),de=q.handshake_url,le=q.frontier_url,St=ax(q.env,de,le),ht=!!p&&p!==W,Xt=m!==void 0&&m!==St,zt=ht||Xt,Qt=await kc({privatecode:W,...de?{endpoint:de}:{},ppeOverride:Ve});if(zt){j.warn("pair config switched, resetting agents",{pcChanged:ht,envChanged:Xt,previousPc:p?Wo(p):"",nextPc:Wo(W),previousEnvKey:m??"",nextEnvKey:St});for(let Te of[...u.agents.values()])await Te.dispose("pair config switch").catch(()=>{}),u.agents.delete(Te.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Mr,"pair switch").catch(()=>{})}E=Qt.deviceId,ts({deviceId:E,pid:process.pid}),Jc({patToken:W,env:q.env}).catch(Te=>j.warn("coze-cli setup error (ignored)",{err:String(Te)}));let qr=new Wi({handshake:Qt,privatecode:W,...le?{urlOverride:le}:{},ppeOverride:Ve,getPatTokenForAgent:Te=>u.agents.get(Te)?.patToken});await c.swap(qr,"pair");try{let Te=new qn;o.frameworksCache=await Te.detectAll(),await Ni(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Te){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Te)})}let ge=Object.keys(o.frameworksCache??{});try{let Te=await u.sendRequest("_agent/pair",{pairCode:re,patToken:W,frameworks:ge,_meta:{cozeDeviceId:E}});j.info("_agent/pair ok",{pairResult:Te}),p=W,m=St,T=Ve,_=de,q.mock_scenario!==void 0&&(u.setMockScenario(q.mock_scenario),j.info("mock scenario set",{scenario:q.mock_scenario})),Ki(W,t).catch(Pe=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),v||(v=new Ri({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(Pe=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:J})),v.start(),y(),zt&&Ko(t,h).catch(Pe=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let Jn;return q.agent_id&&(Jn=await Dv(q.agent_id,t,h,Pe=>u.sendRequest("_agent/detail",Pe),W).catch(Pe=>(j.error("--agent-id ensureAgent failed",{agentId:q.agent_id,err:String(Pe)}),{ok:!1,agentId:q.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...Jn?{agent:Jn}:{}}}catch(Te){return j.error("_agent/pair failed",{err:String(Te)}),{ok:!1,note:`pair failed: ${String(Te)}`}}}},{method:"POST",path:"/connect",handler:P=>N(P)},{method:"POST",path:"/_agent/create",handler:async P=>{let q=P;return{ok:!0,result:await h.createAgent(q)}}},{method:"POST",path:"/agent/send",handler:async P=>{let q=P;if(!q?.agentId||!q?.sessionId||!q?.kind||!q?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=q;return await(W.groupFile?g0:p0)(W,{core:u,patToken:p,handshakeBase:_,ppeOverride:T})}catch(W){if(W instanceof R)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async P=>{let q=P?.agent_id,W=await u.reloadAgents(q);return j.info("IPC /reload: recycled agent subprocesses",{agentId:q??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{fe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await V.start();try{await tx(t.libEntry,t)}catch(P){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await u.start(),Ko(t,h).catch(P=>j.warn("auto-revive top-level error (ignored)",{err:String(P)})),ll().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(nn(),cl));for(let q of["claude-code","codex"]){let W=await P(q);W&&j.info("acp wrapper version",{framework:q,version:W})}}).catch(P=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let ye=null,fe={port:ee,token:X,core:u,ipc:V,shutdown(P){return ye||(j.info("daemon shutdown",{reason:P}),ye=(async()=>{v?.stop(),I?.stop(),await u.stop(P),await V.stop(),await e.release()})(),ye)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{fe.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{j.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name});try{process.stderr.write(`FATAL uncaughtException: ${P.stack??P.message}
106
- `)}catch{}process.exit(1)}),j.info("daemon ready",{port:ee,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),kv({cliSpawned:process.env[$i]==="1",readPatToken:()=>Fo(t),connect:N}).catch(P=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(P)})),fe}async function Rv(t){return rs(t).length>0}function Wo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function ax(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Cv(t,e){let r=rs(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),os));for(let c of r){await o(c,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Dv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),os)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let m={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(h);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Ko(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(rn(),os));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let h;try{h=await o(u,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:h.framework});let p=Ov(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...p?{_meta:p}:{}},{revive:!0}),c+=1}catch(p){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:h.framework,err:String(p)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function kv(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Ov(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}jo();Ne();import{readFile as dx}from"node:fs/promises";var Zt=class{paths;constructor(e){this.paths=e??Z()}async probe(e=1e3){let r=await $o(this.paths);if(!r)return{kind:"not-running"};try{let i=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:Nv(i)}}}async request(e){let r=await $o(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),h=await u.text();return{status:u.status,body:Pv(h)}}finally{clearTimeout(l)}}};async function $o(t){try{let[e,r]=await Promise.all([dx(t.portFile,"utf8"),dx(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=r.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Pv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Nv(t){return t instanceof Error?t.message:String(t)}yn();te();Ne();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}nn();import{chmod as Lv,copyFile as lx,mkdir as fx,readFile as Jo,rename as ux,rm as Id,stat as hx,writeFile as Mv}from"node:fs/promises";import{homedir as hC}from"node:os";import{dirname as Bv,join as Br,resolve as Ad,sep as Ji}from"node:path";import{fileURLToPath as zv}from"node:url";yn();te();Ne();var Td=U("dist-install");function Fv(t){let e=zv(t),r=Bv(e),i=`${Ji}src${Ji}`;if(r.includes(i)||r.endsWith(`${Ji}src${Ji}cli`))return null;let o=Ad(r,"index.js"),c=Ad(r,"..","package.json");return{dist:o,pkgJson:c}}async function Cd(t={}){let e=t.paths??Z(),r=Fv(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let T=JSON.parse(await Jo(o,"utf8"));c=T.version??"unknown",l=T.dependencies??{}}catch(T){return Td.warn("cannot read source package.json,skip dist install",{err:String(T)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(T)}`}}let u=$r.map(T=>`${T}@${l[T]??"latest"}`),h=await xo(e.configFile)??{},p=h.libVersion,m=await Jo(e.libEntry).then(()=>!0).catch(()=>!1),E=p===c;if(E&&m&&await Rd(e))return{kind:"already-current",libVersion:c};if(!E||!m){await fx(e.libDir,{recursive:!0}),await lx(i,e.libEntry),await lx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let T=Ad(e.libDir,"package.json"),_=`${JSON.stringify({type:"module"},null,2)}
107
- `;await Jo(T,"utf8").catch(()=>null)!==_&&await Mv(T,_)}return(!E||!await Rd(e))&&await(t.installWrappers??Uv)(e,u),h.libVersion=c,await Ni(h,e.configFile),Td.info("dist installed",{libEntry:e.libEntry,fromVersion:p,toVersion:c}),E&&m?{kind:"already-current",libVersion:c}:p?{kind:"version-changed",fromVersion:p,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Rd(t){for(let e of $r){let r=Br(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await hx(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function Uv(t,e){await jv(t.installLock,async()=>{if(await Rd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Ji}.staging-${process.pid}-${r}`,o=Br(i,"node_modules"),c=Br(t.libDir,"node_modules");try{await fx(i,{recursive:!0}),await qv(e,i),await Hv(o);let l=`${c}.trash-${r}`;await ux(c,l).catch(()=>{}),await ux(o,c),await Id(l,{recursive:!0,force:!0}).catch(()=>{}),Td.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Id(i,{recursive:!0,force:!0}).catch(()=>{})}})}function qv(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=lt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",h=>{l.length<8192&&(l+=h.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",h=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(h)}`))}),c.once("close",h=>{clearTimeout(u),h===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${h}: ${l.trim().slice(0,2e3)}`))})})}async function Hv(t){for(let e of $r){let r=Br(t,...e.split("/")),i=JSON.parse(await Jo(Br(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Br(t,".bin",o),l=await hx(c);process.platform!=="win32"&&!(l.mode&73)&&await Lv(c,l.mode|73).catch(()=>{})}}async function jv(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Id(t,{force:!0}).catch(()=>{})}}ga();te();Ne();import{closeSync as px,fstatSync as gx,openSync as mx,readFileSync as Gv,readSync as Wv,readdirSync as Kv,statSync as $v}from"node:fs";import{join as Vo}from"node:path";var Jv=new Set(["debug","info","warn","error"]);function _x(t){let e=t,r=Sn(e,"--agent-id");e=r.rest;let i=Sn(e,"--date");e=i.rest;let o=Sn(e,"-n","--lines");e=o.rest;let c=Sn(e,"--level");e=c.rest;let l=Sn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),h=Number.isInteger(u)&&u>=0?u:200,p=c.value&&Jv.has(c.value)?c.value:void 0,m={lines:h,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(m.agentId=r.value),i.value&&(m.date=i.value),p&&(m.level=p),l.value&&(m.grep=l.value),m}function Vv(t,e){return t.agentId?Vo(Xe(t.agentId,e).logs,Xn("agent",t.date)):Vo(e.bridgeLogsDir,Xn("bridge",t.date))}function Yv(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function Zv(t,e){let r;try{r=Kv(t)}catch{return[]}let i=[];for(let o of r){let c=pa(o,e);if(!c)continue;let l=0;try{l=$v(Vo(t,o)).size}catch{}i.push({file:Vo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function yx(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let r;try{r=JSON.parse(t).level}catch{return!0}if(typeof r=="string"&&!rl(r,e.level))return!1}return!0}var xx={debug:"90",info:"36",warn:"33",error:"31"},Xv=new Set(["ts","level","module","msg"]);function Qv(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Ex(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=Qv(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&xx[o]&&(c=`\x1B[${xx[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",h=Object.entries(r).filter(([p])=>!Xv.has(p)).map(([p,m])=>` ${p}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${l} ${u}${h}`}function eS(t,e,r){let c=Gv(t,"utf8").split(`
108
- `).filter(l=>l.length>0).filter(l=>yx(l,{level:e.level,grep:e.grep}));for(let l of Yv(c,e.lines))process.stdout.write(`${Ex(l,{raw:e.raw,color:r})}
109
- `)}async function bx(t,e){let r=e.paths??Z(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Xe(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",h=Zv(l,u);if(h.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
110
- `),1;for(let p of h)process.stdout.write(`${p.date} ${(p.size/1024).toFixed(1)}KB ${p.file}
111
- `);return 0}let o=t.date??An(new Date),c=Vv({agentId:t.agentId,date:o},r);try{eS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
105
+ `}async function sh(t,e=Q()){let r=e.binDir;await Wo.mkdir(r,{recursive:!0});let i=dv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?fv(t,o):lv(t,o);return await Wo.readFile(i,"utf8").catch(()=>null)===c||(await Wo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Wo.chmod(i,493)),r}se();Ne();import{execSync as oh}from"node:child_process";import{readFileSync as ah,unlinkSync as uv}from"node:fs";import{mkdir as xv,readFile as ch,unlink as dh,writeFile as hv}from"node:fs/promises";import{dirname as pv}from"node:path";function Ko(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var gv=q("single-instance"),$o=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(gv.warn("removing stale pid file",{stalePid:e}),await dh(this.pidFile).catch(()=>{})),await xv(pv(this.pidFile),{recursive:!0}),await hv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await ch(this.pidFile,"utf8")).trim()===String(process.pid)&&await dh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await ch(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 Ko(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=ah(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=oh(`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=oh(`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{ah(this.pidFile,"utf8").trim()===String(process.pid)&&uv(this.pidFile)}catch{}})}};Jo();se();var Zn=q("daemon.upstream-watchdog"),Sv=12e4,Iv=9e5,Av=3e4;function Td(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Vo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Sv),this.hardMs=e.hardMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Iv),this.intervalMs=e.intervalMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Av),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Zn.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&&Zn.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&&Zn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Zn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Zn.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,Zn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Zn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var H=q("daemon"),Tv="coze-bridge-daemon";async function uh(){let t=Q();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&rl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:P=>et(P,t).logs,listAgentIds:()=>cs(t)});let e=new $o({processTitle:Tv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await _o(),o=i??{};os({pid:process.pid}),H.info(i?"loaded bridge config":"initialized bridge config");try{let P=new Wn;o.frameworksCache=await P.detectAll(),H.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){H.warn("framework detection failed",{err:String(P)})}await Fi(o);let c=new jo(new Ur),l=null,f=new yo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(P,G,K,ae)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,G,K,ae)}});await Cv(t,f);let x=new go({paths:t,config:o,registry:f});l=x;let h,m,E=null,A={},y,b=null,I=null,S=null,C=new vn;function O(P,G){return C.enqueue(()=>R(P,G))}function w(){I||(I=new Vo({isConnected:()=>c.isConnected(),forceReconnect:()=>S?O(S,{force:!0}):void 0,onFatal:P=>{if(process.env[Xi]==="1"){H.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:P});return}H.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:P}),process.exit(1)}})),I.start()}async function R(P,G){let K=P,ae=K?.privatecode;if(!ae)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Xe=ki(K.env),xe=K.handshake_url,he=K.frontier_url,At=fh(K.env,xe,he);if(S=K,!G?.force&&h===ae&&m===At){let _e=await Dv(t);return f.agents.size===0&&_e?(H.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Zo(t,x).catch(De=>H.warn("connect-noop auto-revive error (ignored)",{err:String(De)}))):H.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let pt=!!h&&h!==ae,en=m!==void 0&&m!==At,Ut=pt||en,tn=await Lc({privatecode:ae,...xe?{endpoint:xe}:{},ppeOverride:Xe});if(Ut){H.warn("connect config switched, resetting agents",{pcChanged:pt,envChanged:en,previousPc:h?Yo(h):"",nextPc:Yo(ae)});for(let _e of[...f.agents.values()])await _e.dispose("connect config switch").catch(()=>{}),f.agents.delete(_e.agentId);f.disconnectedAgents.size>0&&(H.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Ur,"connect switch").catch(()=>{})}E=tn.deviceId,os({deviceId:E,pid:process.pid}),Zc({patToken:ae,env:K.env}).catch(_e=>H.warn("coze-cli setup error (ignored)",{err:String(_e)}));let Wr=new Yi({handshake:tn,privatecode:ae,...he?{urlOverride:he}:{},ppeOverride:Xe,getPatTokenForAgent:_e=>f.agents.get(_e)?.patToken});return await c.swap(Wr,"connect"),h=ae,m=At,A=Xe,y=xe,K.mock_scenario!==void 0&&(f.setMockScenario(K.mock_scenario),H.info("mock scenario set",{scenario:K.mock_scenario})),b||(b=new Oi({core:f,getDeviceId:()=>E??"",onTickEnd:()=>z.retryPending().catch(_e=>H.warn("detailSync.retryPending failed (ignored)",{err:String(_e)})),onAuthFailures:V})),b.start(),w(),Ut&&Zo(t,x).catch(_e=>H.warn("post-connect-switch auto-revive error (ignored)",{err:String(_e)})),Zi(ae,t).catch(_e=>H.warn("writePatToken after /connect failed (ignored)",{err:String(_e)})),H.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async P=>x.createAgent(P.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let k={},B=new so({agents:f.agents,disposeAndMarkDisconnected:async(P,G)=>{let K=f.agents.get(P);if(K){await x.cleanupOpenclawSessionProviders(K).catch(Xe=>H.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(Xe)}));let ae=!0;try{await K.dispose(`disconnect: ${G}`)}catch(Xe){ae=!1,H.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(Xe)}),K.status="error"}ae&&(K.status="disconnected",f.unregister(P),f.disconnectedAgents.add(P))}else f.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await x.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,G)=>{await x.openclawRepair(P,G)},isRuntimePendingPermission:P=>f.hasPendingPermissionFor(P)});f.registerExtension("_agent/listSkills",P=>B.listSkills(P.params)),f.registerExtension("_agent/addSkills",P=>B.addSkills(P.params)),f.registerExtension("_agent/removeSkills",P=>B.removeSkills(P.params)),f.registerExtension("_agent/getFileTree",P=>B.getFileTree(P.params)),f.registerExtension("_agent/getFileContent",P=>B.getFileContent(P.params)),f.registerExtension("_agent/update",P=>B.updateAgent(P.params)),f.registerExtension("_agent/disconnect",P=>B.disconnectAgent(P.params)),f.registerExtension("_agent/switchModel",P=>B.switchModel(P.params)),f.registerExtension("_agent/reset",P=>B.resetAgent(P.params)),f.registerExtension("_agent/repair",P=>B.repairAgent(P.params));let z=new us({paths:t,handlers:B,sendDetail:P=>f.sendRequest("_agent/detail",P)});k.ref=z;let V=async P=>{await Promise.allSettled(P.map(async G=>{try{await B.disconnectAgent({agentId:G.agentId,reason:`auth_failure: code=${G.code} ${G.message}`}),H.info("agent disconnected due to auth failure from heartbeat response",{agentId:G.agentId,code:G.code,message:G.message})}catch(K){H.warn("disconnect during authFailure handling failed (ignored)",{agentId:G.agentId,err:String(K)})}}))};c.onConnect(({initial:P})=>{H.info("frontier upstream connected, triggering detail sync",{initial:P}),z.syncAll(P?"initial-connect":"reconnect").catch(G=>H.warn("detail sync top-level error (ignored)",{err:String(G)}))});let Y=new Eo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let P=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Xi]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let G=P,K=G?.privatecode,ae=G?.pairing_code;if(!K||!ae)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Xe=ki(G.env),xe=G.handshake_url,he=G.frontier_url,At=fh(G.env,xe,he),pt=!!h&&h!==K,en=m!==void 0&&m!==At,Ut=pt||en,tn=await Lc({privatecode:K,...xe?{endpoint:xe}:{},ppeOverride:Xe});if(Ut){H.warn("pair config switched, resetting agents",{pcChanged:pt,envChanged:en,previousPc:h?Yo(h):"",nextPc:Yo(K),previousEnvKey:m??"",nextEnvKey:At});for(let De of[...f.agents.values()])await De.dispose("pair config switch").catch(()=>{}),f.agents.delete(De.agentId);f.disconnectedAgents.size>0&&(H.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Ur,"pair switch").catch(()=>{})}E=tn.deviceId,os({deviceId:E,pid:process.pid}),Zc({patToken:K,env:G.env}).catch(De=>H.warn("coze-cli setup error (ignored)",{err:String(De)}));let Wr=new Yi({handshake:tn,privatecode:K,...he?{urlOverride:he}:{},ppeOverride:Xe,getPatTokenForAgent:De=>f.agents.get(De)?.patToken});await c.swap(Wr,"pair");try{let De=new Wn;o.frameworksCache=await De.detectAll(),await Fi(o),H.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(De){H.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(De)})}let _e=Object.keys(o.frameworksCache??{});try{let De=await f.sendRequest("_agent/pair",{pairCode:ae,patToken:K,frameworks:_e,_meta:{cozeDeviceId:E}});H.info("_agent/pair ok",{pairResult:De}),h=K,m=At,A=Xe,y=xe,G.mock_scenario!==void 0&&(f.setMockScenario(G.mock_scenario),H.info("mock scenario set",{scenario:G.mock_scenario})),Zi(K,t).catch(Le=>H.warn("writePatToken after /pair failed (ignored)",{err:String(Le)})),b||(b=new Oi({core:f,getDeviceId:()=>E??"",onTickEnd:()=>z.retryPending().catch(Le=>H.warn("detailSync.retryPending failed (ignored)",{err:String(Le)})),onAuthFailures:V})),b.start(),w(),Ut&&Zo(t,x).catch(Le=>H.warn("post-pair-switch auto-revive error (ignored)",{err:String(Le)}));let Xn;return G.agent_id&&(Xn=await Rv(G.agent_id,t,x,Le=>f.sendRequest("_agent/detail",Le),K).catch(Le=>(H.error("--agent-id ensureAgent failed",{agentId:G.agent_id,err:String(Le)}),{ok:!1,agentId:G.agent_id??"",note:String(Le)}))),{ok:!0,note:"paired with cloud",...Xn?{agent:Xn}:{}}}catch(De){return H.error("_agent/pair failed",{err:String(De)}),{ok:!1,note:`pair failed: ${String(De)}`}}}},{method:"POST",path:"/connect",handler:P=>O(P)},{method:"POST",path:"/_agent/create",handler:async P=>{let G=P;return{ok:!0,result:await x.createAgent(G)}}},{method:"POST",path:"/agent/send",handler:async P=>{let G=P;if(!G?.agentId||!G?.sessionId||!G?.kind||!G?.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 K=G;return await(K.groupFile?_u:wu)(K,{core:f,patToken:h,handshakeBase:y,ppeOverride:A})}catch(K){if(K instanceof T)return{ok:!1,code:K.code,message:K.message};throw K}}},{method:"POST",path:"/reload",handler:async P=>{let G=P?.agent_id,K=await f.reloadAgents(G);return H.info("IPC /reload: recycled agent subprocesses",{agentId:G??"(all)",recycled:K}),{ok:!0,recycled:K}}},{method:"POST",path:"/shutdown",handler:async()=>(H.info("IPC /shutdown received"),setImmediate(()=>{ge.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:re,token:te}=await Y.start();try{await sh(t.libEntry,t)}catch(P){H.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await f.start(),Zo(t,x).catch(P=>H.warn("auto-revive top-level error (ignored)",{err:String(P)})),xl().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(sn(),fl));for(let G of["claude-code","codex"]){let K=await P(G);K&&H.info("acp wrapper version",{framework:G,version:K})}}).catch(P=>H.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let ve=null,ge={port:re,token:te,core:f,ipc:Y,shutdown(P){return ve||(H.info("daemon shutdown",{reason:P}),ve=(async()=>{b?.stop(),I?.stop(),await f.stop(P),await Y.stop(),await e.release()})(),ve)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{ge.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{H.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{H.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name});try{process.stderr.write(`FATAL uncaughtException: ${P.stack??P.message}
106
+ `)}catch{}process.exit(1)}),H.info("daemon ready",{port:re,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),kv({cliSpawned:process.env[Xi]==="1",readPatToken:()=>Ho(t),connect:O}).catch(P=>H.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(P)})),ge}async function Dv(t){return cs(t).length>0}function Yo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function fh(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Cv(t,e){let r=cs(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(on(),fs));for(let c of r){await o(c,t).catch(l=>H.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),H.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){H.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Rv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(on(),fs)),l=await c(t,e);if(l){H.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let m={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}H.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 Zo(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(on(),fs));H.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){H.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(h)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){H.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{H.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:x.framework});let h=Pv(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){H.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:x.framework,err:String(h)}),l+=1}}return H.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function kv(t){let e=t.logger??H;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Pv(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Jo();Ne();import{readFile as xh}from"node:fs/promises";var Qt=class{paths;constructor(e){this.paths=e??Q()}async probe(e=1e3){let r=await Xo(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:Lv(i)}}}async request(e){let r=await Xo(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:Ov(x)}}finally{clearTimeout(l)}}};async function Xo(t){try{let[e,r]=await Promise.all([xh(t.portFile,"utf8"),xh(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 Ov(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Lv(t){return t instanceof Error?t.message:String(t)}bn();se();Ne();function An(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}}sn();import{chmod as Nv,copyFile as hh,mkdir as gh,readFile as Qo,rename as ph,rm as Dd,stat as mh,writeFile as Mv}from"node:fs/promises";import{homedir as xC}from"node:os";import{dirname as Bv,join as qr,resolve as Cd,sep as Qi}from"node:path";import{fileURLToPath as zv}from"node:url";bn();se();Ne();var Rd=q("dist-install");function Fv(t){let e=zv(t),r=Bv(e),i=`${Qi}src${Qi}`;if(r.includes(i)||r.endsWith(`${Qi}src${Qi}cli`))return null;let o=Cd(r,"index.js"),c=Cd(r,"..","package.json");return{dist:o,pkgJson:c}}async function Pd(t={}){let e=t.paths??Q(),r=Fv(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let A=JSON.parse(await Qo(o,"utf8"));c=A.version??"unknown",l=A.dependencies??{}}catch(A){return Rd.warn("cannot read source package.json,skip dist install",{err:String(A)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(A)}`}}let f=Xr.map(A=>`${A}@${l[A]??"latest"}`),x=await _o(e.configFile)??{},h=x.libVersion,m=await Qo(e.libEntry).then(()=>!0).catch(()=>!1),E=h===c;if(E&&m&&await kd(e))return{kind:"already-current",libVersion:c};if(!E||!m){await gh(e.libDir,{recursive:!0}),await hh(i,e.libEntry),await hh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let A=Cd(e.libDir,"package.json"),y=`${JSON.stringify({type:"module"},null,2)}
107
+ `;await Qo(A,"utf8").catch(()=>null)!==y&&await Mv(A,y)}return(!E||!await kd(e))&&await(t.installWrappers??Uv)(e,f),x.libVersion=c,await Fi(x,e.configFile),Rd.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:c}),E&&m?{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 kd(t){for(let e of Xr){let r=qr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await mh(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function Uv(t,e){await jv(t.installLock,async()=>{if(await kd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Qi}.staging-${process.pid}-${r}`,o=qr(i,"node_modules"),c=qr(t.libDir,"node_modules");try{await gh(i,{recursive:!0}),await qv(e,i),await Gv(o);let l=`${c}.trash-${r}`;await ph(c,l).catch(()=>{}),await ph(o,c),await Dd(l,{recursive:!0,force:!0}).catch(()=>{}),Rd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Dd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function qv(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=ut("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 Gv(t){for(let e of Xr){let r=qr(t,...e.split("/")),i=JSON.parse(await Qo(qr(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=qr(t,".bin",o),l=await mh(c);process.platform!=="win32"&&!(l.mode&73)&&await Nv(c,l.mode|73).catch(()=>{})}}async function jv(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Dd(t,{force:!0}).catch(()=>{})}}_a();se();Ne();import{closeSync as _h,fstatSync as yh,openSync as Eh,readFileSync as Hv,readSync as Wv,readdirSync as Kv,statSync as $v}from"node:fs";import{join as ea}from"node:path";var Jv=new Set(["debug","info","warn","error"]);function bh(t){let e=t,r=An(e,"--agent-id");e=r.rest;let i=An(e,"--date");e=i.rest;let o=An(e,"-n","--lines");e=o.rest;let c=An(e,"--level");e=c.rest;let l=An(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&&Jv.has(c.value)?c.value:void 0,m={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(m.agentId=r.value),i.value&&(m.date=i.value),h&&(m.level=h),l.value&&(m.grep=l.value),m}function Vv(t,e){return t.agentId?ea(et(t.agentId,e).logs,nr("agent",t.date)):ea(e.bridgeLogsDir,nr("bridge",t.date))}function Yv(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function Zv(t,e){let r;try{r=Kv(t)}catch{return[]}let i=[];for(let o of r){let c=wa(o,e);if(!c)continue;let l=0;try{l=$v(ea(t,o)).size}catch{}i.push({file:ea(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function vh(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"&&!ol(r,e.level))return!1}return!0}var wh={debug:"90",info:"36",warn:"33",error:"31"},Xv=new Set(["ts","level","module","msg"]);function Qv(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Sh(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=Qv(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&wh[o]&&(c=`\x1B[${wh[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])=>!Xv.has(h)).map(([h,m])=>` ${h}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${l} ${f}${x}`}function e2(t,e,r){let c=Hv(t,"utf8").split(`
108
+ `).filter(l=>l.length>0).filter(l=>vh(l,{level:e.level,grep:e.grep}));for(let l of Yv(c,e.lines))process.stdout.write(`${Sh(l,{raw:e.raw,color:r})}
109
+ `)}async function Ih(t,e){let r=e.paths??Q(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?et(t.agentId,r).logs:r.bridgeLogsDir,f=t.agentId?"agent":"bridge",x=Zv(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??Rn(new Date),c=Vv({agentId:t.agentId,date:o},r);try{e2(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
112
112
  \u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
113
113
  (legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
114
- `),1}return t.follow&&await rS(c,t,i),0}var tS=500;function nS(t){try{let e=mx(t,"r");try{return gx(e).size}finally{px(e)}}catch{return 0}}async function rS(t,e,r){let i=nS(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let h=mx(t,"r");try{let p=gx(h).size;if(p>i){let m=Buffer.allocUnsafe(p-i),E=Wv(h,m,0,m.length,i);u=m.subarray(0,E).toString("utf8"),i+=E}}finally{px(h)}}catch{}if(u){let h=(o+u).split(`
115
- `);o=h.pop()??"";for(let p of h)p.length>0&&yx(p,{level:e.level,grep:e.grep})&&process.stdout.write(`${Ex(p,{raw:e.raw,color:r})}
116
- `)}await new Promise(h=>setTimeout(h,tS))}}finally{process.off("SIGINT",l)}}import{basename as iS,resolve as sS}from"node:path";Ne();var oS=9e4,aS={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function cS(t){return aS[t]??1}async function vx(t,e={}){let r=e.paths??Z();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
114
+ `),1}return t.follow&&await r2(c,t,i),0}var t2=500;function n2(t){try{let e=Eh(t,"r");try{return yh(e).size}finally{_h(e)}}catch{return 0}}async function r2(t,e,r){let i=n2(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let f="";try{let x=Eh(t,"r");try{let h=yh(x).size;if(h>i){let m=Buffer.allocUnsafe(h-i),E=Wv(x,m,0,m.length,i);f=m.subarray(0,E).toString("utf8"),i+=E}}finally{_h(x)}}catch{}if(f){let x=(o+f).split(`
115
+ `);o=x.pop()??"";for(let h of x)h.length>0&&vh(h,{level:e.level,grep:e.grep})&&process.stdout.write(`${Sh(h,{raw:e.raw,color:r})}
116
+ `)}await new Promise(x=>setTimeout(x,t2))}}finally{process.off("SIGINT",l)}}import{basename as i2,resolve as s2}from"node:path";Ne();var o2=9e4,a2={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 c2(t){return a2[t]??1}async function Ah(t,e={}){let r=e.paths??Q();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
117
117
  `),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
118
- `),3;let i=await $o(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
119
- `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:sS(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await dS(i,"/agent/send",o,oS)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
118
+ `),3;let i=await Xo(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:s2(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 d2(i,"/agent/send",o,o2)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
120
120
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
121
- `),cS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
122
- `);else{let l=t.name??iS(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${u})
123
- `)}else process.stdout.write(`Sent ${t.kind} ${l} (${lS(c.bytes)})
124
- `)}return 0}async function dS(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),u=await l.text(),h=u?JSON.parse(u):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function lS(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Ox=U("cli");function je(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function ta(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
125
- `)}function NS(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="reload"){let{value:C}=je(e.slice(1),"--agent-id");return C?{mode:"reload",agentId:C}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return LS(e.slice(1));if(e[0]==="log")return{mode:"log",..._x(e.slice(1))};if(e[0]==="connect")return MS(e.slice(1));if(e.includes("--status"))return ta("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ta("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ta("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ta("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=je(r,"--pat-token");r=o;let{value:c,rest:l}=je(r,"--pair-code");r=l;let{value:u,rest:h}=je(r,"--env");r=h;let{value:p,rest:m}=je(r,"--handshake-url");r=m;let{value:E,rest:T}=je(r,"--frontier-url");r=T;let{value:_,rest:v}=je(r,"--mock-scenario");r=v;let{value:I}=je(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return u&&(S.env=u),p&&(S.handshakeUrl=p),E&&(S.frontierUrl=E),_&&(S.mockScenario=_),I&&(S.agentId=I),S}function LS(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=je(i,"--caption");i=c;let{value:l,rest:u}=je(i,"--name");i=u;let{value:h,rest:p}=je(i,"--agent-id");i=p;let{value:m,rest:E}=je(i,"--session-id");i=E;let{value:T,rest:_}=je(i,"--mime");i=_;let v=i.includes("--group-file");i=i.filter(C=>C!=="--group-file");let I=i.includes("--json"),S={mode:"send",kind:e,path:r,json:I};return o&&(S.caption=o),l&&(S.name=l),h&&(S.agentId=h),m&&(S.sessionId=m),v&&(S.groupFile=!0),T&&(S.mimeType=T),S}function MS(t){let e=t,{value:r,rest:i}=je(e,"--pat-token");e=i;let{value:o,rest:c}=je(e,"--env");e=c;let{value:l,rest:u}=je(e,"--handshake-url");e=u;let{value:h,rest:p}=je(e,"--frontier-url");e=p;let{value:m,rest:E}=je(e,"--mock-scenario");e=E;let T={mode:"connect"};return r&&(T.privatecode=r),o&&(T.env=o),l&&(T.handshakeUrl=l),h&&(T.frontierUrl=h),m&&(T.mockScenario=m),T}var BS=`
121
+ `),c2(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
122
+ `);else{let l=t.name??i2(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} (${l2(c.bytes)})
124
+ `)}return 0}async function d2(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 l2(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Nh=q("cli");function Ke(t,e){let{value:r,rest:i}=An(t,e);return{value:r,rest:i}}function oa(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
125
+ `)}function L2(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}=Ke(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 N2(e.slice(1));if(e[0]==="log")return{mode:"log",...bh(e.slice(1))};if(e[0]==="connect")return M2(e.slice(1));if(e.includes("--status"))return oa("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return oa("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return oa("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return oa("--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}=Ke(r,"--pat-token");r=o;let{value:c,rest:l}=Ke(r,"--pair-code");r=l;let{value:f,rest:x}=Ke(r,"--env");r=x;let{value:h,rest:m}=Ke(r,"--handshake-url");r=m;let{value:E,rest:A}=Ke(r,"--frontier-url");r=A;let{value:y,rest:b}=Ke(r,"--mock-scenario");r=b;let{value:I}=Ke(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return f&&(S.env=f),h&&(S.handshakeUrl=h),E&&(S.frontierUrl=E),y&&(S.mockScenario=y),I&&(S.agentId=I),S}function N2(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}=Ke(i,"--caption");i=c;let{value:l,rest:f}=Ke(i,"--name");i=f;let{value:x,rest:h}=Ke(i,"--agent-id");i=h;let{value:m,rest:E}=Ke(i,"--session-id");i=E;let{value:A,rest:y}=Ke(i,"--mime");i=y;let b=i.includes("--group-file");i=i.filter(C=>C!=="--group-file");let I=i.includes("--json"),S={mode:"send",kind:e,path:r,json:I};return o&&(S.caption=o),l&&(S.name=l),x&&(S.agentId=x),m&&(S.sessionId=m),b&&(S.groupFile=!0),A&&(S.mimeType=A),S}function M2(t){let e=t,{value:r,rest:i}=Ke(e,"--pat-token");e=i;let{value:o,rest:c}=Ke(e,"--env");e=c;let{value:l,rest:f}=Ke(e,"--handshake-url");e=f;let{value:x,rest:h}=Ke(e,"--frontier-url");e=h;let{value:m,rest:E}=Ke(e,"--mock-scenario");e=E;let A={mode:"connect"};return r&&(A.privatecode=r),o&&(A.env=o),l&&(A.handshakeUrl=l),x&&(A.frontierUrl=x),m&&(A.mockScenario=m),A}var B2=`
126
126
  coze-bridge - local bridge daemon for cloud Agent Service
127
127
 
128
128
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -201,56 +201,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
201
201
 
202
202
  Internal:
203
203
  <node> <entry> --daemon daemon mode (OS supervisor only)
204
- `.trimStart();async function Px(t=process.argv,e={}){let r=NS(t);switch(r.mode){case"help":return process.stdout.write(BS),0;case"version":return process.stdout.write(`${vr}
205
- `),0;case"daemon":{try{await cx()}catch(i){return Ox.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return zS(e);case"stop":return Lx(e);case"reload":return qS(r.agentId,e);case"log":return bx(r,e);case"update":return FS(e);case"purge":return HS(e);case"service-install":return jS(e);case"service-uninstall":return GS(e);case"pair":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),WS(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),KS(r.privatecode,e,i)}case"send":return vx({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function Nx(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function zS(t){let e=t.paths??Z(),r=new Zt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
206
- `),1;if(i.kind==="stale")return await Nx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
204
+ `.trimStart();async function Mh(t=process.argv,e={}){let r=L2(t);switch(r.mode){case"help":return process.stdout.write(B2),0;case"version":return process.stdout.write(`${Tr}
205
+ `),0;case"daemon":{try{await uh()}catch(i){return Nh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return z2(e);case"stop":return zh(e);case"reload":return q2(r.agentId,e);case"log":return Ih(r,e);case"update":return F2(e);case"purge":return G2(e);case"service-install":return j2(e);case"service-uninstall":return H2(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),W2(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),K2(r.privatecode,e,i)}case"send":return Ah({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 Bh(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 z2(t){let e=t.paths??Q(),r=new Qt(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 Bh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
207
207
  `),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
208
208
  ${JSON.stringify(o.body,null,2)}
209
- `),0}async function Lx(t){let e=t.paths??Z(),r=new Zt(e),i=await Yi(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
209
+ `),0}async function zh(t){let e=t.paths??Q(),r=new Qt(e),i=await ts(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
210
210
  `)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
211
211
  `:`coze-bridge: not running
212
- `),0;if(c.kind==="stale")return await Nx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
212
+ `),0;if(c.kind==="stale")return await Bh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
213
213
  `),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
214
214
  `),0}catch(l){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
215
215
  `),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
216
- `),1)}}async function FS(t){return await Lx(t),(t.spawnNpx??US)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function US(t){return new Promise(e=>{let r=lt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
217
- `),e(1)})})}async function qS(t,e){let r=new Zt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
216
+ `),1)}}async function F2(t){return await zh(t),(t.spawnNpx??U2)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function U2(t){return new Promise(e=>{let r=ut("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 q2(t,e){let r=new Qt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
218
218
  `),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
219
219
  `):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
220
220
  `),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
221
221
  `),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
222
- `),1}}async function Yi(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(l,u),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Dx(),Cx)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Mx(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??ox,o=t.waitTimeoutMs??15e3,c=t.sleep??JS,l=t.paths??Z(),u=await Yi(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let h=await kx(e,o,c);if(h.kind==="connected")return h;Wr(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(h){Wr(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(h)})}await u.uninstall().catch(()=>{}),await $S(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(h=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(h)}
222
+ `),1}}async function ts(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(()=>(Oh(),Ph)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Fh(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??lh,o=t.waitTimeoutMs??15e3,c=t.sleep??J2,l=t.paths??Q(),f=await ts(t);if(f&&(f.platform==="darwin"||f.platform==="linux")){try{await f.install({activate:!0});let x=await Lh(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 $2(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)}
223
223
  `));return process.stdout.write(`coze-bridge: starting daemon...
224
- `),await i({paths:t.paths}),kx(e,o,c)}async function HS(t){let e=new Zt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
224
+ `),await i({paths:t.paths}),Lh(e,o,c)}async function G2(t){let e=new Qt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
225
225
  `);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
226
- `)}await new Promise(l=>setTimeout(l,500))}let i=await Yi(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
226
+ `)}await new Promise(l=>setTimeout(l,500))}let i=await ts(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
227
227
  `)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
228
- `)}let o=t.paths??Z(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
228
+ `)}let o=t.paths??Q(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
229
229
  `)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
230
230
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
231
- `),0}async function jS(t){let e=await Yi(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
231
+ `),0}async function j2(t){let e=await ts(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
232
232
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
233
233
  `),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
234
- `),1}}async function GS(t){let e=await Yi(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
234
+ `),1}}async function H2(t){let e=await ts(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
235
235
  `),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
236
- `),1}}async function WS(t,e,r,i={},o){let c=new Zt(r.paths),l=r.paths??Z();if(await Gc(l).catch(p=>Wr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(p)})),!r.skipDistInstall){let p=await Cd({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
237
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
238
- `)}let u=await Mx(r,c);if(u.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
239
- `),1;let h={privatecode:t,pairing_code:e};i.env&&(h.env=i.env),i.handshakeUrl&&(h.handshake_url=i.handshakeUrl),i.frontierUrl&&(h.frontier_url=i.frontierUrl),i.mockScenario&&(h.mock_scenario=i.mockScenario),o&&(h.agent_id=o);try{let p=await c.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let m=p.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
236
+ `),1}}async function W2(t,e,r,i={},o){let c=new Qt(r.paths),l=r.paths??Q();if(await $c(l).catch(h=>Yr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!r.skipDistInstall){let h=await Pd({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(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
238
+ `)}let f=await Fh(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 m=h.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
240
240
  `),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
241
- `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
242
- `),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
243
- `),1}}async function KS(t,e,r={}){let i=e.paths??Z(),o=t??await Fo(i);if(!o)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Zt(e.paths);if(await Gc(i).catch(h=>Wr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!e.skipDistInstall){let h=await Cd({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
244
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(m=>setTimeout(m,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
245
- `)}let l=await Mx(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
246
- `),1;let u={privatecode:o};r.env&&(u.env=r.env),r.handshakeUrl&&(u.handshake_url=r.handshakeUrl),r.frontierUrl&&(u.frontier_url=r.frontierUrl),r.mockScenario&&(u.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:u,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
247
- `),await Ki(o,i).catch(p=>Ox.warn("writePatToken after connect failed (ignored)",{err:String(p)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
248
- `),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
249
- `),1}}async function kx(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}async function $S(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!qo(u))return;await e(i)}}function JS(t){return new Promise(e=>setTimeout(e,t))}te();function VS(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function Bx(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=VS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
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 K2(t,e,r={}){let i=e.paths??Q(),o=t??await Ho(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 Qt(e.paths);if(await $c(i).catch(x=>Yr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!e.skipDistInstall){let x=await Pd({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(m=>setTimeout(m,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
245
+ `)}let l=await Fh(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
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"})
247
+ `),await Zi(o,i).catch(h=>Nh.warn("writePatToken after connect failed (ignored)",{err:String(h)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
248
+ `),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
249
+ `),1}}async function Lh(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 $2(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||!Ko(f))return;await e(i)}}function J2(t){return new Promise(e=>setTimeout(e,t))}se();function V2(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 Uh(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=V2(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
250
250
  `),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
251
251
  \u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
252
252
  npx -y coze-bridge@latest stop
253
253
  npx -y coze-bridge@latest connect
254
254
 
255
- `)}Bx();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&tl("warn");Px(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
255
+ `)}Uh();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&il("warn");Mh(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
256
256
  `),process.exit(1)});