@ohmytr/coding-agent 18.0.3 → 18.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -855,7 +855,7 @@ import{createRequire as PLo}from"node:module";var wLo=Object.create;var{getProto
|
|
|
855
855
|
`,i);if(l===-1)break;let u=s.slice(i,l);r=l+1,i=l+1;let p=u.trim();if(p.length===0)continue;try{o.push(JSON.parse(p))}catch(c){a=c instanceof Error?c:Error(String(c));break}}return{values:o,error:a,read:r,done:a!==void 0&&i>=s.length}}class KVe{filePath;chunks=[];handlePromise=null;ended=!1;constructor(e){this.filePath=e}write(e){let t=typeof e==="string"?Buffer.from(e,"utf8"):Buffer.from(e);return this.chunks.push(t),this.drain(),t.byteLength}async drain(){if(this.chunks.length===0||this.ended)return;this.handlePromise??=F3.open(this.filePath,"w");let e=await this.handlePromise,t=this.chunks;this.chunks=[];for(let n of t)await e.write(n)}async flush(){await this.drain();let e=await this.handlePromise;if(e)await e.sync();return this}async end(){await this.drain(),this.ended=!0;let e=await this.handlePromise;if(!e)return 0;let t=(await e.stat()).size;return await e.close(),this.handlePromise=null,t}}class XVe{path;constructor(e){this.path=e}get size(){try{return zhe.statSync(this.path).size}catch{return 0}}get type(){let e=ry.extname(this.path).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".json":"application/json",".txt":"text/plain",".html":"text/html",".pdf":"application/pdf"}[e]??"application/octet-stream"}async exists(){try{return await F3.access(this.path),!0}catch{return!1}}async text(){return F3.readFile(this.path,"utf8")}async json(){return JSON.parse(await this.text())}async arrayBuffer(){return(await this.bytes()).buffer.slice(0)}async bytes(){return F3.readFile(this.path)}stream(){return Vhe.toWeb(zhe.createReadStream(this.path))}writer(){return new KVe(this.path)}}function HQ(e){return e==="inherit"||e==="ignore"?e:"pipe"}class f5t{stdout;stderr;stdin=null;exitCode=-1;signalCode=null;exited;child;constructor(e,t){if(this.child=e,this.stdout=e.stdout?Vhe.toWeb(e.stdout):null,this.stderr=e.stderr?Vhe.toWeb(e.stderr):null,t&&e.stdin){let o=e.stdin;this.stdin={write(r){let i=typeof r==="string"?Buffer.from(r,"utf8"):Buffer.from(r);return o.write(i),i.byteLength},end(){o.end()}}}let{promise:n,resolve:s}=Promise.withResolvers();e.on("close",(o,r)=>{this.signalCode=r,this.exitCode=o??(r!==null?-1:0),s(this.exitCode)}),this.exited=n,e.on("error",()=>{this.exitCode=this.exitCode===-1?1:this.exitCode})}get success(){return this.exitCode===0}get returnCode(){return this.exitCode===-1?null:this.exitCode}kill(e="SIGTERM"){this.child.kill(e)}ref(){this.child.ref?.()}unref(){this.child.unref?.()}}function ZLo(e,t){let n=Rn("node:child_process"),s=t?.stdin??"inherit",o=t?.stdout??"inherit",r=t?.stderr??"inherit",i=n.spawn(e[0],e.slice(1),{cwd:t?.cwd,env:t?.env,stdio:[HQ(s),HQ(o),HQ(r)],windowsHide:!0}),a=new f5t(i,s==="pipe");return t?.onExit?.(a),a}function m5t(e,t){let s=Rn("node:child_process").spawnSync(e[0],e.slice(1),{cwd:t?.cwd,env:t?.env,input:t?.input!==void 0?Buffer.from(NS(t.input)):void 0,stdio:[t?.input!==void 0?"pipe":"ignore",HQ(t?.stdout),HQ(t?.stderr)],windowsHide:!0,maxBuffer:536870912});return{exitCode:s.status??1,success:s.status===0,signalCode:s.signal,stdout:s.stdout??Buffer.alloc(0),stderr:s.stderr??Buffer.alloc(0)}}function h5t(e,...t){let n="";for(let s=0;s<e.length;s++)if(n+=e[s],s<t.length)n+=String(t[s]).replace(/'/g,"'\\''");return new g5t(n)}class T5t{port=0;hostname="localhost";url="http://localhost:0/";server;constructor(e){this.server=e;let t=e.address();if(t&&typeof t==="object"){this.port=t.port;let n=t.address==="::"||t.address==="0.0.0.0"?"localhost":t.address;this.hostname=n,this.url=`http://${n}:${this.port}/`}}stop(e){return new Promise((t)=>{if(e?.closeAll)this.server.closeAllConnections?.();this.server.close(()=>t())})}ref(){return this.server.ref(),this}unref(){return this.server.unref(),this}requestIP(){return null}listen(...e){return this.server.listen(...e)}close(e){return this.server.close(e)}closeAllConnections(){this.server.closeAllConnections?.()}}async function e_o(e){if(e.method==="GET"||e.method==="HEAD")return;let t=[];for await(let n of e)t.push(n);return Buffer.concat(t)}function t_o(e){let t=_Lo.createServer((s,o)=>{(async()=>{try{let r=await e_o(s),i=new Headers;for(let[c,d]of Object.entries(s.headers)){if(d===void 0)continue;for(let f of Array.isArray(d)?d:[d])i.append(c,f)}let a=s.headers.host??`${e.hostname??"localhost"}:${e.port??80}`,l=new Request(`http://${a}${s.url??"/"}`,{method:s.method,headers:i,body:r!==void 0&&r.byteLength>0?new Uint8Array(r):void 0}),u=await e.fetch(l,{requestIP:()=>s.socket.remoteAddress}),p={};if(u.headers.forEach((c,d)=>{p[d]=d==="set-cookie"?u.headers.getSetCookie():u.headers.get(d)??c}),u.body){let c=Vhe.fromWeb(u.body);c.pipe(o),await new Promise((d)=>c.on("end",d))}else o.end()}catch(r){o.writeHead(500),o.end(`Internal error: ${r instanceof Error?r.message:String(r)}`)}})()}),n=e.unix!==void 0?{path:e.unix}:{host:e.hostname??"127.0.0.1",port:typeof e.port==="string"?Number(e.port):e.port??0};return t.listen(n),new T5t(t)}class JVe{socket;data;readyState="open";constructor(e){this.socket=e}write(e){let t=typeof e==="string"?Buffer.from(e,"utf8"):Buffer.from(e);return this.socket.write(t),t.byteLength}end(){this.socket.end(),this.readyState="closed"}shutdown(){return this.end(),!0}ref(){this.socket.ref()}unref(){this.socket.unref()}}function R5t(e,t){if(!t)return;e.socket.on("data",(n)=>{t.data?.(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}),e.socket.on("close",(n)=>{e.readyState="closed",t.close?.(e,n?Error("socket closed with error"):void 0)}),e.socket.on("error",(n)=>t.error?.(e,n)),e.socket.on("connect",()=>{t.open?.(e)})}function n_o(e){let t=$Ve.createServer((n)=>{let s=new JVe(n);R5t(s,e.socket),e.socket.open?.(s)});return t.listen({host:e.hostname??"127.0.0.1",port:e.port}),{get port(){let n=t.address();return n&&typeof n==="object"?n.port:e.port},hostname:e.hostname??"127.0.0.1",stop(n){if(n)t.closeAllConnections?.();let{promise:s,resolve:o}=Promise.withResolvers();return t.close(()=>o()),s},ref(){t.ref()},unref(){t.unref()}}}async function s_o(e){let t=e.unix!==void 0?$Ve.connect({path:e.unix}):$Ve.connect({host:e.hostname??"127.0.0.1",port:e.port});await new Promise((s,o)=>{t.once("connect",s),t.once("error",o)});let n=new JVe(t);return R5t(n,e.socket),n}function l5t(e){if(e.length>=24&&e[0]===137&&e[1]===80)return{width:e[16]<<24|e[17]<<16|e[18]<<8|e[19],height:e[20]<<24|e[21]<<16|e[22]<<8|e[23],format:"png"};if(e.length>=4&&e[0]===255&&e[1]===216){let t=2;while(t+9<e.length){if(e[t]!==255){t++;continue}let n=e[t+1];if(n>=192&&n<=207&&n!==196&&n!==200&&n!==204)return{height:e[t+5]<<8|e[t+6],width:e[t+7]<<8|e[t+8],format:"jpeg"};t+=2+(e[t+2]<<8|e[t+3])}}throw Error("bun-compat: unsupported or truncated image data")}class y5t{data;constructor(e){this.data=typeof e==="string"?Buffer.from(e,"base64"):NS(e)}async metadata(){return l5t(this.data)}png(){let{format:e}=l5t(this.data);if(e!=="png")throw Error(`bun-compat: ${e} -> png re-encoding is not supported on the Node runtime`);return this}toBase64(){return Buffer.from(this.data).toString("base64")}arrayBuffer(){return this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength)}}function zVe(e){throw Error(`${e} is not supported under the Node runtime yet`)}class BQ{pattern;constructor(e){this.pattern=e}match(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g," ").replace(/\*/g,"[^/]*").replace(/ /g,".*").replace(/\?/g,".");return new RegExp(`^${t}$`).test(this.pattern)}syncWalk(e,t,n){let o=process.getBuiltinModule("node:fs").readdirSync(e,{withFileTypes:!0});for(let r of o){if(!n?.dot&&r.name.startsWith("."))continue;let i=ry.join(e,r.name);if(r.isDirectory())this.syncWalk(i,t,n);else if(!n?.onlyFiles||r.isFile())t.push(n?.absolute?i:ry.relative(n?.cwd??process.cwd(),i))}}scanSync(e){let t=typeof e==="string"?e:e?.cwd??process.cwd(),n=typeof e==="string"?{cwd:t}:e??{},s=[];return this.syncWalk(t,s,n),s.filter((o)=>this.match(o.split(ry.sep).join("/")))}async*scan(e){let t=await p5t().glob({pattern:this.pattern,path:e?.cwd??process.cwd(),dot:e?.dot??!1,fileType:e?.onlyFiles?"file":void 0,gitignore:!0});for(let n of t.matches)yield e?.absolute?ry.resolve(e.cwd??process.cwd(),n.path):n.path}}async function o_o(e,t){let n=e instanceof XVe?e.path:e;if(typeof n!=="string")throw TypeError("bun-compat: unsupported write destination");let s=await GLo(t);return await F3.mkdir(ry.dirname(n),{recursive:!0}).catch(()=>{}),await F3.writeFile(n,s),s.byteLength}function up(e){return ry.dirname(jVe(e))}function a_o(e){let t="",n=!1;for(let s=0;s<e.length;s++){let o=e[s];if(n){if(t+=o,o==="\\")t+=e[s+1]??"",s++;else if(o==='"')n=!1;continue}if(o==='"'){n=!0,t+=o;continue}if(o==="/"&&e[s+1]==="/"){while(s<e.length&&e[s]!==`
|
|
856
856
|
`)s++;continue}if(o==="/"&&e[s+1]==="*"){s+=2;while(s<e.length&&!(e[s]==="*"&&e[s+1]==="/"))s++;s++;continue}t+=o}return t}var LLo,qQ,UQ,zhe,F3,_Lo,$Ve,ry,DLo,Vhe,jVe,HLo,qLo,ULo,DQ,e5t,t5t,n5t,o5t=null,r5t,d5t,g5t,r_o,i_o,C5t,Mo,Ux,S5t,Qs,u5t;var Xo=w(()=>{LLo=process.getBuiltinModule("node:module"),{createRequire:qQ}=LLo,UQ=process.getBuiltinModule("node:crypto"),zhe=process.getBuiltinModule("node:fs"),F3=process.getBuiltinModule("node:fs/promises"),_Lo=process.getBuiltinModule("node:http"),$Ve=process.getBuiltinModule("node:net"),ry=process.getBuiltinModule("node:path"),DLo=process.getBuiltinModule("node:readline"),{Readable:Vhe}=process.getBuiltinModule("node:stream"),{fileURLToPath:jVe,pathToFileURL:HLo}=process.getBuiltinModule("node:url"),{isDeepStrictEqual:qLo,inspect:ULo}=process.getBuiltinModule("node:util"),DQ=process.getBuiltinModule("node:zlib");r5t=/\x1b\[[0-9;:?]*[A-Za-z]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[P^_][\s\S]*?\x1b\\/g;d5t=class d5t extends YVe{constructor(e){super("sha256",e)}static hash(e){return UQ.createHash("sha256").update(NS(e)).digest("hex")}};g5t=class g5t extends Promise{commandText;cwdDir;envOverrides;quietMode=!1;noThrow=!1;constructor(e){super((t)=>{Promise.resolve().then(()=>this.run()).then(t)});this.commandText=e}cwd(e){return this.cwdDir=e,this}env(e){return this.envOverrides=e,this}text(){return this.then((e)=>e.stdout.toString("utf8"))}async run(){let e=process.platform==="win32",t=e?process.env.COMSPEC??"cmd.exe":process.env.SHELL||"/bin/sh",n=e?["/d","/s","/c",this.commandText]:["-c",this.commandText],s=m5t([t,...n],{cwd:this.cwdDir??process.cwd(),env:this.envOverrides,stdout:this.quietMode?"pipe":"inherit",stderr:this.quietMode?"pipe":"inherit"});if(s.exitCode!==0&&!this.noThrow)throw Error(`shell command failed (exit ${s.exitCode})`);return{...s,text:()=>s.stdout.toString("utf8")}}quiet(){return this.quietMode=!0,this}nothrow(){return this.noThrow=!0,this}};r_o=qQ(import.meta.url),i_o={parseChunk:a5t,parse(e){return a5t(e).values},stringify(e){return`${JSON.stringify(e)}
|
|
857
857
|
`}},C5t={argv:process.argv,$:h5t,stdout:process.stdout,wrapAnsi:$Lo,color:VLo,connect:s_o,CryptoHasher:YVe,deepEquals:(e,t)=>qLo(e,t),env:process.env,file:(e)=>new XVe(e instanceof URL?jVe(e):e),FileSink:KVe,fileURLToPath:jVe,gc:()=>{},generateHeapSnapshot:()=>"",Glob:BQ,gzipSync:(e)=>DQ.gzipSync(Buffer.from(NS(e))),gunzipSync:(e)=>DQ.gunzipSync(Buffer.from(e)),hash:Object.assign(i5t,{wyhash:i5t,xxHash32:(e,t)=>KLo(typeof e==="string"?Buffer.from(e,"utf8"):NS(e),t)}),Image:y5t,inspect:ULo,isMainThread:!0,JSON5:{parse:(e)=>BLo().parse(e)},JSONL:i_o,listen:n_o,main:process.argv[1]??"",nanoseconds:()=>Number(process.hrtime.bigint()),pathToFileURL:HLo,randomUUIDv7:JLo,resolveSync:(e,t)=>r_o(t?ry.join(ry.dirname(t),"_"):ry.join(process.cwd(),"_")).resolve(e),SHA256:d5t,sha:(e,t)=>{let[n,s]=typeof e==="string"&&t!==void 0?[e,t]:["sha256",e];return UQ.createHash(n).update(NS(s)).digest("hex")},semver:{order:XLo},serve:t_o,sleep:(e)=>new Promise((t)=>setTimeout(t,e)),sleepSync:(e)=>{let t=Date.now()+e;while(Date.now()<t);},spawn:ZLo,spawnSync:m5t,SQL:class{constructor(){zVe("Bun.SQL")}},stderr:process.stderr,stdin:{text:async()=>{let e=DLo.createInterface({input:process.stdin}),t=[];for await(let n of e)t.push(n);return t.join(`
|
|
858
|
-
`)},json:async()=>JSON.parse(await Bun.stdin.text())},stringWidth:c5t,plugin:()=>{},stripANSI:VVe,subprocess:void 0,Transpiler:class{constructor(){zVe("Bun.Transpiler")}},version:process.version.replace(/^v/,""),which:QLo,write:o_o,zstdCompressSync:(e)=>DQ.zstdCompressSync(Buffer.from(e)),zstdDecompressSync:(e)=>DQ.zstdDecompressSync(Buffer.from(e)),zstdDecompress:(e)=>Promise.resolve(DQ.zstdDecompressSync(Buffer.from(e)))};Object.defineProperty(C5t,"build",{get(){return()=>zVe("Bun.build")}});Mo={parse:(e)=>s5t().parse(e),stringify:(e,t,n)=>s5t().stringify(e,{indent:typeof n==="number"?n:2})};Ux={parse:(e)=>JSON.parse(a_o(e))},S5t={parse:(e)=>WLo().parse(e)},Qs=h5t,u5t=globalThis;if(typeof u5t.Bun>"u")u5t.Bun=C5t});var b5t=w(()=>{Xo()});var Yhe="18.0.2",Khe;var QVe=w(()=>{Khe={bun:">=1.3.14",node:">=24.0.0"}});import*as Am from"node:fs";import*as e6e from"node:os";import*as kf from"node:path";function eTe(e){let t=e?.trim();if(!t||t==="default")return;if(t==="."||t===".."||t.endsWith(".")||!E5t.test(t)||p_o.test(t))throw Error(`Invalid OMP profile "${e}". Profile names must match ${E5t.source}, cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`);return t}function n6e(e,t){return eTe(e!==void 0?e:t)}function c_o(){return n6e(process.env.OMT_PROFILE,process.env.PI_PROFILE)}function d_o(){try{return c_o()}catch{return}}function f_o(){return kf.join(e6e.homedir(),T_o())}function k5t(e){let t=f_o();return e?kf.join(t,"profiles",e):t}function s6e(){try{return eTe(process.env.PI_PROFILE)}catch{return}}function m_o(e){return kf.join(k5t(e),"agent")}function g_o(e,t){return e!==void 0&&t===m_o(e)}function h_o(e){if(process.platform!=="darwin"||!e.startsWith("/private/"))return e;let t=e.slice(8);try{if(Am.realpathSync(e)===Am.realpathSync(t))return t}catch{}return e}function T_o(){return process.env.PI_CONFIG_DIR||l_o}class Jhe{configRoot;agentDir;#e;#t;#n=new Map;#s=new Map;constructor(e={}){let t=eTe(e.profile);this.configRoot=k5t(t);let n=kf.join(this.configRoot,"agent"),s=t?void 0:e.agentDirOverride;this.agentDir=s?kf.resolve(s):n;let o=this.agentDir===n,r,i,a;if((process.platform==="linux"||process.platform==="darwin")&&o){let l=(u)=>{let p=process.env[u];if(!p)return;try{let c=kf.join(p,Qhe);if(t){let d=kf.join(c,"profiles",t);if(Am.existsSync(d))return d;return}if(Am.existsSync(c))return c}catch{}return};r=l("XDG_DATA_HOME"),i=l("XDG_STATE_HOME"),a=l("XDG_CACHE_HOME")}this.#e={data:r??this.configRoot,state:i??this.configRoot,cache:a??this.configRoot},this.#t={data:r??this.agentDir,state:i??this.agentDir,cache:a??this.agentDir}}rootSubdir(e,t){let n=this.#n.get(e);if(n)return n;let s=t?this.#e[t]:this.configRoot,o=kf.join(s,e);return this.#n.set(e,o),o}agentSubdir(e,t,n){if(!e||e===this.agentDir){let s=this.#s.get(t);if(s)return s;let o=n?this.#t[n]:this.agentDir,r=kf.join(o,t);return this.#s.set(t,r),r}return kf.join(e,t)}}function o6e(e,t,n=e){return g_o(e??n,t)?void 0:t}function R_o(){return FS?void 0:o6e(void 0,process.env.PI_CODING_AGENT_DIR,s6e())}function r6e(e){let t=eTe(e);if(t&&!FS)Xhe=o6e(void 0,process.env.PI_CODING_AGENT_DIR,s6e());if(FS=t,FS)ZVe=new Jhe({profile:FS}),process.env.OMT_PROFILE=FS,process.env.PI_PROFILE=FS,process.env.PI_CODING_AGENT_DIR=ZVe.agentDir;else{for(let n of u_o)delete process.env[n];if(Xhe===void 0)delete process.env.PI_CODING_AGENT_DIR;else process.env.PI_CODING_AGENT_DIR=Xhe;ZVe=new Jhe({agentDirOverride:Xhe})}}function A5t(){return FS}var Qhe="omt",l_o=".omt",Zhe,chl,t6e,E5t,u_o,p_o,dhl,FS,ZVe,Xhe,fhl;var I5t=w(()=>{QVe();Zhe=Yhe,chl=`omt/${Zhe}`,t6e=Khe.bun.replace(/[^0-9.]/g,""),E5t=/^[a-z0-9][a-z0-9._-]{0,63}$/,u_o=["OMT_PROFILE","PI_PROFILE"],p_o=/^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\..*)?$/i;dhl=h_o(process.cwd());FS=d_o();ZVe=new Jhe({agentDirOverride:R_o(),profile:FS}),Xhe=o6e(FS,process.env.PI_CODING_AGENT_DIR,FS??s6e()),fhl=e6e.homedir()});import*as $r from"node:fs";import*as GQ from"node:os";import*as Fn from"node:path";function _3(e){let t=e?.trim();if(!t||t==="default")return;if(t==="."||t===".."||t.endsWith(".")||!x5t.test(t)||y_o.test(t))throw Error(`Invalid OMP profile "${e}". Profile names must match ${x5t.source}, cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`);return t}function C_o(e,t){return _3(e!==void 0?e:t)}function S_o(){return C_o(process.env.OMT_PROFILE,process.env.PI_PROFILE)}function b_o(){try{return S_o()}catch{return}}function l6e(){return Fn.join(GQ.homedir(),LS())}function u6e(e){let t=l6e();return e?Fn.join(t,"profiles",e):t}function v5t(){try{return _3(process.env.PI_PROFILE)}catch{return}}function w_o(e){return Fn.join(u6e(e),"agent")}function E_o(e,t){return e!==void 0&&t===w_o(e)}function O5t(e){if(process.platform!=="darwin"||!e.startsWith("/private/"))return e;let t=e.slice(8);try{if($r.realpathSync(e)===$r.realpathSync(t))return t}catch{}return e}function $Q(e){let t=Fn.resolve(e);try{return $r.realpathSync(t)}catch{return t}}function iy(e){let t=$Q(e);return process.platform==="win32"?t.toLowerCase():t}function DS(e,t){let n=iy(e),s=iy(t),o=Fn.relative(n,s);return o===""||!o.startsWith("..")&&!Fn.isAbsolute(o)}function D3(e,t){if(!DS(e,t))return null;let n=iy(e),s=iy(t);return Fn.relative(n,s)||null}function Ue(){return i6e}function HE(e){i6e=O5t(Fn.resolve(e)),process.chdir(i6e)}async function qE(e){try{return(await $r.promises.stat(e)).isDirectory()}catch{return!1}}function LS(){return process.env.PI_CONFIG_DIR||_S}function P5t(){let e=Wx();return e?Fn.join(LS(),"profiles",e,"agent"):`${LS()}/agent`}class p6e{configRoot;agentDir;#e;#t;#n=new Map;#s=new Map;constructor(e={}){let t=_3(e.profile);this.configRoot=u6e(t);let n=Fn.join(this.configRoot,"agent"),s=t?void 0:e.agentDirOverride;this.agentDir=s?Fn.resolve(s):n;let o=this.agentDir===n,r,i,a;if((process.platform==="linux"||process.platform==="darwin")&&o){let l=(u)=>{let p=process.env[u];if(!p)return;try{let c=Fn.join(p,pt);if(t){let d=Fn.join(c,"profiles",t);if($r.existsSync(d))return d;return}if($r.existsSync(c))return c}catch{}return};r=l("XDG_DATA_HOME"),i=l("XDG_STATE_HOME"),a=l("XDG_CACHE_HOME")}this.#e={data:r??this.configRoot,state:i??this.configRoot,cache:a??this.configRoot},this.#t={data:r??this.agentDir,state:i??this.agentDir,cache:a??this.agentDir}}rootSubdir(e,t){let n=this.#n.get(e);if(n)return n;let s=t?this.#e[t]:this.configRoot,o=Fn.join(s,e);return this.#n.set(e,o),o}agentSubdir(e,t,n){if(!e||e===this.agentDir){let s=this.#s.get(t);if(s)return s;let o=n?this.#t[n]:this.agentDir,r=Fn.join(o,t);return this.#s.set(t,r),r}return Fn.join(e,t)}}function N5t(e,t,n=e){return E_o(e??n,t)?void 0:t}function F5t(){return L3?void 0:N5t(void 0,process.env.PI_CODING_AGENT_DIR,v5t())}function L5t(){qs=new p6e({agentDirOverride:F5t(),profile:L3})}function ay(){return qs.configRoot}function Wx(){return L3}function _5t(e){return u6e(_3(e))}function Jt(){return qs.agentDir}function tTe(e=Ue()){return Fn.join(e,_S)}function D5t(){return qs.rootSubdir("reports","state")}function I0(){return qs.rootSubdir("logs","state")}function H3(e=new Date,t=process.pid){return Fn.join(I0(),`${pt}.${e.toISOString().slice(0,10)}.${t}.log`)}function Da(e){if(e!==void 0&&e!==k_o)return Fn.join(e,LS(),"plugins");return qs.rootSubdir("plugins","data")}function HS(e){return Fn.join(Da(e),"node_modules")}function zH(e){return Fn.join(Da(e),"package.json")}function nTe(e){return Fn.join(Da(e),"omt-plugins.lock.json")}function sTe(){return qs.rootSubdir("remote","data")}function H5t(e){let t=e?.trim();if(!t)return;let n=t;if(n==="~")n=GQ.homedir();else if(n.startsWith("~/")||n.startsWith("~\\"))n=GQ.homedir()+n.slice(1);return Fn.isAbsolute(n)?Fn.normalize(n):void 0}function c6e(e){return a6e=H5t(e),a6e}function oTe(){return H5t(process.env.OMT_WORKTREE_DIR)??a6e??qs.rootSubdir("wt","data")}function q5t(){return qs.rootSubdir("ssh-control","state")}function U5t(){return qs.rootSubdir("remote-host","data")}function rTe(){return qs.rootSubdir("python-env","data")}function q3(){return qs.rootSubdir("puppeteer","cache")}function B5t(){return qs.rootSubdir("browser-relay","data")}function W5t(){return qs.rootSubdir("webcache","cache")}function G5t(){return qs.rootSubdir("autoqa.db","data")}function $5t(e){return Bun.hash(Fn.resolve(e)).toString(16).padStart(16,"0").slice(-7)}function iTe(e){return Fn.join(oTe(),e)}function d6e(){return qs.rootSubdir("gpu_cache.json","cache")}function f6e(){let e=process.env.OMT_GITHUB_CACHE_DB;if(e)return e;return qs.rootSubdir(Fn.join("cache","github-cache.db"),"cache")}function j5t(){return qs.rootSubdir(Fn.join("cache","legacy-pi-extension-cache.db"),"cache")}function z5t(){let e=process.env.OMT_AUTH_BROKER_SNAPSHOT_CACHE;if(e)return e;return qs.rootSubdir(Fn.join("cache","auth-broker-snapshot.enc"),"cache")}function jQ(){return qs.rootSubdir(Fn.join("cache","fastembed"),"cache")}function V5t(){return qs.rootSubdir(Fn.join("cache","fastembed-runtime"),"cache")}function ly(){return qs.rootSubdir("stats.db","data")}function Y5t(){return qs.rootSubdir("autoresearch","state")}function K5t(e){return Fn.join(Y5t(),e)}function X5t(e){return Fn.join(Y5t(),`${e}.db`)}function A_o(){return qs.rootSubdir("security","state")}function J5t(e){return Fn.join(A_o(),e)}function Wo(e){return qs.agentSubdir(e,"agent.db","data")}function zQ(e){return qs.agentSubdir(e,"last-changelog-version","state")}function VH(e){return qs.agentSubdir(e,"history.db","data")}function U3(e){return qs.agentSubdir(e,"models.db","data")}function wd(e){return qs.agentSubdir(e,Fn.join("cache","tiny-models"),"cache")}function m6e(e){return qs.agentSubdir(e,Fn.join("cache","document-conversions"),"cache")}function Im(e){return qs.agentSubdir(e,"sessions","data")}function dT(e){return qs.agentSubdir(e,"blobs","data")}function x0(e){return qs.agentSubdir(e,"themes")}function Q5t(e){return qs.agentSubdir(e,"tools")}function Z5t(e){return qs.agentSubdir(e,"prompts")}function aTe(e){return qs.agentSubdir(e,"memories","state")}function g6e(e){return qs.agentSubdir(e,"terminal-sessions","state")}function ezt(e){return qs.agentSubdir(e,`${pt}-debug.log`,"state")}function tzt(e,t){if(t===e)return;try{if($r.existsSync(t)||!$r.existsSync(e))return;$r.mkdirSync(Fn.dirname(t),{recursive:!0}),$r.copyFileSync(e,t,$r.constants.COPYFILE_EXCL)}catch{}}function lTe(){let e=qs.agentSubdir(void 0,"secret-placeholder.key","state");return tzt(Fn.join(qs.agentDir,"secret-placeholder.key"),e),e}function uTe(){return qs.rootSubdir(Fn.join("run","daemons"),"state")}function Ll(e){let t=Bun.hash.wyhash(Fn.resolve(e)).toString(16).padStart(16,"0");return Fn.join(uTe(),t)}function pTe(){return Fn.join(l6e(),"run","daemons","global")}function B3(e){if(!/^[a-z0-9][a-z0-9._-]*$/i.test(e))throw Error(`Invalid global daemon service name: ${JSON.stringify(e)}`);return Fn.join(pTe(),e)}function nzt(){return qs.rootSubdir(Fn.join("run","provider-inflight"),"state")}function fT(){let e=qs.rootSubdir("marketplaces.json","data");return tzt(Fn.join(qs.configRoot,"marketplaces.json"),e),e}function szt(e=Ue()){return Fn.join(tTe(e),"prompts")}function ozt(e=Ue()){return Fn.join(tTe(e),"plugin-overrides.json")}function Jo(e,t=Ue()){if(e==="user")return Fn.join(Jt(),"mcp.json");return Fn.join(tTe(t),"mcp.json")}function Uc(e,t=Ue()){if(e==="user")return Fn.join(Jt(),"ssh.json");return Fn.join(tTe(t),"ssh.json")}function UE(){if(WQ)return WQ;let e=Fn.join(l6e(),I_o),t=!1;try{let s=$r.readFileSync(e,"utf8").trim();if(M5t.test(s))return WQ=s,s;t=s.length>0}catch{}let n=crypto.randomUUID();try{if($r.mkdirSync(Fn.dirname(e),{recursive:!0}),t)try{$r.unlinkSync(e)}catch{}let s=$r.openSync(e,$r.constants.O_WRONLY|$r.constants.O_CREAT|$r.constants.O_EXCL,384);try{$r.writeSync(s,`${n}
|
|
858
|
+
`)},json:async()=>JSON.parse(await Bun.stdin.text())},stringWidth:c5t,plugin:()=>{},stripANSI:VVe,subprocess:void 0,Transpiler:class{constructor(){zVe("Bun.Transpiler")}},version:process.version.replace(/^v/,""),which:QLo,write:o_o,zstdCompressSync:(e)=>DQ.zstdCompressSync(Buffer.from(e)),zstdDecompressSync:(e)=>DQ.zstdDecompressSync(Buffer.from(e)),zstdDecompress:(e)=>Promise.resolve(DQ.zstdDecompressSync(Buffer.from(e)))};Object.defineProperty(C5t,"build",{get(){return()=>zVe("Bun.build")}});Mo={parse:(e)=>s5t().parse(e),stringify:(e,t,n)=>s5t().stringify(e,{indent:typeof n==="number"?n:2})};Ux={parse:(e)=>JSON.parse(a_o(e))},S5t={parse:(e)=>WLo().parse(e)},Qs=h5t,u5t=globalThis;if(typeof u5t.Bun>"u")u5t.Bun=C5t});var b5t=w(()=>{Xo()});var Yhe="18.0.4",Khe;var QVe=w(()=>{Khe={bun:">=1.3.14",node:">=24.0.0"}});import*as Am from"node:fs";import*as e6e from"node:os";import*as kf from"node:path";function eTe(e){let t=e?.trim();if(!t||t==="default")return;if(t==="."||t===".."||t.endsWith(".")||!E5t.test(t)||p_o.test(t))throw Error(`Invalid OMP profile "${e}". Profile names must match ${E5t.source}, cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`);return t}function n6e(e,t){return eTe(e!==void 0?e:t)}function c_o(){return n6e(process.env.OMT_PROFILE,process.env.PI_PROFILE)}function d_o(){try{return c_o()}catch{return}}function f_o(){return kf.join(e6e.homedir(),T_o())}function k5t(e){let t=f_o();return e?kf.join(t,"profiles",e):t}function s6e(){try{return eTe(process.env.PI_PROFILE)}catch{return}}function m_o(e){return kf.join(k5t(e),"agent")}function g_o(e,t){return e!==void 0&&t===m_o(e)}function h_o(e){if(process.platform!=="darwin"||!e.startsWith("/private/"))return e;let t=e.slice(8);try{if(Am.realpathSync(e)===Am.realpathSync(t))return t}catch{}return e}function T_o(){return process.env.PI_CONFIG_DIR||l_o}class Jhe{configRoot;agentDir;#e;#t;#n=new Map;#s=new Map;constructor(e={}){let t=eTe(e.profile);this.configRoot=k5t(t);let n=kf.join(this.configRoot,"agent"),s=t?void 0:e.agentDirOverride;this.agentDir=s?kf.resolve(s):n;let o=this.agentDir===n,r,i,a;if((process.platform==="linux"||process.platform==="darwin")&&o){let l=(u)=>{let p=process.env[u];if(!p)return;try{let c=kf.join(p,Qhe);if(t){let d=kf.join(c,"profiles",t);if(Am.existsSync(d))return d;return}if(Am.existsSync(c))return c}catch{}return};r=l("XDG_DATA_HOME"),i=l("XDG_STATE_HOME"),a=l("XDG_CACHE_HOME")}this.#e={data:r??this.configRoot,state:i??this.configRoot,cache:a??this.configRoot},this.#t={data:r??this.agentDir,state:i??this.agentDir,cache:a??this.agentDir}}rootSubdir(e,t){let n=this.#n.get(e);if(n)return n;let s=t?this.#e[t]:this.configRoot,o=kf.join(s,e);return this.#n.set(e,o),o}agentSubdir(e,t,n){if(!e||e===this.agentDir){let s=this.#s.get(t);if(s)return s;let o=n?this.#t[n]:this.agentDir,r=kf.join(o,t);return this.#s.set(t,r),r}return kf.join(e,t)}}function o6e(e,t,n=e){return g_o(e??n,t)?void 0:t}function R_o(){return FS?void 0:o6e(void 0,process.env.PI_CODING_AGENT_DIR,s6e())}function r6e(e){let t=eTe(e);if(t&&!FS)Xhe=o6e(void 0,process.env.PI_CODING_AGENT_DIR,s6e());if(FS=t,FS)ZVe=new Jhe({profile:FS}),process.env.OMT_PROFILE=FS,process.env.PI_PROFILE=FS,process.env.PI_CODING_AGENT_DIR=ZVe.agentDir;else{for(let n of u_o)delete process.env[n];if(Xhe===void 0)delete process.env.PI_CODING_AGENT_DIR;else process.env.PI_CODING_AGENT_DIR=Xhe;ZVe=new Jhe({agentDirOverride:Xhe})}}function A5t(){return FS}var Qhe="omt",l_o=".omt",Zhe,chl,t6e,E5t,u_o,p_o,dhl,FS,ZVe,Xhe,fhl;var I5t=w(()=>{QVe();Zhe=Yhe,chl=`omt/${Zhe}`,t6e=Khe.bun.replace(/[^0-9.]/g,""),E5t=/^[a-z0-9][a-z0-9._-]{0,63}$/,u_o=["OMT_PROFILE","PI_PROFILE"],p_o=/^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\..*)?$/i;dhl=h_o(process.cwd());FS=d_o();ZVe=new Jhe({agentDirOverride:R_o(),profile:FS}),Xhe=o6e(FS,process.env.PI_CODING_AGENT_DIR,FS??s6e()),fhl=e6e.homedir()});import*as $r from"node:fs";import*as GQ from"node:os";import*as Fn from"node:path";function _3(e){let t=e?.trim();if(!t||t==="default")return;if(t==="."||t===".."||t.endsWith(".")||!x5t.test(t)||y_o.test(t))throw Error(`Invalid OMP profile "${e}". Profile names must match ${x5t.source}, cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`);return t}function C_o(e,t){return _3(e!==void 0?e:t)}function S_o(){return C_o(process.env.OMT_PROFILE,process.env.PI_PROFILE)}function b_o(){try{return S_o()}catch{return}}function l6e(){return Fn.join(GQ.homedir(),LS())}function u6e(e){let t=l6e();return e?Fn.join(t,"profiles",e):t}function v5t(){try{return _3(process.env.PI_PROFILE)}catch{return}}function w_o(e){return Fn.join(u6e(e),"agent")}function E_o(e,t){return e!==void 0&&t===w_o(e)}function O5t(e){if(process.platform!=="darwin"||!e.startsWith("/private/"))return e;let t=e.slice(8);try{if($r.realpathSync(e)===$r.realpathSync(t))return t}catch{}return e}function $Q(e){let t=Fn.resolve(e);try{return $r.realpathSync(t)}catch{return t}}function iy(e){let t=$Q(e);return process.platform==="win32"?t.toLowerCase():t}function DS(e,t){let n=iy(e),s=iy(t),o=Fn.relative(n,s);return o===""||!o.startsWith("..")&&!Fn.isAbsolute(o)}function D3(e,t){if(!DS(e,t))return null;let n=iy(e),s=iy(t);return Fn.relative(n,s)||null}function Ue(){return i6e}function HE(e){i6e=O5t(Fn.resolve(e)),process.chdir(i6e)}async function qE(e){try{return(await $r.promises.stat(e)).isDirectory()}catch{return!1}}function LS(){return process.env.PI_CONFIG_DIR||_S}function P5t(){let e=Wx();return e?Fn.join(LS(),"profiles",e,"agent"):`${LS()}/agent`}class p6e{configRoot;agentDir;#e;#t;#n=new Map;#s=new Map;constructor(e={}){let t=_3(e.profile);this.configRoot=u6e(t);let n=Fn.join(this.configRoot,"agent"),s=t?void 0:e.agentDirOverride;this.agentDir=s?Fn.resolve(s):n;let o=this.agentDir===n,r,i,a;if((process.platform==="linux"||process.platform==="darwin")&&o){let l=(u)=>{let p=process.env[u];if(!p)return;try{let c=Fn.join(p,pt);if(t){let d=Fn.join(c,"profiles",t);if($r.existsSync(d))return d;return}if($r.existsSync(c))return c}catch{}return};r=l("XDG_DATA_HOME"),i=l("XDG_STATE_HOME"),a=l("XDG_CACHE_HOME")}this.#e={data:r??this.configRoot,state:i??this.configRoot,cache:a??this.configRoot},this.#t={data:r??this.agentDir,state:i??this.agentDir,cache:a??this.agentDir}}rootSubdir(e,t){let n=this.#n.get(e);if(n)return n;let s=t?this.#e[t]:this.configRoot,o=Fn.join(s,e);return this.#n.set(e,o),o}agentSubdir(e,t,n){if(!e||e===this.agentDir){let s=this.#s.get(t);if(s)return s;let o=n?this.#t[n]:this.agentDir,r=Fn.join(o,t);return this.#s.set(t,r),r}return Fn.join(e,t)}}function N5t(e,t,n=e){return E_o(e??n,t)?void 0:t}function F5t(){return L3?void 0:N5t(void 0,process.env.PI_CODING_AGENT_DIR,v5t())}function L5t(){qs=new p6e({agentDirOverride:F5t(),profile:L3})}function ay(){return qs.configRoot}function Wx(){return L3}function _5t(e){return u6e(_3(e))}function Jt(){return qs.agentDir}function tTe(e=Ue()){return Fn.join(e,_S)}function D5t(){return qs.rootSubdir("reports","state")}function I0(){return qs.rootSubdir("logs","state")}function H3(e=new Date,t=process.pid){return Fn.join(I0(),`${pt}.${e.toISOString().slice(0,10)}.${t}.log`)}function Da(e){if(e!==void 0&&e!==k_o)return Fn.join(e,LS(),"plugins");return qs.rootSubdir("plugins","data")}function HS(e){return Fn.join(Da(e),"node_modules")}function zH(e){return Fn.join(Da(e),"package.json")}function nTe(e){return Fn.join(Da(e),"omt-plugins.lock.json")}function sTe(){return qs.rootSubdir("remote","data")}function H5t(e){let t=e?.trim();if(!t)return;let n=t;if(n==="~")n=GQ.homedir();else if(n.startsWith("~/")||n.startsWith("~\\"))n=GQ.homedir()+n.slice(1);return Fn.isAbsolute(n)?Fn.normalize(n):void 0}function c6e(e){return a6e=H5t(e),a6e}function oTe(){return H5t(process.env.OMT_WORKTREE_DIR)??a6e??qs.rootSubdir("wt","data")}function q5t(){return qs.rootSubdir("ssh-control","state")}function U5t(){return qs.rootSubdir("remote-host","data")}function rTe(){return qs.rootSubdir("python-env","data")}function q3(){return qs.rootSubdir("puppeteer","cache")}function B5t(){return qs.rootSubdir("browser-relay","data")}function W5t(){return qs.rootSubdir("webcache","cache")}function G5t(){return qs.rootSubdir("autoqa.db","data")}function $5t(e){return Bun.hash(Fn.resolve(e)).toString(16).padStart(16,"0").slice(-7)}function iTe(e){return Fn.join(oTe(),e)}function d6e(){return qs.rootSubdir("gpu_cache.json","cache")}function f6e(){let e=process.env.OMT_GITHUB_CACHE_DB;if(e)return e;return qs.rootSubdir(Fn.join("cache","github-cache.db"),"cache")}function j5t(){return qs.rootSubdir(Fn.join("cache","legacy-pi-extension-cache.db"),"cache")}function z5t(){let e=process.env.OMT_AUTH_BROKER_SNAPSHOT_CACHE;if(e)return e;return qs.rootSubdir(Fn.join("cache","auth-broker-snapshot.enc"),"cache")}function jQ(){return qs.rootSubdir(Fn.join("cache","fastembed"),"cache")}function V5t(){return qs.rootSubdir(Fn.join("cache","fastembed-runtime"),"cache")}function ly(){return qs.rootSubdir("stats.db","data")}function Y5t(){return qs.rootSubdir("autoresearch","state")}function K5t(e){return Fn.join(Y5t(),e)}function X5t(e){return Fn.join(Y5t(),`${e}.db`)}function A_o(){return qs.rootSubdir("security","state")}function J5t(e){return Fn.join(A_o(),e)}function Wo(e){return qs.agentSubdir(e,"agent.db","data")}function zQ(e){return qs.agentSubdir(e,"last-changelog-version","state")}function VH(e){return qs.agentSubdir(e,"history.db","data")}function U3(e){return qs.agentSubdir(e,"models.db","data")}function wd(e){return qs.agentSubdir(e,Fn.join("cache","tiny-models"),"cache")}function m6e(e){return qs.agentSubdir(e,Fn.join("cache","document-conversions"),"cache")}function Im(e){return qs.agentSubdir(e,"sessions","data")}function dT(e){return qs.agentSubdir(e,"blobs","data")}function x0(e){return qs.agentSubdir(e,"themes")}function Q5t(e){return qs.agentSubdir(e,"tools")}function Z5t(e){return qs.agentSubdir(e,"prompts")}function aTe(e){return qs.agentSubdir(e,"memories","state")}function g6e(e){return qs.agentSubdir(e,"terminal-sessions","state")}function ezt(e){return qs.agentSubdir(e,`${pt}-debug.log`,"state")}function tzt(e,t){if(t===e)return;try{if($r.existsSync(t)||!$r.existsSync(e))return;$r.mkdirSync(Fn.dirname(t),{recursive:!0}),$r.copyFileSync(e,t,$r.constants.COPYFILE_EXCL)}catch{}}function lTe(){let e=qs.agentSubdir(void 0,"secret-placeholder.key","state");return tzt(Fn.join(qs.agentDir,"secret-placeholder.key"),e),e}function uTe(){return qs.rootSubdir(Fn.join("run","daemons"),"state")}function Ll(e){let t=Bun.hash.wyhash(Fn.resolve(e)).toString(16).padStart(16,"0");return Fn.join(uTe(),t)}function pTe(){return Fn.join(l6e(),"run","daemons","global")}function B3(e){if(!/^[a-z0-9][a-z0-9._-]*$/i.test(e))throw Error(`Invalid global daemon service name: ${JSON.stringify(e)}`);return Fn.join(pTe(),e)}function nzt(){return qs.rootSubdir(Fn.join("run","provider-inflight"),"state")}function fT(){let e=qs.rootSubdir("marketplaces.json","data");return tzt(Fn.join(qs.configRoot,"marketplaces.json"),e),e}function szt(e=Ue()){return Fn.join(tTe(e),"prompts")}function ozt(e=Ue()){return Fn.join(tTe(e),"plugin-overrides.json")}function Jo(e,t=Ue()){if(e==="user")return Fn.join(Jt(),"mcp.json");return Fn.join(tTe(t),"mcp.json")}function Uc(e,t=Ue()){if(e==="user")return Fn.join(Jt(),"ssh.json");return Fn.join(tTe(t),"ssh.json")}function UE(){if(WQ)return WQ;let e=Fn.join(l6e(),I_o),t=!1;try{let s=$r.readFileSync(e,"utf8").trim();if(M5t.test(s))return WQ=s,s;t=s.length>0}catch{}let n=crypto.randomUUID();try{if($r.mkdirSync(Fn.dirname(e),{recursive:!0}),t)try{$r.unlinkSync(e)}catch{}let s=$r.openSync(e,$r.constants.O_WRONLY|$r.constants.O_CREAT|$r.constants.O_EXCL,384);try{$r.writeSync(s,`${n}
|
|
859
859
|
`)}finally{$r.closeSync(s)}}catch(s){if(s.code==="EEXIST")try{let o=$r.readFileSync(e,"utf8").trim();if(M5t.test(o))return WQ=o,o}catch{}}return WQ=n,n}var pt="omt",_S=".omt",Bx,mi,Zs,hhl,x5t,y_o,i6e,L3,qs,Thl,k_o,a6e,WQ=null,I_o="install-id",M5t;var Bc=w(()=>{QVe();Bx=["config.yml","config.yaml"],mi=Yhe,Zs=`omt/${mi}`,hhl=Khe.bun.replace(/[^0-9.]/g,""),x5t=/^[a-z0-9][a-z0-9._-]{0,63}$/,y_o=/^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\..*)?$/i;i6e=O5t(process.cwd());L3=b_o();qs=new p6e({agentDirOverride:F5t(),profile:L3}),Thl=N5t(L3,process.env.PI_CODING_AGENT_DIR,L3??v5t()),k_o=GQ.homedir();M5t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});import*as rzt from"node:crypto";import*as Wg from"node:fs";import*as izt from"node:os";import*as azt from"node:path";function x_o(e){if(e===null||typeof e!=="object")return!1;let t=e;return typeof t.date==="number"&&typeof t.name==="string"&&typeof t.hash==="string"}class h6e{#e;#t;#n;#s;#o;#r;#a;#i;#l=0;#u;#p=0;#c=!1;constructor(e){this.#e=e.directory,this.#t=e.filenamePrefix,this.#n=e.filenameSuffix,this.#s=e.auditFile,this.#o=e.maxBytes,this.#r=e.maxFiles,this.#a=this.#h();let t=new Date;this.#f(this.#d(t));let n=this.#u;if(n)this.#g(n,t.getTime()),Wg.closeSync(Wg.openSync(n,"a"))}write(e){if(this.#c)return;let t=new Date;this.#f(this.#d(t));let n=this.#u;if(!n)return;this.#g(n,t.getTime());let s=`${e}${izt.EOL}`;Wg.appendFileSync(n,s,"utf8"),this.#p+=Buffer.byteLength(s)}close(){this.#c=!0}#d(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}#f(e){if(e!==this.#i)this.#i=e,this.#l=0,this.#m(e,0);while(this.#p>this.#o)this.#l++,this.#m(e,this.#l)}#m(e,t){let n=t===0?"":`.${t}`;this.#u=azt.join(this.#e,`${this.#t}.${e}.${this.#n}.log${n}`);try{this.#p=Wg.statSync(this.#u).size}catch{this.#p=0}}#g(e,t){if(this.#a.some((s)=>s.name===e))return;let n=rzt.createHash("sha256").update(`${e}LOG_FILE${t}`).digest("hex");this.#a.push({date:t,name:e,hash:n});while(this.#a.length>this.#r){let s=this.#a.shift();if(!s)break;try{Wg.rmSync(s.name,{force:!0})}catch{}}this.#T()}#h(){try{let e=JSON.parse(Wg.readFileSync(this.#s,"utf8"));return Array.isArray(e.files)?e.files.filter(x_o):[]}catch{return[]}}#T(){let e={keep:{days:!1,amount:this.#r},auditLog:this.#s,files:this.#a,hashType:"sha256"};Wg.writeFileSync(this.#s,JSON.stringify(e,void 0,4),"utf8")}}var lzt=()=>{};function pzt(){let e=globalThis,t=e[uzt];if(!t||t.length===0)return[];return e[uzt]=[],t}var uzt;var czt=w(()=>{uzt=Symbol.for("omt.moduleLoadBuffer")});var I={};Ve(I,{debug:()=>ba,endTiming:()=>J_o,error:()=>qS,info:()=>j_o,openSpanPath:()=>Q_o,printTimings:()=>V_o,recordModuleLoadSpan:()=>Tzt,registerLogSink:()=>O_o,setTransports:()=>S6e,shouldExitAfterTimings:()=>z_o,startTiming:()=>Y_o,startupMarker:()=>cTe,time:()=>sDo,timingModeIncludes:()=>mTe,warn:()=>vo});import{AsyncLocalStorage as M_o}from"node:async_hooks";import*as xm from"node:fs";import*as mzt from"node:os";import*as C6e from"node:path";import{isPromise as v_o}from"node:util/types";function O_o(e){return fTe.add(e),()=>{fTe.delete(e)}}function gTe(e,t,n){if(fTe.size===0)return;let s={level:e,message:t,context:n,timestamp:new Date};for(let o of fTe)try{o(s)}catch{}}function __o(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&(t.code==="ESRCH"||t.code==="EINVAL"))}}function D_o(e){let t;try{t=xm.readdirSync(e,{withFileTypes:!0})}catch{return}let n=new Date,s=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-`+String(n.getDate()).padStart(2,"0"),o=new Date(n);o.setDate(o.getDate()-(L_o-1));let r=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}-`+String(o.getDate()).padStart(2,"0"),i=new Map;for(let a of t){if(!a.isFile())continue;let l=P_o.exec(a.name),u=N_o.exec(a.name),p=l?.[2]??u?.[1];if(!p||__o(Number(p)))continue;let c=C6e.join(e,a.name);if(u){if(F_o===0)try{xm.rmSync(c,{force:!0})}catch{}continue}if(!l?.[1])continue;if(l[1]<r||l[1]>s){try{xm.rmSync(c,{force:!0})}catch{}continue}let d=`${p}:${l[1]}`,f=i.get(d)??[];f.push({path:c,rollover:Number(l[3]??0)}),i.set(d,f)}for(let a of i.values()){if(a.length<=dzt)continue;let l=[];for(let u of a)try{l.push({...u,mtimeMs:xm.statSync(u.path).mtimeMs})}catch{}l.sort((u,p)=>p.mtimeMs-u.mtimeMs||p.rollover-u.rollover||(u.path<p.path?-1:u.path>p.path?1:0));for(let u of l.slice(dzt))try{xm.rmSync(u.path,{force:!0})}catch{}}}function H_o(e){if(!xm.existsSync(e))xm.mkdirSync(e,{recursive:!0});return e}function q_o(e,t){if(t instanceof Error){let n={name:t.name,message:t.message,stack:t.stack},s=t;for(let o in s)n[o]=s[o];if(t.cause!==void 0)n.cause=t.cause;return n}return t}function Gx(e,t=2){return String(e).padStart(t,"0")}function U_o(e){let t=-e.getTimezoneOffset(),n=Math.abs(t),s=t>=0?"+":"-";return`${Gx(e.getFullYear(),4)}-${Gx(e.getMonth()+1)}-${Gx(e.getDate())}T${Gx(e.getHours())}:${Gx(e.getMinutes())}:${Gx(e.getSeconds())}.${Gx(e.getMilliseconds(),3)}${s}${Gx(Math.floor(n/60))}:${Gx(n%60)}`}function W_o(e,t,n){let s=!B_o.test(t)&&n!==null&&typeof n==="object"?n:void 0,o=Object.assign({},s,{level:e,message:t});if(s?.message)o.message=`${t} ${s.message}`;if(s?.stack)o.stack=s.stack;if(s?.cause)o.cause=s.cause;return o}function fzt(e){let t=U_o(new Date);e.timestamp=t;let n={timestamp:t,level:e.level,pid:process.pid,message:e.message};for(let[s,o]of Object.entries(e))if(s!=="level"&&s!=="timestamp"&&s!=="message")n[s]=o;return JSON.stringify(n,q_o)}function G_o(e){let t=H_o(e??I0());return D_o(t),new h6e({directory:t,filenamePrefix:"omt",filenameSuffix:String(process.pid),maxBytes:10485760,maxFiles:5,auditFile:C6e.join(t,`.omt.${process.pid}-audit.json`)})}function hzt(e){return{file:e.file?G_o(typeof e.file==="string"?e.file:void 0):void 0,console:e.console===!0}}function $_o(){return W3??=hzt(gzt),W3}function hTe(e,t,n){let s=$_o(),o=W_o(e,t,n);if(!s.file&&!s.console)return;let r=fzt(o);if(s.file)s.file.write(r);if(s.console)xm.writeSync(1,`${fzt(o)}${mzt.EOL}`)}function S6e(e){if(gzt=e,!W3)return;let t=W3;W3={file:void 0,console:!1},t.file?.close(),W3=hzt(e)}function qS(e,t){try{hTe("error",e,t)}catch{}gTe("error",e,t)}function vo(e,t){try{hTe("warn",e,t)}catch{}gTe("warn",e,t)}function j_o(e,t){try{hTe("info",e,t)}catch{}gTe("info",e,t)}function ba(e,t){try{hTe("debug",e,t)}catch{}gTe("debug",e,t)}function cTe(e){if(!process.env.PI_DEBUG_STARTUP)return;try{xm.writeSync(2,`[startup] ${e}
|
|
860
860
|
`)}catch{}}function mTe(e){let t=process.env.PI_TIMING;if(!t)return!1;if(t===e)return!0;let n=0;for(let s=0;s<=t.length;s++){let o=s===t.length?44:t.charCodeAt(s);if(!(o===44||o===58||o===59||o===43||o<=32))continue;if(s>n&&t.slice(n,s)===e)return!0;n=s+1}return!1}function z_o(){return mTe("x")||mTe("full")}function V_o(){if(!G3||!Lu){console.error(`
|
|
861
861
|
--- Startup Timings ---
|
|
@@ -4799,7 +4799,7 @@ ${i.length} entr${i.length===1?"y":"ies"}:
|
|
|
4799
4799
|
|
|
4800
4800
|
${u}
|
|
4801
4801
|
`;return{url:e.url,content:c,contentType:"text/markdown",size:Buffer.byteLength(c,"utf-8"),sourcePath:o,immutable:!0}}async#p(e,t){let{root:n,targetPath:s}=await this.#l(e,t),o=_p.dirname(s);try{let l=await Xu.promises.realpath(o);TC(l,n)}catch(l){if(!le(l))throw l}let r;try{r=await Xu.promises.realpath(s)}catch(l){if(le(l))throw Error(`Vault file not found: ${e.url}`);throw l}TC(r,n);let i=await Xu.promises.stat(r);if(i.isDirectory())return this.#u(e,t);if(!i.isFile())throw Error(`vault:// URL must resolve to a file or directory: ${e.url}`);let a=await Bun.file(r).text();return{url:e.url,content:a,contentType:BXr(r),size:Buffer.byteLength(a,"utf-8"),sourcePath:r}}async#c(e,t,n){let{root:s,targetPath:o}=await this.#l(e,n);try{let r=await Xu.promises.realpath(o);if(TC(r,s),(await Xu.promises.stat(r)).isDirectory())throw Error(`vault:// URL must resolve to a file: ${e.url}`)}catch(r){if(!le(r))throw r;let i=_p.dirname(o),a=await sJr(i,s);TC(a,s),await Xu.promises.mkdir(i,{recursive:!0});let l=await Xu.promises.realpath(i);TC(l,s)}await Bun.write(o,t)}async#d(e,t){let n=iJr(e),s=[...this.#r(e.ref),...n.args],o=await this.#n(s,t);return hPe(n.opLabel,o),{url:e.url,content:o.stdout,contentType:n.contentType,size:Buffer.byteLength(o.stdout,"utf-8"),immutable:!0}}}var Lmt="/Applications/Obsidian.app/Contents/MacOS/obsidian",i$n=30000,qXr,UXr,YA,TPe,VA,SY,Fmt,XXr="vault:// is disabled. Enable it by setting `vault.enabled = true` (Settings → Tools → Obsidian Vault).",yPe;var SPe=w(()=>{B();zt();wh();VF();AA();TB();qXr={outline:!0,backlinks:!0,links:!0,tags:!0,properties:!0,tasks:!0,wordcount:!0,history:!0,base:!0},UXr={search:!0,daily:!0,"daily-path":!0,tags:!0,tag:!0,tasks:!0,orphans:!0,unresolved:!0,deadends:!0,bases:!0,bookmarks:!0,recents:!0,templates:!0,aliases:!0,properties:!0,property:!0},Fmt=new Map;yPe=class yPe extends Error{constructor(){super(XXr);this.name="VaultDisabledError"}}});function dw(e){let t=e.trim();if(!t.toLowerCase().startsWith("xd://"))return null;let n=t.slice(5);if(n.length===0)return{name:null};if(/[/?#]/.test(n))return null;return{name:n}}function f$n(e){if(e.length<=5)return"xd://".startsWith(e.toLowerCase());return e.toLowerCase().startsWith("xd://")}class Hmt{scheme="xd";immutable=!0;async resolve(e,t){let n=dw(e.href);if(!n)throw Error(`Invalid xd:// URL: ${e.href}. Use xd:// or xd://<tool>.`);if(!t?.xd)throw Error("xd:// is not mounted in this session.");let s=await t.xd.read(n.name);return{url:e.href,content:s,contentType:"text/plain",size:Buffer.byteLength(s)}}async write(e,t,n){let s=dw(e.href);if(!s)throw Error(`Invalid xd:// URL: ${e.href}. Use xd://<tool>.`);if(!n?.xd)throw Error("xd:// is not mounted in this session.");await n.xd.write(s.name,t)}}var Zl="xd://";class Bi{static#e;#t=new Map;constructor(){this.register(new mmt),this.register(new Jrt),this.register(new tit),this.register(new fmt),this.register(new oR),this.register(new Dmt),this.register(new Act),this.register(new hmt),this.register(new jie),this.register(new Qct),this.register(new Sct),this.register(new bct),this.register(new Fpt),this.register(new Pmt),this.register(new Hmt)}static instance(){return Bi.#e??=new Bi,Bi.#e}static resetForTests(){Bi.#e=void 0}register(e){this.#t.set(e.scheme.toLowerCase(),e)}unregister(e){return this.#t.delete(e.toLowerCase())}getHandler(e){return this.#t.get(e.toLowerCase())}canHandle(e){let t=e.match(/^([a-z][a-z0-9+.-]*):\/\//i);if(!t)return!1;return this.#t.has(t[1].toLowerCase())}canResolve(e){let t=vMe(e);if(!t)return!1;if(this.#t.has(t))return this.canHandle(e);return this.#n(t)}completionSchemes(){let e=[];for(let[t,n]of this.#t)if(n.complete)e.push(t);return e}async complete(e,t,n){let s=this.#t.get(e.toLowerCase());if(!s?.complete)return null;return s.complete(t,n)}#n(e){return!["file","http","https"].includes(e)&&this.#t.has("mcp")}#s(e,t=!1){let n=Vd(e),s=n.protocol.replace(/:$/,"").toLowerCase(),o=this.#t.get(s)??(t&&this.#n(s)?this.#t.get("mcp"):void 0);if(!o){let r=Array.from(this.#t.keys()).map((i)=>`${i}://`).join(", ");throw Error(`Unknown protocol: ${s}://
|
|
4802
|
-
Supported: ${r||"none"}`)}return{parsed:n,handler:o}}async resolve(e,t){let{parsed:n,handler:s}=this.#s(e,!0),o=await s.resolve(n,t);return{...o,immutable:o.immutable??s.immutable}}async write(e,t,n){let{parsed:s,handler:o}=this.#s(e);if(!o.write){let r=s.protocol.replace(/:$/,"").toLowerCase();throw Error(`${r}:// URLs are read-only for write; use the protocol-specific tool for mutations.`)}await o.write(s,t,n)}}var Qie=w(()=>{Qrt();Hke();Lpt();wct();FMe();Zct();YOe();gmt();AA();Tmt();rPe();TB();Nmt();SPe()});var Cu=w(()=>{Qrt();Hke();Lpt();wct();FMe();Zct();YOe();gmt();AA();Qie();Tmt();rPe();TB();Nmt();SPe()});import*as Zd from"node:fs";import*as w$n from"node:os";import*as Cs from"node:path";import*as E$n from"node:url";import{glob as aJr}from"@ohmytr/natives";function mJr(e){return e.replace(lJr," ")}function gJr(e){return e.replace(/ (AM|PM)\./g,`${fJr}$1.`)}function hJr(e){return e.normalize("NFD")}function T$n(e){return e.replace(/'/g,"’")}function TJr(e){if(!e.includes("\\")||!e.includes("/"))return e;return e.replace(/\\([ \t"'(){}[\]])/g,"$1")}function Zie(e){try{return Zd.accessSync(e,Zd.constants.F_OK),!0}catch{return!1}}function RJr(e){if(!e.startsWith("@"))return e;let t=e.slice(1);if(t.startsWith("/")||t==="~"||t.startsWith("~/")||Cs.win32.isAbsolute(t)||t.startsWith("agent://")||t.startsWith("artifact://")||t.startsWith("skill://")||t.startsWith("rule://")||t.startsWith("security://")||t.startsWith("local:")||t.startsWith("mcp://"))return t;return e}function yJr(e){if(!e.toLowerCase().startsWith("file://"))return e;try{return E$n.fileURLToPath(e)}catch{return e}}function zu(e,t){let n=t??w$n.homedir();if(e==="~")return n;if(e.startsWith("~/")||e.startsWith("~\\"))return n+e.slice(1);if(e.startsWith("~"))return Cs.join(n,e.slice(1));return e}function RC(e){let t=/^:(?=[/\\~]|\.\.?[/\\]|[A-Za-z]:)/.test(e)?e.slice(1):e,n=uy(yJr(mJr(RJr(t))));return zu(n)}function R$n(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function CJr(e){if(!e.startsWith("/"))return;let t=e.split("/");if(t[0]!=="")return;let n,s=2;if(t.length>=2&&R$n(t[1]??""))n=t[1].toUpperCase();else if(t.length>=3&&(t[1]??"").toLowerCase()==="mnt"&&R$n(t[2]??""))n=t[2].toUpperCase(),s=3;if(!n)return;let o=t.slice(s).filter(Boolean).join("\\");return o?`${n}:\\${o}`:`${n}:\\`}function SJr(e,t=process.platform){if(t!=="win32")return e;return CJr(e)??e}function wJr(e){let t=bJr.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);if(n<1)throw new X("Line selector 0 is invalid; lines are 1-indexed. Use :1.");let s=t[2]===".."?"-":t[2],o=t[3]?Number.parseInt(t[3],10):void 0,r;if(s==="+"){if(o===void 0||o<1)throw new X(`Invalid range ${n}+${o??0}: count must be >= 1.`);r=n+o-1}else if(s==="-"){if(o!==void 0){if(o<n)throw new X(`Invalid range ${n}-${o}: end must be >= start.`);r=o}}return{startLine:n,endLine:r}}function Nh(e){let t=e.split(","),n=[];for(let o of t){let r=wJr(o);if(!r)return null;n.push(r)}if(n.length===0)return null;n.sort((o,r)=>o.startLine-r.startLine);let s=[n[0]];for(let o=1;o<n.length;o++){let r=n[o],i=s[s.length-1];if(i.endLine===void 0)continue;if(r.startLine<=i.endLine+1){if(r.endLine===void 0||r.endLine>i.endLine)s[s.length-1]={startLine:i.startLine,endLine:r.endLine};continue}s.push(r)}return s}function EPe(e){if(!e)return;for(let t of e.split(":")){let n=t.toLowerCase();if(n==="raw"||n==="conflicts")continue;let s=Nh(t);if(s)return s}return}function tae(e,t){for(let n of t){if(e<n.startLine)continue;if(n.endLine===void 0||e<=n.endLine)return!0}return!1}function bu(e){let t=e.lastIndexOf(":");if(t<=0)return{path:e};let n=e.slice(t+1);if(!uJr.test(n))return{path:e};let s=e.slice(0,t),o=n,r=s.lastIndexOf(":");if(r>0){let i=s.slice(r+1),a=h$n.test(i),l=h$n.test(n),u=g$n.test(i),p=g$n.test(n);if(a&&p||u&&l)o=`${i}:${n}`,s=s.slice(0,r)}return{path:s,sel:o}}async function JL(e,t){let n=Op(e,t);try{return await Zd.promises.lstat(n),"exists"}catch(s){if(le(s)||tq(s)||la(s,"ENAMETOOLONG"))return"missing";return"unknown"}}async function kPe(e,t){let n=bu(e);if(n.sel===void 0)return n;return await JL(e,t)==="missing"?n:{path:e}}function XB(e){let t=e.match(k$n);if(!t)return{path:e};let n=t[1].toLowerCase();if(dJr.has(n))return{path:e};if(!cJr[n])return{path:e};let s=t[0].length;if(n==="ssh"&&e.indexOf("/",s)===-1)return{path:e};let o=e,r=[];while(!0){let i=o.lastIndexOf(":");if(i<s)break;let a=o.slice(i+1);if(!pJr.test(a))break;r.unshift(a),o=o.slice(0,i)}if(r.length===0)return{path:e};return{path:o,sel:r.join(":")}}function A$n(e){let{path:t,sel:n}=XB(e);if(n===void 0)return e;if(/^(?:raw|conflicts)$/i.test(n))return t;throw new X(`write does not accept the trailing selector ":${n}" — it writes a whole file. `+`Remove ":${n}", or if the filename truly ends with it, percent-encode the ":" as %3A.`)}function EJr(e,t){for(let n of Gmt)if(e.startsWith(n))throw Error(`Path "${t}" uses internal scheme "${n}" and must be resolved through the proper protocol handler, not as a filesystem path.`)}function Kr(e){return e.replace(/^(local:)\/(?!\/)/,"$1//")}function ef(e){let t=Kr(e),n=Kr(RC(t));for(let s of Gmt)if(n.startsWith(s))return!0;return!1}function APe(e){let t=Kr(RC(Kr(e)));if(!Gmt.some((o)=>t.startsWith(o)))return"write";let n=k$n.exec(t)?.[1]?.toLowerCase();return(n?Bi.instance().getHandler(n):void 0)?.write?"write":"read"}function wY(e){return/ssh:\/\//i.test(e)}function $mt(e){return/^ssh:\/\//i.test(e.trim())}function JB(e){return/^https?:\/\/?/i.test(e)||/^www\./i.test(e)}function dn(e,t){let n=Kr(e),s=SJr(RC(n)),o=Kr(s);if(EJr(o,n),/^\/+$/.test(s))return t;if(Cs.isAbsolute(s))return s;return Cs.resolve(t,s)}function I$n(e,t){if(!e||Cs.isAbsolute(e))return null;if(e.startsWith("~")||ef(e))return null;let n=Cs.resolve(t),s=Cs.resolve(n,e);if(!bPe(s,n))return null;let o=qmt(n);if(!o)return null;let r=qmt(s);if(r)return bPe(r,o)?s:null;if(kJr(s))return null;let i=Cs.dirname(s),a=[Cs.basename(s)];for(;;){let l=qmt(i);if(l)return bPe(Cs.join(l,...a.reverse()),o)?s:null;let u=Cs.dirname(i);if(u===i||!bPe(i,n))return null;a.push(Cs.basename(i)),i=u}}function bPe(e,t){let n=Cs.relative(t,e);return!!n&&!n.startsWith("..")&&!Cs.isAbsolute(n)}function qmt(e){try{return Zd.realpathSync.native(e)}catch{return null}}function kJr(e){try{return Zd.lstatSync(e).isSymbolicLink()}catch{return!1}}async function jmt(e,t){let n=Cs.resolve(e);if(t){let r=await y$n(n);if(r!==null)return r;if(!await C$n(n))return null}let s=[Cs.basename(n)],o=Cs.dirname(n);for(;;){let r=await y$n(o);if(r!==null)return Cs.join(r,...s.reverse());if(!await C$n(o))return null;let i=Cs.dirname(o);if(i===o)return null;s.push(Cs.basename(o)),o=i}}async function y$n(e){try{return await Zd.promises.realpath(e)}catch{return null}}async function C$n(e){try{return!(await Zd.promises.lstat(e)).isSymbolicLink()}catch(t){return le(t)}}function Bn(e,t,n={}){let s=Cs.resolve(t),o=Kr(e);if(ef(o))return o;let r=RC(o),i=Cs.isAbsolute(r)?Cs.resolve(r):Cs.resolve(t,r),a=Cs.relative(s,i),l=a===""||!a.startsWith("..")&&!Cs.isAbsolute(a),u=bY(l?a||".":i);if(n.trailingSlash&&u!=="."&&!u.endsWith("/"))u+="/";return u}function zmt(e){return e.startsWith('"')&&e.endsWith('"')&&e.length>1?e.slice(1,-1):e}function Vmt(e){if(ef(e))return e;if(!e.includes("\\"))return e;return e.replace(/\\/g,"/")}function QL(e){return zmt(e.trim())}function AJr(e){let t=e.trim();if(!t.startsWith("[")||!t.endsWith("]"))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!Array.isArray(n)||n.some((s)=>typeof s!=="string"))return null;return n}function dR(e){if(typeof e==="string")return AJr(e)??[e];return e??[]}function fw(e){return IJr.some((t)=>e.includes(t))}function xJr(e,t){if(t==="comma")return e===",";if(t==="semicolon")return e===";";if(t==="whitespace")return Bmt.test(e);return e===","||e===";"||Bmt.test(e)}function MJr(e){let t=0;for(let n=0;n<e.length;n++){let s=e[n];if(s==="\\"&&n+1<e.length){n++;continue}if(s==="{"){t++;continue}if(s==="}"){if(t>0)t--;continue}if(t===0&&(s===","||s===";"||Bmt.test(s)))return!0}return!1}function vJr(e,t){let n=[],s=0,o=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\"&&r+1<e.length){r++;continue}if(i==="{"){s++;continue}if(i==="}"){if(s>0)s--;continue}if(s!==0||!xJr(i,t))continue;n.push(e.slice(o,r)),o=r+1}return n.push(e.slice(o)),n}async function x$n(e,t,n){if(ef(e))return!0;let s=bu(e).path,{basePath:o}=n(s),r=dn(o,t);try{return await Zd.promises.stat(r),!0}catch(i){if(le(i)||la(i,"ENAMETOOLONG"))return!1;throw i}}async function eae(e,t,n,s,o){let r=vJr(e,s);if(r.length<2)return null;let i=r.map(QL).filter((a)=>a.length>0);if(i.length===0)return null;if(i.length<2&&r.length===i.length)return null;if(o!=="none"){let a=await Promise.all(i.map((u)=>x$n(u,t,n)));if(!(o==="all"?a.every(Boolean):a.some(Boolean)))return null}return i}async function Ymt(e,t,n={}){let s=QL(e);if(!MJr(s))return null;let o=n.splitter??wPe;if(n.routedUrlPredicate?.(s)){let i=await eae(s,t,o,"semicolon","none");return i?.every(n.routedUrlPredicate)?i:null}if(ef(s))return null;if(await JL(s,t)!=="missing")return null;let r=bu(s).path;if(!fw(r)&&await x$n(s,t,o))return null;return await eae(s,t,o,"semicolon","none")??await eae(s,t,o,"comma","some")??await eae(s,t,o,"whitespace","all")??await eae(s,t,o,"mixed","all")}async function nae(e,t,n={}){let s=[];for(let o of e){let r=QL(o),i=await Ymt(r,t,n);if(i)s.push(...i);else s.push(r)}return s}function wPe(e){let t=Vmt(e),n=t.split("/"),s=-1;for(let o=0;o<n.length;o++)if(fw(n[o])){s=o;break}if(s===-1)return{basePath:t};if(s<=0)return{basePath:".",glob:t};return{basePath:n.slice(0,s).join("/"),glob:n.slice(s).join("/")}}async function M$n(e,t){if(!fw(e)||ef(e))return wPe(e);try{return await Zd.promises.stat(dn(e,t)),{basePath:Vmt(e)}}catch{return wPe(e)}}function sae(e){let t=Vmt(e),n=t.split("/"),s=-1;for(let o=0;o<n.length;o++)if(fw(n[o])){s=o;break}if(s===-1)return{basePath:t,globPattern:"**/*",hasGlob:!1};if(s===0)return{basePath:".",globPattern:!t.startsWith("**/")?`**/${t}`:t,hasGlob:!0};return{basePath:n.slice(0,s).join("/"),globPattern:n.slice(s).join("/"),hasGlob:!0}}function Umt(e,t){if(!e)return t;if(!t)return e;let n=e.replace(/\/+$/,""),s=t.replace(/^\/+/,"");return`${n}/${s}`}function bY(e){return e.replace(/\\/g,"/")}function S$n(e,t){if(!e||e===".")return bY(t).replace(/^\/+/,"");let n=bY(e).replace(/\/+$/,""),s=bY(t).replace(/^\/+/,"");return`${n}/${s}`}function OJr(e){let t=[...new Set(e.map((n)=>bY(n).trim()).filter(Boolean))];if(t.length===0)return;if(t.length===1)return t[0];return`{${t.join(",")}}`}function PJr(e){if(e.length===0)return".";let t=Cs.resolve(e[0]).split(Cs.sep);for(let s of e.slice(1)){let o=Cs.resolve(s).split(Cs.sep),r=0,i=Math.min(t.length,o.length);while(r<i&&t[r]===o[r])r+=1;t=t.slice(0,r)}if(t.length===0)return Cs.parse(Cs.resolve(e[0])).root;return t.join(Cs.sep)||Cs.parse(Cs.resolve(e[0])).root}function v$n(e,t){return e.map((n)=>Bn(n,t,{trailingSlash:n.endsWith("/")||n.endsWith("\\")})).join(", ")}async function NJr(e,t,n,s=!1){if(e.length<1)return;let o=await Promise.all(e.map(async(c)=>{let d=await M$n(c,t),f=dn(d.basePath,t),m=await Zd.promises.stat(f);return{raw:c,parsedPath:d,absoluteBasePath:f,stat:m}})),r=!n&&o.every((c)=>!c.parsedPath.glob&&c.stat.isFile()),i=PJr(o.map((c)=>c.absoluteBasePath)),a=o.map((c)=>{let d=bY(Cs.relative(i,c.absoluteBasePath))||".";if(c.parsedPath.glob){let f=S$n(d,c.parsedPath.glob);return Umt(f,n)??f}if(n)return Umt(d==="."?void 0:d,n)??n;if(c.stat.isDirectory())return S$n(d,"**/*");return d==="."?Cs.basename(c.absoluteBasePath):d}),l=o.some((c)=>c.absoluteBasePath===i),u=s&&!r&&o.some((c)=>!c.parsedPath.glob&&c.stat.isFile()),p=o.length>1&&(!l||u)?o.map((c)=>({basePath:c.absoluteBasePath,glob:c.parsedPath.glob?Umt(c.parsedPath.glob,n):n})):void 0;return{basePath:i,glob:OJr(a),scopePath:v$n(e,t),exactFilePaths:r?o.map((c)=>c.absoluteBasePath):void 0,targets:p}}async function FJr(e,t,n,s=!1){return NJr([...new Set(e)],t,n,s)}async function LJr(e,t){if(e.length<=1)return;return{targets:e.map((s)=>{let o=sae(s);return{basePath:dn(o.basePath,t),globPattern:o.globPattern,hasGlob:o.hasGlob}}),scopePath:v$n(e,t)}}async function O$n(e,t){return LJr([...new Set(e)],t)}async function Kmt(e,t,n){let s=await Promise.all(e.map(async(i)=>{let{basePath:a}=n(i),l=dn(a,t);try{return await Zd.promises.stat(l),{item:i,exists:!0}}catch(u){if(le(u))return{item:i,exists:!1};throw u}})),o=[],r=[];for(let i of s)if(i.exists)o.push(i.item);else r.push(i.item);return{valid:o,missing:r}}function Op(e,t){let n=dn(e,t),s=TJr(n),o=s!==n?[n,s]:[n];for(let r of o)if(Zie(r))return r;for(let r of o){let i=gJr(r);if(i!==r&&Zie(i))return i;let a=hJr(r);if(a!==r&&Zie(a))return a;let l=T$n(r);if(l!==r&&Zie(l))return l;let u=T$n(a);if(u!==r&&Zie(u))return u}return n}function _Jr(e){return e.replace(/[*?[{]/g,"[$&]")}async function DJr(e,t,n,s){let o=e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"");if(!o)return null;let r=AbortSignal.timeout(b$n),i=n?AbortSignal.any([n,r]):r,a;try{let l=await s({pattern:`**/${_Jr(o)}`,path:t,hidden:!0,signal:i,timeoutMs:b$n});if(n?.aborted)throw new $e;a=l.matches.map((u)=>u.path)}catch{if(n?.aborted)throw new $e;return null}if(a.length!==1)return null;return{absolutePath:Cs.resolve(t,a[0]),displayPath:a[0]}}async function IPe(e,t,n){return DJr(e,t,n,aJr)}async function EY(e){let{rawPaths:t,cwd:n,internalUrlAction:s}=e,o=t.map(QL);if(o.some((R)=>R.length===0))throw new X("Search scope entries must be non-empty paths or globs");let r=await nae(o,n);if(r.some((R)=>R.length===0))throw new X("Search scope entries must be non-empty paths or globs");let i=/^(?:https?|ftp|ws|wss):\/\//i,a=Bi.instance(),l=[],u=new Set;for(let R of r){let y=i.test(R);if(!y&&JB(R)&&!fw(R))try{await Zd.promises.stat(dn(R,n))}catch(S){y=le(S)||tq(S)}if(y){let S=e.resolveExternalUrl?await e.resolveExternalUrl(R):void 0;if(S){if(l.push(S.sourcePath),e.trackImmutableSources&&S.immutable)u.add(Cs.resolve(S.sourcePath));continue}throw new X(`Cannot ${s} external URL: ${R}. Use \`read\` to fetch web content, then search the returned text.`)}if(!a.canHandle(R)){l.push(R);continue}if($mt(R))throw new X(`Cannot ${s} a remote ssh:// path (no local file): ${R}. Use \`read ${R}\` to view it, or use \`grep\` on a specific remote file.`);if(fw(R))throw new X(`Glob patterns are not supported for internal URLs: ${R}`);let C=await a.resolve(R,{cwd:n,settings:e.settings,signal:e.signal,localProtocolOptions:e.localProtocolOptions,skills:e.skills,pathOnly:!0});if(!C.sourcePath)throw new X(`Cannot ${s} internal URL without a backing file: ${R}`);if(e.trackImmutableSources&&C.immutable)u.add(Cs.resolve(C.sourcePath));l.push(C.sourcePath)}let p=[],c=l;if(l.length>1){let R=await Kmt(l,n,wPe);if(R.valid.length===0)throw new X(`Path not found: ${R.missing.join(", ")}`);c=R.valid,p=R.missing}let d,f,m,g,h;if(c.length===1){let R=await M$n(c[0]??".",n);d=dn(R.basePath,n),m=R.glob,f=Bn(d,n)}else{let R=await FJr(c,n,void 0,e.fanOutFileTargets===!0);if(!R)throw new X("`paths` must contain at least one path or glob");if(d=R.basePath,g=R.targets,e.surfaceExactFilePaths)h=R.exactFilePaths,m=h||g?void 0:R.glob;else m=g?void 0:R.glob;f=R.scopePath}let T;try{T=(await Bun.file(d).stat()).isDirectory()}catch{let R=e.multipathStatHint&&r.length>1?e.multipathStatHint:"";throw new X(`Path not found: ${f}${R}`)}return{searchPath:d,scopePath:f,globFilter:m,isDirectory:T,multiTargets:g,exactFilePaths:h,missingPaths:p,immutableSourcePaths:u}}var lJr,m$n,Wmt,uJr,g$n,h$n,pJr,cJr,dJr,k$n,fJr=" ",Gmt,bJr,IJr,Bmt,b$n=5000;var Sn=w(()=>{B();Cu();St();lJr=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g,m$n=String.raw`L?\d+(?:(?:[-+]|\.\.)L?\d+|-|\.\.)?`,Wmt=`${m$n}(?:,${m$n})*`,uJr=new RegExp(`^(?:${Wmt}|raw|conflicts)$`,"i"),g$n=new RegExp(`^${Wmt}$`,"i"),h$n=/^raw$/i,pJr=new RegExp(String.raw`^(?:raw|conflicts|${Wmt}|-\d+(?:[-+]\d+)?)$`,"i"),cJr={agent:!0,artifact:!0,issue:!0,history:!0,local:!0,memory:!0,omt:!0,pr:!0,rule:!0,security:!0,skill:!0,ssh:!0,vault:!0},dJr=new Set(["mcp"]),k$n=/^([a-z][a-z0-9+.-]*):\/\//i,Gmt=["agent://","artifact://","skill://","rule://","security://","local://","mcp://","ssh://","vault://"];bJr=/^L?(\d+)(?:(\.\.|[-+])L?(\d+)?)?$/i;IJr=["*","?","[","{"];Bmt=/\s/});var kY;var xPe=w(()=>{kY={type:"module",name:"@ohmytr/coding-agent",version:"18.0.3",description:"Coding agent CLI with read, bash, edit, write tools and session management",homepage:"https://github.com/ohmytr/ohmytr",author:"Stencil Labs, Inc.",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/ohmytr/ohmytr.git",directory:"packages/coding-agent"},bugs:{url:"https://github.com/ohmytr/ohmytr/issues"},keywords:["coding-agent","ai","llm","cli","tui","agent"],main:"./src/index.ts",types:"./src/index.ts",bin:{omt:"dist/cli.js"},scripts:{build:"bun scripts/build-binary.ts",check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun ../../scripts/ci-test-ts.ts coding-agent-heavy --full",fix:"biome check --write --unsafe . && bun run format-prompts",fmt:"biome format --write . && bun run format-prompts","format-prompts":"bun scripts/format-prompts.ts","gen:tool-views":"bun --cwd=../collab-web run gen:tool-views","gen:bundle":"bun scripts/bundle-dist.ts","gen:native":"bun --cwd=../natives run gen:native","gen:native:reset":"bun --cwd=../natives run gen:native:reset",prepack:"bun run gen:tool-views && bun run gen:bundle","bench:guard":"bun scripts/bench-guard.ts"},dependencies:{"@babel/parser":"catalog:","@ohmytr/hashline":"catalog:","@ohmytr/stats":"catalog:","@ohmytr/omptype":"catalog:","@ohmytr/agent-core":"catalog:","@ohmytr/ai":"catalog:","@ohmytr/catalog":"catalog:","@ohmytr/mnemopi":"catalog:","@ohmytr/natives":"catalog:","@ohmytr/tui":"catalog:","@ohmytr/utils":"catalog:","@ohmytr/wire":"catalog:","@ohmytr/snapcompact":"catalog:","@opentelemetry/api":"catalog:","@opentelemetry/api-logs":"catalog:","@opentelemetry/context-async-hooks":"catalog:","@opentelemetry/exporter-logs-otlp-proto":"catalog:","@opentelemetry/exporter-metrics-otlp-proto":"catalog:","@opentelemetry/exporter-trace-otlp-proto":"catalog:","@opentelemetry/resources":"catalog:","@opentelemetry/sdk-logs":"catalog:","@opentelemetry/sdk-metrics":"catalog:","@opentelemetry/sdk-trace-base":"catalog:","@opentelemetry/sdk-trace-node":"catalog:","puppeteer-core":"catalog:"},optionalDependencies:{"@huggingface/transformers":"catalog:","sherpa-onnx-node":"1.13.2"},devDependencies:{"@types/bun":"catalog:"},engines:{bun:">=1.3.14",node:">=24.0.0"},files:["src","dist/cli.js","dist/docs-index.generated.txt","dist/CHANGELOG-*.md","dist/*.node","dist/template-*.css","dist/template-*.html","dist/template-*.js","dist/tool-views.generated-*.js","scripts","examples","README.md","CHANGELOG.md"],exports:{".":{types:"./src/index.ts",import:"./src/index.ts"},"./*":{types:"./src/*.ts",import:"./src/*.ts"},"./async":{types:"./src/async/index.ts",import:"./src/async/index.ts"},"./async/*":{types:"./src/async/*.ts",import:"./src/async/*.ts"},"./autoresearch":{types:"./src/autoresearch/index.ts",import:"./src/autoresearch/index.ts"},"./autoresearch/*":{types:"./src/autoresearch/*.ts",import:"./src/autoresearch/*.ts"},"./autoresearch/tools/*":{types:"./src/autoresearch/tools/*.ts",import:"./src/autoresearch/tools/*.ts"},"./capability":{types:"./src/capability/index.ts",import:"./src/capability/index.ts"},"./capability/*":{types:"./src/capability/*.ts",import:"./src/capability/*.ts"},"./cli/*":{types:"./src/cli/*.ts",import:"./src/cli/*.ts"},"./cli/gallery-fixtures":{types:"./src/cli/gallery-fixtures/index.ts",import:"./src/cli/gallery-fixtures/index.ts"},"./cli/gallery-fixtures/*":{types:"./src/cli/gallery-fixtures/*.ts",import:"./src/cli/gallery-fixtures/*.ts"},"./cli/commands/*":{types:"./src/cli/commands/*.ts",import:"./src/cli/commands/*.ts"},"./commands/*":{types:"./src/commands/*.ts",import:"./src/commands/*.ts"},"./commit":{types:"./src/commit/index.ts",import:"./src/commit/index.ts"},"./commit/*":{types:"./src/commit/*.ts",import:"./src/commit/*.ts"},"./commit/agentic":{types:"./src/commit/agentic/index.ts",import:"./src/commit/agentic/index.ts"},"./commit/agentic/*":{types:"./src/commit/agentic/*.ts",import:"./src/commit/agentic/*.ts"},"./commit/agentic/tools":{types:"./src/commit/agentic/tools/index.ts",import:"./src/commit/agentic/tools/index.ts"},"./commit/agentic/tools/*":{types:"./src/commit/agentic/tools/*.ts",import:"./src/commit/agentic/tools/*.ts"},"./commit/analysis":{types:"./src/commit/analysis/index.ts",import:"./src/commit/analysis/index.ts"},"./commit/analysis/*":{types:"./src/commit/analysis/*.ts",import:"./src/commit/analysis/*.ts"},"./commit/changelog":{types:"./src/commit/changelog/index.ts",import:"./src/commit/changelog/index.ts"},"./commit/changelog/*":{types:"./src/commit/changelog/*.ts",import:"./src/commit/changelog/*.ts"},"./commit/git/*":{types:"./src/commit/git/*.ts",import:"./src/commit/git/*.ts"},"./commit/map-reduce":{types:"./src/commit/map-reduce/index.ts",import:"./src/commit/map-reduce/index.ts"},"./commit/map-reduce/*":{types:"./src/commit/map-reduce/*.ts",import:"./src/commit/map-reduce/*.ts"},"./commit/utils/*":{types:"./src/commit/utils/*.ts",import:"./src/commit/utils/*.ts"},"./config/*":{types:"./src/config/*.ts",import:"./src/config/*.ts"},"./dap":{types:"./src/dap/index.ts",import:"./src/dap/index.ts"},"./dap/*":{types:"./src/dap/*.ts",import:"./src/dap/*.ts"},"./debug":{types:"./src/debug/index.ts",import:"./src/debug/index.ts"},"./debug/*":{types:"./src/debug/*.ts",import:"./src/debug/*.ts"},"./discovery":{types:"./src/discovery/index.ts",import:"./src/discovery/index.ts"},"./discovery/*":{types:"./src/discovery/*.ts",import:"./src/discovery/*.ts"},"./edit":{types:"./src/edit/index.ts",import:"./src/edit/index.ts"},"./edit/*":{types:"./src/edit/*.ts",import:"./src/edit/*.ts"},"./edit/modes/*":{types:"./src/edit/modes/*.ts",import:"./src/edit/modes/*.ts"},"./exa":{types:"./src/exa/index.ts",import:"./src/exa/index.ts"},"./exa/*":{types:"./src/exa/*.ts",import:"./src/exa/*.ts"},"./exec/*":{types:"./src/exec/*.ts",import:"./src/exec/*.ts"},"./export/*":{types:"./src/export/*.ts",import:"./src/export/*.ts"},"./export/html":{types:"./src/export/html/index.ts",import:"./src/export/html/index.ts"},"./export/html/*":{types:"./src/export/html/*.ts",import:"./src/export/html/*.ts"},"./extensibility/*":{types:"./src/extensibility/*.ts",import:"./src/extensibility/*.ts"},"./extensibility/custom-commands":{types:"./src/extensibility/custom-commands/index.ts",import:"./src/extensibility/custom-commands/index.ts"},"./extensibility/custom-commands/*":{types:"./src/extensibility/custom-commands/*.ts",import:"./src/extensibility/custom-commands/*.ts"},"./extensibility/custom-commands/bundled/ci-green":{types:"./src/extensibility/custom-commands/bundled/ci-green/index.ts",import:"./src/extensibility/custom-commands/bundled/ci-green/index.ts"},"./extensibility/custom-commands/bundled/review":{types:"./src/extensibility/custom-commands/bundled/review/index.ts",import:"./src/extensibility/custom-commands/bundled/review/index.ts"},"./extensibility/custom-tools":{types:"./src/extensibility/custom-tools/index.ts",import:"./src/extensibility/custom-tools/index.ts"},"./extensibility/custom-tools/*":{types:"./src/extensibility/custom-tools/*.ts",import:"./src/extensibility/custom-tools/*.ts"},"./extensibility/extensions":{types:"./src/extensibility/extensions/index.ts",import:"./src/extensibility/extensions/index.ts"},"./extensibility/extensions/*":{types:"./src/extensibility/extensions/*.ts",import:"./src/extensibility/extensions/*.ts"},"./extensibility/hooks":{types:"./src/extensibility/hooks/index.ts",import:"./src/extensibility/hooks/index.ts"},"./extensibility/hooks/*":{types:"./src/extensibility/hooks/*.ts",import:"./src/extensibility/hooks/*.ts"},"./extensibility/plugins":{types:"./src/extensibility/plugins/index.ts",import:"./src/extensibility/plugins/index.ts"},"./extensibility/plugins/*":{types:"./src/extensibility/plugins/*.ts",import:"./src/extensibility/plugins/*.ts"},"./extensibility/plugins/marketplace":{types:"./src/extensibility/plugins/marketplace/index.ts",import:"./src/extensibility/plugins/marketplace/index.ts"},"./extensibility/plugins/marketplace/*":{types:"./src/extensibility/plugins/marketplace/*.ts",import:"./src/extensibility/plugins/marketplace/*.ts"},"./internal-urls":{types:"./src/internal-urls/index.ts",import:"./src/internal-urls/index.ts"},"./internal-urls/*":{types:"./src/internal-urls/*.ts",import:"./src/internal-urls/*.ts"},"./eval":{types:"./src/eval/index.ts",import:"./src/eval/index.ts"},"./eval/js/*":{types:"./src/eval/js/*.ts",import:"./src/eval/js/*.ts"},"./eval/py/*":{types:"./src/eval/py/*.ts",import:"./src/eval/py/*.ts"},"./lsp":{types:"./src/lsp/index.ts",import:"./src/lsp/index.ts"},"./lsp/*":{types:"./src/lsp/*.ts",import:"./src/lsp/*.ts"},"./lsp/clients":{types:"./src/lsp/clients/index.ts",import:"./src/lsp/clients/index.ts"},"./lsp/clients/*":{types:"./src/lsp/clients/*.ts",import:"./src/lsp/clients/*.ts"},"./markit":{types:"./src/markit/index.ts",import:"./src/markit/index.ts"},"./markit/*":{types:"./src/markit/*.ts",import:"./src/markit/*.ts"},"./mcp":{types:"./src/mcp/index.ts",import:"./src/mcp/index.ts"},"./mcp/*":{types:"./src/mcp/*.ts",import:"./src/mcp/*.ts"},"./mcp/transports":{types:"./src/mcp/transports/index.ts",import:"./src/mcp/transports/index.ts"},"./mcp/transports/*":{types:"./src/mcp/transports/*.ts",import:"./src/mcp/transports/*.ts"},"./memories":{types:"./src/memories/index.ts",import:"./src/memories/index.ts"},"./memories/*":{types:"./src/memories/*.ts",import:"./src/memories/*.ts"},"./memory-backend":{types:"./src/memory-backend/index.ts",import:"./src/memory-backend/index.ts"},"./memory-backend/*":{types:"./src/memory-backend/*.ts",import:"./src/memory-backend/*.ts"},"./hindsight":{types:"./src/hindsight/index.ts",import:"./src/hindsight/index.ts"},"./hindsight/*":{types:"./src/hindsight/*.ts",import:"./src/hindsight/*.ts"},"./modes":{types:"./src/modes/index.ts",import:"./src/modes/index.ts"},"./modes/*":{types:"./src/modes/*.ts",import:"./src/modes/*.ts"},"./modes/acp":{types:"./src/modes/acp/index.ts",import:"./src/modes/acp/index.ts"},"./modes/acp/*":{types:"./src/modes/acp/*.ts",import:"./src/modes/acp/*.ts"},"./modes/components":{types:"./src/modes/components/index.ts",import:"./src/modes/components/index.ts"},"./modes/components/*":{types:"./src/modes/components/*.ts",import:"./src/modes/components/*.ts"},"./modes/components/extensions":{types:"./src/modes/components/extensions/index.ts",import:"./src/modes/components/extensions/index.ts"},"./modes/components/extensions/*":{types:"./src/modes/components/extensions/*.ts",import:"./src/modes/components/extensions/*.ts"},"./modes/components/status-line":{types:"./src/modes/components/status-line/index.ts",import:"./src/modes/components/status-line/index.ts"},"./modes/components/status-line/*":{types:"./src/modes/components/status-line/*.ts",import:"./src/modes/components/status-line/*.ts"},"./modes/controllers/*":{types:"./src/modes/controllers/*.ts",import:"./src/modes/controllers/*.ts"},"./modes/setup-wizard":{types:"./src/modes/setup-wizard/index.ts",import:"./src/modes/setup-wizard/index.ts"},"./modes/setup-wizard/*":{types:"./src/modes/setup-wizard/*.ts",import:"./src/modes/setup-wizard/*.ts"},"./modes/rpc/*":{types:"./src/modes/rpc/*.ts",import:"./src/modes/rpc/*.ts"},"./modes/theme/*":{types:"./src/modes/theme/*.ts",import:"./src/modes/theme/*.ts"},"./modes/theme/defaults":{types:"./src/modes/theme/defaults/index.ts",import:"./src/modes/theme/defaults/index.ts"},"./modes/utils/*":{types:"./src/modes/utils/*.ts",import:"./src/modes/utils/*.ts"},"./plan-mode/*":{types:"./src/plan-mode/*.ts",import:"./src/plan-mode/*.ts"},"./prompts/*":"./src/prompts/*.md","./secrets":{types:"./src/secrets/index.ts",import:"./src/secrets/index.ts"},"./secrets/*":{types:"./src/secrets/*.ts",import:"./src/secrets/*.ts"},"./session/*":{types:"./src/session/*.ts",import:"./src/session/*.ts"},"./slash-commands/*":{types:"./src/slash-commands/*.ts",import:"./src/slash-commands/*.ts"},"./ssh/*":{types:"./src/ssh/*.ts",import:"./src/ssh/*.ts"},"./stt":{types:"./src/stt/index.ts",import:"./src/stt/index.ts"},"./stt/*":{types:"./src/stt/*.ts",import:"./src/stt/*.ts"},"./task":{types:"./src/task/index.ts",import:"./src/task/index.ts"},"./task/*":{types:"./src/task/*.ts",import:"./src/task/*.ts"},"./tools":{types:"./src/tools/index.ts",import:"./src/tools/index.ts"},"./tools/hub":{types:"./src/tools/hub/index.ts",import:"./src/tools/hub/index.ts"},"./tools/hub/*":{types:"./src/tools/hub/*.ts",import:"./src/tools/hub/*.ts"},"./tools/*":{types:"./src/tools/*.ts",import:"./src/tools/*.ts"},"./tui":{types:"./src/tui/index.ts",import:"./src/tui/index.ts"},"./tui/*":{types:"./src/tui/*.ts",import:"./src/tui/*.ts"},"./utils/*":{types:"./src/utils/*.ts",import:"./src/utils/*.ts"},"./web/*":{types:"./src/web/*.ts",import:"./src/web/*.ts"},"./web/scrapers":{types:"./src/web/scrapers/index.ts",import:"./src/web/scrapers/index.ts"},"./web/scrapers/*":{types:"./src/web/scrapers/*.ts",import:"./src/web/scrapers/*.ts"},"./web/search":{types:"./src/web/search/index.ts",import:"./src/web/search/index.ts"},"./web/search/*":{types:"./src/web/search/*.ts",import:"./src/web/search/*.ts"},"./web/search/providers/*":{types:"./src/web/search/providers/*.ts",import:"./src/web/search/providers/*.ts"},"./*.js":"./src/*.ts"}}});import*as fR from"node:fs/promises";import*as oae from"node:path";function N$n(e,t){let s=(t.trim().toLowerCase().replace(/^\.+/,"")||"bin").replace(/[^a-z0-9]+/g,"_")||"bin",o=kY.version.replace(/[^a-z0-9]+/gi,"_"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return`v${MPe}-${o}-${s}-${r}`}function UJr(e){return oae.join(m6e(),`${e}.json`)}function QB(e){return e instanceof Error?e.message:String(e)}function BJr(e){let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;if(!("version"in t)||t.version!==MPe)return null;if(!("content"in t)||typeof t.content!=="string"||t.content.length===0)return null;return{version:MPe,content:t.content}}async function F$n(e){let t=UJr(e),n;try{n=await Bun.file(t).text()}catch(o){if(!le(o))I.debug("document conversion cache read failed",{error:QB(o)});return{status:"miss"}}let s;try{s=BJr(n)}catch(o){I.debug("document conversion cache read failed",{error:QB(o)}),s=null}if(!s)return await fR.rm(t,{force:!0}).catch(()=>{return}),{status:"miss"};return{status:"hit",content:s.content}}async function WJr(e){let t;try{t=await fR.readdir(e)}catch(r){if(!le(r))I.debug("document conversion cache prune failed",{error:QB(r)});return}let n=Date.now(),s=[],o=0;for(let r of t){let i=oae.join(e,r),a;try{a=await fR.stat(i)}catch(l){if(!le(l))I.debug("document conversion cache prune failed",{error:QB(l)});continue}if(!a.isFile())continue;if(r.endsWith(".tmp")){if(n-a.mtimeMs>qJr)await fR.rm(i,{force:!0}).catch(()=>{return});continue}if(!r.endsWith(".json"))continue;s.push({path:i,size:a.size,mtimeMs:a.mtimeMs}),o+=a.size}if(o<=P$n)return;s.sort((r,i)=>r.mtimeMs-i.mtimeMs);for(let r of s){if(o<=P$n)break;try{await fR.rm(r.path,{force:!0}),o-=r.size}catch(i){if(!le(i))I.debug("document conversion cache prune failed",{error:QB(i)})}}}async function L$n(e,t){let n=m6e(),s=oae.join(n,`${e}.json`),o=oae.join(n,`${e}.${process.pid}.${Date.now()}.${crypto.randomUUID()}.tmp`),r=JSON.stringify({version:MPe,content:t});try{await fR.mkdir(n,{recursive:!0}),await Bun.write(o,r),await fR.rename(o,s)}catch(i){await fR.rm(o,{force:!0}).catch(()=>{return}),I.debug("document conversion cache write failed",{error:QB(i)});return}WJr(n).catch((i)=>{I.debug("document conversion cache prune failed",{error:QB(i)})})}var MPe=1,P$n=268435456,qJr=300000;var _$n=w(()=>{B();xPe()});var G;var Qr=w(()=>{G=class G extends Error{constructor(e){super(e);this.name="ArchiveError"}}});function Rs(e,t){return e[t]|e[t+1]<<8}function wn(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function KA(e,t){let n=wn(e,t)+wn(e,t+4)*4294967296;if(!Number.isSafeInteger(n))throw new G("Archive uses offsets or sizes too large to read safely");return n}function rae(e,t){return e[t]<<8|e[t+1]}function Fh(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function cd(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255}function Cl(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function ZB(e,t,n){Cl(e,t,n>>>0),Cl(e,t+4,Math.floor(n/4294967296))}function Dp(e,t,n){if(e.byteLength<t+n.length)return!1;for(let s=0;s<n.length;s++)if(e[t+s]!==n.charCodeAt(s))return!1;return!0}var AY;var Lh=w(()=>{Qr();AY=new TextDecoder});function tf(e){if(!e)return"";let t=e.replace(/\\/g,"/").split("/"),n=[];for(let s of t){if(!s||s===".")continue;if(s==="..")return;n.push(s)}return n.join("/")}function Lr(e){let t=e.replace(/\\/g,"/").split("/"),n=[];for(let s of t){if(!s||s===".")continue;if(s==="..")return;n.push(s)}if(n.length===0)return;return n.join("/")}function H$n(e){return e.endsWith("/")||e.endsWith("\\")}function br(e){if(Buffer.byteLength(e,"utf-8")<=D$n)return e;let t=0,n=0;for(let s of e){let o=Buffer.byteLength(s,"utf-8");if(n+o>D$n-3)break;t+=s.length,n+=o}return`${e.slice(0,t)}...`}function wo(e,t,n){if(e>n)throw new G(`Archive ${t} exceeds ${n} bytes`)}function nf(e,t,n){wo(Buffer.byteLength(e,"utf-8"),t,n)}var D$n=256;var sf=w(()=>{Qr()});function ki(e,t){if(!Number.isSafeInteger(e)||e<0)throw new G("Archive is too large to read safely");if(e>t.maxInMemorySize)throw new G(`Archive is too large to read in memory (${ft(e)} > ${ft(t.maxInMemorySize)} limit)`)}function Ns(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw new G(`Invalid archive: ${n} has an invalid size`);if(e>t.maxIndexSize)throw new G(`Archive ${n} is too large (${ft(e)} > ${ft(t.maxIndexSize)} limit)`)}function fa(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw new G(`Archive member '${br(t)}' has an invalid size`);if(e>n.maxMemberSize)throw new G(`Archive member '${br(t)}' is too large to extract in memory (${ft(e)} > ${ft(n.maxMemberSize)} limit)`)}function cr(e,t){if(e>t.maxEntries)throw new G(`Archive has too many entries (> ${t.maxEntries} limit)`)}var iae;var Hp=w(()=>{Qr();sf();iae={maxEntries:1e6,maxInMemorySize:268435456,maxIndexSize:67108864,maxMemberSize:67108864,maxPathBytes:4096,maxLinkDepth:40}});function Sc(e,t){let n=e.get(t.path);if(!n)return e.set(t.path,t),t;if(n.isDirectory&&!t.isDirectory)return e.set(t.path,t),t;if(!n.isDirectory&&t.isDirectory)return;let s={...t,mtimeMs:t.mtimeMs??n.mtimeMs,mode:t.mode??n.mode,storage:t.storage??n.storage};return e.set(t.path,s),s}function ZL(e,t){cr(e.size,t);for(let n of[...e.values()]){let s=n.path.split("/"),o=s.length-1;for(let r=1;r<=o;r++){let i=s.slice(0,r).join("/");if(!i||e.has(i))continue;e.set(i,{path:i,isDirectory:!0,size:0}),cr(e.size,t)}}}function eW(e,t,n){let s=t,o=new Set;for(let r=0;!o.has(s);){o.add(s);let i;for(let a=s.length;a>0;a=s.lastIndexOf("/",a-1)){let l=e.get(s.slice(0,a));if(l?.storage?.type!=="link"||!l.isDirectory&&!l.storage.resolveTarget)continue;let u=s.slice(a+1);i=u?l.storage.targetPath?`${l.storage.targetPath}/${u}`:u:l.storage.targetPath;break}if(i===void 0)return s;if(++r>n)break;s=i}throw new G(`Archive path '${t}' crosses a cyclic symlink`)}var e_=w(()=>{Qr();Hp()});function GJr(e,t){throw new G(`Archive symlink '${br(t)}' cannot be materialized from target '${br(e)}'`)}class Xmt{format;limits;#e=new Map;constructor(e,t,n=iae){this.format=e,this.limits=n;for(let s of t)Sc(this.#e,s);ZL(this.#e,n)}indexEntries(){return this.#e.values()}getNode(e){let t=tf(e);if(t===void 0)return;if(t==="")return{path:"",isDirectory:!0,size:0};let n=eW(this.#e,t,this.limits.maxLinkDepth);if(n==="")return{path:t,isDirectory:!0,size:0};let s=this.#e.get(n);if(!s)return;return{path:t,isDirectory:s.isDirectory,size:s.size,mtimeMs:s.mtimeMs,mode:s.mode}}listDirectory(e){let t=tf(e);if(t===void 0)throw new G("Archive path cannot contain '..'");let n=t?eW(this.#e,t,this.limits.maxLinkDepth):"";if(t&&n!==""){let r=this.#e.get(n);if(!r)throw new G(`Archive path '${t}' not found`);if(!r.isDirectory)throw new G(`Archive path '${t}' is not a directory`)}let s=n?`${n}/`:"",o=new Map;for(let r of this.#e.values()){if(n){if(!r.path.startsWith(s)||r.path===n)continue}let i=n?r.path.slice(s.length):r.path,a=i.split("/")[0];if(!a)continue;let l=t?`${t}/${a}`:a;if(o.has(l))continue;let u=n?`${n}/${a}`:a,p=eW(this.#e,u,this.limits.maxLinkDepth),c=p?this.#e.get(p):void 0,d=p===""||c?.isDirectory===!0||i.includes("/");o.set(l,{name:a,path:l,isDirectory:d,size:d?0:c?.size??r.size,mtimeMs:c?.mtimeMs??r.mtimeMs,mode:c?.mode??r.mode})}return[...o.values()].sort((r,i)=>r.name.toLowerCase().localeCompare(i.name.toLowerCase()))}async readFile(e){let t=tf(e);if(!t)throw new G("Archive file path is required");let n=eW(this.#e,t,this.limits.maxLinkDepth);if(n==="")throw new G(`Archive path '${t}' is a directory`);let s=this.#e.get(n);if(!s)throw new G(`Archive file '${t}' not found`);if(s.isDirectory)throw new G(`Archive path '${t}' is a directory`);if(!s.storage)throw new G(`Archive file '${t}' has no readable storage`);if(fa(s.size,t,this.limits),s.storage.type==="link")GJr(s.storage.targetPath,t);let o=await s.storage.source.read(s.size,t);return{path:t,isDirectory:!1,size:s.size,mtimeMs:s.mtimeMs,mode:s.mode,bytes:o}}}var Jmt=w(()=>{e_();Qr();Hp();sf()});function sa(e,t=0){return Bun.hash.crc32(e,t)>>>0}function B$n(e,t=0n){let n=t^0xffffffffffffffffn,s=Number(n&0xffffffffn)>>>0,o=Number(n>>32n&0xffffffffn)>>>0;for(let r=0;r<e.length;r++){let i=(s^e[r])&255;s=((s>>>8|(o&255)<<24)>>>0^q$n[i])>>>0,o=(o>>>8^U$n[i])>>>0}return(BigInt(o)<<32n|BigInt(s))^0xffffffffffffffffn}function IY(e,t=0){let n=t;for(let s=0;s<e.length;s++)n=(n>>>8^W$n[(n^e[s])&255])&65535;return n}var q$n,U$n,W$n;var pO=w(()=>{q$n=new Uint32Array(256),U$n=new Uint32Array(256);for(let e=0;e<256;e++){let t=e,n=0;for(let s=0;s<8;s++){let o=(t&1)!==0;if(t=(t>>>1|(n&1)<<31)>>>0,n>>>=1,o)t=(t^3615952706)>>>0,n=(n^3379320725)>>>0}q$n[e]=t,U$n[e]=n}W$n=new Uint16Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=(t&1)!==0?t>>>1^40961:t>>>1;W$n[e]=t}});function G$n(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<e)throw new G("Invalid archive range")}function $$n(e,t,n){if(G$n(t,n),n>e.byteLength)throw new G("Invalid archive: truncated data");return e.subarray(t,n)}function vPe(e){return{size:e.byteLength,async read(t,n){return $$n(e,t,n)}}}function Qmt(e){let t=Bun.file(e),n=t.size;if(!Number.isSafeInteger(n))throw new G("Archive is too large to read safely");return{size:n,async read(s,o){G$n(s,o);let r=await t.slice(s,o).bytes();if(r.byteLength!==o-s)throw new G("Invalid archive: truncated data");return r}}}async function XA(e){return e.read(0,e.size)}var JA=w(()=>{Qr()});class egt{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=t}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#n+e>this.#e.byteLength*8)throw new G(`Invalid ${this.#t} compressed data: truncated bitstream`);let t=0;for(let n=0;n<e;n++){let s=this.#n++;t=t*2+(this.#e[s>>>3]>>>7-(s&7)&1)}return t}assertZeroPadding(){while(this.#n<this.#e.byteLength*8)if(this.read(1)!==0)throw new G(`Invalid ${this.#t} compressed data: non-zero trailing bits`)}}class dO{#e=[-1];#t=[-1];#n=[-1];#s;constructor(e){this.#s=e}static single(e,t,n){if(!Number.isInteger(e)||e<0||e>=t)throw new G(`Invalid ${n} Huffman table: symbol is out of range`);let s=new dO(n);return s.#n[0]=e,s}static build(e,t,n){let s=new Uint32Array(17),o=0;for(let l=0;l<t;l++){let u=e[l];if(u>16)throw new G(`Invalid ${n} Huffman table: code is too long`);if(u!==0)s[u]++,o=Math.max(o,u)}if(o===0)throw new G(`Invalid ${n} Huffman table: no symbols`);let r=new Uint32Array(17),i=0;for(let l=1;l<=16;l++){if(i=(i+s[l-1])*2,i+s[l]>2**l)throw new G(`Invalid ${n} Huffman table: oversubscribed codes`);r[l]=i}if(r[o]+s[o]!==2**o)throw new G(`Invalid ${n} Huffman table: incomplete codes`);let a=new dO(n);for(let l=0;l<t;l++){let u=e[l];if(u===0)continue;let p=r[u];r[u]=p+1;let c=0;for(let d=u-1;d>=0;d--){if(a.#n[c]>=0)throw new G(`Invalid ${n} Huffman table: prefix collision`);let f=p>>>d&1,m=f===0?a.#e[c]:a.#t[c];if(m<0)if(m=a.#n.length,a.#e.push(-1),a.#t.push(-1),a.#n.push(-1),f===0)a.#e[c]=m;else a.#t[c]=m;c=m}if(a.#n[c]>=0||a.#e[c]>=0||a.#t[c]>=0)throw new G(`Invalid ${n} Huffman table: duplicate code`);a.#n[c]=l}return a}decode(e){let t=0;for(let n=0;n<=16;n++){let s=this.#n[t];if(s>=0)return s;if(t=e.read(1)===0?this.#e[t]:this.#t[t],t<0)throw new G(`Invalid ${this.#s} Huffman code`)}throw new G(`Invalid ${this.#s} Huffman code: excessive depth`)}}function K$n(e,t){let n=e.read(3);if(n===7){while(e.read(1)!==0)if(n++,n>16)throw new G(`Invalid ${t} Huffman table: code is too long`)}return n}function zJr(e,t){let s=e.read(5);if(s===0)return dO.single(e.read(5),19,t);if(s>19)throw new G(`Invalid ${t} temporary Huffman table size`);let o=new Uint8Array(19),r=0;while(r<s)if(o[r++]=K$n(e,t),r===3){let i=e.read(2);if(r+i>s)throw new G(`Invalid ${t} temporary Huffman table`);r+=i}return dO.build(o,19,t)}function VJr(e,t,n){let o=e.read(9);if(o===0)return dO.single(e.read(9),510,n);if(o>510)throw new G(`Invalid ${n} command Huffman table size`);let r=new Uint8Array(510),i=0;while(i<o){let a=t.decode(e);if(a<=2){let l=a===0?1:a===1?e.read(4)+3:e.read(9)+20;if(i+l>o)throw new G(`Invalid ${n} command Huffman table`);i+=l}else r[i++]=a-2}return dO.build(r,510,n)}function YJr(e,t,n,s){let o=e.read(t);if(o===0)return dO.single(e.read(t),n,s);if(o>n)throw new G(`Invalid ${s} position Huffman table size`);let r=new Uint8Array(n);for(let i=0;i<o;i++)r[i]=K$n(e,s);return dO.build(r,n,s)}function xY(e,t,n,s,o,r){let i=new egt(e,r),a=new Uint8Array(t),l=0,u=0,p,c;while(l<t){if(u===0){if(u=i.read(16),u===0)throw new G(`Invalid ${r} compressed data: empty block`);let T=zJr(i,r);p=VJr(i,T,r),c=YJr(i,s,o,r)}u--;let d=p.decode(i);if(d<256){a[l++]=d;continue}let f=d-256+3;if(f>t-l)throw new G(`Invalid ${r} compressed data: match exceeds declared size`);let m=c.decode(i),g=m;if(m>1){let T=m-1;g=2**T+i.read(T)}if(g>=n||g>=l)throw new G(`Invalid ${r} compressed data: history distance is out of range`);let h=l-g-1;for(let T=0;T<f;T++)a[l++]=a[h++]}if(u!==0)throw new G(`Invalid ${r} compressed data: block exceeds declared size`);return i.assertZeroPadding(),a}function KJr(e,t){let n=new egt(e,"LZH -lzs-"),s=new Uint8Array(t),o=new Uint8Array(2048);o.fill(32);let r=2031,i=0,a=(l)=>{if(i>=t)throw new G("Invalid LZH -lzs- data: output exceeds declared size");s[i++]=l,o[r]=l,r=r+1&2047};while(i<t)if(n.read(1)!==0)a(n.read(8));else{let l=n.read(11),u=n.read(4)+2;if(u>t-i)throw new G("Invalid LZH -lzs- data: match exceeds declared size");for(let p=0;p<u;p++)a(o[l+p&2047])}return n.assertZeroPadding(),s}function JJr(e,t,n){if(t<0)return IY(e);let s=IY(e.subarray(0,t));return s=IY(XJr.subarray(0,n-t),s),IY(e.subarray(n),s)}function cO(e,t){return e[t]|e[t+1]<<8}function QA(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function j$n(e,t){let n=QA(e,t)+QA(e,t+4)*4294967296;if(!Number.isSafeInteger(n))throw new G("LZH uses sizes too large to read safely");return n}function aae(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid LZH archive: truncated ${s}`)}function Zmt(e){let t=e.indexOf(0);if(t<0)t=e.byteLength;return $Jr.decode(e.subarray(0,t))}function z$n(e){if((e.byteLength&1)!==0)throw new G("Invalid LZH Unicode path header: odd UTF-16 length");let t=e.byteLength;while(t>=2&&e[t-1]===0&&e[t-2]===0)t-=2;return jJr.decode(e.subarray(0,t))}function QJr(e){if(e===0)return;let t=1980+(e>>>25&127),n=e>>>21&15,s=e>>>16&31,o=e>>>11&31,r=e>>>5&63,i=(e&31)*2;if(n<1||n>12||s<1||s>31||o>23||r>59||i>59)return;return Date.UTC(t,n-1,s,o,r,i)}function V$n(e,t,n,s){switch(e){case 0:if(t.byteLength<2)throw new G("Invalid LZH common extended header");s.commonCrc=cO(t,0),s.commonCrcOffset=n;break;case 1:s.filename=Zmt(t);break;case 2:s.directory=Zmt(t).replaceAll("ÿ","/");break;case 57:throw new G("Multi-volume LZH archives are unsupported");case 65:if(t.byteLength>=16){let o=QA(t,8),r=QA(t,12),i=o+r*4294967296;if(Number.isSafeInteger(i))s.mtimeMs=i/1e4-11644473600000}break;case 66:if(t.byteLength<16)throw new G("Invalid LZH 64-bit size extended header");s.packedSize=j$n(t,0),s.size=j$n(t,8);break;case 68:s.unicodeFilename=z$n(t);break;case 69:s.unicodeDirectory=z$n(t).replaceAll("ÿ","/");break;case 80:if(t.byteLength<2)throw new G("Invalid LZH Unix permissions extended header");s.mode=cO(t,0);break;case 84:if(t.byteLength<4)throw new G("Invalid LZH Unix timestamp extended header");s.mtimeMs=QA(t,0)*1000;break}}class X$n{#e;#t;#n;#s;#o;constructor(e,t,n,s,o){this.#e=e,this.#t=t,this.#n=n,this.#s=s,this.#o=o}async read(e,t){let n=this.#e.subarray(this.#t,this.#t+this.#n),s;switch(this.#s){case"-lh0-":case"-lz4-":if(n.byteLength!==e)throw new G(`LZH member '${t}' has inconsistent stored size`);s=n.slice();break;case"-lh4-":s=xY(n,e,4096,4,13,"LZH -lh4-");break;case"-lh5-":s=xY(n,e,8192,4,14,"LZH -lh5-");break;case"-lh6-":s=xY(n,e,32768,5,16,"LZH -lh6-");break;case"-lh7-":s=xY(n,e,65536,5,17,"LZH -lh7-");break;case"-lzs-":s=KJr(n,e);break;case"-lh1-":throw new G(`LZH member '${t}' uses unsupported dynamic-Huffman method -lh1-`);default:throw new G(`LZH member '${t}' uses unsupported compression method ${this.#s}`)}if(s.byteLength!==e)throw new G(`LZH member '${t}' extracted to an unexpected size`);if(IY(s)!==this.#o)throw new G(`LZH member '${t}' failed CRC-16 verification`);return s}}function ZJr(e,t,n){aae(e,t,t+22,"header");let s=e[t+20];if(s>2)throw new G(`Unsupported LZH header level ${s}`);let o=String.fromCharCode(...e.subarray(t+2,t+7));if(!Y$n.test(o))throw new G(`Invalid LZH compression method '${o}'`);let r=QA(e,t+7),i=QA(e,t+11),a=0,l,u,p=0,c,d={};if(s<2){let T=e[t];if(T<(s===0?22:25))throw new G(`Invalid LZH level-${s} header size`);let y=t+T+2;aae(e,t,y,"header");let C=0;for(let E=t+2;E<y;E++)C=C+e[E]&255;if(C!==e[t+1])throw new G("Invalid LZH header checksum");let S=e[t+21];if(22+S+2>T+2)throw new G("Invalid LZH filename length");if(wo(S,"member path",n.limits.maxPathBytes),l=Zmt(e.subarray(t+22,t+22+S)),a=cO(e,t+22+S),u=QJr(QA(e,t+15)),s===0){let E=t+24+S;if(y-E>=12){let A=e.subarray(E,y);if((A[0]===85||A[0]===75)&&A[1]===0)p=A[0],d.mtimeMs=QA(A,2)*1000,d.mode=cO(A,A.byteLength-6)}c=y}else{p=e[t+24+S];let E=cO(e,y-2),A=y,k=0,x=0;while(E!==0){if(E<3)throw new G("Invalid LZH extended header size");if(aae(e,A,A+E,"extended header"),k+=E,Ns(T+2+k,n.limits,"header metadata"),++x>65535)throw new G("Invalid LZH archive: too many extended headers");let M=e[A],O=A+E-2,v=e.subarray(A+1,O);if(M===1||M===2||M===68||M===69)wo(v.byteLength,"member path",n.limits.maxPathBytes);V$n(M,v,A+1,d);let P=E;E=cO(e,O),A+=P}if(c=y+k,r=d.packedSize??r-k,r<0)throw new G("Invalid LZH level-1 packed size")}}else{let T=cO(e,t);if(T<26)throw new G("Invalid LZH level-2 header size");let R=t+T;aae(e,t,R,"header"),a=cO(e,t+21),p=e[t+23],u=QA(e,t+15)*1000;let y=t+24,C=0;while(y+2<=R){let S=cO(e,y);if(S===0){y+=2;break}if(S<3||y+S>R)throw new G("Invalid LZH extended header size");if(++C>65535)throw new G("Invalid LZH archive: too many extended headers");let E=e[y+2],A=e.subarray(y+3,y+S);if(E===1||E===2||E===68||E===69)wo(A.byteLength,"member path",n.limits.maxPathBytes);V$n(E,A,y+3,d),y+=S}if(y!==R)throw new G("Invalid LZH level-2 extended header chain");c=R,r=d.packedSize??r}if(s===1&&p===32&&o==="-lh7-")throw new G("LZH uses the incompatible LHARK -lh7- variant");i=d.size??i,u=d.mtimeMs??u;let f=d.mode;if(d.commonCrc!==void 0){let T=d.commonCrcOffset-t;if(JJr(e.subarray(t,c),T,T+2)!==d.commonCrc)throw new G("Invalid LZH common header CRC-16")}let m=d.unicodeFilename??d.filename??l??"",g=d.unicodeDirectory??d.directory??"",h=`${g}${g&&!/[\\/]$/.test(g)?"/":""}${m}`;return nf(h,"member path",n.limits.maxPathBytes),fa(i,h||"<unnamed>",n.limits),aae(e,c,c+r,"member data"),{method:o,packedSize:r,size:i,dataStart:c,nextOffset:c+r,crc:a,path:Lr(h),mtimeMs:u,mode:f}}function tgt(e){if(e.byteLength<22||e[2]!==45||e[6]!==45||e[3]!==108)return!1;let t=String.fromCharCode(...e.subarray(2,7));return Y$n.test(t)&&e[20]<=2}var $Jr,jJr,Y$n,XJr,J$n=async(e,t)=>{ki(e.size,t.limits);let n;try{n=await XA(e)}catch(a){if(a instanceof G)throw a;throw new G(`Unable to read LZH archive: ${a instanceof Error?a.message:String(a)}`)}if(n.byteLength!==e.size)throw new G("Invalid LZH archive: truncated data");if(!tgt(n))throw new G("Invalid LZH archive header");let s=[],o=0,r=0,i=0;while(o<n.byteLength&&n[o]!==0){let a=ZJr(n,o,t);if(i+=a.dataStart-o,Ns(i,t.limits,"index"),cr(++r,t.limits),a.nextOffset<=o)throw new G("Invalid LZH archive: header did not advance");if(o=a.nextOffset,!a.path)continue;let l=a.method==="-lhd-";if(l&&a.mode!==void 0&&(a.mode&61440)===40960){let u=a.path.indexOf("|");if(u<1)throw new G(`Invalid LZH symbolic link '${a.path}'`);let p=Lr(a.path.slice(0,u)),c=Lr(a.path.slice(u+1));if(!p||!c)continue;s.push({path:p,isDirectory:!1,size:0,mtimeMs:a.mtimeMs,mode:a.mode,storage:{type:"link",targetPath:c,resolveTarget:!1}});continue}s.push({path:a.path,isDirectory:l,size:l?0:a.size,mtimeMs:a.mtimeMs,mode:a.mode,storage:l?void 0:{type:"member",source:new X$n(n,a.dataStart,a.packedSize,a.method,a.crc)}})}if(s.length===0&&r===0)throw new G("Invalid LZH archive: no members");return s};var ngt=w(()=>{pO();Qr();Hp();sf();JA();$Jr=new TextDecoder("windows-1252"),jJr=new TextDecoder("utf-16"),Y$n=/^-(?:lh[0-7d]|lz[45s])-$/;XJr=new Uint8Array(2)});function OPe(e,t){return e[t]|e[t+1]<<8}function tW(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function lae(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid ARJ archive: truncated ${s}`)}function tQr(e){if(e===0)return;let t=1980+(e>>>25&127),n=e>>>21&15,s=e>>>16&31,o=e>>>11&31,r=e>>>5&63,i=(e&31)*2;if(n<1||n>12||s<1||s>31||o>23||r>59||i>59)return;return Date.UTC(t,n-1,s,o,r,i)}function Q$n(e,t,n,s){let o=t;while(o<n&&e[o]!==0)o++;if(o===n)throw new G(`Invalid ARJ ${s}: missing terminator`);return{value:eQr.decode(e.subarray(t,o)),next:o+1}}function Z$n(e,t,n){if(lae(e,t,t+4,"header signature"),e[t]!==e3n||e[t+1]!==t3n)throw new G("Invalid ARJ header signature");let s=OPe(e,t+2);if(s===0)return{bodyStart:t+4,bodySize:0,nextOffset:t+4,metadataSize:4,isEnd:!0};if(s<30||s>n3n)throw new G("Invalid ARJ basic header size");let o=t+4,r=o+s;if(lae(e,o,r+4,"basic header"),sa(e.subarray(o,r))!==tW(e,r))throw new G("Invalid ARJ basic header CRC32");let i=r+4,a=0;for(;;){lae(e,i,i+2,"extended header size");let l=OPe(e,i);if(i+=2,l===0)break;if(++a>65535)throw new G("Invalid ARJ archive: too many extended headers");if(lae(e,i,i+l+4,"extended header"),sa(e.subarray(i,i+l))!==tW(e,i+l))throw new G("Invalid ARJ extended header CRC32");i+=l+4,Ns(i-t,n.limits,"header metadata")}return{bodyStart:o,bodySize:s,nextOffset:i,metadataSize:i-t,isEnd:!1}}class s3n{#e;#t=0;constructor(e){this.#e=e}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#t+e>this.#e.byteLength*8)throw new G("Invalid ARJ method-4 compressed data: truncated bitstream");let t=0;for(let n=0;n<e;n++){let s=this.#t++;t=t*2+(this.#e[s>>>3]>>>7-(s&7)&1)}return t}assertZeroPadding(){while(this.#t<this.#e.byteLength*8)if(this.read(1)!==0)throw new G("Invalid ARJ method-4 compressed data: non-zero trailing bits")}}function nQr(e,t){let n=new s3n(e),s=new Uint8Array(t),o=0;while(o<t){let r=0,i=0;for(;i<7;i++){if(n.read(1)===0)break;r+=2**i}if(i!==0)r+=n.read(i);if(r===0){s[o++]=n.read(8);continue}let a=r+2;if(a>t-o)throw new G("Invalid ARJ method-4 compressed data: match exceeds declared size");let l=0,u=9;for(;u<13;u++){if(n.read(1)===0)break;l+=2**u}if(l+=n.read(u),l>=26624||l>=o)throw new G("Invalid ARJ method-4 compressed data: history distance is out of range");let p=o-l-1;for(let c=0;c<a;c++)s[o++]=s[p++]}return n.assertZeroPadding(),s}class o3n{#e;#t;#n;#s;#o;constructor(e,t,n,s,o){this.#e=e,this.#t=t,this.#n=n,this.#s=s,this.#o=o}async read(e,t){let n=this.#e.subarray(this.#t,this.#t+this.#n),s;switch(this.#s){case 0:if(n.byteLength!==e)throw new G(`ARJ member '${t}' has inconsistent stored size`);s=n.slice();break;case 1:case 2:case 3:s=xY(n,e,26624,5,17,`ARJ method ${this.#s}`);break;case 4:s=nQr(n,e);break;case 8:case 9:if(e!==0||n.byteLength!==0)throw new G(`ARJ member '${t}' has invalid no-data method sizes`);s=new Uint8Array(0);break;default:throw new G(`ARJ member '${t}' uses unsupported compression method ${this.#s}`)}if(s.byteLength!==e)throw new G(`ARJ member '${t}' extracted to an unexpected size`);if(this.#s!==8&&sa(s)!==this.#o)throw new G(`ARJ member '${t}' failed CRC32 verification`);return s}}function sQr(e,t){let n=e.replaceAll("\\","/");if(t===1)n=n.replaceAll(">","/");else if(t===4)n=n.replaceAll(":","/");return n}function sgt(e){if(e.byteLength<34||e[0]!==e3n||e[1]!==t3n)return!1;let t=OPe(e,2);if(t<30||t>n3n||e.byteLength<t+8)return!1;let n=e.subarray(4,4+t);return n[0]>=30&&n[0]<=t&&n[6]===2&&sa(n)===tW(e,4+t)}var e3n=96,t3n=234,n3n=2600,eQr,r3n=async(e,t)=>{ki(e.size,t.limits);let n;try{n=await XA(e)}catch(p){if(p instanceof G)throw p;throw new G(`Unable to read ARJ archive: ${p instanceof Error?p.message:String(p)}`)}if(n.byteLength!==e.size)throw new G("Invalid ARJ archive: truncated data");if(!sgt(n))throw new G("Invalid ARJ archive header");let s=Z$n(n,0,t);if(s.isEnd)throw new G("Invalid ARJ archive: missing main header");let o=n[s.bodyStart];if(o<30||o>s.bodySize||n[s.bodyStart+6]!==2)throw new G("Invalid ARJ main header");let r=n[s.bodyStart+4];if((r&1)!==0)throw new G("Encrypted ARJ archives are unsupported");if((r&4)!==0)throw new G("Multi-volume ARJ archives are unsupported");let i=[],a=s.nextOffset,l=s.metadataSize,u=0;for(;;){let p=Z$n(n,a,t);if(l+=p.metadataSize,Ns(l,t.limits,"index"),p.isEnd)break;cr(++u,t.limits);let c=n[p.bodyStart];if(c<30||c>p.bodySize)throw new G("Invalid ARJ local header");let d=n[p.bodyStart+3],f=n[p.bodyStart+4],m=n[p.bodyStart+5],g=n[p.bodyStart+6];if((f&1)!==0)throw new G("Encrypted ARJ members are unsupported");if((f&12)!==0)throw new G("Multi-volume ARJ members are unsupported");let h=tW(n,p.bodyStart+12),T=tW(n,p.bodyStart+16),R=tW(n,p.bodyStart+20),y=OPe(n,p.bodyStart+26),C=Q$n(n,p.bodyStart+c,p.bodyStart+p.bodySize,"filename");Q$n(n,C.next,p.bodyStart+p.bodySize,"comment"),wo(C.next-(p.bodyStart+c)-1,"member path",t.limits.maxPathBytes);let S=sQr(C.value,d);nf(S,"member path",t.limits.maxPathBytes),fa(T,S||"<unnamed>",t.limits);let E=p.nextOffset;lae(n,E,E+h,"member data"),a=E+h;let A=Lr(S);if(!A)continue;let k=g===3,x;if((d===2||d===8)&&y!==0)x=(k?16384:32768)|y&4095;let M=tW(n,p.bodyStart+8),O=d===2||d===8?M===0?void 0:M*1000:tQr(M);i.push({path:A,isDirectory:k,size:k?0:T,mtimeMs:O,mode:x,storage:k?void 0:{type:"member",source:new o3n(n,E,h,m,R)}})}if(u===0)throw new G("Invalid ARJ archive: no members");return i};var i3n=w(()=>{pO();Qr();Hp();ngt();sf();JA();eQr=new TextDecoder("windows-1252")});import*as l3n from"node:path";function Wi(e){return new G(`Invalid ASAR archive: ${e}`)}function NPe(e){return e instanceof Error&&e.message?e.message:String(e)}function ogt(e){return e+(4-e%4)%4}function uae(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function aQr(e,t,n){if(e===void 0)return;let s=br(t);if(!uae(e))throw Wi(`file '${s}' has an invalid integrity record`);if(e.algorithm!=="SHA256")throw Wi(`file '${s}' uses unsupported integrity algorithm '${String(e.algorithm)}'`);if(typeof e.hash!=="string"||!a3n.test(e.hash))throw Wi(`file '${s}' has an invalid integrity hash`);if(typeof e.blockSize!=="number"||!Number.isSafeInteger(e.blockSize)||e.blockSize<=0)throw Wi(`file '${s}' has an invalid integrity block size`);if(!Array.isArray(e.blocks))throw Wi(`file '${s}' has invalid integrity blocks`);let o=Math.max(1,Math.ceil(n/e.blockSize));if(e.blocks.length!==o)throw Wi(`file '${s}' has an inconsistent integrity block count`);for(let r of e.blocks)if(typeof r!=="string"||!a3n.test(r))throw Wi(`file '${s}' has an invalid integrity block hash`);return{algorithm:"SHA256",hash:e.hash.toLowerCase()}}function u3n(e,t,n){if(!t)return;if(new Bun.CryptoHasher("sha256").update(e).digest("hex")!==t.hash)throw new G(`ASAR member '${br(n)}' failed SHA256 integrity verification`)}class p3n{#e;#t;#n;#s;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}async read(e,t){if(e!==this.#n)throw new G(`ASAR member '${br(t)}' has an inconsistent size`);let n;try{n=await this.#e.read(this.#t,this.#t+this.#n)}catch(s){if(s instanceof G)throw s;throw new G(`Failed to read ASAR member '${br(t)}': ${NPe(s)}`)}if(n.byteLength!==this.#n)throw new G(`ASAR member '${br(t)}' is truncated`);return u3n(n,this.#s,t),n}}class c3n{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){let n=br(t);if(e!==this.#t)throw new G(`ASAR member '${n}' has an inconsistent size`);if(!this.#e)throw new G(`Archive file '${n}' is unpacked and requires a filesystem-backed ASAR archive`);let s=Bun.file(this.#e),o=await s.stat().catch(()=>{throw new G(`Unpacked ASAR file '${n}' was not found`)});if(o.isDirectory())throw new G(`Unpacked ASAR file '${n}' is a directory`);if(o.size!==this.#t)throw new G(`Unpacked ASAR file '${n}' size differs from its archive header (${o.size} != ${this.#t} bytes)`);let r;try{r=await s.bytes()}catch(i){throw new G(`Failed to read unpacked ASAR file '${n}': ${NPe(i)}`)}if(r.byteLength!==this.#t)throw new G(`Unpacked ASAR file '${n}' changed while being read`);return u3n(r,this.#n,t),r}}async function lQr(e,t){if(!Number.isSafeInteger(e.size)||e.size<PPe)throw Wi("truncated header");let n=await e.read(0,MY);if(n.byteLength!==MY)throw Wi("truncated size pickle");if(wn(n,0)!==4)throw Wi("invalid size pickle");let s=wn(n,4);if(s<pae)throw Wi("header is too small");Ns(s,t.limits,"ASAR header");let o=MY+s;if(!Number.isSafeInteger(o)||o>e.size)throw Wi("header extends beyond archive boundary");let r=await e.read(MY,o);if(r.byteLength!==s)throw Wi("truncated header pickle");let i=wn(r,0),a=wn(r,4);if(i+4!==s||i!==4+ogt(a))throw Wi("inconsistent pickle lengths");let l=pae+a;for(let g=l;g<r.byteLength;g++)if(r[g]!==0)throw Wi("non-zero pickle string padding");let u;try{u=oQr.decode(r.subarray(pae,l))}catch{throw Wi("header is not valid UTF-8")}let p;try{p=JSON.parse(u)}catch{throw Wi("header is not valid JSON")}if(!uae(p)||!uae(p.files))throw Wi("root must contain a files object");let c=[],d=[],f=0,m=(g,h,T)=>{for(let R in g)cr(++f,t.limits),d.push({parentPath:h,parentPathBytes:T,name:R,node:g[R]})};m(p.files,"",0);while(d.length>0){let g=d.pop(),h=Buffer.byteLength(g.name,"utf-8");if(wo(h,"entry name",t.limits.maxPathBytes),g.name.length===0||g.name==="."||g.name===".."||g.name.includes("/")||g.name.includes("\\")||g.name.includes("\x00"))throw Wi(`invalid entry name '${br(g.name)}'`);if(!uae(g.node))throw Wi(`entry '${br(g.name)}' must be an object`);let T=g.parentPathBytes+(g.parentPath?1:0)+h;wo(T,"member path",t.limits.maxPathBytes);let R=g.parentPath?`${g.parentPath}/${g.name}`:g.name;if(Lr(R)!==R)throw Wi(`invalid entry path '${br(R)}'`);let C=br(R);if(g.node.unpacked!==void 0&&typeof g.node.unpacked!=="boolean")throw Wi(`entry '${C}' has a non-boolean unpacked flag`);if("link"in g.node){if(typeof g.node.link!=="string"||g.node.link.length===0)throw Wi(`entry '${C}' has an invalid link target`);nf(g.node.link,"link target",t.limits.maxPathBytes);let O=g.node.link.replace(/\\/g,"/"),v=O.startsWith("/")||/^[A-Za-z]:\//.test(O)?void 0:tf(O);if(v===void 0)throw Wi(`entry '${C}' links outside the archive`);c.push({path:R,isDirectory:!1,size:0,storage:{type:"link",targetPath:v,resolveTarget:!0}});continue}if("files"in g.node){if(!uae(g.node.files))throw Wi(`directory '${C}' must contain a files object`);c.push({path:R,isDirectory:!0,size:0}),m(g.node.files,R,T);continue}let S=g.node.size;if(typeof S!=="number"||!Number.isSafeInteger(S)||S<0)throw Wi(`file '${C}' has an invalid size`);if(fa(S,R,t.limits),g.node.executable!==void 0&&typeof g.node.executable!=="boolean")throw Wi(`file '${C}' has a non-boolean executable flag`);let E=typeof g.node.executable==="boolean"?iQr|(g.node.executable?493:420):void 0,A=aQr(g.node.integrity,R,S);if(g.node.unpacked===!0){let O=t.archivePath?l3n.join(`${t.archivePath}.unpacked`,...R.split("/")):void 0;c.push({path:R,isDirectory:!1,size:S,mode:E,storage:{type:"member",source:new c3n(O,S,A)}});continue}if(typeof g.node.offset!=="string"||!/^\d+$/.test(g.node.offset))throw Wi(`file '${C}' has an invalid offset`);let k=Number(g.node.offset),x=o+k,M=x+S;if(!Number.isSafeInteger(k)||!Number.isSafeInteger(x)||!Number.isSafeInteger(M)||M>e.size)throw Wi(`file '${C}' extends beyond archive boundary`);c.push({path:R,isDirectory:!1,size:S,mode:E,storage:{type:"member",source:new p3n(e,x,S,A)}})}return c}function f3n(e){if(e.byteLength<PPe+1)return!1;let t=wn(e,0),n=wn(e,4),s=wn(e,8),o=wn(e,12);return t===4&&n>=pae&&n===s+4&&s===4+ogt(o)&&o>0&&e[PPe]===123}function uQr(e){let t=e.replace(/\\/g,"/"),n=Lr(t);if(n===void 0||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.includes("\x00")||t.split("/").some((s)=>!s||s==="."||s===".."))throw new G(`Invalid ASAR member path '${br(e)}'`);return n}async function m3n(e){try{let t={files:Object.create(null)},n=[],s=0;for(let d of e){if(!Array.isArray(d)||d.length!==2||typeof d[0]!=="string"||!(d[1]instanceof Uint8Array))throw new G("ASAR members must be [path, Uint8Array] pairs");let f=uQr(d[0]),m=f.split("/"),g=t;for(let T=0;T<m.length-1;T++){let R=m[T],y=g.files[R];if(y&&!("files"in y))throw new G(`ASAR member path '${f}' crosses file '${m.slice(0,T+1).join("/")}'`);if(!y)g.files[R]={files:Object.create(null)};g=g.files[R]}let h=m.at(-1);if(g.files[h])throw new G(`Duplicate or conflicting ASAR member path '${f}'`);if(!Number.isSafeInteger(d[1].byteLength)||!Number.isSafeInteger(s+d[1].byteLength))throw new G("ASAR payload is too large to encode safely");g.files[h]={size:d[1].byteLength,offset:String(s)},n.push(d[1]),s+=d[1].byteLength}let o=rQr.encode(JSON.stringify(t)),i=4+ogt(o.byteLength),a=4+i;if(o.byteLength>4294967295||a>4294967295)throw new G("ASAR header is too large to encode");let l=MY+a,u=l+s;if(!Number.isSafeInteger(u))throw new G("ASAR archive is too large to encode safely");let p;try{p=new Uint8Array(u)}catch{throw new G("ASAR archive is too large to encode in memory")}Cl(p,0,4),Cl(p,4,a),Cl(p,8,i),Cl(p,12,o.byteLength),p.set(o,PPe);let c=l;for(let d of n)p.set(d,c),c+=d.byteLength;return p}catch(t){if(t instanceof G)throw t;throw new G(`Failed to encode ASAR archive: ${NPe(t)}`)}}var oQr,rQr,MY=8,pae=8,PPe,iQr=32768,a3n,d3n=async(e,t)=>{try{return await lQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(`Failed to read ASAR archive: ${NPe(n)}`)}};var rgt=w(()=>{Lh();Qr();Hp();sf();oQr=new TextDecoder("utf-8",{fatal:!0}),rQr=new TextEncoder,PPe=MY+pae,a3n=/^[0-9a-f]{64}$/i});class T3n{#e;#t=0;#n=0;#s=0;constructor(e){this.#e=e}readBits(e){let t=0,n=e;while(n>0){if(this.#s===0){if(this.#t+2>this.#e.byteLength)throw new G("Invalid CAB archive: truncated LZX bitstream");this.#n=this.#e[this.#t]|this.#e[this.#t+1]<<8,this.#t+=2,this.#s=16}let s=Math.min(n,this.#s);t=t*2**s+(this.#n>>>this.#s-s&2**s-1),this.#s-=s,n-=s}return t}alignWord(){this.#s=0}readByte(){if(this.#s!==0)throw new G("Invalid CAB archive: misaligned LZX byte stream");if(this.#t>=this.#e.byteLength)throw new G("Invalid CAB archive: truncated LZX data");return this.#e[this.#t++]}readUInt32LE(){let e=this.readByte(),t=this.readByte(),n=this.readByte(),s=this.readByte();return(e|t<<8|n<<16|s<<24)>>>0}}class cae{#e=new Uint32Array(17);#t=new Uint32Array(17);#n=new Uint32Array(17);#s;empty;constructor(e,t=!1){let n=0;for(let i of e){if(i>16)throw new G("Invalid CAB archive: invalid LZX Huffman code length");if(i!==0)this.#e[i]++,n++}if(this.empty=n===0,this.empty&&!t)throw new G("Invalid CAB archive: empty LZX Huffman tree");let s=0,o=0;for(let i=1;i<=16;i++){if(s=(s+this.#e[i-1])*2,s+this.#e[i]>2**i)throw new G("Invalid CAB archive: oversubscribed LZX Huffman tree");this.#t[i]=s,this.#n[i]=o,o+=this.#e[i]}this.#s=new Uint16Array(n);let r=this.#n.slice();for(let i=0;i<e.byteLength;i++){let a=e[i];if(a!==0)this.#s[r[a]]=i;r[a]++}}decode(e){if(this.empty)throw new G("Invalid CAB archive: LZX stream uses an empty Huffman tree");let t=0;for(let n=1;n<=16;n++){t=t*2+e.readBits(1);let s=t-this.#t[n];if(s>=0&&s<this.#e[n])return this.#s[this.#n[n]+s]}throw new G("Invalid CAB archive: invalid LZX Huffman symbol")}}function igt(e,t,n,s){let o=new Uint8Array(20);for(let a=0;a<o.byteLength;a++)o[a]=e.readBits(4);let r=new cae(o),i=n;while(i<s){let a=r.decode(e);if(a===17||a===18){let l=e.readBits(a===17?4:5)+(a===17?4:20);if(i+l>s)throw new G("Invalid CAB archive: LZX code-length run exceeds its tree");t.fill(0,i,i+l),i+=l;continue}if(a===19){let l=e.readBits(1)+4;if(i+l>s)throw new G("Invalid CAB archive: LZX code-length run exceeds its tree");let u=r.decode(e),p=(t[i]-u+17)%17;t.fill(p,i,i+l),i+=l;continue}t[i]=(t[i]-a+17)%17,i++}}function h3n(e){return e>2147483647?e-4294967296:e}class agt{#e;#t;#n;#s;#o=new Uint8Array(dQr);#r;#a;#i;#l=0;#u=0;#p=0;#c=1;#d=1;#f=1;#m=!1;#g=0;#h=!1;#T=0;#R=0;#C=0;#y=!1;constructor(e){if(!Number.isInteger(e)||e<15||e>21)throw new G(`Unsupported CAB LZX window size: ${e} bits (expected 15-21)`);this.#e=new Uint8Array(2**e);let t=fQr[e-15];this.#s=new Uint8Array(256+t*8),this.#n=new Uint8Array(t),this.#t=new Uint32Array(t);for(let n=0;n<t;n++)if(this.#n[n]=n<4?0:Math.min(17,Math.floor(n/2)-1),n>0)this.#t[n]=this.#t[n-1]+2**this.#n[n-1]}decompressFrame(e,t){if(!Number.isInteger(t)||t<0||t>pQr)throw new G(`Invalid CAB archive: LZX frame size ${t} exceeds 32768 bytes`);if(t===0)return new Uint8Array(0);let n=new T3n(e);if(!this.#m){if(n.readBits(1)!==0){let i=n.readBits(16),a=n.readBits(16);this.#g=h3n(i*65536+a>>>0)}this.#m=!0}let s=new Uint8Array(t),o=0;while(o<t){if(this.#C===0)this.#b(n);let i=Math.min(this.#C,t-o),a=this.#w(n,s,o,i);if(a!==i)throw new G("Invalid CAB archive: LZX block produced the wrong byte count");o+=a,this.#C-=a}if(this.#C===0&&this.#T===3&&this.#y)n.readByte(),this.#y=!1;n.alignWord();let r=this.#k(s);return this.#p++,r}#b(e){if(this.#T===3&&this.#y)e.readByte();if(this.#y=!1,this.#T=e.readBits(3),this.#R=e.readBits(16)*256+e.readBits(8),this.#R===0)throw new G("Invalid CAB archive: zero-length LZX block");if(this.#C=this.#R,this.#T===1||this.#T===2){if(this.#T===2){let t=new Uint8Array(8);for(let n=0;n<t.byteLength;n++)t[n]=e.readBits(3);this.#i=new cae(t)}if(igt(e,this.#s,0,256),igt(e,this.#s,256,this.#s.byteLength),this.#r=new cae(this.#s),this.#s[232]!==0)this.#h=!0;igt(e,this.#o,0,this.#o.byteLength),this.#a=new cae(this.#o,!0);return}if(this.#T===3){if(this.#h=!0,e.alignWord(),this.#c=e.readUInt32LE(),this.#d=e.readUInt32LE(),this.#f=e.readUInt32LE(),this.#c===0||this.#d===0||this.#f===0)throw new G("Invalid CAB archive: invalid LZX repeated offset");this.#y=(this.#R&1)!==0;return}throw new G(`Invalid CAB archive: unsupported LZX block type ${this.#T}`)}#w(e,t,n,s){if(this.#T===3){for(let r=0;r<s;r++)this.#S(e.readByte(),t,n+r);return s}if(!this.#r||!this.#a)throw new G("Invalid CAB archive: missing LZX decode trees");let o=0;while(o<s){let r=this.#r.decode(e);if(r<256){this.#S(r,t,n+o),o++;continue}let i=r-256,a=i&g3n;if(a===g3n)a+=this.#a.decode(e);if(a+=cQr,a>s-o||a>this.#C-o)throw new G("Invalid CAB archive: LZX match crosses a frame or block boundary");let l=i>>>3,u;if(l===0)u=this.#c;else if(l===1)u=this.#d,this.#d=this.#c,this.#c=u;else if(l===2)u=this.#f,this.#f=this.#c,this.#c=u;else{if(l>=this.#t.byteLength)throw new G("Invalid CAB archive: LZX position slot is out of range");let p=this.#n[l];if(u=this.#t[l]-2,this.#T===2&&p>=3){if(p>3)u+=e.readBits(p-3)*8;if(!this.#i)throw new G("Invalid CAB archive: missing LZX aligned tree");u+=this.#i.decode(e)}else if(p!==0)u+=e.readBits(p);this.#f=this.#d,this.#d=this.#c,this.#c=u}if(u<=0||u>Math.min(this.#u,this.#e.byteLength))throw new G("Invalid CAB archive: LZX match offset exceeds available history");for(let p=0;p<a;p++){let c=(this.#l-u+this.#e.byteLength)%this.#e.byteLength;this.#S(this.#e[c],t,n+o+p)}o+=a}return o}#S(e,t,n){t[n]=e,this.#e[this.#l]=e,this.#l=(this.#l+1)%this.#e.byteLength,this.#u++}#k(e){if(!this.#h||this.#g===0||this.#p>=32768||e.byteLength<=10)return e;let t=e.slice(),n=0,s=this.#u-e.byteLength,o=t.byteLength-10;while(n<o){if(t[n++]!==232){s++;continue}let r=h3n((t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0);if(r>=-s&&r<this.#g){let i=r>=0?r-s:r+this.#g;t[n]=i&255,t[n+1]=i>>>8&255,t[n+2]=i>>>16&255,t[n+3]=i>>>24&255}n+=4,s+=5}return t}}var pQr=32768,cQr=2,g3n=7,dQr=249,fQr;var R3n=w(()=>{Qr();fQr=[30,32,34,36,38,42,50]});import*as S3n from"node:zlib";async function dae(e,t,n,s=e.size){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>s)throw new G("Invalid CAB archive: metadata range is out of bounds");let o;try{o=await e.read(t,n)}catch(r){if(r instanceof G)throw r;throw new G(`Unable to read CAB archive: ${r instanceof Error?r.message:String(r)}`)}if(o.byteLength!==n-t)throw new G("Invalid CAB archive: truncated data");return o}function b3n(e){return e.byteLength>=4&&e[0]===77&&e[1]===83&&e[2]===67&&e[3]===70}function C3n(e,t=0){let n=t>>>0,s=0;while(s+4<=e.byteLength)n^=wn(e,s),s+=4;let o=e.byteLength-s,r=0;if(o===3)r=e[s]<<16|e[s+1]<<8|e[s+2];else if(o===2)r=e[s]<<8|e[s+1];else if(o===1)r=e[s];return(n^r)>>>0}function SQr(e,t){try{return t?yQr.decode(e):CQr.decode(e)}catch{throw new G("Invalid CAB archive: file name is not valid UTF-8")}}function bQr(e,t){if(e===0&&t===0)return;let n=1980+(e>>>9),s=e>>>5&15,o=e&31,r=t>>>11,i=t>>>5&63,a=(t&31)*2;if(s<1||s>12||o<1||o>31||r>23||i>59||a>59)throw new G("Invalid CAB archive: file has an invalid DOS timestamp");return new Date(n,s-1,o,r,i,a).getTime()}function wQr(e,t){if(t)return 16877;let n=e&gQr?292:420;if(e&TQr)n|=73;return 32768|n}class w3n{#e;#t;#n;#s;#o;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}readAll(){return this.#o??=this.#r(),this.#o}async#r(){let e=this.#t;if(e.method===2)throw new G(`Unsupported CAB compression method: Quantum (level ${e.parameter})`);if(e.method>3)throw new G(`Unsupported CAB compression method: ${e.method}`);if(e.method===3&&(e.parameter<15||e.parameter>21))throw new G(`Unsupported CAB LZX window size: ${e.parameter} bits (expected 15-21)`);let t=e.dataEnd-e.dataStart;ki(t,this.#s);let n=await dae(this.#e,e.dataStart,e.dataEnd),s=0,o=0;for(let l=0;l<e.blockCount;l++){if(s+lgt+this.#n>n.byteLength)throw new G("Invalid CAB archive: truncated CFDATA header");let u=Rs(n,s+4),p=Rs(n,s+6);if(p===0)throw new G("Unsupported multi-volume CAB archive: split CFDATA block");if(p>y3n)throw new G(`Invalid CAB archive: CFDATA expands to ${p} bytes (maximum 32768)`);let c=s+lgt+this.#n,d=c+u;if(d>n.byteLength)throw new G("Invalid CAB archive: truncated CFDATA payload");let f=wn(n,s);if(f!==0){let m=C3n(n.subarray(c,d));if(C3n(n.subarray(s+4,c),m)!==f)throw new G(`Invalid CAB archive: CFDATA block ${l} checksum mismatch`)}o+=p,ki(o,this.#s),s=d}if(o<e.requiredSize)throw new G("Invalid CAB archive: folder data is shorter than its file table declares");let r=new Uint8Array(o),i=e.method===3?new agt(e.parameter):void 0;s=0;let a=0;for(let l=0;l<e.blockCount;l++){let u=Rs(n,s+4),p=Rs(n,s+6),c=s+lgt+this.#n,d=c+u,f=n.subarray(c,d),m;if(e.method===0){if(u!==p)throw new G("Invalid CAB archive: uncompressed CFDATA sizes do not match");m=f}else if(e.method===1){if(f.byteLength<2||f[0]!==67||f[1]!==75)throw new G("Invalid CAB archive: MSZIP block is missing its CK signature");try{let g=r.subarray(Math.max(0,a-y3n),a);m=new Uint8Array(S3n.inflateRawSync(f.subarray(2),{dictionary:g,maxOutputLength:p}))}catch(g){throw new G(`Invalid CAB archive: MSZIP decompression failed${g instanceof Error?`: ${g.message}`:""}`)}}else m=i.decompressFrame(f,p);if(m.byteLength!==p)throw new G(`Invalid CAB archive: CFDATA block ${l} produced ${m.byteLength} bytes, expected ${p}`);r.set(m,a),a+=m.byteLength,s=d}return r}}class E3n{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){if(e!==this.#n)throw new G(`Invalid CAB archive: size changed while extracting '${t}'`);let n=await this.#e.readAll(),s=this.#t+e;if(!Number.isSafeInteger(s)||this.#t<0||s>n.byteLength)throw new G(`Invalid CAB archive: member '${t}' is outside its folder data`);return n.slice(this.#t,s)}}async function EQr(e,t){if(e.size<nW)throw new G("Invalid CAB archive: truncated CFHEADER");let n=await dae(e,0,nW);if(!b3n(n))throw new G(`Invalid CAB archive: expected ${mQr} signature`);if(wn(n,4)!==0||wn(n,12)!==0||wn(n,20)!==0)throw new G("Invalid CAB archive: reserved CFHEADER fields must be zero");let s=wn(n,8);if(s<nW||s>e.size)throw new G("Invalid CAB archive: declared cabinet size is out of bounds");let o=wn(n,16);if(o<nW||o>s)throw new G("Invalid CAB archive: CFFILE table offset is out of bounds");if(n[24]!==3||n[25]!==1)throw new G(`Unsupported CAB format version ${n[25]}.${n[24]} (expected 1.3)`);let r=Rs(n,26),i=Rs(n,28),a=Rs(n,30);if(a&3)throw new G("Unsupported multi-volume CAB archive (previous/next cabinet link)");if(cr(r+i,t.limits),r===0&&i!==0)throw new G("Invalid CAB archive: files exist without a folder");let l=0,u=0,p=0,c=nW;if(a&4){let S=await dae(e,nW,nW+4,s);if(l=Rs(S,0),u=S[2],p=S[3],l>60000)throw new G("Invalid CAB archive: CFHEADER reserve area exceeds 60000 bytes");c+=4+l}let d=8+u,f=c+r*d;if(!Number.isSafeInteger(f)||f>s||f>o)throw new G("Invalid CAB archive: CFFOLDER table is out of bounds");Ns(f,t.limits,"CAB header");let m=await dae(e,0,f,s),g=[];for(let S=0;S<r;S++){let E=c+S*d,A=Rs(m,E+6);g.push({dataStart:wn(m,E),dataEnd:s,blockCount:Rs(m,E+4),method:A&15,parameter:A>>>8,requiredSize:0})}for(let S of g){if(S.dataStart<f||S.dataStart>s)throw new G("Invalid CAB archive: CFFOLDER data offset is out of bounds");for(let E of g)if(E.dataStart>S.dataStart&&E.dataStart<S.dataEnd)S.dataEnd=E.dataStart}let h=g.reduce((S,E)=>Math.min(S,E.dataStart),s);if(o>h)throw new G("Invalid CAB archive: CFFILE table overlaps folder data");Ns(f+(h-o),t.limits,"CAB index");let T=await dae(e,o,h,s),R=g.map((S)=>new w3n(e,S,p,t.limits)),y=[],C=0;for(let S=0;S<i;S++){if(C+16>T.byteLength)throw new G("Invalid CAB archive: truncated CFFILE entry");let E=wn(T,C),A=wn(T,C+4),k=Rs(T,C+8),x=Rs(T,C+10),M=Rs(T,C+12),O=Rs(T,C+14);C+=16;let v=T.indexOf(0,C);if(v<0)throw new G("Invalid CAB archive: unterminated CFFILE name");let P=T.subarray(C,v);if(P.byteLength>256)throw new G("Invalid CAB archive: CFFILE name exceeds 256 bytes");if(wo(P.byteLength,"member path",t.limits.maxPathBytes),C=v+1,k>=65533)throw new G("Unsupported multi-volume CAB archive: continued file");if(k>=R.length)throw new G("Invalid CAB archive: CFFILE references a missing folder");let N=SQr(P,(O&RQr)!==0);fa(E,N,t.limits);let F=A+E;if(!Number.isSafeInteger(F))throw new G("Invalid CAB archive: CFFILE range is too large");if(F>g[k].requiredSize)g[k].requiredSize=F;let _=Lr(N);if(!_)continue;let L=(O&hQr)!==0;y.push({path:_,isDirectory:L,size:E,mtimeMs:bQr(x,M),mode:wQr(O,L),storage:L?void 0:{type:"member",source:new E3n(R[k],A,E)}})}for(let S of g)ki(S.requiredSize,t.limits);return y}function k3n(e){return b3n(e)}var mQr="MSCF",nW=36,lgt=8,y3n=32768,gQr=1,hQr=16,TQr=64,RQr=128,yQr,CQr,A3n=async(e,t)=>{try{return await EQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(`Invalid CAB archive: ${n instanceof Error?n.message:String(n)}`)}};var I3n=w(()=>{Lh();R3n();Qr();Hp();sf();yQr=new TextDecoder("utf-8",{fatal:!0}),CQr=new TextDecoder("windows-1252")});function OQr(){let e=new Uint32Array(256);for(let t=0;t<e.length;t++){let n=t<<24;for(let s=0;s<8;s++)n=(n&2147483648)!==0?n<<1^79764919:n<<1;e[t]=n>>>0}return e}function x3n(e,t){return(vQr[(e>>>24^t)&255]^e<<8)>>>0}class v3n{#e;#t=0;constructor(e){this.#e=e}get done(){return this.#t===this.#e.byteLength*8}readBit(){if(this.#t>=this.#e.byteLength*8)throw new G("Truncated bzip2 stream");let t=this.#e[this.#t>>>3]>>>7-(this.#t&7)&1;return this.#t++,t}readBits(e){let t=0;for(let n=0;n<e;n++)t=t*2+this.readBit();return t}readUint32(){return this.readBits(16)*65536+this.readBits(16)>>>0}readMarker(){return[this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8)]}alignToByte(){while((this.#t&7)!==0)if(this.readBit()!==0)throw new G("Invalid non-zero bzip2 stream padding")}}class O3n{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=new Uint8Array(Math.min(e,Math.max(64,Math.min(t*2,65536))))}push(e){this.#s(1),this.#t[this.#n++]=e}pushRepeated(e,t){this.#s(t),this.#t.fill(e,this.#n,this.#n+t),this.#n+=t}finish(){return this.#t.slice(0,this.#n)}#s(e){let t=this.#n+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new G(`Bzip2 output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let n=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(n>this.#e)n=this.#e;let s=new Uint8Array(n);s.set(this.#t.subarray(0,this.#n)),this.#t=s}}class P3n{#e=new Uint16Array(sW+1);#t=new Uint32Array(sW+1);#n=new Uint16Array(sW+1);#s;constructor(e){for(let o of e){if(o<1||o>sW)throw new G("Invalid bzip2 Huffman code length");this.#e[o]++}let t=0,n=0;for(let o=1;o<=sW;o++){if(t=(t+this.#e[o-1])*2,t+this.#e[o]>2**o)throw new G("Oversubscribed bzip2 Huffman table");this.#t[o]=t,this.#n[o]=n,n+=this.#e[o]}this.#s=new Uint16Array(e.length);let s=new Uint16Array(this.#n);for(let o=0;o<e.length;o++){let r=e[o];this.#s[s[r]]=o,s[r]++}}decode(e){let t=0;for(let n=1;n<=sW;n++){t=t*2+e.readBit();let s=t-this.#t[n];if(s>=0&&s<this.#e[n])return this.#s[this.#n[n]+s]}throw new G("Invalid bzip2 Huffman code")}}function M3n(e,t){return e.every((n,s)=>n===t[s])}function PQr(e){if(e.readBits(8)!==66||e.readBits(8)!==90||e.readBits(8)!==104)throw new G("Invalid bzip2 stream header");let t=e.readBits(8)-48;if(t<1||t>9)throw new G("Invalid bzip2 block-size level");return t*1e5}function NQr(e,t){let n=e.readBits(3);if(n<2||n>6)throw new G("Invalid bzip2 Huffman group count");let s=e.readBits(15);if(s<1||s>IQr)throw new G("Invalid bzip2 selector count");let o=new Uint8Array(s),r=new Uint8Array(n);for(let l=0;l<n;l++)r[l]=l;for(let l=0;l<s;l++){let u=0;while(e.readBit()!==0)if(u++,u>=n)throw new G("Invalid bzip2 selector MTF value");let p=r[u];o[l]=p,r.copyWithin(1,0,u),r[0]=p}let i=t.length+2,a=[];for(let l=0;l<n;l++){let u=new Uint8Array(i),p=e.readBits(5);for(let c=0;c<i;c++){while(e.readBit()!==0)if(p+=e.readBit()===0?1:-1,p<1||p>sW)throw new G("Invalid bzip2 Huffman code length");u[c]=p}a.push(new P3n(u))}return{selectors:o,tables:a}}function FQr(e,t,n,s,o){let r=new Uint8Array(n),i=new Uint8Array(t),a=0,l=0,u=0,p,c=()=>{if(u===0){if(l>=s.length)throw new G("Bzip2 block exhausted its Huffman selectors");p=o[s[l++]],u=xQr}return u--,p.decode(e)},d=(g,h)=>{if(h<0||a+h>t)throw new G("Bzip2 block exceeds its declared block-size level");i.fill(g,a,a+h),a+=h},f=n.length+1,m=c();while(m!==f){if(m===0||m===1){let T=0,R=1;do{if(T+=m===0?R:R*2,T>t||R>t)throw new G("Invalid bzip2 RLE run length");R*=2,m=c()}while(m===0||m===1);if(d(r[0],T),m===f)break}let g=m-1;if(g<0||g>=r.length)throw new G("Invalid bzip2 MTF symbol");let h=r[g];r.copyWithin(1,0,g),r[0]=h,d(h,1),m=c()}return i.slice(0,a)}function LQr(e,t){if(e.length===0||t<0||t>=e.length)throw new G("Invalid bzip2 BWT origin pointer");let n=new Uint32Array(257);for(let a of e)n[a+1]++;for(let a=1;a<n.length;a++)n[a]+=n[a-1];let s=new Uint32Array(n.subarray(0,256)),o=new Uint32Array(e.length);for(let a=0;a<e.length;a++){let l=e[a];o[s[l]]=a,s[l]++}let r=new Uint8Array(e.length),i=o[t];for(let a=0;a<r.length;a++)r[a]=e[i],i=o[i];return r}function _Qr(e,t,n){let s=4294967295,o=-1,r=0,i=0,a=0,l=(p)=>{n.push(p),s=x3n(s,p)},u=(p,c)=>{n.pushRepeated(p,c);for(let d=0;d<c;d++)s=x3n(s,p)};for(let p of e){if(t){if(a===0)a=MQr[i],i=i+1&511;if(a--,a===1)p^=1}if(r===4){u(o,p),r=0;continue}if(l(p),p===o)r++;else o=p,r=1}if(r===4)throw new G("Truncated bzip2 RLE run");return(s^4294967295)>>>0}function DQr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid bzip2 output limit");let n=new v3n(e),s=new O3n(t,e.byteLength);for(;;){let o=PQr(n),r=0;for(;;){let i=n.readMarker();if(M3n(i,AQr)){let y=n.readUint32();if(r!==y)throw new G("Bzip2 stream CRC mismatch");n.alignToByte();break}if(!M3n(i,kQr))throw new G("Invalid bzip2 block marker");let a=n.readUint32(),l=n.readBit()!==0,u=n.readBits(24),p=n.readBits(16),c=new Uint8Array(256),d=0;for(let y=0;y<16;y++){if((p&32768>>>y)===0)continue;for(let C=0;C<16;C++)if(n.readBit()!==0)c[d++]=y*16+C}if(d===0)throw new G("Bzip2 block has an empty symbol map");let f=c.slice(0,d),{selectors:m,tables:g}=NQr(n,f),h=FQr(n,o,f,m,g),T=LQr(h,u),R=_Qr(T,l,s);if(R!==a)throw new G("Bzip2 block CRC mismatch");r=((r<<1|r>>>31)^R)>>>0}if(n.done)return s.finish()}}function FPe(e){return e.byteLength>=4&&e[0]===66&&e[1]===90&&e[2]===104&&e[3]>=49&&e[3]<=57}async function fO(e,t){try{return DQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}}var kQr,AQr,sW=20,IQr=18002,xQr=50,MQr,vQr;var fae=w(()=>{Qr();kQr=[49,65,89,38,83,89],AQr=[23,114,69,56,80,144],MQr=new Uint16Array([619,720,127,481,931,816,813,233,566,247,985,724,205,454,863,491,741,242,949,214,733,859,335,708,621,574,73,654,730,472,419,436,278,496,867,210,399,680,480,51,878,465,811,169,869,675,611,697,867,561,862,687,507,283,482,129,807,591,733,623,150,238,59,379,684,877,625,169,643,105,170,607,520,932,727,476,693,425,174,647,73,122,335,530,442,853,695,249,445,515,909,545,703,919,874,474,882,500,594,612,641,801,220,162,819,984,589,513,495,799,161,604,958,533,221,400,386,867,600,782,382,596,414,171,516,375,682,485,911,276,98,553,163,354,666,933,424,341,533,870,227,730,475,186,263,647,537,686,600,224,469,68,770,919,190,373,294,822,808,206,184,943,795,384,383,461,404,758,839,887,715,67,618,276,204,918,873,777,604,560,951,160,578,722,79,804,96,409,713,940,652,934,970,447,318,353,859,672,112,785,645,863,803,350,139,93,354,99,820,908,609,772,154,274,580,184,79,626,630,742,653,282,762,623,680,81,927,626,789,125,411,521,938,300,821,78,343,175,128,250,170,774,972,275,999,639,495,78,352,126,857,956,358,619,580,124,737,594,701,612,669,112,134,694,363,992,809,743,168,974,944,375,748,52,600,747,642,182,862,81,344,805,988,739,511,655,814,334,249,515,897,955,664,981,649,113,974,459,893,228,433,837,553,268,926,240,102,654,459,51,686,754,806,760,493,403,415,394,687,700,946,670,656,610,738,392,760,799,887,653,978,321,576,617,626,502,894,679,243,440,680,879,194,572,640,724,926,56,204,700,707,151,457,449,797,195,791,558,945,679,297,59,87,824,713,663,412,693,342,606,134,108,571,364,631,212,174,643,304,329,343,97,430,751,497,314,983,374,822,928,140,206,73,263,980,736,876,478,430,305,170,514,364,692,829,82,855,953,676,246,369,970,294,750,807,827,150,790,288,923,804,378,215,828,592,281,565,555,710,82,896,831,547,261,524,462,293,465,502,56,661,821,976,991,658,869,905,758,745,193,768,550,608,933,378,286,215,979,792,961,61,688,793,644,986,403,106,366,905,644,372,567,466,434,645,210,389,550,919,135,780,773,635,389,707,100,626,958,165,504,920,176,193,713,857,265,203,50,668,108,645,990,626,197,510,357,358,850,858,364,936,638]),vQr=OQr()});import{promisify as N3n}from"node:util";import*as LPe from"node:zlib";function _Pe(e){return e.byteLength>=2&&e[0]===31&&e[1]===139}async function oW(e,t){try{return await qQr(e,{maxOutputLength:Math.max(t,1)})}catch(n){throw new G(n instanceof Error?n.message:String(n))}}function F3n(e){return HQr(e)}var HQr,qQr;var mae=w(()=>{Qr();HQr=N3n(LPe.gzip),qQr=N3n(LPe.gunzip)});class D3n{bytes;pos=0;range=4294967295;code=0;constructor(e){if(this.bytes=e,e.byteLength<5||e[0]!==0)throw new G("Invalid LZMA range-coded stream");for(let t=0;t<5;t++)this.code=(this.code<<8|e[this.pos++])>>>0}#e(){if(this.range<UQr){if(this.pos>=this.bytes.byteLength)throw new G("Invalid LZMA stream: truncated range data");this.range=this.range<<8>>>0,this.code=(this.code<<8|this.bytes[this.pos++])>>>0}}decodeBit(e,t){this.#e();let n=e[t],s=Math.imul(this.range>>>11,n)>>>0;if(this.code<s)return this.range=s,e[t]=n+(im-n>>>L3n),0;return this.range=this.range-s>>>0,this.code=this.code-s>>>0,e[t]=n-(n>>>L3n),1}decodeDirectBits(e){let t=0;for(let n=0;n<e;n++){this.#e(),this.range>>>=1;let s=0;if(this.code>=this.range)this.code=this.code-this.range>>>0,s=1;t=(t<<1|s)>>>0}return t}}function gg(e){let t=new Uint16Array(e);return t.fill(im>>>1),t}class cgt{choice=gg(2);low=gg(HPe<<3);mid=gg(HPe<<3);high=gg(256);reset(){this.choice.fill(im>>>1),this.low.fill(im>>>1),this.mid.fill(im>>>1),this.high.fill(im>>>1)}decode(e,t){if(e.decodeBit(this.choice,0)===0)return DPe(e,this.low,t<<3,3);if(e.decodeBit(this.choice,1)===0)return 8+DPe(e,this.mid,t<<3,3);return 16+DPe(e,this.high,0,8)}}function DPe(e,t,n,s){let o=1;for(let r=0;r<s;r++)o=o<<1|e.decodeBit(t,n+o);return o-(1<<s)}function _3n(e,t,n,s){let o=1,r=0;for(let i=0;i<s;i++){let a=e.decodeBit(t,n+o);o=o<<1|a,r|=a<<i}return r>>>0}function H3n(e){if(e.byteLength!==5)throw new G("Invalid LZMA properties: expected 5 bytes");let t=e[0];if(t>=225)throw new G("Invalid LZMA properties");let n=t%9;t=Math.floor(t/9);let s=t%5,o=Math.floor(t/5),r=(e[1]|e[2]<<8|e[3]<<16|e[4]<<24)>>>0;return{lc:n,lp:s,pb:o,dictionarySize:Math.max(r,4096)}}class qPe{#e;#t;#n=0;#s=0;#o=0;#r=0;#a=0;#i=0;#l=0;#u=1;#p=1;#c=1;#d=1;#f=gg(ugt);#m=gg(vY*HPe);#g=gg(vY);#h=gg(vY);#T=gg(vY);#R=gg(vY);#C=gg(vY*HPe);#y=gg(256);#b=gg(115);#w=gg(16);#S=new cgt;#k=new cgt;constructor(e,t){this.#e=e,this.#t=t.dictionarySize,this.setProperties(t.lc,t.lp,t.pb),this.resetDictionary()}get outputPos(){return this.#n}setProperties(e,t,n){if(e>8||t>4||n>4||e+t>12)throw new G("Invalid LZMA properties");this.#r=e,this.#a=t,this.#i=n;let s=ugt*2**(e+t);if(this.#f.length!==s)this.#f=gg(s)}resetDictionary(){this.#s=this.#n,this.#o=0,this.resetState()}resetState(){this.#l=0,this.#u=this.#p=this.#c=this.#d=1,this.#f.fill(im>>>1),this.#m.fill(im>>>1),this.#g.fill(im>>>1),this.#h.fill(im>>>1),this.#T.fill(im>>>1),this.#R.fill(im>>>1),this.#C.fill(im>>>1),this.#y.fill(im>>>1),this.#b.fill(im>>>1),this.#w.fill(im>>>1),this.#S.reset(),this.#k.reset()}appendUncompressed(e,t){if(t)this.resetDictionary();if(e.byteLength>this.#e.byteLength-this.#n)throw new G("LZMA2 output exceeds its limit");this.#e.set(e,this.#n),this.#n+=e.byteLength,this.#o+=e.byteLength}decodeChunk(e,t,n=!1){if(!Number.isSafeInteger(t)||t<0||t>this.#e.byteLength-this.#n)throw new G("LZMA output exceeds its declared size");let s=this.#n+t,o=new D3n(e),r=(1<<this.#i)-1,i=(1<<this.#a)-1;while(this.#n<s||n){let a=this.#o&r;if(o.decodeBit(this.#m,(this.#l<<4)+a)===0){let u=this.#n===this.#s?0:this.#e[this.#n-1],p=(((this.#o&i)<<this.#r)+(u>>>8-this.#r))*ugt,c=1;if(this.#l>=7){this.#v(this.#u);let d=this.#e[this.#n-this.#u];while(c<256){let f=d>>>7&1;d=d<<1&255;let m=o.decodeBit(this.#f,p+(1+f<<8)+c);if(c=c<<1|m,f!==m)break}}while(c<256)c=c<<1|o.decodeBit(this.#f,p+c);if(this.#n>=s)throw new G("LZMA output exceeds its size limit before the end marker");this.#e[this.#n++]=c&255,this.#o++,this.#l=this.#l<4?0:this.#l<10?this.#l-3:this.#l-6;continue}let l;if(o.decodeBit(this.#g,this.#l)===1){if(o.decodeBit(this.#h,this.#l)===0){if(o.decodeBit(this.#C,(this.#l<<4)+a)===0){this.#l=this.#l<7?9:11,this.#E(this.#u,1,s);continue}}else{let u;if(o.decodeBit(this.#T,this.#l)===0)u=this.#p;else{if(o.decodeBit(this.#R,this.#l)===0)u=this.#c;else u=this.#d,this.#d=this.#c;this.#c=this.#p}this.#p=this.#u,this.#u=u}l=this.#k.decode(o,a)+pgt,this.#l=this.#l<7?8:11}else{this.#d=this.#c,this.#c=this.#p,this.#p=this.#u,l=this.#S.decode(o,a)+pgt,this.#l=this.#l<7?7:10;let u=Math.min(l-pgt,3),p=DPe(o,this.#y,u<<6,6),c;if(p<4)c=p;else{let d=(p>>>1)-1;if(c=(2|p&1)<<d>>>0,p<14)c=c+_3n(o,this.#b,c-p,d)>>>0;else if(c=c+(o.decodeDirectBits(d-4)<<4)>>>0,c=c+_3n(o,this.#w,0,4)>>>0,c===4294967295){if(n)return!0;throw new G("LZMA stream ended before its declared output size")}}this.#u=c+1>>>0}this.#E(this.#u,l,s)}return!1}#v(e){let t=this.#n-this.#s;if(e<1||e>t||e>this.#t)throw new G(`Invalid LZMA match distance ${e} with ${t} bytes available`)}#E(e,t,n){if(this.#v(e),t>n-this.#n)throw new G("LZMA match exceeds its declared output size");for(let s=0;s<t;s++)this.#e[this.#n]=this.#e[this.#n-e],this.#n++;this.#o+=t}}async function gae(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid LZMA output size");try{let s=new Uint8Array(n),o=new qPe(s,H3n(e));if(o.decodeChunk(t,n),o.outputPos!==n)throw new G("LZMA output size mismatch");return s}catch(s){if(s instanceof G)throw s;throw new G(`Invalid LZMA stream: ${s instanceof Error?s.message:String(s)}`)}}async function OY(e,t){if(e.byteLength<13)throw new G("Invalid LZMA-alone stream: truncated header");if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid LZMA output limit");let n=e.subarray(0,5),s=!0,o=0;for(let r=0;r<8;r++){let i=e[5+r];if(i!==255)s=!1;o+=i*2**(r*8)}if(!s){if(!Number.isSafeInteger(o)||o>t)throw new G("LZMA-alone output exceeds its size limit");return gae(n,e.subarray(13),o)}try{let r=new Uint8Array(t),i=new qPe(r,H3n(n));if(!i.decodeChunk(e.subarray(13),t,!0))throw new G("LZMA-alone output exceeds its size limit before the end marker");return r.subarray(0,i.outputPos)}catch(r){if(r instanceof G)throw r;throw new G(`Invalid LZMA-alone stream: ${r instanceof Error?r.message:String(r)}`)}}async function UPe(e,t,n){if(!Number.isInteger(e)||e<0||e>40)throw new G("Unsupported LZMA2 dictionary property");if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid LZMA2 output limit");let s=e===40?4294967295:(2|e&1)*2**(Math.floor(e/2)+11),o=new Uint8Array(n),r=new qPe(o,{lc:3,lp:0,pb:2,dictionarySize:s}),i=0,a=!0,l=!1,u=()=>{if(i>=t.byteLength)throw new G("Invalid LZMA2 stream: truncated chunk header");return t[i++]};try{for(;;){let p=u();if(p===0)break;if(p<128){if(p!==1&&p!==2)throw new G(`Invalid LZMA2 control byte 0x${p.toString(16)}`);if(p===2&&a)throw new G("Invalid LZMA2 stream: dictionary was not initialized");let h=(u()<<8)+u()+1;if(h>n-r.outputPos||h>t.byteLength-i)throw new G("Invalid LZMA2 uncompressed chunk size");if(r.appendUncompressed(t.subarray(i,i+h),p===1),i+=h,p===1)a=!1,l=!1;continue}let c=((p&31)<<16)+(u()<<8)+u()+1,d=(u()<<8)+u()+1,f=p>=224,m=p>=160,g=p>=192;if(a&&!f)throw new G("Invalid LZMA2 stream: dictionary was not initialized");if(!l&&!g)throw new G("Invalid LZMA2 stream: properties were not initialized");if(g){let h=u();if(h>=225)throw new G("Invalid LZMA2 properties");let T=h%9;h=Math.floor(h/9);let R=h%5,y=Math.floor(h/5);if(T+R>4)throw new G("Invalid LZMA2 literal properties");r.setProperties(T,R,y),l=!0}if(d>t.byteLength-i||c>n-r.outputPos)throw new G("Invalid LZMA2 chunk size");if(f)r.resetDictionary();else if(m)r.resetState();r.decodeChunk(t.subarray(i,i+d),c),i+=d,a=!1}if(i!==t.byteLength)throw new G("Invalid LZMA2 stream: trailing data");return o.subarray(0,r.outputPos)}catch(p){if(p instanceof G)throw p;throw new G(`Invalid LZMA2 stream: ${p instanceof Error?p.message:String(p)}`)}}var UQr=16777216,im=2048,L3n=5,ugt=768,vY=12,HPe=16,pgt=2;var rW=w(()=>{Qr()});class U3n{#e;#t=0;#n=0;constructor(e){this.#e=e}get remainingBits(){return this.#e.byteLength*8-this.#t}read(e){if(this.remainingBits<e)return;let t=0;for(let n=0;n<e;n++){let s=this.#t+n;t+=(this.#e[s>>>3]>>>(s&7)&1)*2**n}return this.#t+=e,t}alignCodeGroup(e){let t=e*8,n=this.#n+Math.ceil((this.#t-this.#n)/t)*t;if(n>this.#e.byteLength*8)throw new G("Truncated compress (.Z) code group");this.#t=n,this.#n=n}assertFinalPadding(){this.#s(this.#e.byteLength*8)}#s(e){for(let t=this.#t;t<e;t++)if((this.#e[t>>>3]>>>(t&7)&1)!==0)throw new G("Invalid non-zero compress (.Z) padding")}}class B3n{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=new Uint8Array(Math.min(e,Math.max(64,Math.min(t*2,65536))))}appendReversed(e,t){this.#s(t);for(let n=t-1;n>=0;n--)this.#t[this.#n++]=e[n]}finish(){return this.#t.slice(0,this.#n)}#s(e){let t=this.#n+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new G(`Compress (.Z) output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let n=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(n>this.#e)n=this.#e;let s=new Uint8Array(n);s.set(this.#t.subarray(0,this.#n)),this.#t=s}}function GQr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid compress (.Z) output limit");if(e.byteLength<3)throw new G("Truncated compress (.Z) header");if(e[0]!==31||e[1]!==157)throw new G("Invalid compress (.Z) header");let n=e[2];if((n&96)!==0)throw new G("Unsupported compress (.Z) header flags");let s=n&31;if(s<dgt||s>WQr)throw new G(`Invalid compress (.Z) maximum code width ${s}`);let o=(n&128)!==0,r=2**s,i=new Uint16Array(r),a=new Uint8Array(r),l=new Uint8Array(r),u=new U3n(e.subarray(3)),p=new B3n(t,e.byteLength),c=dgt,d=o?q3n:256,f=!1;for(;;){let m=u.read(c);if(m===void 0)return u.assertFinalPadding(),p.finish();if(m>=d)throw new G(`Corrupt compress (.Z) dictionary code ${m}`);if(o&&m===BQr){u.alignCodeGroup(c),c=dgt,d=q3n,f=!1;continue}let g=m,h=0;while(g>=256){if(g>=d||h>=l.length-1)throw new G("Corrupt compress (.Z) dictionary chain");l[h++]=a[g],g=i[g]}if(l[h++]=g,f){if(a[d-1]=g,m===d-1)l[0]=g}if(p.appendReversed(l,h),d<r){if(f=!0,i[d++]=m,d>2**c&&c<s)u.alignCodeGroup(c),c++}else f=!1}}function W3n(e){return e.byteLength>=2&&e[0]===31&&e[1]===157}async function fgt(e,t){try{return GQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}}var BQr=256,q3n=257,dgt=9,WQr=16;var G3n=w(()=>{Qr()});function mw(e,t){if(t<0||t+4>e.byteLength)throw new G("Invalid XZ stream: truncated integer");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function WPe(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24}function $3n(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function $Qr(e,t,n){e[t]=n>>>24,e[t+1]=n>>>16&255,e[t+2]=n>>>8&255,e[t+3]=n&255}function mgt(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function iW(e){let t=0;for(let n=0;n<9;n++){if(e.pos>=e.limit)throw new G("Invalid XZ stream: truncated variable-length integer");let s=e.bytes[e.pos++];if(n>0&&s===0)throw new G("Invalid XZ stream: non-canonical variable-length integer");if(t+=(s&127)*2**(n*7),!Number.isSafeInteger(t))throw new G("XZ stream uses sizes too large to read safely");if((s&128)===0)return t}throw new G("Invalid XZ stream: variable-length integer is too long")}function j3n(e){switch(e){case 0:return 0;case 1:return 4;case 4:return 8;case 10:return 32;default:throw new G(`Unsupported XZ integrity check ID 0x${e.toString(16)}`)}}function jQr(e,t,n){if(n<8||t<0||t+n>e.byteLength)throw new G("Invalid XZ stream: index range is invalid");let s=t+n;if(e[t]!==0)throw new G("Invalid XZ stream: missing index indicator");if(sa(e.subarray(t,s-4))!==mw(e,s-4))throw new G("Invalid XZ stream: index CRC32 mismatch");let o={bytes:e,pos:t+1,limit:s-4},r=iW(o);if(r>Math.floor(n/2))throw new G("Invalid XZ stream: impossible index record count");let i=[];for(let a=0;a<r;a++){let l=iW(o),u=iW(o);if(l===0)throw new G("Invalid XZ stream: zero unpadded block size");i.push({unpaddedSize:l,uncompressedSize:u})}while(o.pos<o.limit)if(e[o.pos++]!==0)throw new G("Invalid XZ stream: non-zero index padding");return i}function zQr(e){if(e.byteLength===0||(e.byteLength&3)!==0)throw new G("Invalid XZ stream: size is not a multiple of four bytes");let t=[],n=e.byteLength;while(n>0){let s=0;while(n>=4&&e[n-1]===0&&e[n-2]===0&&e[n-3]===0&&e[n-4]===0)n-=4,s+=4;if(n===0)throw new G("Invalid XZ stream: padding without a stream");if(n<24)throw new G("Invalid XZ stream: truncated stream framing");let o=n-12;if(e[o+10]!==89||e[o+11]!==90)throw new G("Invalid XZ stream: footer magic mismatch");if(sa(e.subarray(o+4,o+10))!==mw(e,o))throw new G("Invalid XZ stream: footer CRC32 mismatch");let r=e[o+8],i=e[o+9];if(r!==0||(i&240)!==0)throw new G("Unsupported XZ stream flags");let a=i&15;j3n(a);let l=(mw(e,o+4)+1)*4;if(!Number.isSafeInteger(l)||l>o)throw new G("Invalid XZ stream: backward index size is invalid");let u=o-l,p=jQr(e,u,l),c=0;for(let f of p)if(c+=Math.ceil(f.unpaddedSize/4)*4,!Number.isSafeInteger(c))throw new G("XZ stream uses sizes too large to read safely");let d=u-c-12;if(d<0||d+12>e.byteLength||!mgt(e.subarray(d,d+6),BPe))throw new G("Invalid XZ stream: header position or magic is invalid");if(e[d+6]!==r||e[d+7]!==i)throw new G("Invalid XZ stream: header and footer flags differ");if(sa(e.subarray(d+6,d+8))!==mw(e,d+8))throw new G("Invalid XZ stream: header CRC32 mismatch");t.unshift({start:d,indexStart:u,footerStart:o,checkId:a,records:p}),n=d}return t}function VQr(e,t){let n=new Uint8Array(256),s=0;for(let o=0;o<e.byteLength;o++){let r=e[o]+n[t+s&255]&255;n[s]=r,e[o]=r,s=s-1&255}}function YQr(e,t){let n=[0,1,2,2,3],s=0,o=4294967291;if(e.byteLength<5)return;let r=0,i=e.byteLength-5;while(r<=i){let a=e[r];if(a!==232&&a!==233){r++;continue}let l=t+r>>>0,u=l-o>>>0;if(o=l,u>5)s=0;else for(let p=0;p<u;p++)s=(s&119)<<1>>>0;if(a=e[r+4],(a===0||a===255)&&s>>>1<=4&&s>>>1!==3){let p=mw(e,r+1),c=0;for(;;){if(c=p-l-5>>>0,s===0)break;let d=n[s>>>1]*8,f=c>>>24-d&255;if(f!==0&&f!==255)break;let m=d===0?4294967295:2**(32-d)-1;p=(c^m)>>>0}e[r+4]=~((c>>>24&1)-1)&255,e[r+3]=c>>>16,e[r+2]=c>>>8,e[r+1]=c,r+=5,s=0}else if(r++,s|=1,a===0||a===255)s|=16}}function KQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(e[n]>>>2!==18||(e[n+3]&3)!==1)continue;let o=(((e[n]&3)<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]&252)>>>0)-t-n>>>0;e[n]=72|o>>>24&3,e[n+1]=o>>>16,e[n+2]=o>>>8,e[n+3]=e[n+3]&3|o&252}}function XQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(e[n+3]!==235)continue;let o=((e[n+2]<<18|e[n+1]<<10|e[n]<<2)>>>0)-t-n-8>>>2;e[n]=o,e[n+1]=o>>>8,e[n+2]=o>>>16}}function JQr(e,t){for(let n=0;n+4<=e.byteLength;n+=2){if((e[n+1]&248)!==240||(e[n+3]&248)!==248)continue;let o=(((e[n+1]&7)<<19|e[n]<<11|(e[n+3]&7)<<8|e[n+2])<<1>>>0)-t-n-4>>>1;e[n+1]=240|o>>>19&7,e[n]=o>>>11,e[n+3]=248|o>>>8&7,e[n+2]=o,n+=2}}function QQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(!(e[n]===64&&(e[n+1]&192)===0||e[n]===127&&(e[n+1]&192)===192))continue;let o=($3n(e,n)<<2>>>0)-t-n>>>2;o=0-(o>>>22&1)<<22&1073741823|o&4194303|1073741824,$Qr(e,n,o>>>0)}}function ZQr(e,t){let n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0];for(let s=0;s+16<=e.byteLength;s+=16){let o=n[e[s]&31],r=5;for(let i=0;i<3;i++,r+=41){if((o>>>i&1)===0)continue;let a=r>>>3,l=r&7,u=0n;for(let f=0;f<6;f++)u|=BigInt(e[s+a+f])<<BigInt(f*8);let p=u>>BigInt(l);if((p>>37n&15n)!==5n||(p>>9n&7n)!==0n)continue;let c=Number(p>>13n&0xfffffn)|Number(p>>36n&1n)<<20;c=c<<4>>>0;let d=c-t-s>>>4>>>0;p&=~(0x8fffffn<<13n),p|=BigInt(d&1048575)<<13n,p|=BigInt(d&1048576)<<16n,u&=(1n<<BigInt(l))-1n,u|=p<<BigInt(l);for(let f=0;f<6;f++)e[s+a+f]=Number(u>>BigInt(f*8))&255}}}function eZr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){let s=t+n>>>0,o=mw(e,n);if(o>>>26===37)o=(2483027968|o-(s>>>2)&67108863)>>>0,WPe(e,n,o);else if((o&2667577344)===2415919104){let r=o>>>29&3|o>>>3&2097148;if((r+131072&1835008)!==0)continue;let i=r-(s>>>12)>>>0;o&=2415919135,o|=(i&3)<<29,o|=(i&262140)<<3,o|=0-(i&131072)&14680064,WPe(e,n,o>>>0)}}}function tZr(e,t){if(e.byteLength<8)return;for(let n=0;n<=e.byteLength-8;n+=2){let s=e[n];if(s===239){let r=e[n+1];if((r&13)!==0)continue;let i=((r&240)<<13|e[n+2]<<9|e[n+3]<<1)-t-n>>>0;e[n+1]=r&15|i>>>8&240,e[n+2]=i>>>16&15|i>>>7&16|i<<4&224,e[n+3]=i>>>4&127|i>>>13&128,n+=2;continue}if((s&127)!==23)continue;s=mw(e,n);let o;if((s&3712)!==0){if(o=mw(e,n+4),(s<<8^o-3&1015811)!==0){n+=4;continue}let r=(s&4294963200)+(o>>>20);s=(279|o<<12)>>>0,o=r>>>0}else{let r=s>>>27;if(s-12567<<18>>>0>=(r&29)){n+=2;continue}let i=$3n(e,n+4)-t-n>>>0;o=(s>>>12|i<<20)>>>0,s=(23|r<<7|i+2048&4294963200)>>>0}WPe(e,n,s),WPe(e,n+4,o),n+=6}}function nZr(e,t){if(t.id===3){if(t.properties.byteLength!==1)throw new G("Invalid XZ Delta filter properties");VQr(e,t.properties[0]+1);return}if(t.properties.byteLength!==0&&t.properties.byteLength!==4)throw new G(`Invalid XZ BCJ filter 0x${t.id.toString(16)} properties`);let n=t.properties.byteLength===4?mw(t.properties,0):0,s=t.id===6?16:t.id===8||t.id===11?2:t.id===4?1:4;if((n&s-1)!==0)throw new G(`Invalid XZ BCJ filter 0x${t.id.toString(16)} start offset`);switch(t.id){case 4:YQr(e,n);break;case 5:KQr(e,n);break;case 6:ZQr(e,n);break;case 7:XQr(e,n);break;case 8:JQr(e,n);break;case 9:QQr(e,n);break;case 10:eZr(e,n);break;case 11:tZr(e,n);break;default:throw new G(`Unsupported XZ filter ID 0x${t.id.toString(16)}`)}}function sZr(e,t,n){if(e===0)return;if(e===1){if(mw(n,0)!==sa(t))throw new G("Invalid XZ stream: block CRC32 mismatch");return}if(e===4){let o=B$n(t),r=0n;for(let i=0;i<8;i++)r|=BigInt(n[i])<<BigInt(i*8);if(o!==r)throw new G("Invalid XZ stream: block CRC64 mismatch");return}let s=new Uint8Array(new Bun.CryptoHasher("sha256").update(t).digest());if(!mgt(s,n))throw new G("Invalid XZ stream: block SHA-256 mismatch")}async function oZr(e,t,n,s){if(t>=e.byteLength||e[t]===0)throw new G("Invalid XZ stream: missing block header");let o=(e[t]+1)*4;if(t+o>e.byteLength||o<8)throw new G("Invalid XZ stream: truncated block header");if(sa(e.subarray(t,t+o-4))!==mw(e,t+o-4))throw new G("Invalid XZ stream: block header CRC32 mismatch");let r={bytes:e,pos:t+1,limit:t+o-4},i=e[r.pos++];if((i&60)!==0)throw new G("Unsupported XZ block flags");let a=(i&3)+1,l=(i&64)!==0?iW(r):void 0,u=(i&128)!==0?iW(r):void 0,p=[];for(let C=0;C<a;C++){let S=iW(r),E=iW(r);if(E>r.limit-r.pos)throw new G("Invalid XZ stream: truncated filter properties");p.push({id:S,properties:e.slice(r.pos,r.pos+E)}),r.pos+=E}while(r.pos<r.limit)if(e[r.pos++]!==0)throw new G("Invalid XZ stream: non-zero block header padding");let c=j3n(s),d=n.unpaddedSize-o-c;if(!Number.isSafeInteger(d)||d<=0)throw new G("Invalid XZ stream: compressed block size is invalid");if(l!==void 0&&l!==d)throw new G("Invalid XZ stream: block compressed size mismatch");if(u!==void 0&&u!==n.uncompressedSize)throw new G("Invalid XZ stream: block uncompressed size mismatch");let f=t+o,m=f+d,g=4-(o+d&3)&3,h=m+g;if(h+c>e.byteLength)throw new G("Invalid XZ stream: truncated block data");let T=p[p.length-1];if(T.id!==33||T.properties.byteLength!==1)throw new G(`Unsupported XZ terminal filter ID 0x${T.id.toString(16)} (LZMA2 required)`);let R=await UPe(T.properties[0],e.subarray(f,m),n.uncompressedSize);if(R.byteLength!==n.uncompressedSize)throw new G("Invalid XZ stream: decoded block size mismatch");R=R.slice();for(let C=p.length-2;C>=0;C--)nZr(R,p[C]);for(let C=m;C<h;C++)if(e[C]!==0)throw new G("Invalid XZ stream: non-zero block padding");sZr(s,R,e.subarray(h,h+c));let y=t+Math.ceil(n.unpaddedSize/4)*4;if(h+c!==y)throw new G("Invalid XZ stream: block size does not match its index record");return R}function GPe(e){return e.byteLength>=BPe.byteLength&&mgt(e.subarray(0,BPe.byteLength),BPe)}async function mO(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid XZ output limit");try{let n=zQr(e),s=0;for(let i of n)for(let a of i.records)if(s+=a.uncompressedSize,!Number.isSafeInteger(s)||s>t)throw new G("XZ output exceeds its size limit");let o=new Uint8Array(s),r=0;for(let i of n){let a=i.start+12;for(let l of i.records){let u=await oZr(e,a,l,i.checkId);o.set(u,r),r+=u.byteLength,a+=Math.ceil(l.unpaddedSize/4)*4}if(a!==i.indexStart)throw new G("Invalid XZ stream: blocks do not align with index")}return o}catch(n){if(n instanceof G)throw n;throw new G(`Invalid XZ stream: ${n instanceof Error?n.message:String(n)}`)}}var BPe;var hae=w(()=>{pO();Qr();rW();BPe=Uint8Array.of(253,55,122,88,90,0)});import{promisify as z3n}from"node:util";import*as $Pe from"node:zlib";function jPe(e){return e.byteLength>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function gO(e,t){try{return await iZr(e,{maxOutputLength:Math.max(t,1)})}catch(n){throw new G(n instanceof Error?n.message:String(n))}}function V3n(e){return rZr(e)}var rZr,iZr;var PY=w(()=>{Qr();rZr=z3n($Pe.zstdCompress),iZr=z3n($Pe.zstdDecompress)});import*as VPe from"node:path";class Tgt{#e;#t;#n;#s;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}async read(e,t){if(e!==this.#n)throw new G(`CPIO member '${t}' has an inconsistent declared size`);let n=this.#t+this.#n;if(n>this.#e.byteLength)throw new G(`CPIO member '${t}' is truncated`);let s=this.#e.subarray(this.#t,n);if(this.#s!==void 0&&ejn(s)!==this.#s)throw new G(`CPIO member '${t}' has an invalid CRC checksum`);return s}}function ejn(e){let t=0;for(let n of e)t=t+n>>>0;return t}function Z3n(e,t){let n=e%t;return n===0?e:e+t-n}function hO(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid CPIO archive: truncated ${s}`)}function zPe(e,t,n,s,o){hO(e,t,t+n,`${o} field`);let r=0;for(let i=t;i<t+n;i++){let a=e[i],l;if(a>=48&&a<=57)l=a-48;else if(s===16&&a>=65&&a<=70)l=a-65+10;else if(s===16&&a>=97&&a<=102)l=a-97+10;else throw new G(`Invalid CPIO archive: ${o} is not a valid base-${s} number`);if(l>=s)throw new G(`Invalid CPIO archive: ${o} is not a valid base-${s} number`);r=r*s+l}if(!Number.isSafeInteger(r))throw new G(`Invalid CPIO archive: ${o} is too large`);return r}function tjn(e,t){hO(e,t,t+2,"header");let n=e[t],s=e[t+1];if(n===199&&s===113||n===113&&s===199){hO(e,t,t+X3n,"old binary header");let i=n===199?Rs:rae,a=(l)=>i(e,t+l)*65536+i(e,t+l+2);return{headerSize:X3n,alignment:2,devMajor:0,devMinor:i(e,t+2),inode:i(e,t+4),mode:i(e,t+6),nlink:i(e,t+12),mtime:a(16),nameSize:i(e,t+20),fileSize:a(22)}}hO(e,t,t+6,"magic");let o=String.fromCharCode(...e.subarray(t,t+6));if(o==="070701"||o==="070702"){hO(e,t,t+Y3n,"new ASCII header");let r=(a,l)=>zPe(e,t+6+a*8,8,16,l),i=r(12,"checksum");if(o==="070701"&&i!==0)throw new G("Invalid CPIO archive: newc checksum field must be zero");return{headerSize:Y3n,alignment:4,inode:r(0,"inode"),mode:r(1,"mode"),nlink:r(4,"link count"),mtime:r(5,"modification time"),fileSize:r(6,"file size"),devMajor:r(7,"device major"),devMinor:r(8,"device minor"),nameSize:r(11,"name size"),checksum:o==="070702"?i:void 0}}if(o==="070707"){hO(e,t,t+K3n,"portable ASCII header");let r=(i,a)=>zPe(e,t+i,6,8,a);return{headerSize:K3n,alignment:1,devMajor:0,devMinor:r(6,"device"),inode:r(12,"inode"),mode:r(18,"mode"),nlink:r(36,"link count"),mtime:zPe(e,t+48,11,8,"modification time"),nameSize:r(59,"name size"),fileSize:zPe(e,t+65,11,8,"file size")}}throw new G(`Invalid CPIO archive: unsupported or corrupt magic at offset ${t}`)}function njn(e){try{return uZr.decode(e)}catch{return}}function hgt(e,t,n,s){for(let o=t;o<n;o++)if(e[o]!==0)throw new G(`Invalid CPIO archive: non-zero ${s} padding`)}function pZr(e,t,n){wo(t.byteLength,"link target",n);let s=njn(t);if(s===void 0||s.includes("\x00"))throw new G(`Invalid CPIO archive: symlink '${e}' has an invalid UTF-8 target`);let o=s.replace(/\\/g,"/");if(VPe.posix.isAbsolute(o))return{path:o,resolveTarget:!1};let r=tf(VPe.posix.join(VPe.posix.dirname(e),o));return r===void 0?{path:o,resolveTarget:!1}:{path:r,resolveTarget:!0}}function Rgt(e,t){ki(e.byteLength,t.limits);let n=[],s=0,o=0,r=!1;while(s<e.byteLength){let u=tjn(e,s);if(u.mode>65535)throw new G("Invalid CPIO archive: mode exceeds 16 bits");if(u.nameSize<1)throw new G("Invalid CPIO archive: name size must include a NUL terminator");wo(u.nameSize-1,"member path",t.limits.maxPathBytes),fa(u.fileSize,"(CPIO entry)",t.limits);let p=s+u.headerSize,c=p+u.nameSize,d=Z3n(c,u.alignment),f=d+u.fileSize,m=Z3n(f,u.alignment);if(hO(e,p,c,"member name"),hO(e,d,f,"member data"),hO(e,f,m,"member padding"),e[c-1]!==0)throw new G("Invalid CPIO archive: member name is not NUL-terminated");for(let R=p;R<c-1;R++)if(e[R]===0)throw new G("Invalid CPIO archive: member name contains an embedded NUL");hgt(e,c,d,"name"),hgt(e,f,m,"data"),o+=d-s,Ns(o,t.limits,"CPIO index");let g=njn(e.subarray(p,c-1));if(g===aZr){if(u.fileSize!==0)throw new G("Invalid CPIO archive: TRAILER!!! has non-empty data");r=!0,s=m;break}let h=u.mode&ggt;if((h===Q3n||h===4096)&&u.fileSize!==0)throw new G("Invalid CPIO archive: directory or FIFO has non-empty data");cr(n.length+1,t.limits);let T=g===void 0?void 0:Lr(g);n.push({path:T,mode:u.mode,mtimeMs:u.mtime*1000,nlink:u.nlink,inode:u.inode,devMajor:u.devMajor,devMinor:u.devMinor,fileSize:u.fileSize,dataOffset:d,checksum:u.checksum}),s=m}if(!r)throw new G("Invalid CPIO archive: missing TRAILER!!! terminator");hgt(e,s,e.byteLength,"trailing");let i=new Map,a=new Set,l=new Map;for(let u of n){if((u.mode&ggt)!==J3n||u.nlink<=1)continue;let p=`${u.devMajor}:${u.devMinor}:${u.inode}`,c=l.get(p);if(c)c.push(u);else l.set(p,[u])}for(let u of l.values()){if(u.length<2)continue;for(let f of u)a.add(f);let p=u.filter((f)=>f.path!==void 0);if(p.length===0)continue;let c=u.find((f)=>f.fileSize!==0)??u[0],d=p.find((f)=>f===c)??p[0];for(let f of p){let m={path:f.path,isDirectory:!1,size:c.fileSize,mtimeMs:f.mtimeMs,mode:f.mode,storage:f===d?{type:"member",source:new Tgt(e,c.dataOffset,c.fileSize,c.checksum)}:{type:"link",targetPath:d.path,resolveTarget:!1}};Sc(i,m)}}for(let u of n){if(a.has(u)||u.path===void 0)continue;let p=u.mode&ggt;if(p===Q3n){Sc(i,{path:u.path,isDirectory:!0,size:0,mtimeMs:u.mtimeMs,mode:u.mode});continue}if(p===lZr){let c=e.subarray(u.dataOffset,u.dataOffset+u.fileSize);if(u.checksum!==void 0&&ejn(c)!==u.checksum)throw new G(`CPIO symlink '${u.path}' has an invalid CRC checksum`);let d=pZr(u.path,c,t.limits.maxPathBytes);Sc(i,{path:u.path,isDirectory:!1,size:0,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"link",targetPath:d.path,resolveTarget:d.resolveTarget}});continue}if(p!==J3n)continue;Sc(i,{path:u.path,isDirectory:!1,size:u.fileSize,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"member",source:new Tgt(e,u.dataOffset,u.fileSize,u.checksum)}})}return ZL(i,t.limits),[...i.values()]}function Tae(e){try{let t=tjn(e,0);if(t.mode>65535||t.nameSize<1)return!1;let n=t.headerSize+t.nameSize;return n<=e.byteLength&&e[n-1]===0}catch{return!1}}var Y3n=110,K3n=76,X3n=26,aZr="TRAILER!!!",ggt=61440,J3n=32768,Q3n=16384,lZr=40960,uZr,sjn=async(e,t)=>{try{return ki(e.size,t.limits),Rgt(await XA(e),t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}};var ygt=w(()=>{Lh();e_();Qr();Hp();sf();JA();uZr=new TextDecoder("utf-8",{fatal:!0})});import*as yae from"node:path";class bjn{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){if(this.#n)throw new G(`Archive member '${br(t)}' is a sparse file and cannot be read`);if(e>this.#e.byteLength-this.#t)throw new G(`Archive member '${br(t)}' is truncated`);let n=this.#e.subarray(this.#t,this.#t+e);if(n.byteLength!==e)throw new G(`Archive member '${br(t)}' has an invalid size`);return n}}function KPe(e,t,n){let s=Math.min(t+n,e.byteLength),o=t;while(o<s&&e[o]!==0)o++;return Sae.decode(e.subarray(t,o))}function aW(e,t){return e.byteLength===t.length&&Dp(e,0,t)}function hZr(e,t){return Dp(e,t+yjn,bgt)&&Dp(e,t+Cjn,wgt)}function XPe(e,t,n){let s=e.indexOf(0),o=e.subarray(0,s===-1?e.byteLength:s);return wo(o.byteLength,t,n.maxPathBytes),Sae.decode(o)}function ijn(e,t,n){return wo(e.byteLength,t,n.maxPathBytes),Sae.decode(e)}function JPe(e,t,n){if(t<0||n<=0||t+n>e.byteLength)throw new G("Invalid tar numeric field");let s=e[t],o=0n;if((s&128)!==0){o=BigInt(s&127);for(let r=1;r<n;r++)o=o<<8n|BigInt(e[t+r]);if((s&64)!==0)o-=1n<<BigInt(n*8-1)}else for(let r=0;r<n;r++){let i=e[t+r];if(i>=48&&i<=55)o=o*8n+BigInt(i-48)}return Number(o)}function wjn(e,t){let n=JPe(e,t,gjn);if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid tar member size");return n}function QPe(e){let t=e%gw,n=e+(t===0?0:gw-t);if(!Number.isSafeInteger(n))throw new G("Invalid tar member size");return n}function ajn(e,t){if(!/^\d+$/.test(e))throw new G(`Invalid tar ${t}`);let n=Number(e);if(!Number.isSafeInteger(n)||n<0)throw new G(`Invalid tar ${t}`);return n}function Ejn(e,t){for(let n=0;n<gw;n++)if(e[t+n]!==0)return!1;return!0}function kjn(e,t){let n=JPe(e,t+t_,Sgt),s=0,o=0;for(let r=0;r<gw;r++){let a=r>=t_&&r<t_+Sgt?32:e[t+r]??0;s+=a,o+=a<<24>>24}return n===s||n===o}function ljn(e,t){Ns(e.byteLength,t,"tar PAX metadata");let n=new Map,s=0;while(s<e.byteLength){let o=s;while(o<e.byteLength&&e[o]!==32)o++;if(o===s||o>=e.byteLength||o-s>16)throw new G("Invalid tar PAX record");let r=0;for(let l=s;l<o;l++){let u=e[l];if(u<48||u>57)throw new G("Invalid tar PAX record");if(r=r*10+(u-48),r>e.byteLength-s)throw new G("Invalid tar PAX record")}if(r<=0||s+r>e.byteLength||e[s+r-1]!==10)throw new G("Invalid tar PAX record");let i=e.subarray(o+1,s+r-1),a=i.indexOf(61);if(a>=0){let l=i.subarray(0,a),u=i.subarray(a+1);if(Dp(l,0,Egt)){if(n.set(Egt,u.byteLength===0?"":"1"),aW(l,"GNU.sparse.name"))n.set("GNU.sparse.name",ijn(u,"PAX sparse path",t));else if(aW(l,"GNU.sparse.realsize")||aW(l,"GNU.sparse.size")){if(u.byteLength>ojn)throw new G("Invalid tar sparse real size");n.set("GNU.sparse.realsize",Sae.decode(u))}}else if(aW(l,"path")||aW(l,"linkpath")){let p=aW(l,"path")?"PAX path":"PAX link target";n.set(p==="PAX path"?"path":"linkpath",ijn(u,p,t))}else if(aW(l,"size")){if(u.byteLength>ojn)throw new G("Invalid tar member size");n.set("size",Sae.decode(u))}}s+=r}return n}function TZr(e,t){for(let[n,s]of t)if(s==="")e.delete(n);else e.set(n,s)}function NY(e,t,n){if(t?.has(n))return t.get(n);return e.get(n)}function RZr(e,t){return NY(e,t,Egt)==="1"}function yZr(e,t,n){for(let s=n;s<=e.byteLength-t.length;s++)if(Dp(e,s,t))return s;return-1}function ujn(e,t,n){let s=e.replace(/\\/g,"/");if(yae.posix.isAbsolute(s))throw new G(`Invalid old-GNU ${t}`);let o=Lr(s);if(!o)throw new G(`Invalid old-GNU ${t}`);return nf(o,t,n.maxPathBytes),o}function CZr(e,t,n,s,o){let r=[...e.entries()].filter(([i])=>i===n||i.startsWith(`${n}/`));if(r.length===0)return;for(let[i]of r)e.delete(i);for(let[i,a]of r){let l=i.slice(n.length),u=`${s}${l}`;nf(u,"member path",o.maxPathBytes),a.path=u;let p=e.get(u);if(p)t.delete(p);e.set(u,a)}for(let i of t.values())if(i.kind==="hard link"&&(i.targetPath===n||i.targetPath.startsWith(`${n}/`)))i.targetPath=`${s}${i.targetPath.slice(n.length)}`}function SZr(e,t,n,s){Ns(e.byteLength,s,"old-GNU name metadata");let o=e.indexOf(0),r=o===-1?e.byteLength:o,i=0;while(i<r){let a=e.indexOf(10,i),l=a===-1||a>r?r:a,u=e.subarray(i,l);if(Dp(u,0,"Rename ")){let p=yZr(u," to ",7);if(p===-1)throw new G("Invalid old-GNU name record");let c=XPe(u.subarray(7,p),"old-GNU source path",s),d=u[u.byteLength-1]===47?u.byteLength-1:u.byteLength,f=XPe(u.subarray(p+4,d),"old-GNU target path",s);CZr(t,n,ujn(c,"source path",s),ujn(f,"target path",s),s)}i=l+1}}function bZr(e,t,n){if(t.size===0)return;let s=new Set;for(let l of e.values())for(let u=l.path.lastIndexOf("/");u>0;u=l.path.lastIndexOf("/",u-1)){let p=l.path.slice(0,u);if(s.has(p))break;s.add(p)}let o=new Set(t.keys()),r=new Map,i=(l)=>{for(let u=l.length;u>0;u=l.lastIndexOf("/",u-1)){let p=e.get(l.slice(0,u));if(p&&o.has(p))return p}return null},a=[...o];while(a.length>0){let l=a.pop();if(!o.has(l))continue;let u=t.get(l),p=i(u.targetPath),c=u.targetPath;if(p===null){try{c=eW(e,c,n.maxLinkDepth)}catch(g){if(!(g instanceof G))throw new G("Invalid archive link")}if(c!==u.targetPath)p=i(c)}if(p!==null&&p!==l){let g=r.get(p);if(g)g.push(l);else r.set(p,[l]);continue}o.delete(l);let d=r.get(l);if(d)r.delete(l),a.push(...d);if(p===l){if(u.kind==="hard link")throw new G(`Archive hard link '${br(l.path)}' has a cyclic target '${br(u.targetPath)}'`);l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1};continue}let f=e.get(c);if(f?.storage&&!f.isDirectory&&!o.has(f)){l.size=f.size,l.storage=f.storage;continue}if(!(c===""||f?.isDirectory===!0||s.has(c))){if(u.kind==="symlink"){l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1};continue}let g=f?"unreadable member":"missing member";throw new G(`Archive hard link '${br(l.path)}' targets ${g} '${br(u.targetPath)}'`)}if(u.kind==="hard link")throw new G(`Archive hard link '${br(l.path)}' targets directory '${br(u.targetPath)}'`);l.isDirectory=!0,l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1}}if(o.size>0)throw new G("Archive contains cyclic or unsupported links")}function bae(e,t){let{limits:n}=t;ki(e.byteLength,n);let s=new Map,o=new Map,r=(d,f)=>{let m=s.get(d.path),g=Sc(s,d);if(!g)return;if(m)o.delete(m);if(f)o.set(g,f);cr(s.size,n)},i=0,a,l,u,p=new Map,c=!1;while(i+gw<=e.byteLength){if(Ejn(e,i)){c=!0;break}if(!kjn(e,i))throw new G("Invalid or corrupt tar archive header");let d=i,f=String.fromCharCode(e[d+Rjn]||48),m=wjn(e,d+Agt),g=KPe(e,d+kgt,Cae);if(hZr(e,d)){let q=KPe(e,d+Sjn,Igt);if(q)g=`${q}/${g}`}let h=KPe(e,d+cZr,dZr),T=JPe(e,d+hjn,Tjn),R=JPe(e,d+fjn,mjn),y=Number.isSafeInteger(R)&&R>=0?R:void 0;i+=gw;let C=QPe(m);if(C>e.byteLength-i)throw new G("Archive member data is truncated");let S=e.subarray(i,i+m);if(f==="L"){Ns(S.byteLength,n,"GNU long-name metadata"),a=XPe(S,"GNU long path",n),i+=C;continue}if(f==="K"){Ns(S.byteLength,n,"GNU long-link metadata"),l=XPe(S,"GNU long link target",n),i+=C;continue}if(f==="N"){SZr(S,s,o,n),i+=C;continue}if(f==="x"||f==="X"){u=ljn(S,n),i+=C;continue}if(f==="g"){TZr(p,ljn(S,n)),i+=C;continue}if(f==="M")throw new G("GNU multi-volume tar members are not supported");if(a!==void 0)g=a;if(l!==void 0)h=l;let E=NY(p,u,"path");if(E!==void 0)g=E;let A=NY(p,u,"linkpath");if(A!==void 0)h=A;let k=NY(p,u,"size");if(k!==void 0)m=ajn(k,"member size");let x=NY(p,u,"GNU.sparse.name");if(x!==void 0)g=x;let M=m,O=NY(p,u,"GNU.sparse.realsize");if(O!==void 0)M=ajn(O,"sparse real size");let v=f==="S"||RZr(p,u);if(f==="S"&&e[d+fZr]===1){let q=!0;while(q){if(i+gw>e.byteLength)throw new G("Archive sparse metadata is truncated");q=e[i+mZr]===1,i+=gw}}let P=i,N=QPe(m);if(N>e.byteLength-P)throw new G(`Archive member '${br(g)}' is truncated`);i+=N,a=void 0,l=void 0,u=void 0;let F=f==="5"||g.endsWith("/"),_=Lr(g);if(!_)continue;nf(_,"member path",n.maxPathBytes);let L=T*1000,D=T!==0&&Number.isSafeInteger(L)?L:void 0;if(F){r({path:_,isDirectory:!0,size:0,mtimeMs:D,mode:y});continue}if(f==="1"||f==="2"){let q=f==="1"?"hard link":"symlink",U=h.replace(/\\/g,"/");nf(U,"link target",n.maxPathBytes);let z=f==="1"?Lr(U):yae.posix.isAbsolute(U)?void 0:tf(yae.posix.join(yae.posix.dirname(_),U)),Q={path:_,isDirectory:!1,size:0,mtimeMs:D,mode:y};if(z===void 0||Buffer.byteLength(z,"utf-8")>n.maxPathBytes){if(q==="hard link")throw new G(`Archive hard link '${br(_)}' has an invalid target`);Q.storage={type:"link",targetPath:U,resolveTarget:!1},r(Q);continue}r(Q,{kind:q,targetPath:z});continue}if(f!=="0"&&f!=="\x00"&&f!=="7"&&f!=="S")continue;fa(M,_,n),r({path:_,isDirectory:!1,size:M,mtimeMs:D,mode:y,storage:{type:"member",source:new bjn(e,P,v)}})}if(!c)throw new G("Not a valid tar archive: missing terminating zero block");return bZr(s,o,n),[...s.values()]}function xgt(e){if(e.byteLength<gw)return!1;if(Ejn(e,0))return!0;try{if(KPe(e,kgt,Cae).length===0)return!1;let t=wjn(e,Agt);return Number.isSafeInteger(QPe(t))&&kjn(e,0)}catch{return!1}}function YPe(e,t,n,s){if(s.byteLength>n)throw new G("Tar header field is too long");e.set(s,t)}function Rae(e,t,n,s){if(!Number.isSafeInteger(s)||s<0)throw new G("Invalid tar numeric value");let o=s.toString(8);if(o.length>n-1)throw new G("Tar numeric value does not fit its header field");for(let r=t;r<t+n-1-o.length;r++)e[r]=48;for(let r=0;r<o.length;r++)e[t+n-1-o.length+r]=o.charCodeAt(r);e[t+n-1]=0}function wZr(e){if(e.byteLength<=Cae)return[e,new Uint8Array(0)];for(let t=e.byteLength-1;t>0;t--){if(e[t]!==47)continue;let n=e.subarray(0,t),s=e.subarray(t+1);if(n.byteLength<=Igt&&s.byteLength>0&&s.byteLength<=Cae)return[s,n]}return}function Cgt(e,t){let n=n_.encode(`${e}=${t}
|
|
4802
|
+
Supported: ${r||"none"}`)}return{parsed:n,handler:o}}async resolve(e,t){let{parsed:n,handler:s}=this.#s(e,!0),o=await s.resolve(n,t);return{...o,immutable:o.immutable??s.immutable}}async write(e,t,n){let{parsed:s,handler:o}=this.#s(e);if(!o.write){let r=s.protocol.replace(/:$/,"").toLowerCase();throw Error(`${r}:// URLs are read-only for write; use the protocol-specific tool for mutations.`)}await o.write(s,t,n)}}var Qie=w(()=>{Qrt();Hke();Lpt();wct();FMe();Zct();YOe();gmt();AA();Tmt();rPe();TB();Nmt();SPe()});var Cu=w(()=>{Qrt();Hke();Lpt();wct();FMe();Zct();YOe();gmt();AA();Qie();Tmt();rPe();TB();Nmt();SPe()});import*as Zd from"node:fs";import*as w$n from"node:os";import*as Cs from"node:path";import*as E$n from"node:url";import{glob as aJr}from"@ohmytr/natives";function mJr(e){return e.replace(lJr," ")}function gJr(e){return e.replace(/ (AM|PM)\./g,`${fJr}$1.`)}function hJr(e){return e.normalize("NFD")}function T$n(e){return e.replace(/'/g,"’")}function TJr(e){if(!e.includes("\\")||!e.includes("/"))return e;return e.replace(/\\([ \t"'(){}[\]])/g,"$1")}function Zie(e){try{return Zd.accessSync(e,Zd.constants.F_OK),!0}catch{return!1}}function RJr(e){if(!e.startsWith("@"))return e;let t=e.slice(1);if(t.startsWith("/")||t==="~"||t.startsWith("~/")||Cs.win32.isAbsolute(t)||t.startsWith("agent://")||t.startsWith("artifact://")||t.startsWith("skill://")||t.startsWith("rule://")||t.startsWith("security://")||t.startsWith("local:")||t.startsWith("mcp://"))return t;return e}function yJr(e){if(!e.toLowerCase().startsWith("file://"))return e;try{return E$n.fileURLToPath(e)}catch{return e}}function zu(e,t){let n=t??w$n.homedir();if(e==="~")return n;if(e.startsWith("~/")||e.startsWith("~\\"))return n+e.slice(1);if(e.startsWith("~"))return Cs.join(n,e.slice(1));return e}function RC(e){let t=/^:(?=[/\\~]|\.\.?[/\\]|[A-Za-z]:)/.test(e)?e.slice(1):e,n=uy(yJr(mJr(RJr(t))));return zu(n)}function R$n(e){if(e.length!==1)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function CJr(e){if(!e.startsWith("/"))return;let t=e.split("/");if(t[0]!=="")return;let n,s=2;if(t.length>=2&&R$n(t[1]??""))n=t[1].toUpperCase();else if(t.length>=3&&(t[1]??"").toLowerCase()==="mnt"&&R$n(t[2]??""))n=t[2].toUpperCase(),s=3;if(!n)return;let o=t.slice(s).filter(Boolean).join("\\");return o?`${n}:\\${o}`:`${n}:\\`}function SJr(e,t=process.platform){if(t!=="win32")return e;return CJr(e)??e}function wJr(e){let t=bJr.exec(e);if(!t)return null;let n=Number.parseInt(t[1],10);if(n<1)throw new X("Line selector 0 is invalid; lines are 1-indexed. Use :1.");let s=t[2]===".."?"-":t[2],o=t[3]?Number.parseInt(t[3],10):void 0,r;if(s==="+"){if(o===void 0||o<1)throw new X(`Invalid range ${n}+${o??0}: count must be >= 1.`);r=n+o-1}else if(s==="-"){if(o!==void 0){if(o<n)throw new X(`Invalid range ${n}-${o}: end must be >= start.`);r=o}}return{startLine:n,endLine:r}}function Nh(e){let t=e.split(","),n=[];for(let o of t){let r=wJr(o);if(!r)return null;n.push(r)}if(n.length===0)return null;n.sort((o,r)=>o.startLine-r.startLine);let s=[n[0]];for(let o=1;o<n.length;o++){let r=n[o],i=s[s.length-1];if(i.endLine===void 0)continue;if(r.startLine<=i.endLine+1){if(r.endLine===void 0||r.endLine>i.endLine)s[s.length-1]={startLine:i.startLine,endLine:r.endLine};continue}s.push(r)}return s}function EPe(e){if(!e)return;for(let t of e.split(":")){let n=t.toLowerCase();if(n==="raw"||n==="conflicts")continue;let s=Nh(t);if(s)return s}return}function tae(e,t){for(let n of t){if(e<n.startLine)continue;if(n.endLine===void 0||e<=n.endLine)return!0}return!1}function bu(e){let t=e.lastIndexOf(":");if(t<=0)return{path:e};let n=e.slice(t+1);if(!uJr.test(n))return{path:e};let s=e.slice(0,t),o=n,r=s.lastIndexOf(":");if(r>0){let i=s.slice(r+1),a=h$n.test(i),l=h$n.test(n),u=g$n.test(i),p=g$n.test(n);if(a&&p||u&&l)o=`${i}:${n}`,s=s.slice(0,r)}return{path:s,sel:o}}async function JL(e,t){let n=Op(e,t);try{return await Zd.promises.lstat(n),"exists"}catch(s){if(le(s)||tq(s)||la(s,"ENAMETOOLONG"))return"missing";return"unknown"}}async function kPe(e,t){let n=bu(e);if(n.sel===void 0)return n;return await JL(e,t)==="missing"?n:{path:e}}function XB(e){let t=e.match(k$n);if(!t)return{path:e};let n=t[1].toLowerCase();if(dJr.has(n))return{path:e};if(!cJr[n])return{path:e};let s=t[0].length;if(n==="ssh"&&e.indexOf("/",s)===-1)return{path:e};let o=e,r=[];while(!0){let i=o.lastIndexOf(":");if(i<s)break;let a=o.slice(i+1);if(!pJr.test(a))break;r.unshift(a),o=o.slice(0,i)}if(r.length===0)return{path:e};return{path:o,sel:r.join(":")}}function A$n(e){let{path:t,sel:n}=XB(e);if(n===void 0)return e;if(/^(?:raw|conflicts)$/i.test(n))return t;throw new X(`write does not accept the trailing selector ":${n}" — it writes a whole file. `+`Remove ":${n}", or if the filename truly ends with it, percent-encode the ":" as %3A.`)}function EJr(e,t){for(let n of Gmt)if(e.startsWith(n))throw Error(`Path "${t}" uses internal scheme "${n}" and must be resolved through the proper protocol handler, not as a filesystem path.`)}function Kr(e){return e.replace(/^(local:)\/(?!\/)/,"$1//")}function ef(e){let t=Kr(e),n=Kr(RC(t));for(let s of Gmt)if(n.startsWith(s))return!0;return!1}function APe(e){let t=Kr(RC(Kr(e)));if(!Gmt.some((o)=>t.startsWith(o)))return"write";let n=k$n.exec(t)?.[1]?.toLowerCase();return(n?Bi.instance().getHandler(n):void 0)?.write?"write":"read"}function wY(e){return/ssh:\/\//i.test(e)}function $mt(e){return/^ssh:\/\//i.test(e.trim())}function JB(e){return/^https?:\/\/?/i.test(e)||/^www\./i.test(e)}function dn(e,t){let n=Kr(e),s=SJr(RC(n)),o=Kr(s);if(EJr(o,n),/^\/+$/.test(s))return t;if(Cs.isAbsolute(s))return s;return Cs.resolve(t,s)}function I$n(e,t){if(!e||Cs.isAbsolute(e))return null;if(e.startsWith("~")||ef(e))return null;let n=Cs.resolve(t),s=Cs.resolve(n,e);if(!bPe(s,n))return null;let o=qmt(n);if(!o)return null;let r=qmt(s);if(r)return bPe(r,o)?s:null;if(kJr(s))return null;let i=Cs.dirname(s),a=[Cs.basename(s)];for(;;){let l=qmt(i);if(l)return bPe(Cs.join(l,...a.reverse()),o)?s:null;let u=Cs.dirname(i);if(u===i||!bPe(i,n))return null;a.push(Cs.basename(i)),i=u}}function bPe(e,t){let n=Cs.relative(t,e);return!!n&&!n.startsWith("..")&&!Cs.isAbsolute(n)}function qmt(e){try{return Zd.realpathSync.native(e)}catch{return null}}function kJr(e){try{return Zd.lstatSync(e).isSymbolicLink()}catch{return!1}}async function jmt(e,t){let n=Cs.resolve(e);if(t){let r=await y$n(n);if(r!==null)return r;if(!await C$n(n))return null}let s=[Cs.basename(n)],o=Cs.dirname(n);for(;;){let r=await y$n(o);if(r!==null)return Cs.join(r,...s.reverse());if(!await C$n(o))return null;let i=Cs.dirname(o);if(i===o)return null;s.push(Cs.basename(o)),o=i}}async function y$n(e){try{return await Zd.promises.realpath(e)}catch{return null}}async function C$n(e){try{return!(await Zd.promises.lstat(e)).isSymbolicLink()}catch(t){return le(t)}}function Bn(e,t,n={}){let s=Cs.resolve(t),o=Kr(e);if(ef(o))return o;let r=RC(o),i=Cs.isAbsolute(r)?Cs.resolve(r):Cs.resolve(t,r),a=Cs.relative(s,i),l=a===""||!a.startsWith("..")&&!Cs.isAbsolute(a),u=bY(l?a||".":i);if(n.trailingSlash&&u!=="."&&!u.endsWith("/"))u+="/";return u}function zmt(e){return e.startsWith('"')&&e.endsWith('"')&&e.length>1?e.slice(1,-1):e}function Vmt(e){if(ef(e))return e;if(!e.includes("\\"))return e;return e.replace(/\\/g,"/")}function QL(e){return zmt(e.trim())}function AJr(e){let t=e.trim();if(!t.startsWith("[")||!t.endsWith("]"))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!Array.isArray(n)||n.some((s)=>typeof s!=="string"))return null;return n}function dR(e){if(typeof e==="string")return AJr(e)??[e];return e??[]}function fw(e){return IJr.some((t)=>e.includes(t))}function xJr(e,t){if(t==="comma")return e===",";if(t==="semicolon")return e===";";if(t==="whitespace")return Bmt.test(e);return e===","||e===";"||Bmt.test(e)}function MJr(e){let t=0;for(let n=0;n<e.length;n++){let s=e[n];if(s==="\\"&&n+1<e.length){n++;continue}if(s==="{"){t++;continue}if(s==="}"){if(t>0)t--;continue}if(t===0&&(s===","||s===";"||Bmt.test(s)))return!0}return!1}function vJr(e,t){let n=[],s=0,o=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\"&&r+1<e.length){r++;continue}if(i==="{"){s++;continue}if(i==="}"){if(s>0)s--;continue}if(s!==0||!xJr(i,t))continue;n.push(e.slice(o,r)),o=r+1}return n.push(e.slice(o)),n}async function x$n(e,t,n){if(ef(e))return!0;let s=bu(e).path,{basePath:o}=n(s),r=dn(o,t);try{return await Zd.promises.stat(r),!0}catch(i){if(le(i)||la(i,"ENAMETOOLONG"))return!1;throw i}}async function eae(e,t,n,s,o){let r=vJr(e,s);if(r.length<2)return null;let i=r.map(QL).filter((a)=>a.length>0);if(i.length===0)return null;if(i.length<2&&r.length===i.length)return null;if(o!=="none"){let a=await Promise.all(i.map((u)=>x$n(u,t,n)));if(!(o==="all"?a.every(Boolean):a.some(Boolean)))return null}return i}async function Ymt(e,t,n={}){let s=QL(e);if(!MJr(s))return null;let o=n.splitter??wPe;if(n.routedUrlPredicate?.(s)){let i=await eae(s,t,o,"semicolon","none");return i?.every(n.routedUrlPredicate)?i:null}if(ef(s))return null;if(await JL(s,t)!=="missing")return null;let r=bu(s).path;if(!fw(r)&&await x$n(s,t,o))return null;return await eae(s,t,o,"semicolon","none")??await eae(s,t,o,"comma","some")??await eae(s,t,o,"whitespace","all")??await eae(s,t,o,"mixed","all")}async function nae(e,t,n={}){let s=[];for(let o of e){let r=QL(o),i=await Ymt(r,t,n);if(i)s.push(...i);else s.push(r)}return s}function wPe(e){let t=Vmt(e),n=t.split("/"),s=-1;for(let o=0;o<n.length;o++)if(fw(n[o])){s=o;break}if(s===-1)return{basePath:t};if(s<=0)return{basePath:".",glob:t};return{basePath:n.slice(0,s).join("/"),glob:n.slice(s).join("/")}}async function M$n(e,t){if(!fw(e)||ef(e))return wPe(e);try{return await Zd.promises.stat(dn(e,t)),{basePath:Vmt(e)}}catch{return wPe(e)}}function sae(e){let t=Vmt(e),n=t.split("/"),s=-1;for(let o=0;o<n.length;o++)if(fw(n[o])){s=o;break}if(s===-1)return{basePath:t,globPattern:"**/*",hasGlob:!1};if(s===0)return{basePath:".",globPattern:!t.startsWith("**/")?`**/${t}`:t,hasGlob:!0};return{basePath:n.slice(0,s).join("/"),globPattern:n.slice(s).join("/"),hasGlob:!0}}function Umt(e,t){if(!e)return t;if(!t)return e;let n=e.replace(/\/+$/,""),s=t.replace(/^\/+/,"");return`${n}/${s}`}function bY(e){return e.replace(/\\/g,"/")}function S$n(e,t){if(!e||e===".")return bY(t).replace(/^\/+/,"");let n=bY(e).replace(/\/+$/,""),s=bY(t).replace(/^\/+/,"");return`${n}/${s}`}function OJr(e){let t=[...new Set(e.map((n)=>bY(n).trim()).filter(Boolean))];if(t.length===0)return;if(t.length===1)return t[0];return`{${t.join(",")}}`}function PJr(e){if(e.length===0)return".";let t=Cs.resolve(e[0]).split(Cs.sep);for(let s of e.slice(1)){let o=Cs.resolve(s).split(Cs.sep),r=0,i=Math.min(t.length,o.length);while(r<i&&t[r]===o[r])r+=1;t=t.slice(0,r)}if(t.length===0)return Cs.parse(Cs.resolve(e[0])).root;return t.join(Cs.sep)||Cs.parse(Cs.resolve(e[0])).root}function v$n(e,t){return e.map((n)=>Bn(n,t,{trailingSlash:n.endsWith("/")||n.endsWith("\\")})).join(", ")}async function NJr(e,t,n,s=!1){if(e.length<1)return;let o=await Promise.all(e.map(async(c)=>{let d=await M$n(c,t),f=dn(d.basePath,t),m=await Zd.promises.stat(f);return{raw:c,parsedPath:d,absoluteBasePath:f,stat:m}})),r=!n&&o.every((c)=>!c.parsedPath.glob&&c.stat.isFile()),i=PJr(o.map((c)=>c.absoluteBasePath)),a=o.map((c)=>{let d=bY(Cs.relative(i,c.absoluteBasePath))||".";if(c.parsedPath.glob){let f=S$n(d,c.parsedPath.glob);return Umt(f,n)??f}if(n)return Umt(d==="."?void 0:d,n)??n;if(c.stat.isDirectory())return S$n(d,"**/*");return d==="."?Cs.basename(c.absoluteBasePath):d}),l=o.some((c)=>c.absoluteBasePath===i),u=s&&!r&&o.some((c)=>!c.parsedPath.glob&&c.stat.isFile()),p=o.length>1&&(!l||u)?o.map((c)=>({basePath:c.absoluteBasePath,glob:c.parsedPath.glob?Umt(c.parsedPath.glob,n):n})):void 0;return{basePath:i,glob:OJr(a),scopePath:v$n(e,t),exactFilePaths:r?o.map((c)=>c.absoluteBasePath):void 0,targets:p}}async function FJr(e,t,n,s=!1){return NJr([...new Set(e)],t,n,s)}async function LJr(e,t){if(e.length<=1)return;return{targets:e.map((s)=>{let o=sae(s);return{basePath:dn(o.basePath,t),globPattern:o.globPattern,hasGlob:o.hasGlob}}),scopePath:v$n(e,t)}}async function O$n(e,t){return LJr([...new Set(e)],t)}async function Kmt(e,t,n){let s=await Promise.all(e.map(async(i)=>{let{basePath:a}=n(i),l=dn(a,t);try{return await Zd.promises.stat(l),{item:i,exists:!0}}catch(u){if(le(u))return{item:i,exists:!1};throw u}})),o=[],r=[];for(let i of s)if(i.exists)o.push(i.item);else r.push(i.item);return{valid:o,missing:r}}function Op(e,t){let n=dn(e,t),s=TJr(n),o=s!==n?[n,s]:[n];for(let r of o)if(Zie(r))return r;for(let r of o){let i=gJr(r);if(i!==r&&Zie(i))return i;let a=hJr(r);if(a!==r&&Zie(a))return a;let l=T$n(r);if(l!==r&&Zie(l))return l;let u=T$n(a);if(u!==r&&Zie(u))return u}return n}function _Jr(e){return e.replace(/[*?[{]/g,"[$&]")}async function DJr(e,t,n,s){let o=e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"");if(!o)return null;let r=AbortSignal.timeout(b$n),i=n?AbortSignal.any([n,r]):r,a;try{let l=await s({pattern:`**/${_Jr(o)}`,path:t,hidden:!0,signal:i,timeoutMs:b$n});if(n?.aborted)throw new $e;a=l.matches.map((u)=>u.path)}catch{if(n?.aborted)throw new $e;return null}if(a.length!==1)return null;return{absolutePath:Cs.resolve(t,a[0]),displayPath:a[0]}}async function IPe(e,t,n){return DJr(e,t,n,aJr)}async function EY(e){let{rawPaths:t,cwd:n,internalUrlAction:s}=e,o=t.map(QL);if(o.some((R)=>R.length===0))throw new X("Search scope entries must be non-empty paths or globs");let r=await nae(o,n);if(r.some((R)=>R.length===0))throw new X("Search scope entries must be non-empty paths or globs");let i=/^(?:https?|ftp|ws|wss):\/\//i,a=Bi.instance(),l=[],u=new Set;for(let R of r){let y=i.test(R);if(!y&&JB(R)&&!fw(R))try{await Zd.promises.stat(dn(R,n))}catch(S){y=le(S)||tq(S)}if(y){let S=e.resolveExternalUrl?await e.resolveExternalUrl(R):void 0;if(S){if(l.push(S.sourcePath),e.trackImmutableSources&&S.immutable)u.add(Cs.resolve(S.sourcePath));continue}throw new X(`Cannot ${s} external URL: ${R}. Use \`read\` to fetch web content, then search the returned text.`)}if(!a.canHandle(R)){l.push(R);continue}if($mt(R))throw new X(`Cannot ${s} a remote ssh:// path (no local file): ${R}. Use \`read ${R}\` to view it, or use \`grep\` on a specific remote file.`);if(fw(R))throw new X(`Glob patterns are not supported for internal URLs: ${R}`);let C=await a.resolve(R,{cwd:n,settings:e.settings,signal:e.signal,localProtocolOptions:e.localProtocolOptions,skills:e.skills,pathOnly:!0});if(!C.sourcePath)throw new X(`Cannot ${s} internal URL without a backing file: ${R}`);if(e.trackImmutableSources&&C.immutable)u.add(Cs.resolve(C.sourcePath));l.push(C.sourcePath)}let p=[],c=l;if(l.length>1){let R=await Kmt(l,n,wPe);if(R.valid.length===0)throw new X(`Path not found: ${R.missing.join(", ")}`);c=R.valid,p=R.missing}let d,f,m,g,h;if(c.length===1){let R=await M$n(c[0]??".",n);d=dn(R.basePath,n),m=R.glob,f=Bn(d,n)}else{let R=await FJr(c,n,void 0,e.fanOutFileTargets===!0);if(!R)throw new X("`paths` must contain at least one path or glob");if(d=R.basePath,g=R.targets,e.surfaceExactFilePaths)h=R.exactFilePaths,m=h||g?void 0:R.glob;else m=g?void 0:R.glob;f=R.scopePath}let T;try{T=(await Bun.file(d).stat()).isDirectory()}catch{let R=e.multipathStatHint&&r.length>1?e.multipathStatHint:"";throw new X(`Path not found: ${f}${R}`)}return{searchPath:d,scopePath:f,globFilter:m,isDirectory:T,multiTargets:g,exactFilePaths:h,missingPaths:p,immutableSourcePaths:u}}var lJr,m$n,Wmt,uJr,g$n,h$n,pJr,cJr,dJr,k$n,fJr=" ",Gmt,bJr,IJr,Bmt,b$n=5000;var Sn=w(()=>{B();Cu();St();lJr=/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g,m$n=String.raw`L?\d+(?:(?:[-+]|\.\.)L?\d+|-|\.\.)?`,Wmt=`${m$n}(?:,${m$n})*`,uJr=new RegExp(`^(?:${Wmt}|raw|conflicts)$`,"i"),g$n=new RegExp(`^${Wmt}$`,"i"),h$n=/^raw$/i,pJr=new RegExp(String.raw`^(?:raw|conflicts|${Wmt}|-\d+(?:[-+]\d+)?)$`,"i"),cJr={agent:!0,artifact:!0,issue:!0,history:!0,local:!0,memory:!0,omt:!0,pr:!0,rule:!0,security:!0,skill:!0,ssh:!0,vault:!0},dJr=new Set(["mcp"]),k$n=/^([a-z][a-z0-9+.-]*):\/\//i,Gmt=["agent://","artifact://","skill://","rule://","security://","local://","mcp://","ssh://","vault://"];bJr=/^L?(\d+)(?:(\.\.|[-+])L?(\d+)?)?$/i;IJr=["*","?","[","{"];Bmt=/\s/});var kY;var xPe=w(()=>{kY={type:"module",name:"@ohmytr/coding-agent",version:"18.0.4",description:"Coding agent CLI with read, bash, edit, write tools and session management",homepage:"https://github.com/ohmytr/ohmytr",author:"Stencil Labs, Inc.",contributors:["Mario Zechner"],license:"MIT",repository:{type:"git",url:"git+https://github.com/ohmytr/ohmytr.git",directory:"packages/coding-agent"},bugs:{url:"https://github.com/ohmytr/ohmytr/issues"},keywords:["coding-agent","ai","llm","cli","tui","agent"],main:"./src/index.ts",types:"./src/index.ts",bin:{omt:"dist/cli.js"},scripts:{build:"bun scripts/build-binary.ts",check:"biome check . && bun run check:types","check:types":"tsgo -p tsconfig.json --noEmit",lint:"biome lint .",test:"bun ../../scripts/ci-test-ts.ts coding-agent-heavy --full",fix:"biome check --write --unsafe . && bun run format-prompts",fmt:"biome format --write . && bun run format-prompts","format-prompts":"bun scripts/format-prompts.ts","gen:tool-views":"bun --cwd=../collab-web run gen:tool-views","gen:bundle":"bun scripts/bundle-dist.ts","gen:native":"bun --cwd=../natives run gen:native","gen:native:reset":"bun --cwd=../natives run gen:native:reset",prepack:"bun run gen:tool-views && bun run gen:bundle","bench:guard":"bun scripts/bench-guard.ts"},dependencies:{"@babel/parser":"catalog:","@ohmytr/hashline":"catalog:","@ohmytr/stats":"catalog:","@ohmytr/omptype":"catalog:","@ohmytr/agent-core":"catalog:","@ohmytr/ai":"catalog:","@ohmytr/catalog":"catalog:","@ohmytr/mnemopi":"catalog:","@ohmytr/natives":"catalog:","@ohmytr/tui":"catalog:","@ohmytr/utils":"catalog:","@ohmytr/wire":"catalog:","@ohmytr/snapcompact":"catalog:","@opentelemetry/api":"catalog:","@opentelemetry/api-logs":"catalog:","@opentelemetry/context-async-hooks":"catalog:","@opentelemetry/exporter-logs-otlp-proto":"catalog:","@opentelemetry/exporter-metrics-otlp-proto":"catalog:","@opentelemetry/exporter-trace-otlp-proto":"catalog:","@opentelemetry/resources":"catalog:","@opentelemetry/sdk-logs":"catalog:","@opentelemetry/sdk-metrics":"catalog:","@opentelemetry/sdk-trace-base":"catalog:","@opentelemetry/sdk-trace-node":"catalog:","puppeteer-core":"catalog:"},optionalDependencies:{"@huggingface/transformers":"catalog:","sherpa-onnx-node":"1.13.2"},devDependencies:{"@types/bun":"catalog:"},engines:{bun:">=1.3.14",node:">=24.0.0"},files:["src","dist/cli.js","dist/docs-index.generated.txt","dist/CHANGELOG-*.md","dist/*.node","dist/template-*.css","dist/template-*.html","dist/template-*.js","dist/tool-views.generated-*.js","scripts","examples","README.md","CHANGELOG.md"],exports:{".":{types:"./src/index.ts",import:"./src/index.ts"},"./*":{types:"./src/*.ts",import:"./src/*.ts"},"./async":{types:"./src/async/index.ts",import:"./src/async/index.ts"},"./async/*":{types:"./src/async/*.ts",import:"./src/async/*.ts"},"./autoresearch":{types:"./src/autoresearch/index.ts",import:"./src/autoresearch/index.ts"},"./autoresearch/*":{types:"./src/autoresearch/*.ts",import:"./src/autoresearch/*.ts"},"./autoresearch/tools/*":{types:"./src/autoresearch/tools/*.ts",import:"./src/autoresearch/tools/*.ts"},"./capability":{types:"./src/capability/index.ts",import:"./src/capability/index.ts"},"./capability/*":{types:"./src/capability/*.ts",import:"./src/capability/*.ts"},"./cli/*":{types:"./src/cli/*.ts",import:"./src/cli/*.ts"},"./cli/gallery-fixtures":{types:"./src/cli/gallery-fixtures/index.ts",import:"./src/cli/gallery-fixtures/index.ts"},"./cli/gallery-fixtures/*":{types:"./src/cli/gallery-fixtures/*.ts",import:"./src/cli/gallery-fixtures/*.ts"},"./cli/commands/*":{types:"./src/cli/commands/*.ts",import:"./src/cli/commands/*.ts"},"./commands/*":{types:"./src/commands/*.ts",import:"./src/commands/*.ts"},"./commit":{types:"./src/commit/index.ts",import:"./src/commit/index.ts"},"./commit/*":{types:"./src/commit/*.ts",import:"./src/commit/*.ts"},"./commit/agentic":{types:"./src/commit/agentic/index.ts",import:"./src/commit/agentic/index.ts"},"./commit/agentic/*":{types:"./src/commit/agentic/*.ts",import:"./src/commit/agentic/*.ts"},"./commit/agentic/tools":{types:"./src/commit/agentic/tools/index.ts",import:"./src/commit/agentic/tools/index.ts"},"./commit/agentic/tools/*":{types:"./src/commit/agentic/tools/*.ts",import:"./src/commit/agentic/tools/*.ts"},"./commit/analysis":{types:"./src/commit/analysis/index.ts",import:"./src/commit/analysis/index.ts"},"./commit/analysis/*":{types:"./src/commit/analysis/*.ts",import:"./src/commit/analysis/*.ts"},"./commit/changelog":{types:"./src/commit/changelog/index.ts",import:"./src/commit/changelog/index.ts"},"./commit/changelog/*":{types:"./src/commit/changelog/*.ts",import:"./src/commit/changelog/*.ts"},"./commit/git/*":{types:"./src/commit/git/*.ts",import:"./src/commit/git/*.ts"},"./commit/map-reduce":{types:"./src/commit/map-reduce/index.ts",import:"./src/commit/map-reduce/index.ts"},"./commit/map-reduce/*":{types:"./src/commit/map-reduce/*.ts",import:"./src/commit/map-reduce/*.ts"},"./commit/utils/*":{types:"./src/commit/utils/*.ts",import:"./src/commit/utils/*.ts"},"./config/*":{types:"./src/config/*.ts",import:"./src/config/*.ts"},"./dap":{types:"./src/dap/index.ts",import:"./src/dap/index.ts"},"./dap/*":{types:"./src/dap/*.ts",import:"./src/dap/*.ts"},"./debug":{types:"./src/debug/index.ts",import:"./src/debug/index.ts"},"./debug/*":{types:"./src/debug/*.ts",import:"./src/debug/*.ts"},"./discovery":{types:"./src/discovery/index.ts",import:"./src/discovery/index.ts"},"./discovery/*":{types:"./src/discovery/*.ts",import:"./src/discovery/*.ts"},"./edit":{types:"./src/edit/index.ts",import:"./src/edit/index.ts"},"./edit/*":{types:"./src/edit/*.ts",import:"./src/edit/*.ts"},"./edit/modes/*":{types:"./src/edit/modes/*.ts",import:"./src/edit/modes/*.ts"},"./exa":{types:"./src/exa/index.ts",import:"./src/exa/index.ts"},"./exa/*":{types:"./src/exa/*.ts",import:"./src/exa/*.ts"},"./exec/*":{types:"./src/exec/*.ts",import:"./src/exec/*.ts"},"./export/*":{types:"./src/export/*.ts",import:"./src/export/*.ts"},"./export/html":{types:"./src/export/html/index.ts",import:"./src/export/html/index.ts"},"./export/html/*":{types:"./src/export/html/*.ts",import:"./src/export/html/*.ts"},"./extensibility/*":{types:"./src/extensibility/*.ts",import:"./src/extensibility/*.ts"},"./extensibility/custom-commands":{types:"./src/extensibility/custom-commands/index.ts",import:"./src/extensibility/custom-commands/index.ts"},"./extensibility/custom-commands/*":{types:"./src/extensibility/custom-commands/*.ts",import:"./src/extensibility/custom-commands/*.ts"},"./extensibility/custom-commands/bundled/ci-green":{types:"./src/extensibility/custom-commands/bundled/ci-green/index.ts",import:"./src/extensibility/custom-commands/bundled/ci-green/index.ts"},"./extensibility/custom-commands/bundled/review":{types:"./src/extensibility/custom-commands/bundled/review/index.ts",import:"./src/extensibility/custom-commands/bundled/review/index.ts"},"./extensibility/custom-tools":{types:"./src/extensibility/custom-tools/index.ts",import:"./src/extensibility/custom-tools/index.ts"},"./extensibility/custom-tools/*":{types:"./src/extensibility/custom-tools/*.ts",import:"./src/extensibility/custom-tools/*.ts"},"./extensibility/extensions":{types:"./src/extensibility/extensions/index.ts",import:"./src/extensibility/extensions/index.ts"},"./extensibility/extensions/*":{types:"./src/extensibility/extensions/*.ts",import:"./src/extensibility/extensions/*.ts"},"./extensibility/hooks":{types:"./src/extensibility/hooks/index.ts",import:"./src/extensibility/hooks/index.ts"},"./extensibility/hooks/*":{types:"./src/extensibility/hooks/*.ts",import:"./src/extensibility/hooks/*.ts"},"./extensibility/plugins":{types:"./src/extensibility/plugins/index.ts",import:"./src/extensibility/plugins/index.ts"},"./extensibility/plugins/*":{types:"./src/extensibility/plugins/*.ts",import:"./src/extensibility/plugins/*.ts"},"./extensibility/plugins/marketplace":{types:"./src/extensibility/plugins/marketplace/index.ts",import:"./src/extensibility/plugins/marketplace/index.ts"},"./extensibility/plugins/marketplace/*":{types:"./src/extensibility/plugins/marketplace/*.ts",import:"./src/extensibility/plugins/marketplace/*.ts"},"./internal-urls":{types:"./src/internal-urls/index.ts",import:"./src/internal-urls/index.ts"},"./internal-urls/*":{types:"./src/internal-urls/*.ts",import:"./src/internal-urls/*.ts"},"./eval":{types:"./src/eval/index.ts",import:"./src/eval/index.ts"},"./eval/js/*":{types:"./src/eval/js/*.ts",import:"./src/eval/js/*.ts"},"./eval/py/*":{types:"./src/eval/py/*.ts",import:"./src/eval/py/*.ts"},"./lsp":{types:"./src/lsp/index.ts",import:"./src/lsp/index.ts"},"./lsp/*":{types:"./src/lsp/*.ts",import:"./src/lsp/*.ts"},"./lsp/clients":{types:"./src/lsp/clients/index.ts",import:"./src/lsp/clients/index.ts"},"./lsp/clients/*":{types:"./src/lsp/clients/*.ts",import:"./src/lsp/clients/*.ts"},"./markit":{types:"./src/markit/index.ts",import:"./src/markit/index.ts"},"./markit/*":{types:"./src/markit/*.ts",import:"./src/markit/*.ts"},"./mcp":{types:"./src/mcp/index.ts",import:"./src/mcp/index.ts"},"./mcp/*":{types:"./src/mcp/*.ts",import:"./src/mcp/*.ts"},"./mcp/transports":{types:"./src/mcp/transports/index.ts",import:"./src/mcp/transports/index.ts"},"./mcp/transports/*":{types:"./src/mcp/transports/*.ts",import:"./src/mcp/transports/*.ts"},"./memories":{types:"./src/memories/index.ts",import:"./src/memories/index.ts"},"./memories/*":{types:"./src/memories/*.ts",import:"./src/memories/*.ts"},"./memory-backend":{types:"./src/memory-backend/index.ts",import:"./src/memory-backend/index.ts"},"./memory-backend/*":{types:"./src/memory-backend/*.ts",import:"./src/memory-backend/*.ts"},"./hindsight":{types:"./src/hindsight/index.ts",import:"./src/hindsight/index.ts"},"./hindsight/*":{types:"./src/hindsight/*.ts",import:"./src/hindsight/*.ts"},"./modes":{types:"./src/modes/index.ts",import:"./src/modes/index.ts"},"./modes/*":{types:"./src/modes/*.ts",import:"./src/modes/*.ts"},"./modes/acp":{types:"./src/modes/acp/index.ts",import:"./src/modes/acp/index.ts"},"./modes/acp/*":{types:"./src/modes/acp/*.ts",import:"./src/modes/acp/*.ts"},"./modes/components":{types:"./src/modes/components/index.ts",import:"./src/modes/components/index.ts"},"./modes/components/*":{types:"./src/modes/components/*.ts",import:"./src/modes/components/*.ts"},"./modes/components/extensions":{types:"./src/modes/components/extensions/index.ts",import:"./src/modes/components/extensions/index.ts"},"./modes/components/extensions/*":{types:"./src/modes/components/extensions/*.ts",import:"./src/modes/components/extensions/*.ts"},"./modes/components/status-line":{types:"./src/modes/components/status-line/index.ts",import:"./src/modes/components/status-line/index.ts"},"./modes/components/status-line/*":{types:"./src/modes/components/status-line/*.ts",import:"./src/modes/components/status-line/*.ts"},"./modes/controllers/*":{types:"./src/modes/controllers/*.ts",import:"./src/modes/controllers/*.ts"},"./modes/setup-wizard":{types:"./src/modes/setup-wizard/index.ts",import:"./src/modes/setup-wizard/index.ts"},"./modes/setup-wizard/*":{types:"./src/modes/setup-wizard/*.ts",import:"./src/modes/setup-wizard/*.ts"},"./modes/rpc/*":{types:"./src/modes/rpc/*.ts",import:"./src/modes/rpc/*.ts"},"./modes/theme/*":{types:"./src/modes/theme/*.ts",import:"./src/modes/theme/*.ts"},"./modes/theme/defaults":{types:"./src/modes/theme/defaults/index.ts",import:"./src/modes/theme/defaults/index.ts"},"./modes/utils/*":{types:"./src/modes/utils/*.ts",import:"./src/modes/utils/*.ts"},"./plan-mode/*":{types:"./src/plan-mode/*.ts",import:"./src/plan-mode/*.ts"},"./prompts/*":"./src/prompts/*.md","./secrets":{types:"./src/secrets/index.ts",import:"./src/secrets/index.ts"},"./secrets/*":{types:"./src/secrets/*.ts",import:"./src/secrets/*.ts"},"./session/*":{types:"./src/session/*.ts",import:"./src/session/*.ts"},"./slash-commands/*":{types:"./src/slash-commands/*.ts",import:"./src/slash-commands/*.ts"},"./ssh/*":{types:"./src/ssh/*.ts",import:"./src/ssh/*.ts"},"./stt":{types:"./src/stt/index.ts",import:"./src/stt/index.ts"},"./stt/*":{types:"./src/stt/*.ts",import:"./src/stt/*.ts"},"./task":{types:"./src/task/index.ts",import:"./src/task/index.ts"},"./task/*":{types:"./src/task/*.ts",import:"./src/task/*.ts"},"./tools":{types:"./src/tools/index.ts",import:"./src/tools/index.ts"},"./tools/hub":{types:"./src/tools/hub/index.ts",import:"./src/tools/hub/index.ts"},"./tools/hub/*":{types:"./src/tools/hub/*.ts",import:"./src/tools/hub/*.ts"},"./tools/*":{types:"./src/tools/*.ts",import:"./src/tools/*.ts"},"./tui":{types:"./src/tui/index.ts",import:"./src/tui/index.ts"},"./tui/*":{types:"./src/tui/*.ts",import:"./src/tui/*.ts"},"./utils/*":{types:"./src/utils/*.ts",import:"./src/utils/*.ts"},"./web/*":{types:"./src/web/*.ts",import:"./src/web/*.ts"},"./web/scrapers":{types:"./src/web/scrapers/index.ts",import:"./src/web/scrapers/index.ts"},"./web/scrapers/*":{types:"./src/web/scrapers/*.ts",import:"./src/web/scrapers/*.ts"},"./web/search":{types:"./src/web/search/index.ts",import:"./src/web/search/index.ts"},"./web/search/*":{types:"./src/web/search/*.ts",import:"./src/web/search/*.ts"},"./web/search/providers/*":{types:"./src/web/search/providers/*.ts",import:"./src/web/search/providers/*.ts"},"./*.js":"./src/*.ts"}}});import*as fR from"node:fs/promises";import*as oae from"node:path";function N$n(e,t){let s=(t.trim().toLowerCase().replace(/^\.+/,"")||"bin").replace(/[^a-z0-9]+/g,"_")||"bin",o=kY.version.replace(/[^a-z0-9]+/gi,"_"),r=new Bun.CryptoHasher("sha256").update(e).digest("hex");return`v${MPe}-${o}-${s}-${r}`}function UJr(e){return oae.join(m6e(),`${e}.json`)}function QB(e){return e instanceof Error?e.message:String(e)}function BJr(e){let t=JSON.parse(e);if(typeof t!=="object"||t===null)return null;if(!("version"in t)||t.version!==MPe)return null;if(!("content"in t)||typeof t.content!=="string"||t.content.length===0)return null;return{version:MPe,content:t.content}}async function F$n(e){let t=UJr(e),n;try{n=await Bun.file(t).text()}catch(o){if(!le(o))I.debug("document conversion cache read failed",{error:QB(o)});return{status:"miss"}}let s;try{s=BJr(n)}catch(o){I.debug("document conversion cache read failed",{error:QB(o)}),s=null}if(!s)return await fR.rm(t,{force:!0}).catch(()=>{return}),{status:"miss"};return{status:"hit",content:s.content}}async function WJr(e){let t;try{t=await fR.readdir(e)}catch(r){if(!le(r))I.debug("document conversion cache prune failed",{error:QB(r)});return}let n=Date.now(),s=[],o=0;for(let r of t){let i=oae.join(e,r),a;try{a=await fR.stat(i)}catch(l){if(!le(l))I.debug("document conversion cache prune failed",{error:QB(l)});continue}if(!a.isFile())continue;if(r.endsWith(".tmp")){if(n-a.mtimeMs>qJr)await fR.rm(i,{force:!0}).catch(()=>{return});continue}if(!r.endsWith(".json"))continue;s.push({path:i,size:a.size,mtimeMs:a.mtimeMs}),o+=a.size}if(o<=P$n)return;s.sort((r,i)=>r.mtimeMs-i.mtimeMs);for(let r of s){if(o<=P$n)break;try{await fR.rm(r.path,{force:!0}),o-=r.size}catch(i){if(!le(i))I.debug("document conversion cache prune failed",{error:QB(i)})}}}async function L$n(e,t){let n=m6e(),s=oae.join(n,`${e}.json`),o=oae.join(n,`${e}.${process.pid}.${Date.now()}.${crypto.randomUUID()}.tmp`),r=JSON.stringify({version:MPe,content:t});try{await fR.mkdir(n,{recursive:!0}),await Bun.write(o,r),await fR.rename(o,s)}catch(i){await fR.rm(o,{force:!0}).catch(()=>{return}),I.debug("document conversion cache write failed",{error:QB(i)});return}WJr(n).catch((i)=>{I.debug("document conversion cache prune failed",{error:QB(i)})})}var MPe=1,P$n=268435456,qJr=300000;var _$n=w(()=>{B();xPe()});var G;var Qr=w(()=>{G=class G extends Error{constructor(e){super(e);this.name="ArchiveError"}}});function Rs(e,t){return e[t]|e[t+1]<<8}function wn(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function KA(e,t){let n=wn(e,t)+wn(e,t+4)*4294967296;if(!Number.isSafeInteger(n))throw new G("Archive uses offsets or sizes too large to read safely");return n}function rae(e,t){return e[t]<<8|e[t+1]}function Fh(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function cd(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255}function Cl(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24&255}function ZB(e,t,n){Cl(e,t,n>>>0),Cl(e,t+4,Math.floor(n/4294967296))}function Dp(e,t,n){if(e.byteLength<t+n.length)return!1;for(let s=0;s<n.length;s++)if(e[t+s]!==n.charCodeAt(s))return!1;return!0}var AY;var Lh=w(()=>{Qr();AY=new TextDecoder});function tf(e){if(!e)return"";let t=e.replace(/\\/g,"/").split("/"),n=[];for(let s of t){if(!s||s===".")continue;if(s==="..")return;n.push(s)}return n.join("/")}function Lr(e){let t=e.replace(/\\/g,"/").split("/"),n=[];for(let s of t){if(!s||s===".")continue;if(s==="..")return;n.push(s)}if(n.length===0)return;return n.join("/")}function H$n(e){return e.endsWith("/")||e.endsWith("\\")}function br(e){if(Buffer.byteLength(e,"utf-8")<=D$n)return e;let t=0,n=0;for(let s of e){let o=Buffer.byteLength(s,"utf-8");if(n+o>D$n-3)break;t+=s.length,n+=o}return`${e.slice(0,t)}...`}function wo(e,t,n){if(e>n)throw new G(`Archive ${t} exceeds ${n} bytes`)}function nf(e,t,n){wo(Buffer.byteLength(e,"utf-8"),t,n)}var D$n=256;var sf=w(()=>{Qr()});function ki(e,t){if(!Number.isSafeInteger(e)||e<0)throw new G("Archive is too large to read safely");if(e>t.maxInMemorySize)throw new G(`Archive is too large to read in memory (${ft(e)} > ${ft(t.maxInMemorySize)} limit)`)}function Ns(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw new G(`Invalid archive: ${n} has an invalid size`);if(e>t.maxIndexSize)throw new G(`Archive ${n} is too large (${ft(e)} > ${ft(t.maxIndexSize)} limit)`)}function fa(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw new G(`Archive member '${br(t)}' has an invalid size`);if(e>n.maxMemberSize)throw new G(`Archive member '${br(t)}' is too large to extract in memory (${ft(e)} > ${ft(n.maxMemberSize)} limit)`)}function cr(e,t){if(e>t.maxEntries)throw new G(`Archive has too many entries (> ${t.maxEntries} limit)`)}var iae;var Hp=w(()=>{Qr();sf();iae={maxEntries:1e6,maxInMemorySize:268435456,maxIndexSize:67108864,maxMemberSize:67108864,maxPathBytes:4096,maxLinkDepth:40}});function Sc(e,t){let n=e.get(t.path);if(!n)return e.set(t.path,t),t;if(n.isDirectory&&!t.isDirectory)return e.set(t.path,t),t;if(!n.isDirectory&&t.isDirectory)return;let s={...t,mtimeMs:t.mtimeMs??n.mtimeMs,mode:t.mode??n.mode,storage:t.storage??n.storage};return e.set(t.path,s),s}function ZL(e,t){cr(e.size,t);for(let n of[...e.values()]){let s=n.path.split("/"),o=s.length-1;for(let r=1;r<=o;r++){let i=s.slice(0,r).join("/");if(!i||e.has(i))continue;e.set(i,{path:i,isDirectory:!0,size:0}),cr(e.size,t)}}}function eW(e,t,n){let s=t,o=new Set;for(let r=0;!o.has(s);){o.add(s);let i;for(let a=s.length;a>0;a=s.lastIndexOf("/",a-1)){let l=e.get(s.slice(0,a));if(l?.storage?.type!=="link"||!l.isDirectory&&!l.storage.resolveTarget)continue;let u=s.slice(a+1);i=u?l.storage.targetPath?`${l.storage.targetPath}/${u}`:u:l.storage.targetPath;break}if(i===void 0)return s;if(++r>n)break;s=i}throw new G(`Archive path '${t}' crosses a cyclic symlink`)}var e_=w(()=>{Qr();Hp()});function GJr(e,t){throw new G(`Archive symlink '${br(t)}' cannot be materialized from target '${br(e)}'`)}class Xmt{format;limits;#e=new Map;constructor(e,t,n=iae){this.format=e,this.limits=n;for(let s of t)Sc(this.#e,s);ZL(this.#e,n)}indexEntries(){return this.#e.values()}getNode(e){let t=tf(e);if(t===void 0)return;if(t==="")return{path:"",isDirectory:!0,size:0};let n=eW(this.#e,t,this.limits.maxLinkDepth);if(n==="")return{path:t,isDirectory:!0,size:0};let s=this.#e.get(n);if(!s)return;return{path:t,isDirectory:s.isDirectory,size:s.size,mtimeMs:s.mtimeMs,mode:s.mode}}listDirectory(e){let t=tf(e);if(t===void 0)throw new G("Archive path cannot contain '..'");let n=t?eW(this.#e,t,this.limits.maxLinkDepth):"";if(t&&n!==""){let r=this.#e.get(n);if(!r)throw new G(`Archive path '${t}' not found`);if(!r.isDirectory)throw new G(`Archive path '${t}' is not a directory`)}let s=n?`${n}/`:"",o=new Map;for(let r of this.#e.values()){if(n){if(!r.path.startsWith(s)||r.path===n)continue}let i=n?r.path.slice(s.length):r.path,a=i.split("/")[0];if(!a)continue;let l=t?`${t}/${a}`:a;if(o.has(l))continue;let u=n?`${n}/${a}`:a,p=eW(this.#e,u,this.limits.maxLinkDepth),c=p?this.#e.get(p):void 0,d=p===""||c?.isDirectory===!0||i.includes("/");o.set(l,{name:a,path:l,isDirectory:d,size:d?0:c?.size??r.size,mtimeMs:c?.mtimeMs??r.mtimeMs,mode:c?.mode??r.mode})}return[...o.values()].sort((r,i)=>r.name.toLowerCase().localeCompare(i.name.toLowerCase()))}async readFile(e){let t=tf(e);if(!t)throw new G("Archive file path is required");let n=eW(this.#e,t,this.limits.maxLinkDepth);if(n==="")throw new G(`Archive path '${t}' is a directory`);let s=this.#e.get(n);if(!s)throw new G(`Archive file '${t}' not found`);if(s.isDirectory)throw new G(`Archive path '${t}' is a directory`);if(!s.storage)throw new G(`Archive file '${t}' has no readable storage`);if(fa(s.size,t,this.limits),s.storage.type==="link")GJr(s.storage.targetPath,t);let o=await s.storage.source.read(s.size,t);return{path:t,isDirectory:!1,size:s.size,mtimeMs:s.mtimeMs,mode:s.mode,bytes:o}}}var Jmt=w(()=>{e_();Qr();Hp();sf()});function sa(e,t=0){return Bun.hash.crc32(e,t)>>>0}function B$n(e,t=0n){let n=t^0xffffffffffffffffn,s=Number(n&0xffffffffn)>>>0,o=Number(n>>32n&0xffffffffn)>>>0;for(let r=0;r<e.length;r++){let i=(s^e[r])&255;s=((s>>>8|(o&255)<<24)>>>0^q$n[i])>>>0,o=(o>>>8^U$n[i])>>>0}return(BigInt(o)<<32n|BigInt(s))^0xffffffffffffffffn}function IY(e,t=0){let n=t;for(let s=0;s<e.length;s++)n=(n>>>8^W$n[(n^e[s])&255])&65535;return n}var q$n,U$n,W$n;var pO=w(()=>{q$n=new Uint32Array(256),U$n=new Uint32Array(256);for(let e=0;e<256;e++){let t=e,n=0;for(let s=0;s<8;s++){let o=(t&1)!==0;if(t=(t>>>1|(n&1)<<31)>>>0,n>>>=1,o)t=(t^3615952706)>>>0,n=(n^3379320725)>>>0}q$n[e]=t,U$n[e]=n}W$n=new Uint16Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=(t&1)!==0?t>>>1^40961:t>>>1;W$n[e]=t}});function G$n(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<e)throw new G("Invalid archive range")}function $$n(e,t,n){if(G$n(t,n),n>e.byteLength)throw new G("Invalid archive: truncated data");return e.subarray(t,n)}function vPe(e){return{size:e.byteLength,async read(t,n){return $$n(e,t,n)}}}function Qmt(e){let t=Bun.file(e),n=t.size;if(!Number.isSafeInteger(n))throw new G("Archive is too large to read safely");return{size:n,async read(s,o){G$n(s,o);let r=await t.slice(s,o).bytes();if(r.byteLength!==o-s)throw new G("Invalid archive: truncated data");return r}}}async function XA(e){return e.read(0,e.size)}var JA=w(()=>{Qr()});class egt{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=t}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#n+e>this.#e.byteLength*8)throw new G(`Invalid ${this.#t} compressed data: truncated bitstream`);let t=0;for(let n=0;n<e;n++){let s=this.#n++;t=t*2+(this.#e[s>>>3]>>>7-(s&7)&1)}return t}assertZeroPadding(){while(this.#n<this.#e.byteLength*8)if(this.read(1)!==0)throw new G(`Invalid ${this.#t} compressed data: non-zero trailing bits`)}}class dO{#e=[-1];#t=[-1];#n=[-1];#s;constructor(e){this.#s=e}static single(e,t,n){if(!Number.isInteger(e)||e<0||e>=t)throw new G(`Invalid ${n} Huffman table: symbol is out of range`);let s=new dO(n);return s.#n[0]=e,s}static build(e,t,n){let s=new Uint32Array(17),o=0;for(let l=0;l<t;l++){let u=e[l];if(u>16)throw new G(`Invalid ${n} Huffman table: code is too long`);if(u!==0)s[u]++,o=Math.max(o,u)}if(o===0)throw new G(`Invalid ${n} Huffman table: no symbols`);let r=new Uint32Array(17),i=0;for(let l=1;l<=16;l++){if(i=(i+s[l-1])*2,i+s[l]>2**l)throw new G(`Invalid ${n} Huffman table: oversubscribed codes`);r[l]=i}if(r[o]+s[o]!==2**o)throw new G(`Invalid ${n} Huffman table: incomplete codes`);let a=new dO(n);for(let l=0;l<t;l++){let u=e[l];if(u===0)continue;let p=r[u];r[u]=p+1;let c=0;for(let d=u-1;d>=0;d--){if(a.#n[c]>=0)throw new G(`Invalid ${n} Huffman table: prefix collision`);let f=p>>>d&1,m=f===0?a.#e[c]:a.#t[c];if(m<0)if(m=a.#n.length,a.#e.push(-1),a.#t.push(-1),a.#n.push(-1),f===0)a.#e[c]=m;else a.#t[c]=m;c=m}if(a.#n[c]>=0||a.#e[c]>=0||a.#t[c]>=0)throw new G(`Invalid ${n} Huffman table: duplicate code`);a.#n[c]=l}return a}decode(e){let t=0;for(let n=0;n<=16;n++){let s=this.#n[t];if(s>=0)return s;if(t=e.read(1)===0?this.#e[t]:this.#t[t],t<0)throw new G(`Invalid ${this.#s} Huffman code`)}throw new G(`Invalid ${this.#s} Huffman code: excessive depth`)}}function K$n(e,t){let n=e.read(3);if(n===7){while(e.read(1)!==0)if(n++,n>16)throw new G(`Invalid ${t} Huffman table: code is too long`)}return n}function zJr(e,t){let s=e.read(5);if(s===0)return dO.single(e.read(5),19,t);if(s>19)throw new G(`Invalid ${t} temporary Huffman table size`);let o=new Uint8Array(19),r=0;while(r<s)if(o[r++]=K$n(e,t),r===3){let i=e.read(2);if(r+i>s)throw new G(`Invalid ${t} temporary Huffman table`);r+=i}return dO.build(o,19,t)}function VJr(e,t,n){let o=e.read(9);if(o===0)return dO.single(e.read(9),510,n);if(o>510)throw new G(`Invalid ${n} command Huffman table size`);let r=new Uint8Array(510),i=0;while(i<o){let a=t.decode(e);if(a<=2){let l=a===0?1:a===1?e.read(4)+3:e.read(9)+20;if(i+l>o)throw new G(`Invalid ${n} command Huffman table`);i+=l}else r[i++]=a-2}return dO.build(r,510,n)}function YJr(e,t,n,s){let o=e.read(t);if(o===0)return dO.single(e.read(t),n,s);if(o>n)throw new G(`Invalid ${s} position Huffman table size`);let r=new Uint8Array(n);for(let i=0;i<o;i++)r[i]=K$n(e,s);return dO.build(r,n,s)}function xY(e,t,n,s,o,r){let i=new egt(e,r),a=new Uint8Array(t),l=0,u=0,p,c;while(l<t){if(u===0){if(u=i.read(16),u===0)throw new G(`Invalid ${r} compressed data: empty block`);let T=zJr(i,r);p=VJr(i,T,r),c=YJr(i,s,o,r)}u--;let d=p.decode(i);if(d<256){a[l++]=d;continue}let f=d-256+3;if(f>t-l)throw new G(`Invalid ${r} compressed data: match exceeds declared size`);let m=c.decode(i),g=m;if(m>1){let T=m-1;g=2**T+i.read(T)}if(g>=n||g>=l)throw new G(`Invalid ${r} compressed data: history distance is out of range`);let h=l-g-1;for(let T=0;T<f;T++)a[l++]=a[h++]}if(u!==0)throw new G(`Invalid ${r} compressed data: block exceeds declared size`);return i.assertZeroPadding(),a}function KJr(e,t){let n=new egt(e,"LZH -lzs-"),s=new Uint8Array(t),o=new Uint8Array(2048);o.fill(32);let r=2031,i=0,a=(l)=>{if(i>=t)throw new G("Invalid LZH -lzs- data: output exceeds declared size");s[i++]=l,o[r]=l,r=r+1&2047};while(i<t)if(n.read(1)!==0)a(n.read(8));else{let l=n.read(11),u=n.read(4)+2;if(u>t-i)throw new G("Invalid LZH -lzs- data: match exceeds declared size");for(let p=0;p<u;p++)a(o[l+p&2047])}return n.assertZeroPadding(),s}function JJr(e,t,n){if(t<0)return IY(e);let s=IY(e.subarray(0,t));return s=IY(XJr.subarray(0,n-t),s),IY(e.subarray(n),s)}function cO(e,t){return e[t]|e[t+1]<<8}function QA(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function j$n(e,t){let n=QA(e,t)+QA(e,t+4)*4294967296;if(!Number.isSafeInteger(n))throw new G("LZH uses sizes too large to read safely");return n}function aae(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid LZH archive: truncated ${s}`)}function Zmt(e){let t=e.indexOf(0);if(t<0)t=e.byteLength;return $Jr.decode(e.subarray(0,t))}function z$n(e){if((e.byteLength&1)!==0)throw new G("Invalid LZH Unicode path header: odd UTF-16 length");let t=e.byteLength;while(t>=2&&e[t-1]===0&&e[t-2]===0)t-=2;return jJr.decode(e.subarray(0,t))}function QJr(e){if(e===0)return;let t=1980+(e>>>25&127),n=e>>>21&15,s=e>>>16&31,o=e>>>11&31,r=e>>>5&63,i=(e&31)*2;if(n<1||n>12||s<1||s>31||o>23||r>59||i>59)return;return Date.UTC(t,n-1,s,o,r,i)}function V$n(e,t,n,s){switch(e){case 0:if(t.byteLength<2)throw new G("Invalid LZH common extended header");s.commonCrc=cO(t,0),s.commonCrcOffset=n;break;case 1:s.filename=Zmt(t);break;case 2:s.directory=Zmt(t).replaceAll("ÿ","/");break;case 57:throw new G("Multi-volume LZH archives are unsupported");case 65:if(t.byteLength>=16){let o=QA(t,8),r=QA(t,12),i=o+r*4294967296;if(Number.isSafeInteger(i))s.mtimeMs=i/1e4-11644473600000}break;case 66:if(t.byteLength<16)throw new G("Invalid LZH 64-bit size extended header");s.packedSize=j$n(t,0),s.size=j$n(t,8);break;case 68:s.unicodeFilename=z$n(t);break;case 69:s.unicodeDirectory=z$n(t).replaceAll("ÿ","/");break;case 80:if(t.byteLength<2)throw new G("Invalid LZH Unix permissions extended header");s.mode=cO(t,0);break;case 84:if(t.byteLength<4)throw new G("Invalid LZH Unix timestamp extended header");s.mtimeMs=QA(t,0)*1000;break}}class X$n{#e;#t;#n;#s;#o;constructor(e,t,n,s,o){this.#e=e,this.#t=t,this.#n=n,this.#s=s,this.#o=o}async read(e,t){let n=this.#e.subarray(this.#t,this.#t+this.#n),s;switch(this.#s){case"-lh0-":case"-lz4-":if(n.byteLength!==e)throw new G(`LZH member '${t}' has inconsistent stored size`);s=n.slice();break;case"-lh4-":s=xY(n,e,4096,4,13,"LZH -lh4-");break;case"-lh5-":s=xY(n,e,8192,4,14,"LZH -lh5-");break;case"-lh6-":s=xY(n,e,32768,5,16,"LZH -lh6-");break;case"-lh7-":s=xY(n,e,65536,5,17,"LZH -lh7-");break;case"-lzs-":s=KJr(n,e);break;case"-lh1-":throw new G(`LZH member '${t}' uses unsupported dynamic-Huffman method -lh1-`);default:throw new G(`LZH member '${t}' uses unsupported compression method ${this.#s}`)}if(s.byteLength!==e)throw new G(`LZH member '${t}' extracted to an unexpected size`);if(IY(s)!==this.#o)throw new G(`LZH member '${t}' failed CRC-16 verification`);return s}}function ZJr(e,t,n){aae(e,t,t+22,"header");let s=e[t+20];if(s>2)throw new G(`Unsupported LZH header level ${s}`);let o=String.fromCharCode(...e.subarray(t+2,t+7));if(!Y$n.test(o))throw new G(`Invalid LZH compression method '${o}'`);let r=QA(e,t+7),i=QA(e,t+11),a=0,l,u,p=0,c,d={};if(s<2){let T=e[t];if(T<(s===0?22:25))throw new G(`Invalid LZH level-${s} header size`);let y=t+T+2;aae(e,t,y,"header");let C=0;for(let E=t+2;E<y;E++)C=C+e[E]&255;if(C!==e[t+1])throw new G("Invalid LZH header checksum");let S=e[t+21];if(22+S+2>T+2)throw new G("Invalid LZH filename length");if(wo(S,"member path",n.limits.maxPathBytes),l=Zmt(e.subarray(t+22,t+22+S)),a=cO(e,t+22+S),u=QJr(QA(e,t+15)),s===0){let E=t+24+S;if(y-E>=12){let A=e.subarray(E,y);if((A[0]===85||A[0]===75)&&A[1]===0)p=A[0],d.mtimeMs=QA(A,2)*1000,d.mode=cO(A,A.byteLength-6)}c=y}else{p=e[t+24+S];let E=cO(e,y-2),A=y,k=0,x=0;while(E!==0){if(E<3)throw new G("Invalid LZH extended header size");if(aae(e,A,A+E,"extended header"),k+=E,Ns(T+2+k,n.limits,"header metadata"),++x>65535)throw new G("Invalid LZH archive: too many extended headers");let M=e[A],O=A+E-2,v=e.subarray(A+1,O);if(M===1||M===2||M===68||M===69)wo(v.byteLength,"member path",n.limits.maxPathBytes);V$n(M,v,A+1,d);let P=E;E=cO(e,O),A+=P}if(c=y+k,r=d.packedSize??r-k,r<0)throw new G("Invalid LZH level-1 packed size")}}else{let T=cO(e,t);if(T<26)throw new G("Invalid LZH level-2 header size");let R=t+T;aae(e,t,R,"header"),a=cO(e,t+21),p=e[t+23],u=QA(e,t+15)*1000;let y=t+24,C=0;while(y+2<=R){let S=cO(e,y);if(S===0){y+=2;break}if(S<3||y+S>R)throw new G("Invalid LZH extended header size");if(++C>65535)throw new G("Invalid LZH archive: too many extended headers");let E=e[y+2],A=e.subarray(y+3,y+S);if(E===1||E===2||E===68||E===69)wo(A.byteLength,"member path",n.limits.maxPathBytes);V$n(E,A,y+3,d),y+=S}if(y!==R)throw new G("Invalid LZH level-2 extended header chain");c=R,r=d.packedSize??r}if(s===1&&p===32&&o==="-lh7-")throw new G("LZH uses the incompatible LHARK -lh7- variant");i=d.size??i,u=d.mtimeMs??u;let f=d.mode;if(d.commonCrc!==void 0){let T=d.commonCrcOffset-t;if(JJr(e.subarray(t,c),T,T+2)!==d.commonCrc)throw new G("Invalid LZH common header CRC-16")}let m=d.unicodeFilename??d.filename??l??"",g=d.unicodeDirectory??d.directory??"",h=`${g}${g&&!/[\\/]$/.test(g)?"/":""}${m}`;return nf(h,"member path",n.limits.maxPathBytes),fa(i,h||"<unnamed>",n.limits),aae(e,c,c+r,"member data"),{method:o,packedSize:r,size:i,dataStart:c,nextOffset:c+r,crc:a,path:Lr(h),mtimeMs:u,mode:f}}function tgt(e){if(e.byteLength<22||e[2]!==45||e[6]!==45||e[3]!==108)return!1;let t=String.fromCharCode(...e.subarray(2,7));return Y$n.test(t)&&e[20]<=2}var $Jr,jJr,Y$n,XJr,J$n=async(e,t)=>{ki(e.size,t.limits);let n;try{n=await XA(e)}catch(a){if(a instanceof G)throw a;throw new G(`Unable to read LZH archive: ${a instanceof Error?a.message:String(a)}`)}if(n.byteLength!==e.size)throw new G("Invalid LZH archive: truncated data");if(!tgt(n))throw new G("Invalid LZH archive header");let s=[],o=0,r=0,i=0;while(o<n.byteLength&&n[o]!==0){let a=ZJr(n,o,t);if(i+=a.dataStart-o,Ns(i,t.limits,"index"),cr(++r,t.limits),a.nextOffset<=o)throw new G("Invalid LZH archive: header did not advance");if(o=a.nextOffset,!a.path)continue;let l=a.method==="-lhd-";if(l&&a.mode!==void 0&&(a.mode&61440)===40960){let u=a.path.indexOf("|");if(u<1)throw new G(`Invalid LZH symbolic link '${a.path}'`);let p=Lr(a.path.slice(0,u)),c=Lr(a.path.slice(u+1));if(!p||!c)continue;s.push({path:p,isDirectory:!1,size:0,mtimeMs:a.mtimeMs,mode:a.mode,storage:{type:"link",targetPath:c,resolveTarget:!1}});continue}s.push({path:a.path,isDirectory:l,size:l?0:a.size,mtimeMs:a.mtimeMs,mode:a.mode,storage:l?void 0:{type:"member",source:new X$n(n,a.dataStart,a.packedSize,a.method,a.crc)}})}if(s.length===0&&r===0)throw new G("Invalid LZH archive: no members");return s};var ngt=w(()=>{pO();Qr();Hp();sf();JA();$Jr=new TextDecoder("windows-1252"),jJr=new TextDecoder("utf-16"),Y$n=/^-(?:lh[0-7d]|lz[45s])-$/;XJr=new Uint8Array(2)});function OPe(e,t){return e[t]|e[t+1]<<8}function tW(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function lae(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid ARJ archive: truncated ${s}`)}function tQr(e){if(e===0)return;let t=1980+(e>>>25&127),n=e>>>21&15,s=e>>>16&31,o=e>>>11&31,r=e>>>5&63,i=(e&31)*2;if(n<1||n>12||s<1||s>31||o>23||r>59||i>59)return;return Date.UTC(t,n-1,s,o,r,i)}function Q$n(e,t,n,s){let o=t;while(o<n&&e[o]!==0)o++;if(o===n)throw new G(`Invalid ARJ ${s}: missing terminator`);return{value:eQr.decode(e.subarray(t,o)),next:o+1}}function Z$n(e,t,n){if(lae(e,t,t+4,"header signature"),e[t]!==e3n||e[t+1]!==t3n)throw new G("Invalid ARJ header signature");let s=OPe(e,t+2);if(s===0)return{bodyStart:t+4,bodySize:0,nextOffset:t+4,metadataSize:4,isEnd:!0};if(s<30||s>n3n)throw new G("Invalid ARJ basic header size");let o=t+4,r=o+s;if(lae(e,o,r+4,"basic header"),sa(e.subarray(o,r))!==tW(e,r))throw new G("Invalid ARJ basic header CRC32");let i=r+4,a=0;for(;;){lae(e,i,i+2,"extended header size");let l=OPe(e,i);if(i+=2,l===0)break;if(++a>65535)throw new G("Invalid ARJ archive: too many extended headers");if(lae(e,i,i+l+4,"extended header"),sa(e.subarray(i,i+l))!==tW(e,i+l))throw new G("Invalid ARJ extended header CRC32");i+=l+4,Ns(i-t,n.limits,"header metadata")}return{bodyStart:o,bodySize:s,nextOffset:i,metadataSize:i-t,isEnd:!1}}class s3n{#e;#t=0;constructor(e){this.#e=e}read(e){if(!Number.isInteger(e)||e<0||e>24||this.#t+e>this.#e.byteLength*8)throw new G("Invalid ARJ method-4 compressed data: truncated bitstream");let t=0;for(let n=0;n<e;n++){let s=this.#t++;t=t*2+(this.#e[s>>>3]>>>7-(s&7)&1)}return t}assertZeroPadding(){while(this.#t<this.#e.byteLength*8)if(this.read(1)!==0)throw new G("Invalid ARJ method-4 compressed data: non-zero trailing bits")}}function nQr(e,t){let n=new s3n(e),s=new Uint8Array(t),o=0;while(o<t){let r=0,i=0;for(;i<7;i++){if(n.read(1)===0)break;r+=2**i}if(i!==0)r+=n.read(i);if(r===0){s[o++]=n.read(8);continue}let a=r+2;if(a>t-o)throw new G("Invalid ARJ method-4 compressed data: match exceeds declared size");let l=0,u=9;for(;u<13;u++){if(n.read(1)===0)break;l+=2**u}if(l+=n.read(u),l>=26624||l>=o)throw new G("Invalid ARJ method-4 compressed data: history distance is out of range");let p=o-l-1;for(let c=0;c<a;c++)s[o++]=s[p++]}return n.assertZeroPadding(),s}class o3n{#e;#t;#n;#s;#o;constructor(e,t,n,s,o){this.#e=e,this.#t=t,this.#n=n,this.#s=s,this.#o=o}async read(e,t){let n=this.#e.subarray(this.#t,this.#t+this.#n),s;switch(this.#s){case 0:if(n.byteLength!==e)throw new G(`ARJ member '${t}' has inconsistent stored size`);s=n.slice();break;case 1:case 2:case 3:s=xY(n,e,26624,5,17,`ARJ method ${this.#s}`);break;case 4:s=nQr(n,e);break;case 8:case 9:if(e!==0||n.byteLength!==0)throw new G(`ARJ member '${t}' has invalid no-data method sizes`);s=new Uint8Array(0);break;default:throw new G(`ARJ member '${t}' uses unsupported compression method ${this.#s}`)}if(s.byteLength!==e)throw new G(`ARJ member '${t}' extracted to an unexpected size`);if(this.#s!==8&&sa(s)!==this.#o)throw new G(`ARJ member '${t}' failed CRC32 verification`);return s}}function sQr(e,t){let n=e.replaceAll("\\","/");if(t===1)n=n.replaceAll(">","/");else if(t===4)n=n.replaceAll(":","/");return n}function sgt(e){if(e.byteLength<34||e[0]!==e3n||e[1]!==t3n)return!1;let t=OPe(e,2);if(t<30||t>n3n||e.byteLength<t+8)return!1;let n=e.subarray(4,4+t);return n[0]>=30&&n[0]<=t&&n[6]===2&&sa(n)===tW(e,4+t)}var e3n=96,t3n=234,n3n=2600,eQr,r3n=async(e,t)=>{ki(e.size,t.limits);let n;try{n=await XA(e)}catch(p){if(p instanceof G)throw p;throw new G(`Unable to read ARJ archive: ${p instanceof Error?p.message:String(p)}`)}if(n.byteLength!==e.size)throw new G("Invalid ARJ archive: truncated data");if(!sgt(n))throw new G("Invalid ARJ archive header");let s=Z$n(n,0,t);if(s.isEnd)throw new G("Invalid ARJ archive: missing main header");let o=n[s.bodyStart];if(o<30||o>s.bodySize||n[s.bodyStart+6]!==2)throw new G("Invalid ARJ main header");let r=n[s.bodyStart+4];if((r&1)!==0)throw new G("Encrypted ARJ archives are unsupported");if((r&4)!==0)throw new G("Multi-volume ARJ archives are unsupported");let i=[],a=s.nextOffset,l=s.metadataSize,u=0;for(;;){let p=Z$n(n,a,t);if(l+=p.metadataSize,Ns(l,t.limits,"index"),p.isEnd)break;cr(++u,t.limits);let c=n[p.bodyStart];if(c<30||c>p.bodySize)throw new G("Invalid ARJ local header");let d=n[p.bodyStart+3],f=n[p.bodyStart+4],m=n[p.bodyStart+5],g=n[p.bodyStart+6];if((f&1)!==0)throw new G("Encrypted ARJ members are unsupported");if((f&12)!==0)throw new G("Multi-volume ARJ members are unsupported");let h=tW(n,p.bodyStart+12),T=tW(n,p.bodyStart+16),R=tW(n,p.bodyStart+20),y=OPe(n,p.bodyStart+26),C=Q$n(n,p.bodyStart+c,p.bodyStart+p.bodySize,"filename");Q$n(n,C.next,p.bodyStart+p.bodySize,"comment"),wo(C.next-(p.bodyStart+c)-1,"member path",t.limits.maxPathBytes);let S=sQr(C.value,d);nf(S,"member path",t.limits.maxPathBytes),fa(T,S||"<unnamed>",t.limits);let E=p.nextOffset;lae(n,E,E+h,"member data"),a=E+h;let A=Lr(S);if(!A)continue;let k=g===3,x;if((d===2||d===8)&&y!==0)x=(k?16384:32768)|y&4095;let M=tW(n,p.bodyStart+8),O=d===2||d===8?M===0?void 0:M*1000:tQr(M);i.push({path:A,isDirectory:k,size:k?0:T,mtimeMs:O,mode:x,storage:k?void 0:{type:"member",source:new o3n(n,E,h,m,R)}})}if(u===0)throw new G("Invalid ARJ archive: no members");return i};var i3n=w(()=>{pO();Qr();Hp();ngt();sf();JA();eQr=new TextDecoder("windows-1252")});import*as l3n from"node:path";function Wi(e){return new G(`Invalid ASAR archive: ${e}`)}function NPe(e){return e instanceof Error&&e.message?e.message:String(e)}function ogt(e){return e+(4-e%4)%4}function uae(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function aQr(e,t,n){if(e===void 0)return;let s=br(t);if(!uae(e))throw Wi(`file '${s}' has an invalid integrity record`);if(e.algorithm!=="SHA256")throw Wi(`file '${s}' uses unsupported integrity algorithm '${String(e.algorithm)}'`);if(typeof e.hash!=="string"||!a3n.test(e.hash))throw Wi(`file '${s}' has an invalid integrity hash`);if(typeof e.blockSize!=="number"||!Number.isSafeInteger(e.blockSize)||e.blockSize<=0)throw Wi(`file '${s}' has an invalid integrity block size`);if(!Array.isArray(e.blocks))throw Wi(`file '${s}' has invalid integrity blocks`);let o=Math.max(1,Math.ceil(n/e.blockSize));if(e.blocks.length!==o)throw Wi(`file '${s}' has an inconsistent integrity block count`);for(let r of e.blocks)if(typeof r!=="string"||!a3n.test(r))throw Wi(`file '${s}' has an invalid integrity block hash`);return{algorithm:"SHA256",hash:e.hash.toLowerCase()}}function u3n(e,t,n){if(!t)return;if(new Bun.CryptoHasher("sha256").update(e).digest("hex")!==t.hash)throw new G(`ASAR member '${br(n)}' failed SHA256 integrity verification`)}class p3n{#e;#t;#n;#s;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}async read(e,t){if(e!==this.#n)throw new G(`ASAR member '${br(t)}' has an inconsistent size`);let n;try{n=await this.#e.read(this.#t,this.#t+this.#n)}catch(s){if(s instanceof G)throw s;throw new G(`Failed to read ASAR member '${br(t)}': ${NPe(s)}`)}if(n.byteLength!==this.#n)throw new G(`ASAR member '${br(t)}' is truncated`);return u3n(n,this.#s,t),n}}class c3n{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){let n=br(t);if(e!==this.#t)throw new G(`ASAR member '${n}' has an inconsistent size`);if(!this.#e)throw new G(`Archive file '${n}' is unpacked and requires a filesystem-backed ASAR archive`);let s=Bun.file(this.#e),o=await s.stat().catch(()=>{throw new G(`Unpacked ASAR file '${n}' was not found`)});if(o.isDirectory())throw new G(`Unpacked ASAR file '${n}' is a directory`);if(o.size!==this.#t)throw new G(`Unpacked ASAR file '${n}' size differs from its archive header (${o.size} != ${this.#t} bytes)`);let r;try{r=await s.bytes()}catch(i){throw new G(`Failed to read unpacked ASAR file '${n}': ${NPe(i)}`)}if(r.byteLength!==this.#t)throw new G(`Unpacked ASAR file '${n}' changed while being read`);return u3n(r,this.#n,t),r}}async function lQr(e,t){if(!Number.isSafeInteger(e.size)||e.size<PPe)throw Wi("truncated header");let n=await e.read(0,MY);if(n.byteLength!==MY)throw Wi("truncated size pickle");if(wn(n,0)!==4)throw Wi("invalid size pickle");let s=wn(n,4);if(s<pae)throw Wi("header is too small");Ns(s,t.limits,"ASAR header");let o=MY+s;if(!Number.isSafeInteger(o)||o>e.size)throw Wi("header extends beyond archive boundary");let r=await e.read(MY,o);if(r.byteLength!==s)throw Wi("truncated header pickle");let i=wn(r,0),a=wn(r,4);if(i+4!==s||i!==4+ogt(a))throw Wi("inconsistent pickle lengths");let l=pae+a;for(let g=l;g<r.byteLength;g++)if(r[g]!==0)throw Wi("non-zero pickle string padding");let u;try{u=oQr.decode(r.subarray(pae,l))}catch{throw Wi("header is not valid UTF-8")}let p;try{p=JSON.parse(u)}catch{throw Wi("header is not valid JSON")}if(!uae(p)||!uae(p.files))throw Wi("root must contain a files object");let c=[],d=[],f=0,m=(g,h,T)=>{for(let R in g)cr(++f,t.limits),d.push({parentPath:h,parentPathBytes:T,name:R,node:g[R]})};m(p.files,"",0);while(d.length>0){let g=d.pop(),h=Buffer.byteLength(g.name,"utf-8");if(wo(h,"entry name",t.limits.maxPathBytes),g.name.length===0||g.name==="."||g.name===".."||g.name.includes("/")||g.name.includes("\\")||g.name.includes("\x00"))throw Wi(`invalid entry name '${br(g.name)}'`);if(!uae(g.node))throw Wi(`entry '${br(g.name)}' must be an object`);let T=g.parentPathBytes+(g.parentPath?1:0)+h;wo(T,"member path",t.limits.maxPathBytes);let R=g.parentPath?`${g.parentPath}/${g.name}`:g.name;if(Lr(R)!==R)throw Wi(`invalid entry path '${br(R)}'`);let C=br(R);if(g.node.unpacked!==void 0&&typeof g.node.unpacked!=="boolean")throw Wi(`entry '${C}' has a non-boolean unpacked flag`);if("link"in g.node){if(typeof g.node.link!=="string"||g.node.link.length===0)throw Wi(`entry '${C}' has an invalid link target`);nf(g.node.link,"link target",t.limits.maxPathBytes);let O=g.node.link.replace(/\\/g,"/"),v=O.startsWith("/")||/^[A-Za-z]:\//.test(O)?void 0:tf(O);if(v===void 0)throw Wi(`entry '${C}' links outside the archive`);c.push({path:R,isDirectory:!1,size:0,storage:{type:"link",targetPath:v,resolveTarget:!0}});continue}if("files"in g.node){if(!uae(g.node.files))throw Wi(`directory '${C}' must contain a files object`);c.push({path:R,isDirectory:!0,size:0}),m(g.node.files,R,T);continue}let S=g.node.size;if(typeof S!=="number"||!Number.isSafeInteger(S)||S<0)throw Wi(`file '${C}' has an invalid size`);if(fa(S,R,t.limits),g.node.executable!==void 0&&typeof g.node.executable!=="boolean")throw Wi(`file '${C}' has a non-boolean executable flag`);let E=typeof g.node.executable==="boolean"?iQr|(g.node.executable?493:420):void 0,A=aQr(g.node.integrity,R,S);if(g.node.unpacked===!0){let O=t.archivePath?l3n.join(`${t.archivePath}.unpacked`,...R.split("/")):void 0;c.push({path:R,isDirectory:!1,size:S,mode:E,storage:{type:"member",source:new c3n(O,S,A)}});continue}if(typeof g.node.offset!=="string"||!/^\d+$/.test(g.node.offset))throw Wi(`file '${C}' has an invalid offset`);let k=Number(g.node.offset),x=o+k,M=x+S;if(!Number.isSafeInteger(k)||!Number.isSafeInteger(x)||!Number.isSafeInteger(M)||M>e.size)throw Wi(`file '${C}' extends beyond archive boundary`);c.push({path:R,isDirectory:!1,size:S,mode:E,storage:{type:"member",source:new p3n(e,x,S,A)}})}return c}function f3n(e){if(e.byteLength<PPe+1)return!1;let t=wn(e,0),n=wn(e,4),s=wn(e,8),o=wn(e,12);return t===4&&n>=pae&&n===s+4&&s===4+ogt(o)&&o>0&&e[PPe]===123}function uQr(e){let t=e.replace(/\\/g,"/"),n=Lr(t);if(n===void 0||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.includes("\x00")||t.split("/").some((s)=>!s||s==="."||s===".."))throw new G(`Invalid ASAR member path '${br(e)}'`);return n}async function m3n(e){try{let t={files:Object.create(null)},n=[],s=0;for(let d of e){if(!Array.isArray(d)||d.length!==2||typeof d[0]!=="string"||!(d[1]instanceof Uint8Array))throw new G("ASAR members must be [path, Uint8Array] pairs");let f=uQr(d[0]),m=f.split("/"),g=t;for(let T=0;T<m.length-1;T++){let R=m[T],y=g.files[R];if(y&&!("files"in y))throw new G(`ASAR member path '${f}' crosses file '${m.slice(0,T+1).join("/")}'`);if(!y)g.files[R]={files:Object.create(null)};g=g.files[R]}let h=m.at(-1);if(g.files[h])throw new G(`Duplicate or conflicting ASAR member path '${f}'`);if(!Number.isSafeInteger(d[1].byteLength)||!Number.isSafeInteger(s+d[1].byteLength))throw new G("ASAR payload is too large to encode safely");g.files[h]={size:d[1].byteLength,offset:String(s)},n.push(d[1]),s+=d[1].byteLength}let o=rQr.encode(JSON.stringify(t)),i=4+ogt(o.byteLength),a=4+i;if(o.byteLength>4294967295||a>4294967295)throw new G("ASAR header is too large to encode");let l=MY+a,u=l+s;if(!Number.isSafeInteger(u))throw new G("ASAR archive is too large to encode safely");let p;try{p=new Uint8Array(u)}catch{throw new G("ASAR archive is too large to encode in memory")}Cl(p,0,4),Cl(p,4,a),Cl(p,8,i),Cl(p,12,o.byteLength),p.set(o,PPe);let c=l;for(let d of n)p.set(d,c),c+=d.byteLength;return p}catch(t){if(t instanceof G)throw t;throw new G(`Failed to encode ASAR archive: ${NPe(t)}`)}}var oQr,rQr,MY=8,pae=8,PPe,iQr=32768,a3n,d3n=async(e,t)=>{try{return await lQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(`Failed to read ASAR archive: ${NPe(n)}`)}};var rgt=w(()=>{Lh();Qr();Hp();sf();oQr=new TextDecoder("utf-8",{fatal:!0}),rQr=new TextEncoder,PPe=MY+pae,a3n=/^[0-9a-f]{64}$/i});class T3n{#e;#t=0;#n=0;#s=0;constructor(e){this.#e=e}readBits(e){let t=0,n=e;while(n>0){if(this.#s===0){if(this.#t+2>this.#e.byteLength)throw new G("Invalid CAB archive: truncated LZX bitstream");this.#n=this.#e[this.#t]|this.#e[this.#t+1]<<8,this.#t+=2,this.#s=16}let s=Math.min(n,this.#s);t=t*2**s+(this.#n>>>this.#s-s&2**s-1),this.#s-=s,n-=s}return t}alignWord(){this.#s=0}readByte(){if(this.#s!==0)throw new G("Invalid CAB archive: misaligned LZX byte stream");if(this.#t>=this.#e.byteLength)throw new G("Invalid CAB archive: truncated LZX data");return this.#e[this.#t++]}readUInt32LE(){let e=this.readByte(),t=this.readByte(),n=this.readByte(),s=this.readByte();return(e|t<<8|n<<16|s<<24)>>>0}}class cae{#e=new Uint32Array(17);#t=new Uint32Array(17);#n=new Uint32Array(17);#s;empty;constructor(e,t=!1){let n=0;for(let i of e){if(i>16)throw new G("Invalid CAB archive: invalid LZX Huffman code length");if(i!==0)this.#e[i]++,n++}if(this.empty=n===0,this.empty&&!t)throw new G("Invalid CAB archive: empty LZX Huffman tree");let s=0,o=0;for(let i=1;i<=16;i++){if(s=(s+this.#e[i-1])*2,s+this.#e[i]>2**i)throw new G("Invalid CAB archive: oversubscribed LZX Huffman tree");this.#t[i]=s,this.#n[i]=o,o+=this.#e[i]}this.#s=new Uint16Array(n);let r=this.#n.slice();for(let i=0;i<e.byteLength;i++){let a=e[i];if(a!==0)this.#s[r[a]]=i;r[a]++}}decode(e){if(this.empty)throw new G("Invalid CAB archive: LZX stream uses an empty Huffman tree");let t=0;for(let n=1;n<=16;n++){t=t*2+e.readBits(1);let s=t-this.#t[n];if(s>=0&&s<this.#e[n])return this.#s[this.#n[n]+s]}throw new G("Invalid CAB archive: invalid LZX Huffman symbol")}}function igt(e,t,n,s){let o=new Uint8Array(20);for(let a=0;a<o.byteLength;a++)o[a]=e.readBits(4);let r=new cae(o),i=n;while(i<s){let a=r.decode(e);if(a===17||a===18){let l=e.readBits(a===17?4:5)+(a===17?4:20);if(i+l>s)throw new G("Invalid CAB archive: LZX code-length run exceeds its tree");t.fill(0,i,i+l),i+=l;continue}if(a===19){let l=e.readBits(1)+4;if(i+l>s)throw new G("Invalid CAB archive: LZX code-length run exceeds its tree");let u=r.decode(e),p=(t[i]-u+17)%17;t.fill(p,i,i+l),i+=l;continue}t[i]=(t[i]-a+17)%17,i++}}function h3n(e){return e>2147483647?e-4294967296:e}class agt{#e;#t;#n;#s;#o=new Uint8Array(dQr);#r;#a;#i;#l=0;#u=0;#p=0;#c=1;#d=1;#f=1;#m=!1;#g=0;#h=!1;#T=0;#R=0;#C=0;#y=!1;constructor(e){if(!Number.isInteger(e)||e<15||e>21)throw new G(`Unsupported CAB LZX window size: ${e} bits (expected 15-21)`);this.#e=new Uint8Array(2**e);let t=fQr[e-15];this.#s=new Uint8Array(256+t*8),this.#n=new Uint8Array(t),this.#t=new Uint32Array(t);for(let n=0;n<t;n++)if(this.#n[n]=n<4?0:Math.min(17,Math.floor(n/2)-1),n>0)this.#t[n]=this.#t[n-1]+2**this.#n[n-1]}decompressFrame(e,t){if(!Number.isInteger(t)||t<0||t>pQr)throw new G(`Invalid CAB archive: LZX frame size ${t} exceeds 32768 bytes`);if(t===0)return new Uint8Array(0);let n=new T3n(e);if(!this.#m){if(n.readBits(1)!==0){let i=n.readBits(16),a=n.readBits(16);this.#g=h3n(i*65536+a>>>0)}this.#m=!0}let s=new Uint8Array(t),o=0;while(o<t){if(this.#C===0)this.#b(n);let i=Math.min(this.#C,t-o),a=this.#w(n,s,o,i);if(a!==i)throw new G("Invalid CAB archive: LZX block produced the wrong byte count");o+=a,this.#C-=a}if(this.#C===0&&this.#T===3&&this.#y)n.readByte(),this.#y=!1;n.alignWord();let r=this.#k(s);return this.#p++,r}#b(e){if(this.#T===3&&this.#y)e.readByte();if(this.#y=!1,this.#T=e.readBits(3),this.#R=e.readBits(16)*256+e.readBits(8),this.#R===0)throw new G("Invalid CAB archive: zero-length LZX block");if(this.#C=this.#R,this.#T===1||this.#T===2){if(this.#T===2){let t=new Uint8Array(8);for(let n=0;n<t.byteLength;n++)t[n]=e.readBits(3);this.#i=new cae(t)}if(igt(e,this.#s,0,256),igt(e,this.#s,256,this.#s.byteLength),this.#r=new cae(this.#s),this.#s[232]!==0)this.#h=!0;igt(e,this.#o,0,this.#o.byteLength),this.#a=new cae(this.#o,!0);return}if(this.#T===3){if(this.#h=!0,e.alignWord(),this.#c=e.readUInt32LE(),this.#d=e.readUInt32LE(),this.#f=e.readUInt32LE(),this.#c===0||this.#d===0||this.#f===0)throw new G("Invalid CAB archive: invalid LZX repeated offset");this.#y=(this.#R&1)!==0;return}throw new G(`Invalid CAB archive: unsupported LZX block type ${this.#T}`)}#w(e,t,n,s){if(this.#T===3){for(let r=0;r<s;r++)this.#S(e.readByte(),t,n+r);return s}if(!this.#r||!this.#a)throw new G("Invalid CAB archive: missing LZX decode trees");let o=0;while(o<s){let r=this.#r.decode(e);if(r<256){this.#S(r,t,n+o),o++;continue}let i=r-256,a=i&g3n;if(a===g3n)a+=this.#a.decode(e);if(a+=cQr,a>s-o||a>this.#C-o)throw new G("Invalid CAB archive: LZX match crosses a frame or block boundary");let l=i>>>3,u;if(l===0)u=this.#c;else if(l===1)u=this.#d,this.#d=this.#c,this.#c=u;else if(l===2)u=this.#f,this.#f=this.#c,this.#c=u;else{if(l>=this.#t.byteLength)throw new G("Invalid CAB archive: LZX position slot is out of range");let p=this.#n[l];if(u=this.#t[l]-2,this.#T===2&&p>=3){if(p>3)u+=e.readBits(p-3)*8;if(!this.#i)throw new G("Invalid CAB archive: missing LZX aligned tree");u+=this.#i.decode(e)}else if(p!==0)u+=e.readBits(p);this.#f=this.#d,this.#d=this.#c,this.#c=u}if(u<=0||u>Math.min(this.#u,this.#e.byteLength))throw new G("Invalid CAB archive: LZX match offset exceeds available history");for(let p=0;p<a;p++){let c=(this.#l-u+this.#e.byteLength)%this.#e.byteLength;this.#S(this.#e[c],t,n+o+p)}o+=a}return o}#S(e,t,n){t[n]=e,this.#e[this.#l]=e,this.#l=(this.#l+1)%this.#e.byteLength,this.#u++}#k(e){if(!this.#h||this.#g===0||this.#p>=32768||e.byteLength<=10)return e;let t=e.slice(),n=0,s=this.#u-e.byteLength,o=t.byteLength-10;while(n<o){if(t[n++]!==232){s++;continue}let r=h3n((t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0);if(r>=-s&&r<this.#g){let i=r>=0?r-s:r+this.#g;t[n]=i&255,t[n+1]=i>>>8&255,t[n+2]=i>>>16&255,t[n+3]=i>>>24&255}n+=4,s+=5}return t}}var pQr=32768,cQr=2,g3n=7,dQr=249,fQr;var R3n=w(()=>{Qr();fQr=[30,32,34,36,38,42,50]});import*as S3n from"node:zlib";async function dae(e,t,n,s=e.size){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>s)throw new G("Invalid CAB archive: metadata range is out of bounds");let o;try{o=await e.read(t,n)}catch(r){if(r instanceof G)throw r;throw new G(`Unable to read CAB archive: ${r instanceof Error?r.message:String(r)}`)}if(o.byteLength!==n-t)throw new G("Invalid CAB archive: truncated data");return o}function b3n(e){return e.byteLength>=4&&e[0]===77&&e[1]===83&&e[2]===67&&e[3]===70}function C3n(e,t=0){let n=t>>>0,s=0;while(s+4<=e.byteLength)n^=wn(e,s),s+=4;let o=e.byteLength-s,r=0;if(o===3)r=e[s]<<16|e[s+1]<<8|e[s+2];else if(o===2)r=e[s]<<8|e[s+1];else if(o===1)r=e[s];return(n^r)>>>0}function SQr(e,t){try{return t?yQr.decode(e):CQr.decode(e)}catch{throw new G("Invalid CAB archive: file name is not valid UTF-8")}}function bQr(e,t){if(e===0&&t===0)return;let n=1980+(e>>>9),s=e>>>5&15,o=e&31,r=t>>>11,i=t>>>5&63,a=(t&31)*2;if(s<1||s>12||o<1||o>31||r>23||i>59||a>59)throw new G("Invalid CAB archive: file has an invalid DOS timestamp");return new Date(n,s-1,o,r,i,a).getTime()}function wQr(e,t){if(t)return 16877;let n=e&gQr?292:420;if(e&TQr)n|=73;return 32768|n}class w3n{#e;#t;#n;#s;#o;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}readAll(){return this.#o??=this.#r(),this.#o}async#r(){let e=this.#t;if(e.method===2)throw new G(`Unsupported CAB compression method: Quantum (level ${e.parameter})`);if(e.method>3)throw new G(`Unsupported CAB compression method: ${e.method}`);if(e.method===3&&(e.parameter<15||e.parameter>21))throw new G(`Unsupported CAB LZX window size: ${e.parameter} bits (expected 15-21)`);let t=e.dataEnd-e.dataStart;ki(t,this.#s);let n=await dae(this.#e,e.dataStart,e.dataEnd),s=0,o=0;for(let l=0;l<e.blockCount;l++){if(s+lgt+this.#n>n.byteLength)throw new G("Invalid CAB archive: truncated CFDATA header");let u=Rs(n,s+4),p=Rs(n,s+6);if(p===0)throw new G("Unsupported multi-volume CAB archive: split CFDATA block");if(p>y3n)throw new G(`Invalid CAB archive: CFDATA expands to ${p} bytes (maximum 32768)`);let c=s+lgt+this.#n,d=c+u;if(d>n.byteLength)throw new G("Invalid CAB archive: truncated CFDATA payload");let f=wn(n,s);if(f!==0){let m=C3n(n.subarray(c,d));if(C3n(n.subarray(s+4,c),m)!==f)throw new G(`Invalid CAB archive: CFDATA block ${l} checksum mismatch`)}o+=p,ki(o,this.#s),s=d}if(o<e.requiredSize)throw new G("Invalid CAB archive: folder data is shorter than its file table declares");let r=new Uint8Array(o),i=e.method===3?new agt(e.parameter):void 0;s=0;let a=0;for(let l=0;l<e.blockCount;l++){let u=Rs(n,s+4),p=Rs(n,s+6),c=s+lgt+this.#n,d=c+u,f=n.subarray(c,d),m;if(e.method===0){if(u!==p)throw new G("Invalid CAB archive: uncompressed CFDATA sizes do not match");m=f}else if(e.method===1){if(f.byteLength<2||f[0]!==67||f[1]!==75)throw new G("Invalid CAB archive: MSZIP block is missing its CK signature");try{let g=r.subarray(Math.max(0,a-y3n),a);m=new Uint8Array(S3n.inflateRawSync(f.subarray(2),{dictionary:g,maxOutputLength:p}))}catch(g){throw new G(`Invalid CAB archive: MSZIP decompression failed${g instanceof Error?`: ${g.message}`:""}`)}}else m=i.decompressFrame(f,p);if(m.byteLength!==p)throw new G(`Invalid CAB archive: CFDATA block ${l} produced ${m.byteLength} bytes, expected ${p}`);r.set(m,a),a+=m.byteLength,s=d}return r}}class E3n{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){if(e!==this.#n)throw new G(`Invalid CAB archive: size changed while extracting '${t}'`);let n=await this.#e.readAll(),s=this.#t+e;if(!Number.isSafeInteger(s)||this.#t<0||s>n.byteLength)throw new G(`Invalid CAB archive: member '${t}' is outside its folder data`);return n.slice(this.#t,s)}}async function EQr(e,t){if(e.size<nW)throw new G("Invalid CAB archive: truncated CFHEADER");let n=await dae(e,0,nW);if(!b3n(n))throw new G(`Invalid CAB archive: expected ${mQr} signature`);if(wn(n,4)!==0||wn(n,12)!==0||wn(n,20)!==0)throw new G("Invalid CAB archive: reserved CFHEADER fields must be zero");let s=wn(n,8);if(s<nW||s>e.size)throw new G("Invalid CAB archive: declared cabinet size is out of bounds");let o=wn(n,16);if(o<nW||o>s)throw new G("Invalid CAB archive: CFFILE table offset is out of bounds");if(n[24]!==3||n[25]!==1)throw new G(`Unsupported CAB format version ${n[25]}.${n[24]} (expected 1.3)`);let r=Rs(n,26),i=Rs(n,28),a=Rs(n,30);if(a&3)throw new G("Unsupported multi-volume CAB archive (previous/next cabinet link)");if(cr(r+i,t.limits),r===0&&i!==0)throw new G("Invalid CAB archive: files exist without a folder");let l=0,u=0,p=0,c=nW;if(a&4){let S=await dae(e,nW,nW+4,s);if(l=Rs(S,0),u=S[2],p=S[3],l>60000)throw new G("Invalid CAB archive: CFHEADER reserve area exceeds 60000 bytes");c+=4+l}let d=8+u,f=c+r*d;if(!Number.isSafeInteger(f)||f>s||f>o)throw new G("Invalid CAB archive: CFFOLDER table is out of bounds");Ns(f,t.limits,"CAB header");let m=await dae(e,0,f,s),g=[];for(let S=0;S<r;S++){let E=c+S*d,A=Rs(m,E+6);g.push({dataStart:wn(m,E),dataEnd:s,blockCount:Rs(m,E+4),method:A&15,parameter:A>>>8,requiredSize:0})}for(let S of g){if(S.dataStart<f||S.dataStart>s)throw new G("Invalid CAB archive: CFFOLDER data offset is out of bounds");for(let E of g)if(E.dataStart>S.dataStart&&E.dataStart<S.dataEnd)S.dataEnd=E.dataStart}let h=g.reduce((S,E)=>Math.min(S,E.dataStart),s);if(o>h)throw new G("Invalid CAB archive: CFFILE table overlaps folder data");Ns(f+(h-o),t.limits,"CAB index");let T=await dae(e,o,h,s),R=g.map((S)=>new w3n(e,S,p,t.limits)),y=[],C=0;for(let S=0;S<i;S++){if(C+16>T.byteLength)throw new G("Invalid CAB archive: truncated CFFILE entry");let E=wn(T,C),A=wn(T,C+4),k=Rs(T,C+8),x=Rs(T,C+10),M=Rs(T,C+12),O=Rs(T,C+14);C+=16;let v=T.indexOf(0,C);if(v<0)throw new G("Invalid CAB archive: unterminated CFFILE name");let P=T.subarray(C,v);if(P.byteLength>256)throw new G("Invalid CAB archive: CFFILE name exceeds 256 bytes");if(wo(P.byteLength,"member path",t.limits.maxPathBytes),C=v+1,k>=65533)throw new G("Unsupported multi-volume CAB archive: continued file");if(k>=R.length)throw new G("Invalid CAB archive: CFFILE references a missing folder");let N=SQr(P,(O&RQr)!==0);fa(E,N,t.limits);let F=A+E;if(!Number.isSafeInteger(F))throw new G("Invalid CAB archive: CFFILE range is too large");if(F>g[k].requiredSize)g[k].requiredSize=F;let _=Lr(N);if(!_)continue;let L=(O&hQr)!==0;y.push({path:_,isDirectory:L,size:E,mtimeMs:bQr(x,M),mode:wQr(O,L),storage:L?void 0:{type:"member",source:new E3n(R[k],A,E)}})}for(let S of g)ki(S.requiredSize,t.limits);return y}function k3n(e){return b3n(e)}var mQr="MSCF",nW=36,lgt=8,y3n=32768,gQr=1,hQr=16,TQr=64,RQr=128,yQr,CQr,A3n=async(e,t)=>{try{return await EQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(`Invalid CAB archive: ${n instanceof Error?n.message:String(n)}`)}};var I3n=w(()=>{Lh();R3n();Qr();Hp();sf();yQr=new TextDecoder("utf-8",{fatal:!0}),CQr=new TextDecoder("windows-1252")});function OQr(){let e=new Uint32Array(256);for(let t=0;t<e.length;t++){let n=t<<24;for(let s=0;s<8;s++)n=(n&2147483648)!==0?n<<1^79764919:n<<1;e[t]=n>>>0}return e}function x3n(e,t){return(vQr[(e>>>24^t)&255]^e<<8)>>>0}class v3n{#e;#t=0;constructor(e){this.#e=e}get done(){return this.#t===this.#e.byteLength*8}readBit(){if(this.#t>=this.#e.byteLength*8)throw new G("Truncated bzip2 stream");let t=this.#e[this.#t>>>3]>>>7-(this.#t&7)&1;return this.#t++,t}readBits(e){let t=0;for(let n=0;n<e;n++)t=t*2+this.readBit();return t}readUint32(){return this.readBits(16)*65536+this.readBits(16)>>>0}readMarker(){return[this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8),this.readBits(8)]}alignToByte(){while((this.#t&7)!==0)if(this.readBit()!==0)throw new G("Invalid non-zero bzip2 stream padding")}}class O3n{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=new Uint8Array(Math.min(e,Math.max(64,Math.min(t*2,65536))))}push(e){this.#s(1),this.#t[this.#n++]=e}pushRepeated(e,t){this.#s(t),this.#t.fill(e,this.#n,this.#n+t),this.#n+=t}finish(){return this.#t.slice(0,this.#n)}#s(e){let t=this.#n+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new G(`Bzip2 output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let n=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(n>this.#e)n=this.#e;let s=new Uint8Array(n);s.set(this.#t.subarray(0,this.#n)),this.#t=s}}class P3n{#e=new Uint16Array(sW+1);#t=new Uint32Array(sW+1);#n=new Uint16Array(sW+1);#s;constructor(e){for(let o of e){if(o<1||o>sW)throw new G("Invalid bzip2 Huffman code length");this.#e[o]++}let t=0,n=0;for(let o=1;o<=sW;o++){if(t=(t+this.#e[o-1])*2,t+this.#e[o]>2**o)throw new G("Oversubscribed bzip2 Huffman table");this.#t[o]=t,this.#n[o]=n,n+=this.#e[o]}this.#s=new Uint16Array(e.length);let s=new Uint16Array(this.#n);for(let o=0;o<e.length;o++){let r=e[o];this.#s[s[r]]=o,s[r]++}}decode(e){let t=0;for(let n=1;n<=sW;n++){t=t*2+e.readBit();let s=t-this.#t[n];if(s>=0&&s<this.#e[n])return this.#s[this.#n[n]+s]}throw new G("Invalid bzip2 Huffman code")}}function M3n(e,t){return e.every((n,s)=>n===t[s])}function PQr(e){if(e.readBits(8)!==66||e.readBits(8)!==90||e.readBits(8)!==104)throw new G("Invalid bzip2 stream header");let t=e.readBits(8)-48;if(t<1||t>9)throw new G("Invalid bzip2 block-size level");return t*1e5}function NQr(e,t){let n=e.readBits(3);if(n<2||n>6)throw new G("Invalid bzip2 Huffman group count");let s=e.readBits(15);if(s<1||s>IQr)throw new G("Invalid bzip2 selector count");let o=new Uint8Array(s),r=new Uint8Array(n);for(let l=0;l<n;l++)r[l]=l;for(let l=0;l<s;l++){let u=0;while(e.readBit()!==0)if(u++,u>=n)throw new G("Invalid bzip2 selector MTF value");let p=r[u];o[l]=p,r.copyWithin(1,0,u),r[0]=p}let i=t.length+2,a=[];for(let l=0;l<n;l++){let u=new Uint8Array(i),p=e.readBits(5);for(let c=0;c<i;c++){while(e.readBit()!==0)if(p+=e.readBit()===0?1:-1,p<1||p>sW)throw new G("Invalid bzip2 Huffman code length");u[c]=p}a.push(new P3n(u))}return{selectors:o,tables:a}}function FQr(e,t,n,s,o){let r=new Uint8Array(n),i=new Uint8Array(t),a=0,l=0,u=0,p,c=()=>{if(u===0){if(l>=s.length)throw new G("Bzip2 block exhausted its Huffman selectors");p=o[s[l++]],u=xQr}return u--,p.decode(e)},d=(g,h)=>{if(h<0||a+h>t)throw new G("Bzip2 block exceeds its declared block-size level");i.fill(g,a,a+h),a+=h},f=n.length+1,m=c();while(m!==f){if(m===0||m===1){let T=0,R=1;do{if(T+=m===0?R:R*2,T>t||R>t)throw new G("Invalid bzip2 RLE run length");R*=2,m=c()}while(m===0||m===1);if(d(r[0],T),m===f)break}let g=m-1;if(g<0||g>=r.length)throw new G("Invalid bzip2 MTF symbol");let h=r[g];r.copyWithin(1,0,g),r[0]=h,d(h,1),m=c()}return i.slice(0,a)}function LQr(e,t){if(e.length===0||t<0||t>=e.length)throw new G("Invalid bzip2 BWT origin pointer");let n=new Uint32Array(257);for(let a of e)n[a+1]++;for(let a=1;a<n.length;a++)n[a]+=n[a-1];let s=new Uint32Array(n.subarray(0,256)),o=new Uint32Array(e.length);for(let a=0;a<e.length;a++){let l=e[a];o[s[l]]=a,s[l]++}let r=new Uint8Array(e.length),i=o[t];for(let a=0;a<r.length;a++)r[a]=e[i],i=o[i];return r}function _Qr(e,t,n){let s=4294967295,o=-1,r=0,i=0,a=0,l=(p)=>{n.push(p),s=x3n(s,p)},u=(p,c)=>{n.pushRepeated(p,c);for(let d=0;d<c;d++)s=x3n(s,p)};for(let p of e){if(t){if(a===0)a=MQr[i],i=i+1&511;if(a--,a===1)p^=1}if(r===4){u(o,p),r=0;continue}if(l(p),p===o)r++;else o=p,r=1}if(r===4)throw new G("Truncated bzip2 RLE run");return(s^4294967295)>>>0}function DQr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid bzip2 output limit");let n=new v3n(e),s=new O3n(t,e.byteLength);for(;;){let o=PQr(n),r=0;for(;;){let i=n.readMarker();if(M3n(i,AQr)){let y=n.readUint32();if(r!==y)throw new G("Bzip2 stream CRC mismatch");n.alignToByte();break}if(!M3n(i,kQr))throw new G("Invalid bzip2 block marker");let a=n.readUint32(),l=n.readBit()!==0,u=n.readBits(24),p=n.readBits(16),c=new Uint8Array(256),d=0;for(let y=0;y<16;y++){if((p&32768>>>y)===0)continue;for(let C=0;C<16;C++)if(n.readBit()!==0)c[d++]=y*16+C}if(d===0)throw new G("Bzip2 block has an empty symbol map");let f=c.slice(0,d),{selectors:m,tables:g}=NQr(n,f),h=FQr(n,o,f,m,g),T=LQr(h,u),R=_Qr(T,l,s);if(R!==a)throw new G("Bzip2 block CRC mismatch");r=((r<<1|r>>>31)^R)>>>0}if(n.done)return s.finish()}}function FPe(e){return e.byteLength>=4&&e[0]===66&&e[1]===90&&e[2]===104&&e[3]>=49&&e[3]<=57}async function fO(e,t){try{return DQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}}var kQr,AQr,sW=20,IQr=18002,xQr=50,MQr,vQr;var fae=w(()=>{Qr();kQr=[49,65,89,38,83,89],AQr=[23,114,69,56,80,144],MQr=new Uint16Array([619,720,127,481,931,816,813,233,566,247,985,724,205,454,863,491,741,242,949,214,733,859,335,708,621,574,73,654,730,472,419,436,278,496,867,210,399,680,480,51,878,465,811,169,869,675,611,697,867,561,862,687,507,283,482,129,807,591,733,623,150,238,59,379,684,877,625,169,643,105,170,607,520,932,727,476,693,425,174,647,73,122,335,530,442,853,695,249,445,515,909,545,703,919,874,474,882,500,594,612,641,801,220,162,819,984,589,513,495,799,161,604,958,533,221,400,386,867,600,782,382,596,414,171,516,375,682,485,911,276,98,553,163,354,666,933,424,341,533,870,227,730,475,186,263,647,537,686,600,224,469,68,770,919,190,373,294,822,808,206,184,943,795,384,383,461,404,758,839,887,715,67,618,276,204,918,873,777,604,560,951,160,578,722,79,804,96,409,713,940,652,934,970,447,318,353,859,672,112,785,645,863,803,350,139,93,354,99,820,908,609,772,154,274,580,184,79,626,630,742,653,282,762,623,680,81,927,626,789,125,411,521,938,300,821,78,343,175,128,250,170,774,972,275,999,639,495,78,352,126,857,956,358,619,580,124,737,594,701,612,669,112,134,694,363,992,809,743,168,974,944,375,748,52,600,747,642,182,862,81,344,805,988,739,511,655,814,334,249,515,897,955,664,981,649,113,974,459,893,228,433,837,553,268,926,240,102,654,459,51,686,754,806,760,493,403,415,394,687,700,946,670,656,610,738,392,760,799,887,653,978,321,576,617,626,502,894,679,243,440,680,879,194,572,640,724,926,56,204,700,707,151,457,449,797,195,791,558,945,679,297,59,87,824,713,663,412,693,342,606,134,108,571,364,631,212,174,643,304,329,343,97,430,751,497,314,983,374,822,928,140,206,73,263,980,736,876,478,430,305,170,514,364,692,829,82,855,953,676,246,369,970,294,750,807,827,150,790,288,923,804,378,215,828,592,281,565,555,710,82,896,831,547,261,524,462,293,465,502,56,661,821,976,991,658,869,905,758,745,193,768,550,608,933,378,286,215,979,792,961,61,688,793,644,986,403,106,366,905,644,372,567,466,434,645,210,389,550,919,135,780,773,635,389,707,100,626,958,165,504,920,176,193,713,857,265,203,50,668,108,645,990,626,197,510,357,358,850,858,364,936,638]),vQr=OQr()});import{promisify as N3n}from"node:util";import*as LPe from"node:zlib";function _Pe(e){return e.byteLength>=2&&e[0]===31&&e[1]===139}async function oW(e,t){try{return await qQr(e,{maxOutputLength:Math.max(t,1)})}catch(n){throw new G(n instanceof Error?n.message:String(n))}}function F3n(e){return HQr(e)}var HQr,qQr;var mae=w(()=>{Qr();HQr=N3n(LPe.gzip),qQr=N3n(LPe.gunzip)});class D3n{bytes;pos=0;range=4294967295;code=0;constructor(e){if(this.bytes=e,e.byteLength<5||e[0]!==0)throw new G("Invalid LZMA range-coded stream");for(let t=0;t<5;t++)this.code=(this.code<<8|e[this.pos++])>>>0}#e(){if(this.range<UQr){if(this.pos>=this.bytes.byteLength)throw new G("Invalid LZMA stream: truncated range data");this.range=this.range<<8>>>0,this.code=(this.code<<8|this.bytes[this.pos++])>>>0}}decodeBit(e,t){this.#e();let n=e[t],s=Math.imul(this.range>>>11,n)>>>0;if(this.code<s)return this.range=s,e[t]=n+(im-n>>>L3n),0;return this.range=this.range-s>>>0,this.code=this.code-s>>>0,e[t]=n-(n>>>L3n),1}decodeDirectBits(e){let t=0;for(let n=0;n<e;n++){this.#e(),this.range>>>=1;let s=0;if(this.code>=this.range)this.code=this.code-this.range>>>0,s=1;t=(t<<1|s)>>>0}return t}}function gg(e){let t=new Uint16Array(e);return t.fill(im>>>1),t}class cgt{choice=gg(2);low=gg(HPe<<3);mid=gg(HPe<<3);high=gg(256);reset(){this.choice.fill(im>>>1),this.low.fill(im>>>1),this.mid.fill(im>>>1),this.high.fill(im>>>1)}decode(e,t){if(e.decodeBit(this.choice,0)===0)return DPe(e,this.low,t<<3,3);if(e.decodeBit(this.choice,1)===0)return 8+DPe(e,this.mid,t<<3,3);return 16+DPe(e,this.high,0,8)}}function DPe(e,t,n,s){let o=1;for(let r=0;r<s;r++)o=o<<1|e.decodeBit(t,n+o);return o-(1<<s)}function _3n(e,t,n,s){let o=1,r=0;for(let i=0;i<s;i++){let a=e.decodeBit(t,n+o);o=o<<1|a,r|=a<<i}return r>>>0}function H3n(e){if(e.byteLength!==5)throw new G("Invalid LZMA properties: expected 5 bytes");let t=e[0];if(t>=225)throw new G("Invalid LZMA properties");let n=t%9;t=Math.floor(t/9);let s=t%5,o=Math.floor(t/5),r=(e[1]|e[2]<<8|e[3]<<16|e[4]<<24)>>>0;return{lc:n,lp:s,pb:o,dictionarySize:Math.max(r,4096)}}class qPe{#e;#t;#n=0;#s=0;#o=0;#r=0;#a=0;#i=0;#l=0;#u=1;#p=1;#c=1;#d=1;#f=gg(ugt);#m=gg(vY*HPe);#g=gg(vY);#h=gg(vY);#T=gg(vY);#R=gg(vY);#C=gg(vY*HPe);#y=gg(256);#b=gg(115);#w=gg(16);#S=new cgt;#k=new cgt;constructor(e,t){this.#e=e,this.#t=t.dictionarySize,this.setProperties(t.lc,t.lp,t.pb),this.resetDictionary()}get outputPos(){return this.#n}setProperties(e,t,n){if(e>8||t>4||n>4||e+t>12)throw new G("Invalid LZMA properties");this.#r=e,this.#a=t,this.#i=n;let s=ugt*2**(e+t);if(this.#f.length!==s)this.#f=gg(s)}resetDictionary(){this.#s=this.#n,this.#o=0,this.resetState()}resetState(){this.#l=0,this.#u=this.#p=this.#c=this.#d=1,this.#f.fill(im>>>1),this.#m.fill(im>>>1),this.#g.fill(im>>>1),this.#h.fill(im>>>1),this.#T.fill(im>>>1),this.#R.fill(im>>>1),this.#C.fill(im>>>1),this.#y.fill(im>>>1),this.#b.fill(im>>>1),this.#w.fill(im>>>1),this.#S.reset(),this.#k.reset()}appendUncompressed(e,t){if(t)this.resetDictionary();if(e.byteLength>this.#e.byteLength-this.#n)throw new G("LZMA2 output exceeds its limit");this.#e.set(e,this.#n),this.#n+=e.byteLength,this.#o+=e.byteLength}decodeChunk(e,t,n=!1){if(!Number.isSafeInteger(t)||t<0||t>this.#e.byteLength-this.#n)throw new G("LZMA output exceeds its declared size");let s=this.#n+t,o=new D3n(e),r=(1<<this.#i)-1,i=(1<<this.#a)-1;while(this.#n<s||n){let a=this.#o&r;if(o.decodeBit(this.#m,(this.#l<<4)+a)===0){let u=this.#n===this.#s?0:this.#e[this.#n-1],p=(((this.#o&i)<<this.#r)+(u>>>8-this.#r))*ugt,c=1;if(this.#l>=7){this.#v(this.#u);let d=this.#e[this.#n-this.#u];while(c<256){let f=d>>>7&1;d=d<<1&255;let m=o.decodeBit(this.#f,p+(1+f<<8)+c);if(c=c<<1|m,f!==m)break}}while(c<256)c=c<<1|o.decodeBit(this.#f,p+c);if(this.#n>=s)throw new G("LZMA output exceeds its size limit before the end marker");this.#e[this.#n++]=c&255,this.#o++,this.#l=this.#l<4?0:this.#l<10?this.#l-3:this.#l-6;continue}let l;if(o.decodeBit(this.#g,this.#l)===1){if(o.decodeBit(this.#h,this.#l)===0){if(o.decodeBit(this.#C,(this.#l<<4)+a)===0){this.#l=this.#l<7?9:11,this.#E(this.#u,1,s);continue}}else{let u;if(o.decodeBit(this.#T,this.#l)===0)u=this.#p;else{if(o.decodeBit(this.#R,this.#l)===0)u=this.#c;else u=this.#d,this.#d=this.#c;this.#c=this.#p}this.#p=this.#u,this.#u=u}l=this.#k.decode(o,a)+pgt,this.#l=this.#l<7?8:11}else{this.#d=this.#c,this.#c=this.#p,this.#p=this.#u,l=this.#S.decode(o,a)+pgt,this.#l=this.#l<7?7:10;let u=Math.min(l-pgt,3),p=DPe(o,this.#y,u<<6,6),c;if(p<4)c=p;else{let d=(p>>>1)-1;if(c=(2|p&1)<<d>>>0,p<14)c=c+_3n(o,this.#b,c-p,d)>>>0;else if(c=c+(o.decodeDirectBits(d-4)<<4)>>>0,c=c+_3n(o,this.#w,0,4)>>>0,c===4294967295){if(n)return!0;throw new G("LZMA stream ended before its declared output size")}}this.#u=c+1>>>0}this.#E(this.#u,l,s)}return!1}#v(e){let t=this.#n-this.#s;if(e<1||e>t||e>this.#t)throw new G(`Invalid LZMA match distance ${e} with ${t} bytes available`)}#E(e,t,n){if(this.#v(e),t>n-this.#n)throw new G("LZMA match exceeds its declared output size");for(let s=0;s<t;s++)this.#e[this.#n]=this.#e[this.#n-e],this.#n++;this.#o+=t}}async function gae(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid LZMA output size");try{let s=new Uint8Array(n),o=new qPe(s,H3n(e));if(o.decodeChunk(t,n),o.outputPos!==n)throw new G("LZMA output size mismatch");return s}catch(s){if(s instanceof G)throw s;throw new G(`Invalid LZMA stream: ${s instanceof Error?s.message:String(s)}`)}}async function OY(e,t){if(e.byteLength<13)throw new G("Invalid LZMA-alone stream: truncated header");if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid LZMA output limit");let n=e.subarray(0,5),s=!0,o=0;for(let r=0;r<8;r++){let i=e[5+r];if(i!==255)s=!1;o+=i*2**(r*8)}if(!s){if(!Number.isSafeInteger(o)||o>t)throw new G("LZMA-alone output exceeds its size limit");return gae(n,e.subarray(13),o)}try{let r=new Uint8Array(t),i=new qPe(r,H3n(n));if(!i.decodeChunk(e.subarray(13),t,!0))throw new G("LZMA-alone output exceeds its size limit before the end marker");return r.subarray(0,i.outputPos)}catch(r){if(r instanceof G)throw r;throw new G(`Invalid LZMA-alone stream: ${r instanceof Error?r.message:String(r)}`)}}async function UPe(e,t,n){if(!Number.isInteger(e)||e<0||e>40)throw new G("Unsupported LZMA2 dictionary property");if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid LZMA2 output limit");let s=e===40?4294967295:(2|e&1)*2**(Math.floor(e/2)+11),o=new Uint8Array(n),r=new qPe(o,{lc:3,lp:0,pb:2,dictionarySize:s}),i=0,a=!0,l=!1,u=()=>{if(i>=t.byteLength)throw new G("Invalid LZMA2 stream: truncated chunk header");return t[i++]};try{for(;;){let p=u();if(p===0)break;if(p<128){if(p!==1&&p!==2)throw new G(`Invalid LZMA2 control byte 0x${p.toString(16)}`);if(p===2&&a)throw new G("Invalid LZMA2 stream: dictionary was not initialized");let h=(u()<<8)+u()+1;if(h>n-r.outputPos||h>t.byteLength-i)throw new G("Invalid LZMA2 uncompressed chunk size");if(r.appendUncompressed(t.subarray(i,i+h),p===1),i+=h,p===1)a=!1,l=!1;continue}let c=((p&31)<<16)+(u()<<8)+u()+1,d=(u()<<8)+u()+1,f=p>=224,m=p>=160,g=p>=192;if(a&&!f)throw new G("Invalid LZMA2 stream: dictionary was not initialized");if(!l&&!g)throw new G("Invalid LZMA2 stream: properties were not initialized");if(g){let h=u();if(h>=225)throw new G("Invalid LZMA2 properties");let T=h%9;h=Math.floor(h/9);let R=h%5,y=Math.floor(h/5);if(T+R>4)throw new G("Invalid LZMA2 literal properties");r.setProperties(T,R,y),l=!0}if(d>t.byteLength-i||c>n-r.outputPos)throw new G("Invalid LZMA2 chunk size");if(f)r.resetDictionary();else if(m)r.resetState();r.decodeChunk(t.subarray(i,i+d),c),i+=d,a=!1}if(i!==t.byteLength)throw new G("Invalid LZMA2 stream: trailing data");return o.subarray(0,r.outputPos)}catch(p){if(p instanceof G)throw p;throw new G(`Invalid LZMA2 stream: ${p instanceof Error?p.message:String(p)}`)}}var UQr=16777216,im=2048,L3n=5,ugt=768,vY=12,HPe=16,pgt=2;var rW=w(()=>{Qr()});class U3n{#e;#t=0;#n=0;constructor(e){this.#e=e}get remainingBits(){return this.#e.byteLength*8-this.#t}read(e){if(this.remainingBits<e)return;let t=0;for(let n=0;n<e;n++){let s=this.#t+n;t+=(this.#e[s>>>3]>>>(s&7)&1)*2**n}return this.#t+=e,t}alignCodeGroup(e){let t=e*8,n=this.#n+Math.ceil((this.#t-this.#n)/t)*t;if(n>this.#e.byteLength*8)throw new G("Truncated compress (.Z) code group");this.#t=n,this.#n=n}assertFinalPadding(){this.#s(this.#e.byteLength*8)}#s(e){for(let t=this.#t;t<e;t++)if((this.#e[t>>>3]>>>(t&7)&1)!==0)throw new G("Invalid non-zero compress (.Z) padding")}}class B3n{#e;#t;#n=0;constructor(e,t){this.#e=e,this.#t=new Uint8Array(Math.min(e,Math.max(64,Math.min(t*2,65536))))}appendReversed(e,t){this.#s(t);for(let n=t-1;n>=0;n--)this.#t[this.#n++]=e[n]}finish(){return this.#t.slice(0,this.#n)}#s(e){let t=this.#n+e;if(!Number.isSafeInteger(t)||t>this.#e)throw new G(`Compress (.Z) output exceeds the ${this.#e}-byte limit`);if(t<=this.#t.byteLength)return;let n=Math.max(t,Math.min(this.#e,Math.max(64,this.#t.byteLength*2)));if(n>this.#e)n=this.#e;let s=new Uint8Array(n);s.set(this.#t.subarray(0,this.#n)),this.#t=s}}function GQr(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid compress (.Z) output limit");if(e.byteLength<3)throw new G("Truncated compress (.Z) header");if(e[0]!==31||e[1]!==157)throw new G("Invalid compress (.Z) header");let n=e[2];if((n&96)!==0)throw new G("Unsupported compress (.Z) header flags");let s=n&31;if(s<dgt||s>WQr)throw new G(`Invalid compress (.Z) maximum code width ${s}`);let o=(n&128)!==0,r=2**s,i=new Uint16Array(r),a=new Uint8Array(r),l=new Uint8Array(r),u=new U3n(e.subarray(3)),p=new B3n(t,e.byteLength),c=dgt,d=o?q3n:256,f=!1;for(;;){let m=u.read(c);if(m===void 0)return u.assertFinalPadding(),p.finish();if(m>=d)throw new G(`Corrupt compress (.Z) dictionary code ${m}`);if(o&&m===BQr){u.alignCodeGroup(c),c=dgt,d=q3n,f=!1;continue}let g=m,h=0;while(g>=256){if(g>=d||h>=l.length-1)throw new G("Corrupt compress (.Z) dictionary chain");l[h++]=a[g],g=i[g]}if(l[h++]=g,f){if(a[d-1]=g,m===d-1)l[0]=g}if(p.appendReversed(l,h),d<r){if(f=!0,i[d++]=m,d>2**c&&c<s)u.alignCodeGroup(c),c++}else f=!1}}function W3n(e){return e.byteLength>=2&&e[0]===31&&e[1]===157}async function fgt(e,t){try{return GQr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}}var BQr=256,q3n=257,dgt=9,WQr=16;var G3n=w(()=>{Qr()});function mw(e,t){if(t<0||t+4>e.byteLength)throw new G("Invalid XZ stream: truncated integer");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function WPe(e,t,n){e[t]=n&255,e[t+1]=n>>>8&255,e[t+2]=n>>>16&255,e[t+3]=n>>>24}function $3n(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function $Qr(e,t,n){e[t]=n>>>24,e[t+1]=n>>>16&255,e[t+2]=n>>>8&255,e[t+3]=n&255}function mgt(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function iW(e){let t=0;for(let n=0;n<9;n++){if(e.pos>=e.limit)throw new G("Invalid XZ stream: truncated variable-length integer");let s=e.bytes[e.pos++];if(n>0&&s===0)throw new G("Invalid XZ stream: non-canonical variable-length integer");if(t+=(s&127)*2**(n*7),!Number.isSafeInteger(t))throw new G("XZ stream uses sizes too large to read safely");if((s&128)===0)return t}throw new G("Invalid XZ stream: variable-length integer is too long")}function j3n(e){switch(e){case 0:return 0;case 1:return 4;case 4:return 8;case 10:return 32;default:throw new G(`Unsupported XZ integrity check ID 0x${e.toString(16)}`)}}function jQr(e,t,n){if(n<8||t<0||t+n>e.byteLength)throw new G("Invalid XZ stream: index range is invalid");let s=t+n;if(e[t]!==0)throw new G("Invalid XZ stream: missing index indicator");if(sa(e.subarray(t,s-4))!==mw(e,s-4))throw new G("Invalid XZ stream: index CRC32 mismatch");let o={bytes:e,pos:t+1,limit:s-4},r=iW(o);if(r>Math.floor(n/2))throw new G("Invalid XZ stream: impossible index record count");let i=[];for(let a=0;a<r;a++){let l=iW(o),u=iW(o);if(l===0)throw new G("Invalid XZ stream: zero unpadded block size");i.push({unpaddedSize:l,uncompressedSize:u})}while(o.pos<o.limit)if(e[o.pos++]!==0)throw new G("Invalid XZ stream: non-zero index padding");return i}function zQr(e){if(e.byteLength===0||(e.byteLength&3)!==0)throw new G("Invalid XZ stream: size is not a multiple of four bytes");let t=[],n=e.byteLength;while(n>0){let s=0;while(n>=4&&e[n-1]===0&&e[n-2]===0&&e[n-3]===0&&e[n-4]===0)n-=4,s+=4;if(n===0)throw new G("Invalid XZ stream: padding without a stream");if(n<24)throw new G("Invalid XZ stream: truncated stream framing");let o=n-12;if(e[o+10]!==89||e[o+11]!==90)throw new G("Invalid XZ stream: footer magic mismatch");if(sa(e.subarray(o+4,o+10))!==mw(e,o))throw new G("Invalid XZ stream: footer CRC32 mismatch");let r=e[o+8],i=e[o+9];if(r!==0||(i&240)!==0)throw new G("Unsupported XZ stream flags");let a=i&15;j3n(a);let l=(mw(e,o+4)+1)*4;if(!Number.isSafeInteger(l)||l>o)throw new G("Invalid XZ stream: backward index size is invalid");let u=o-l,p=jQr(e,u,l),c=0;for(let f of p)if(c+=Math.ceil(f.unpaddedSize/4)*4,!Number.isSafeInteger(c))throw new G("XZ stream uses sizes too large to read safely");let d=u-c-12;if(d<0||d+12>e.byteLength||!mgt(e.subarray(d,d+6),BPe))throw new G("Invalid XZ stream: header position or magic is invalid");if(e[d+6]!==r||e[d+7]!==i)throw new G("Invalid XZ stream: header and footer flags differ");if(sa(e.subarray(d+6,d+8))!==mw(e,d+8))throw new G("Invalid XZ stream: header CRC32 mismatch");t.unshift({start:d,indexStart:u,footerStart:o,checkId:a,records:p}),n=d}return t}function VQr(e,t){let n=new Uint8Array(256),s=0;for(let o=0;o<e.byteLength;o++){let r=e[o]+n[t+s&255]&255;n[s]=r,e[o]=r,s=s-1&255}}function YQr(e,t){let n=[0,1,2,2,3],s=0,o=4294967291;if(e.byteLength<5)return;let r=0,i=e.byteLength-5;while(r<=i){let a=e[r];if(a!==232&&a!==233){r++;continue}let l=t+r>>>0,u=l-o>>>0;if(o=l,u>5)s=0;else for(let p=0;p<u;p++)s=(s&119)<<1>>>0;if(a=e[r+4],(a===0||a===255)&&s>>>1<=4&&s>>>1!==3){let p=mw(e,r+1),c=0;for(;;){if(c=p-l-5>>>0,s===0)break;let d=n[s>>>1]*8,f=c>>>24-d&255;if(f!==0&&f!==255)break;let m=d===0?4294967295:2**(32-d)-1;p=(c^m)>>>0}e[r+4]=~((c>>>24&1)-1)&255,e[r+3]=c>>>16,e[r+2]=c>>>8,e[r+1]=c,r+=5,s=0}else if(r++,s|=1,a===0||a===255)s|=16}}function KQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(e[n]>>>2!==18||(e[n+3]&3)!==1)continue;let o=(((e[n]&3)<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]&252)>>>0)-t-n>>>0;e[n]=72|o>>>24&3,e[n+1]=o>>>16,e[n+2]=o>>>8,e[n+3]=e[n+3]&3|o&252}}function XQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(e[n+3]!==235)continue;let o=((e[n+2]<<18|e[n+1]<<10|e[n]<<2)>>>0)-t-n-8>>>2;e[n]=o,e[n+1]=o>>>8,e[n+2]=o>>>16}}function JQr(e,t){for(let n=0;n+4<=e.byteLength;n+=2){if((e[n+1]&248)!==240||(e[n+3]&248)!==248)continue;let o=(((e[n+1]&7)<<19|e[n]<<11|(e[n+3]&7)<<8|e[n+2])<<1>>>0)-t-n-4>>>1;e[n+1]=240|o>>>19&7,e[n]=o>>>11,e[n+3]=248|o>>>8&7,e[n+2]=o,n+=2}}function QQr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){if(!(e[n]===64&&(e[n+1]&192)===0||e[n]===127&&(e[n+1]&192)===192))continue;let o=($3n(e,n)<<2>>>0)-t-n>>>2;o=0-(o>>>22&1)<<22&1073741823|o&4194303|1073741824,$Qr(e,n,o>>>0)}}function ZQr(e,t){let n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,6,6,0,0,7,7,4,4,0,0,4,4,0,0];for(let s=0;s+16<=e.byteLength;s+=16){let o=n[e[s]&31],r=5;for(let i=0;i<3;i++,r+=41){if((o>>>i&1)===0)continue;let a=r>>>3,l=r&7,u=0n;for(let f=0;f<6;f++)u|=BigInt(e[s+a+f])<<BigInt(f*8);let p=u>>BigInt(l);if((p>>37n&15n)!==5n||(p>>9n&7n)!==0n)continue;let c=Number(p>>13n&0xfffffn)|Number(p>>36n&1n)<<20;c=c<<4>>>0;let d=c-t-s>>>4>>>0;p&=~(0x8fffffn<<13n),p|=BigInt(d&1048575)<<13n,p|=BigInt(d&1048576)<<16n,u&=(1n<<BigInt(l))-1n,u|=p<<BigInt(l);for(let f=0;f<6;f++)e[s+a+f]=Number(u>>BigInt(f*8))&255}}}function eZr(e,t){for(let n=0;n+4<=e.byteLength;n+=4){let s=t+n>>>0,o=mw(e,n);if(o>>>26===37)o=(2483027968|o-(s>>>2)&67108863)>>>0,WPe(e,n,o);else if((o&2667577344)===2415919104){let r=o>>>29&3|o>>>3&2097148;if((r+131072&1835008)!==0)continue;let i=r-(s>>>12)>>>0;o&=2415919135,o|=(i&3)<<29,o|=(i&262140)<<3,o|=0-(i&131072)&14680064,WPe(e,n,o>>>0)}}}function tZr(e,t){if(e.byteLength<8)return;for(let n=0;n<=e.byteLength-8;n+=2){let s=e[n];if(s===239){let r=e[n+1];if((r&13)!==0)continue;let i=((r&240)<<13|e[n+2]<<9|e[n+3]<<1)-t-n>>>0;e[n+1]=r&15|i>>>8&240,e[n+2]=i>>>16&15|i>>>7&16|i<<4&224,e[n+3]=i>>>4&127|i>>>13&128,n+=2;continue}if((s&127)!==23)continue;s=mw(e,n);let o;if((s&3712)!==0){if(o=mw(e,n+4),(s<<8^o-3&1015811)!==0){n+=4;continue}let r=(s&4294963200)+(o>>>20);s=(279|o<<12)>>>0,o=r>>>0}else{let r=s>>>27;if(s-12567<<18>>>0>=(r&29)){n+=2;continue}let i=$3n(e,n+4)-t-n>>>0;o=(s>>>12|i<<20)>>>0,s=(23|r<<7|i+2048&4294963200)>>>0}WPe(e,n,s),WPe(e,n+4,o),n+=6}}function nZr(e,t){if(t.id===3){if(t.properties.byteLength!==1)throw new G("Invalid XZ Delta filter properties");VQr(e,t.properties[0]+1);return}if(t.properties.byteLength!==0&&t.properties.byteLength!==4)throw new G(`Invalid XZ BCJ filter 0x${t.id.toString(16)} properties`);let n=t.properties.byteLength===4?mw(t.properties,0):0,s=t.id===6?16:t.id===8||t.id===11?2:t.id===4?1:4;if((n&s-1)!==0)throw new G(`Invalid XZ BCJ filter 0x${t.id.toString(16)} start offset`);switch(t.id){case 4:YQr(e,n);break;case 5:KQr(e,n);break;case 6:ZQr(e,n);break;case 7:XQr(e,n);break;case 8:JQr(e,n);break;case 9:QQr(e,n);break;case 10:eZr(e,n);break;case 11:tZr(e,n);break;default:throw new G(`Unsupported XZ filter ID 0x${t.id.toString(16)}`)}}function sZr(e,t,n){if(e===0)return;if(e===1){if(mw(n,0)!==sa(t))throw new G("Invalid XZ stream: block CRC32 mismatch");return}if(e===4){let o=B$n(t),r=0n;for(let i=0;i<8;i++)r|=BigInt(n[i])<<BigInt(i*8);if(o!==r)throw new G("Invalid XZ stream: block CRC64 mismatch");return}let s=new Uint8Array(new Bun.CryptoHasher("sha256").update(t).digest());if(!mgt(s,n))throw new G("Invalid XZ stream: block SHA-256 mismatch")}async function oZr(e,t,n,s){if(t>=e.byteLength||e[t]===0)throw new G("Invalid XZ stream: missing block header");let o=(e[t]+1)*4;if(t+o>e.byteLength||o<8)throw new G("Invalid XZ stream: truncated block header");if(sa(e.subarray(t,t+o-4))!==mw(e,t+o-4))throw new G("Invalid XZ stream: block header CRC32 mismatch");let r={bytes:e,pos:t+1,limit:t+o-4},i=e[r.pos++];if((i&60)!==0)throw new G("Unsupported XZ block flags");let a=(i&3)+1,l=(i&64)!==0?iW(r):void 0,u=(i&128)!==0?iW(r):void 0,p=[];for(let C=0;C<a;C++){let S=iW(r),E=iW(r);if(E>r.limit-r.pos)throw new G("Invalid XZ stream: truncated filter properties");p.push({id:S,properties:e.slice(r.pos,r.pos+E)}),r.pos+=E}while(r.pos<r.limit)if(e[r.pos++]!==0)throw new G("Invalid XZ stream: non-zero block header padding");let c=j3n(s),d=n.unpaddedSize-o-c;if(!Number.isSafeInteger(d)||d<=0)throw new G("Invalid XZ stream: compressed block size is invalid");if(l!==void 0&&l!==d)throw new G("Invalid XZ stream: block compressed size mismatch");if(u!==void 0&&u!==n.uncompressedSize)throw new G("Invalid XZ stream: block uncompressed size mismatch");let f=t+o,m=f+d,g=4-(o+d&3)&3,h=m+g;if(h+c>e.byteLength)throw new G("Invalid XZ stream: truncated block data");let T=p[p.length-1];if(T.id!==33||T.properties.byteLength!==1)throw new G(`Unsupported XZ terminal filter ID 0x${T.id.toString(16)} (LZMA2 required)`);let R=await UPe(T.properties[0],e.subarray(f,m),n.uncompressedSize);if(R.byteLength!==n.uncompressedSize)throw new G("Invalid XZ stream: decoded block size mismatch");R=R.slice();for(let C=p.length-2;C>=0;C--)nZr(R,p[C]);for(let C=m;C<h;C++)if(e[C]!==0)throw new G("Invalid XZ stream: non-zero block padding");sZr(s,R,e.subarray(h,h+c));let y=t+Math.ceil(n.unpaddedSize/4)*4;if(h+c!==y)throw new G("Invalid XZ stream: block size does not match its index record");return R}function GPe(e){return e.byteLength>=BPe.byteLength&&mgt(e.subarray(0,BPe.byteLength),BPe)}async function mO(e,t){if(!Number.isSafeInteger(t)||t<0)throw new G("Invalid XZ output limit");try{let n=zQr(e),s=0;for(let i of n)for(let a of i.records)if(s+=a.uncompressedSize,!Number.isSafeInteger(s)||s>t)throw new G("XZ output exceeds its size limit");let o=new Uint8Array(s),r=0;for(let i of n){let a=i.start+12;for(let l of i.records){let u=await oZr(e,a,l,i.checkId);o.set(u,r),r+=u.byteLength,a+=Math.ceil(l.unpaddedSize/4)*4}if(a!==i.indexStart)throw new G("Invalid XZ stream: blocks do not align with index")}return o}catch(n){if(n instanceof G)throw n;throw new G(`Invalid XZ stream: ${n instanceof Error?n.message:String(n)}`)}}var BPe;var hae=w(()=>{pO();Qr();rW();BPe=Uint8Array.of(253,55,122,88,90,0)});import{promisify as z3n}from"node:util";import*as $Pe from"node:zlib";function jPe(e){return e.byteLength>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function gO(e,t){try{return await iZr(e,{maxOutputLength:Math.max(t,1)})}catch(n){throw new G(n instanceof Error?n.message:String(n))}}function V3n(e){return rZr(e)}var rZr,iZr;var PY=w(()=>{Qr();rZr=z3n($Pe.zstdCompress),iZr=z3n($Pe.zstdDecompress)});import*as VPe from"node:path";class Tgt{#e;#t;#n;#s;constructor(e,t,n,s){this.#e=e,this.#t=t,this.#n=n,this.#s=s}async read(e,t){if(e!==this.#n)throw new G(`CPIO member '${t}' has an inconsistent declared size`);let n=this.#t+this.#n;if(n>this.#e.byteLength)throw new G(`CPIO member '${t}' is truncated`);let s=this.#e.subarray(this.#t,n);if(this.#s!==void 0&&ejn(s)!==this.#s)throw new G(`CPIO member '${t}' has an invalid CRC checksum`);return s}}function ejn(e){let t=0;for(let n of e)t=t+n>>>0;return t}function Z3n(e,t){let n=e%t;return n===0?e:e+t-n}function hO(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.byteLength)throw new G(`Invalid CPIO archive: truncated ${s}`)}function zPe(e,t,n,s,o){hO(e,t,t+n,`${o} field`);let r=0;for(let i=t;i<t+n;i++){let a=e[i],l;if(a>=48&&a<=57)l=a-48;else if(s===16&&a>=65&&a<=70)l=a-65+10;else if(s===16&&a>=97&&a<=102)l=a-97+10;else throw new G(`Invalid CPIO archive: ${o} is not a valid base-${s} number`);if(l>=s)throw new G(`Invalid CPIO archive: ${o} is not a valid base-${s} number`);r=r*s+l}if(!Number.isSafeInteger(r))throw new G(`Invalid CPIO archive: ${o} is too large`);return r}function tjn(e,t){hO(e,t,t+2,"header");let n=e[t],s=e[t+1];if(n===199&&s===113||n===113&&s===199){hO(e,t,t+X3n,"old binary header");let i=n===199?Rs:rae,a=(l)=>i(e,t+l)*65536+i(e,t+l+2);return{headerSize:X3n,alignment:2,devMajor:0,devMinor:i(e,t+2),inode:i(e,t+4),mode:i(e,t+6),nlink:i(e,t+12),mtime:a(16),nameSize:i(e,t+20),fileSize:a(22)}}hO(e,t,t+6,"magic");let o=String.fromCharCode(...e.subarray(t,t+6));if(o==="070701"||o==="070702"){hO(e,t,t+Y3n,"new ASCII header");let r=(a,l)=>zPe(e,t+6+a*8,8,16,l),i=r(12,"checksum");if(o==="070701"&&i!==0)throw new G("Invalid CPIO archive: newc checksum field must be zero");return{headerSize:Y3n,alignment:4,inode:r(0,"inode"),mode:r(1,"mode"),nlink:r(4,"link count"),mtime:r(5,"modification time"),fileSize:r(6,"file size"),devMajor:r(7,"device major"),devMinor:r(8,"device minor"),nameSize:r(11,"name size"),checksum:o==="070702"?i:void 0}}if(o==="070707"){hO(e,t,t+K3n,"portable ASCII header");let r=(i,a)=>zPe(e,t+i,6,8,a);return{headerSize:K3n,alignment:1,devMajor:0,devMinor:r(6,"device"),inode:r(12,"inode"),mode:r(18,"mode"),nlink:r(36,"link count"),mtime:zPe(e,t+48,11,8,"modification time"),nameSize:r(59,"name size"),fileSize:zPe(e,t+65,11,8,"file size")}}throw new G(`Invalid CPIO archive: unsupported or corrupt magic at offset ${t}`)}function njn(e){try{return uZr.decode(e)}catch{return}}function hgt(e,t,n,s){for(let o=t;o<n;o++)if(e[o]!==0)throw new G(`Invalid CPIO archive: non-zero ${s} padding`)}function pZr(e,t,n){wo(t.byteLength,"link target",n);let s=njn(t);if(s===void 0||s.includes("\x00"))throw new G(`Invalid CPIO archive: symlink '${e}' has an invalid UTF-8 target`);let o=s.replace(/\\/g,"/");if(VPe.posix.isAbsolute(o))return{path:o,resolveTarget:!1};let r=tf(VPe.posix.join(VPe.posix.dirname(e),o));return r===void 0?{path:o,resolveTarget:!1}:{path:r,resolveTarget:!0}}function Rgt(e,t){ki(e.byteLength,t.limits);let n=[],s=0,o=0,r=!1;while(s<e.byteLength){let u=tjn(e,s);if(u.mode>65535)throw new G("Invalid CPIO archive: mode exceeds 16 bits");if(u.nameSize<1)throw new G("Invalid CPIO archive: name size must include a NUL terminator");wo(u.nameSize-1,"member path",t.limits.maxPathBytes),fa(u.fileSize,"(CPIO entry)",t.limits);let p=s+u.headerSize,c=p+u.nameSize,d=Z3n(c,u.alignment),f=d+u.fileSize,m=Z3n(f,u.alignment);if(hO(e,p,c,"member name"),hO(e,d,f,"member data"),hO(e,f,m,"member padding"),e[c-1]!==0)throw new G("Invalid CPIO archive: member name is not NUL-terminated");for(let R=p;R<c-1;R++)if(e[R]===0)throw new G("Invalid CPIO archive: member name contains an embedded NUL");hgt(e,c,d,"name"),hgt(e,f,m,"data"),o+=d-s,Ns(o,t.limits,"CPIO index");let g=njn(e.subarray(p,c-1));if(g===aZr){if(u.fileSize!==0)throw new G("Invalid CPIO archive: TRAILER!!! has non-empty data");r=!0,s=m;break}let h=u.mode&ggt;if((h===Q3n||h===4096)&&u.fileSize!==0)throw new G("Invalid CPIO archive: directory or FIFO has non-empty data");cr(n.length+1,t.limits);let T=g===void 0?void 0:Lr(g);n.push({path:T,mode:u.mode,mtimeMs:u.mtime*1000,nlink:u.nlink,inode:u.inode,devMajor:u.devMajor,devMinor:u.devMinor,fileSize:u.fileSize,dataOffset:d,checksum:u.checksum}),s=m}if(!r)throw new G("Invalid CPIO archive: missing TRAILER!!! terminator");hgt(e,s,e.byteLength,"trailing");let i=new Map,a=new Set,l=new Map;for(let u of n){if((u.mode&ggt)!==J3n||u.nlink<=1)continue;let p=`${u.devMajor}:${u.devMinor}:${u.inode}`,c=l.get(p);if(c)c.push(u);else l.set(p,[u])}for(let u of l.values()){if(u.length<2)continue;for(let f of u)a.add(f);let p=u.filter((f)=>f.path!==void 0);if(p.length===0)continue;let c=u.find((f)=>f.fileSize!==0)??u[0],d=p.find((f)=>f===c)??p[0];for(let f of p){let m={path:f.path,isDirectory:!1,size:c.fileSize,mtimeMs:f.mtimeMs,mode:f.mode,storage:f===d?{type:"member",source:new Tgt(e,c.dataOffset,c.fileSize,c.checksum)}:{type:"link",targetPath:d.path,resolveTarget:!1}};Sc(i,m)}}for(let u of n){if(a.has(u)||u.path===void 0)continue;let p=u.mode&ggt;if(p===Q3n){Sc(i,{path:u.path,isDirectory:!0,size:0,mtimeMs:u.mtimeMs,mode:u.mode});continue}if(p===lZr){let c=e.subarray(u.dataOffset,u.dataOffset+u.fileSize);if(u.checksum!==void 0&&ejn(c)!==u.checksum)throw new G(`CPIO symlink '${u.path}' has an invalid CRC checksum`);let d=pZr(u.path,c,t.limits.maxPathBytes);Sc(i,{path:u.path,isDirectory:!1,size:0,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"link",targetPath:d.path,resolveTarget:d.resolveTarget}});continue}if(p!==J3n)continue;Sc(i,{path:u.path,isDirectory:!1,size:u.fileSize,mtimeMs:u.mtimeMs,mode:u.mode,storage:{type:"member",source:new Tgt(e,u.dataOffset,u.fileSize,u.checksum)}})}return ZL(i,t.limits),[...i.values()]}function Tae(e){try{let t=tjn(e,0);if(t.mode>65535||t.nameSize<1)return!1;let n=t.headerSize+t.nameSize;return n<=e.byteLength&&e[n-1]===0}catch{return!1}}var Y3n=110,K3n=76,X3n=26,aZr="TRAILER!!!",ggt=61440,J3n=32768,Q3n=16384,lZr=40960,uZr,sjn=async(e,t)=>{try{return ki(e.size,t.limits),Rgt(await XA(e),t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}};var ygt=w(()=>{Lh();e_();Qr();Hp();sf();JA();uZr=new TextDecoder("utf-8",{fatal:!0})});import*as yae from"node:path";class bjn{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){if(this.#n)throw new G(`Archive member '${br(t)}' is a sparse file and cannot be read`);if(e>this.#e.byteLength-this.#t)throw new G(`Archive member '${br(t)}' is truncated`);let n=this.#e.subarray(this.#t,this.#t+e);if(n.byteLength!==e)throw new G(`Archive member '${br(t)}' has an invalid size`);return n}}function KPe(e,t,n){let s=Math.min(t+n,e.byteLength),o=t;while(o<s&&e[o]!==0)o++;return Sae.decode(e.subarray(t,o))}function aW(e,t){return e.byteLength===t.length&&Dp(e,0,t)}function hZr(e,t){return Dp(e,t+yjn,bgt)&&Dp(e,t+Cjn,wgt)}function XPe(e,t,n){let s=e.indexOf(0),o=e.subarray(0,s===-1?e.byteLength:s);return wo(o.byteLength,t,n.maxPathBytes),Sae.decode(o)}function ijn(e,t,n){return wo(e.byteLength,t,n.maxPathBytes),Sae.decode(e)}function JPe(e,t,n){if(t<0||n<=0||t+n>e.byteLength)throw new G("Invalid tar numeric field");let s=e[t],o=0n;if((s&128)!==0){o=BigInt(s&127);for(let r=1;r<n;r++)o=o<<8n|BigInt(e[t+r]);if((s&64)!==0)o-=1n<<BigInt(n*8-1)}else for(let r=0;r<n;r++){let i=e[t+r];if(i>=48&&i<=55)o=o*8n+BigInt(i-48)}return Number(o)}function wjn(e,t){let n=JPe(e,t,gjn);if(!Number.isSafeInteger(n)||n<0)throw new G("Invalid tar member size");return n}function QPe(e){let t=e%gw,n=e+(t===0?0:gw-t);if(!Number.isSafeInteger(n))throw new G("Invalid tar member size");return n}function ajn(e,t){if(!/^\d+$/.test(e))throw new G(`Invalid tar ${t}`);let n=Number(e);if(!Number.isSafeInteger(n)||n<0)throw new G(`Invalid tar ${t}`);return n}function Ejn(e,t){for(let n=0;n<gw;n++)if(e[t+n]!==0)return!1;return!0}function kjn(e,t){let n=JPe(e,t+t_,Sgt),s=0,o=0;for(let r=0;r<gw;r++){let a=r>=t_&&r<t_+Sgt?32:e[t+r]??0;s+=a,o+=a<<24>>24}return n===s||n===o}function ljn(e,t){Ns(e.byteLength,t,"tar PAX metadata");let n=new Map,s=0;while(s<e.byteLength){let o=s;while(o<e.byteLength&&e[o]!==32)o++;if(o===s||o>=e.byteLength||o-s>16)throw new G("Invalid tar PAX record");let r=0;for(let l=s;l<o;l++){let u=e[l];if(u<48||u>57)throw new G("Invalid tar PAX record");if(r=r*10+(u-48),r>e.byteLength-s)throw new G("Invalid tar PAX record")}if(r<=0||s+r>e.byteLength||e[s+r-1]!==10)throw new G("Invalid tar PAX record");let i=e.subarray(o+1,s+r-1),a=i.indexOf(61);if(a>=0){let l=i.subarray(0,a),u=i.subarray(a+1);if(Dp(l,0,Egt)){if(n.set(Egt,u.byteLength===0?"":"1"),aW(l,"GNU.sparse.name"))n.set("GNU.sparse.name",ijn(u,"PAX sparse path",t));else if(aW(l,"GNU.sparse.realsize")||aW(l,"GNU.sparse.size")){if(u.byteLength>ojn)throw new G("Invalid tar sparse real size");n.set("GNU.sparse.realsize",Sae.decode(u))}}else if(aW(l,"path")||aW(l,"linkpath")){let p=aW(l,"path")?"PAX path":"PAX link target";n.set(p==="PAX path"?"path":"linkpath",ijn(u,p,t))}else if(aW(l,"size")){if(u.byteLength>ojn)throw new G("Invalid tar member size");n.set("size",Sae.decode(u))}}s+=r}return n}function TZr(e,t){for(let[n,s]of t)if(s==="")e.delete(n);else e.set(n,s)}function NY(e,t,n){if(t?.has(n))return t.get(n);return e.get(n)}function RZr(e,t){return NY(e,t,Egt)==="1"}function yZr(e,t,n){for(let s=n;s<=e.byteLength-t.length;s++)if(Dp(e,s,t))return s;return-1}function ujn(e,t,n){let s=e.replace(/\\/g,"/");if(yae.posix.isAbsolute(s))throw new G(`Invalid old-GNU ${t}`);let o=Lr(s);if(!o)throw new G(`Invalid old-GNU ${t}`);return nf(o,t,n.maxPathBytes),o}function CZr(e,t,n,s,o){let r=[...e.entries()].filter(([i])=>i===n||i.startsWith(`${n}/`));if(r.length===0)return;for(let[i]of r)e.delete(i);for(let[i,a]of r){let l=i.slice(n.length),u=`${s}${l}`;nf(u,"member path",o.maxPathBytes),a.path=u;let p=e.get(u);if(p)t.delete(p);e.set(u,a)}for(let i of t.values())if(i.kind==="hard link"&&(i.targetPath===n||i.targetPath.startsWith(`${n}/`)))i.targetPath=`${s}${i.targetPath.slice(n.length)}`}function SZr(e,t,n,s){Ns(e.byteLength,s,"old-GNU name metadata");let o=e.indexOf(0),r=o===-1?e.byteLength:o,i=0;while(i<r){let a=e.indexOf(10,i),l=a===-1||a>r?r:a,u=e.subarray(i,l);if(Dp(u,0,"Rename ")){let p=yZr(u," to ",7);if(p===-1)throw new G("Invalid old-GNU name record");let c=XPe(u.subarray(7,p),"old-GNU source path",s),d=u[u.byteLength-1]===47?u.byteLength-1:u.byteLength,f=XPe(u.subarray(p+4,d),"old-GNU target path",s);CZr(t,n,ujn(c,"source path",s),ujn(f,"target path",s),s)}i=l+1}}function bZr(e,t,n){if(t.size===0)return;let s=new Set;for(let l of e.values())for(let u=l.path.lastIndexOf("/");u>0;u=l.path.lastIndexOf("/",u-1)){let p=l.path.slice(0,u);if(s.has(p))break;s.add(p)}let o=new Set(t.keys()),r=new Map,i=(l)=>{for(let u=l.length;u>0;u=l.lastIndexOf("/",u-1)){let p=e.get(l.slice(0,u));if(p&&o.has(p))return p}return null},a=[...o];while(a.length>0){let l=a.pop();if(!o.has(l))continue;let u=t.get(l),p=i(u.targetPath),c=u.targetPath;if(p===null){try{c=eW(e,c,n.maxLinkDepth)}catch(g){if(!(g instanceof G))throw new G("Invalid archive link")}if(c!==u.targetPath)p=i(c)}if(p!==null&&p!==l){let g=r.get(p);if(g)g.push(l);else r.set(p,[l]);continue}o.delete(l);let d=r.get(l);if(d)r.delete(l),a.push(...d);if(p===l){if(u.kind==="hard link")throw new G(`Archive hard link '${br(l.path)}' has a cyclic target '${br(u.targetPath)}'`);l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1};continue}let f=e.get(c);if(f?.storage&&!f.isDirectory&&!o.has(f)){l.size=f.size,l.storage=f.storage;continue}if(!(c===""||f?.isDirectory===!0||s.has(c))){if(u.kind==="symlink"){l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1};continue}let g=f?"unreadable member":"missing member";throw new G(`Archive hard link '${br(l.path)}' targets ${g} '${br(u.targetPath)}'`)}if(u.kind==="hard link")throw new G(`Archive hard link '${br(l.path)}' targets directory '${br(u.targetPath)}'`);l.isDirectory=!0,l.storage={type:"link",targetPath:u.targetPath,resolveTarget:!1}}if(o.size>0)throw new G("Archive contains cyclic or unsupported links")}function bae(e,t){let{limits:n}=t;ki(e.byteLength,n);let s=new Map,o=new Map,r=(d,f)=>{let m=s.get(d.path),g=Sc(s,d);if(!g)return;if(m)o.delete(m);if(f)o.set(g,f);cr(s.size,n)},i=0,a,l,u,p=new Map,c=!1;while(i+gw<=e.byteLength){if(Ejn(e,i)){c=!0;break}if(!kjn(e,i))throw new G("Invalid or corrupt tar archive header");let d=i,f=String.fromCharCode(e[d+Rjn]||48),m=wjn(e,d+Agt),g=KPe(e,d+kgt,Cae);if(hZr(e,d)){let q=KPe(e,d+Sjn,Igt);if(q)g=`${q}/${g}`}let h=KPe(e,d+cZr,dZr),T=JPe(e,d+hjn,Tjn),R=JPe(e,d+fjn,mjn),y=Number.isSafeInteger(R)&&R>=0?R:void 0;i+=gw;let C=QPe(m);if(C>e.byteLength-i)throw new G("Archive member data is truncated");let S=e.subarray(i,i+m);if(f==="L"){Ns(S.byteLength,n,"GNU long-name metadata"),a=XPe(S,"GNU long path",n),i+=C;continue}if(f==="K"){Ns(S.byteLength,n,"GNU long-link metadata"),l=XPe(S,"GNU long link target",n),i+=C;continue}if(f==="N"){SZr(S,s,o,n),i+=C;continue}if(f==="x"||f==="X"){u=ljn(S,n),i+=C;continue}if(f==="g"){TZr(p,ljn(S,n)),i+=C;continue}if(f==="M")throw new G("GNU multi-volume tar members are not supported");if(a!==void 0)g=a;if(l!==void 0)h=l;let E=NY(p,u,"path");if(E!==void 0)g=E;let A=NY(p,u,"linkpath");if(A!==void 0)h=A;let k=NY(p,u,"size");if(k!==void 0)m=ajn(k,"member size");let x=NY(p,u,"GNU.sparse.name");if(x!==void 0)g=x;let M=m,O=NY(p,u,"GNU.sparse.realsize");if(O!==void 0)M=ajn(O,"sparse real size");let v=f==="S"||RZr(p,u);if(f==="S"&&e[d+fZr]===1){let q=!0;while(q){if(i+gw>e.byteLength)throw new G("Archive sparse metadata is truncated");q=e[i+mZr]===1,i+=gw}}let P=i,N=QPe(m);if(N>e.byteLength-P)throw new G(`Archive member '${br(g)}' is truncated`);i+=N,a=void 0,l=void 0,u=void 0;let F=f==="5"||g.endsWith("/"),_=Lr(g);if(!_)continue;nf(_,"member path",n.maxPathBytes);let L=T*1000,D=T!==0&&Number.isSafeInteger(L)?L:void 0;if(F){r({path:_,isDirectory:!0,size:0,mtimeMs:D,mode:y});continue}if(f==="1"||f==="2"){let q=f==="1"?"hard link":"symlink",U=h.replace(/\\/g,"/");nf(U,"link target",n.maxPathBytes);let z=f==="1"?Lr(U):yae.posix.isAbsolute(U)?void 0:tf(yae.posix.join(yae.posix.dirname(_),U)),Q={path:_,isDirectory:!1,size:0,mtimeMs:D,mode:y};if(z===void 0||Buffer.byteLength(z,"utf-8")>n.maxPathBytes){if(q==="hard link")throw new G(`Archive hard link '${br(_)}' has an invalid target`);Q.storage={type:"link",targetPath:U,resolveTarget:!1},r(Q);continue}r(Q,{kind:q,targetPath:z});continue}if(f!=="0"&&f!=="\x00"&&f!=="7"&&f!=="S")continue;fa(M,_,n),r({path:_,isDirectory:!1,size:M,mtimeMs:D,mode:y,storage:{type:"member",source:new bjn(e,P,v)}})}if(!c)throw new G("Not a valid tar archive: missing terminating zero block");return bZr(s,o,n),[...s.values()]}function xgt(e){if(e.byteLength<gw)return!1;if(Ejn(e,0))return!0;try{if(KPe(e,kgt,Cae).length===0)return!1;let t=wjn(e,Agt);return Number.isSafeInteger(QPe(t))&&kjn(e,0)}catch{return!1}}function YPe(e,t,n,s){if(s.byteLength>n)throw new G("Tar header field is too long");e.set(s,t)}function Rae(e,t,n,s){if(!Number.isSafeInteger(s)||s<0)throw new G("Invalid tar numeric value");let o=s.toString(8);if(o.length>n-1)throw new G("Tar numeric value does not fit its header field");for(let r=t;r<t+n-1-o.length;r++)e[r]=48;for(let r=0;r<o.length;r++)e[t+n-1-o.length+r]=o.charCodeAt(r);e[t+n-1]=0}function wZr(e){if(e.byteLength<=Cae)return[e,new Uint8Array(0)];for(let t=e.byteLength-1;t>0;t--){if(e[t]!==47)continue;let n=e.subarray(0,t),s=e.subarray(t+1);if(n.byteLength<=Igt&&s.byteLength>0&&s.byteLength<=Cae)return[s,n]}return}function Cgt(e,t){let n=n_.encode(`${e}=${t}
|
|
4803
4803
|
`),s=n.byteLength+2;for(;;){let a=String(s).length+1+n.byteLength;if(a===s)break;s=a}let o=n_.encode(`${s} `),r=new Uint8Array(s);return r.set(o),r.set(n,o.byteLength),r}function Ijn(e){let t=0;for(let o of e)if(t+=o.byteLength,!Number.isSafeInteger(t))throw new G("Tar archive is too large to encode safely");let n=new Uint8Array(t),s=0;for(let o of e)n.set(o,s),s+=o.byteLength;return n}function pjn(e,t,n,s,o,r){let i=new Uint8Array(gw);YPe(i,kgt,Cae,e),Rae(i,fjn,mjn,o),Rae(i,108,8,0),Rae(i,116,8,0),Rae(i,Agt,gjn,n),Rae(i,hjn,Tjn,s),i.fill(32,t_,t_+Sgt),i[Rjn]=r,YPe(i,yjn,bgt.length,n_.encode(bgt)),YPe(i,Cjn,wgt.length,n_.encode(wgt)),YPe(i,Sjn,Igt,t);let a=0;for(let u of i)a+=u;let l=a.toString(8).padStart(6,"0");for(let u=0;u<6;u++)i[t_+u]=l.charCodeAt(u);return i[t_+6]=0,i[t_+7]=32,i}function cjn(e,t){e.push(t);let n=QPe(t.byteLength)-t.byteLength;if(n>0)e.push(new Uint8Array(n))}function djn(e,t,n,s,o){let r=n_.encode(s?`${t}/`:t),i=wZr(r),a=s?0:n.byteLength,l=0,u=[];if(!i)u.push(Cgt("path",s?`${t}/`:t));if(a>rjn)u.push(Cgt("size",String(a)));if(0>gZr)u.push(Cgt("mtime",String(0)));if(u.length>0){let c=Ijn(u),d=n_.encode(`PaxHeaders/${String(o).padStart(8,"0")}`);e.push(pjn(d,new Uint8Array(0),c.byteLength,0,420,120)),cjn(e,c)}let p=i??[n_.encode(`PaxFile/${String(o).padStart(8,"0")}`),new Uint8Array(0)];if(e.push(pjn(p[0],p[1],a<=rjn?a:0,0,s?493:420,s?53:48)),!s)cjn(e,n)}async function ZPe(e){let t=[],n=new Map,s=0;for(let[o,r]of e){let i=o.endsWith("/")||o.endsWith("\\"),a=Lr(o);if(!a)throw new G(`Invalid tar member path '${br(o)}'`);if(n_.encode(a).byteLength===0)throw new G("Invalid empty tar member path");if(i&&r.byteLength!==0)throw new G(`Tar directory '${br(a)}' cannot contain file data`);let u=a.split("/");for(let c=1;c<u.length;c++){let d=u.slice(0,c).join("/"),f=n.get(d);if(f==="file")throw new G(`Tar member '${br(d)}' is not a directory`);if(f==="directory")continue;n.set(d,"directory"),djn(t,d,new Uint8Array(0),!0,s++)}let p=n.get(a);if(p){if(i&&p==="directory")continue;throw new G(`Duplicate tar member path '${br(a)}'`)}n.set(a,i?"directory":"file"),djn(t,a,r,i,s++)}return t.push(new Uint8Array(gw*2)),Ijn(t)}var gw=512,kgt=0,Cae=100,fjn=100,mjn=8,Agt=124,gjn=12,hjn=136,Tjn=12,t_=148,Sgt=8,Rjn=156,cZr=157,dZr=100,yjn=257,bgt="ustar\x00",Cjn=263,wgt="00",Sjn=345,Igt=155,fZr=482,mZr=504,ojn=32,Egt="GNU.sparse.",Sae,n_,rjn=8589934591,gZr=8589934591,Ajn=async(e,t)=>{ki(e.size,t.limits);let n;try{n=await XA(e)}catch(s){if(s instanceof G)throw s;throw new G(s instanceof Error?s.message:"Failed to read tar archive")}if(n.byteLength!==e.size)throw new G("Invalid archive: truncated data");return bae(n,t)};var e0e=w(()=>{Lh();e_();Qr();Hp();sf();JA();Sae=new TextDecoder,n_=new TextEncoder});class Mjn{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async read(e,t){try{let n=await this.#e.read(this.#t,this.#t+e);if(n.byteLength!==e)throw new G(`Archive member '${t}' is truncated`);return n}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}}}function FY(e,t,n){let s=t+n;while(s>t&&e[s-1]===32)s--;let o="";for(let r=t;r<s;r++){let i=e[r];if(i<32||i>126)throw new G("Invalid ar archive header field");o+=String.fromCharCode(i)}return o}function wae(e,t,n){if(e===""||e==="-1")return;if(!(t===8?/^[0-7]+$/:/^\d+$/).test(e))throw new G(`Invalid ar archive ${n}`);let o=Number.parseInt(e,t);if(!Number.isSafeInteger(o))throw new G(`Invalid ar archive ${n}`);return o}function IZr(e){let t=wae(e,10,"member size");if(t===void 0)throw new G("Invalid ar archive member size");return t}function xZr(e){if(e.byteLength!==s0e||e[xjn]!==96||e[xjn+1]!==10)throw new G("Invalid ar archive member header");let t=FY(e,0,EZr),n=wae(FY(e,16,12),10,"modification time");wae(FY(e,28,6),10,"user id"),wae(FY(e,34,6),10,"group id");let s=wae(FY(e,40,8),8,"mode"),o=IZr(FY(e,48,10)),r;if(t.startsWith("#1/")){let i=t.slice(3);if(!/^\d+$/.test(i))throw new G("Invalid ar archive BSD extended name length");if(r=Number.parseInt(i,10),!Number.isSafeInteger(r)||r<=0||r>o)throw new G("Invalid ar archive BSD extended name length")}return{rawName:t,physicalSize:o,mtimeSeconds:n,mode:s,bsdNameLength:r}}function vjn(e,t){return wo(e.byteLength,"member path",t.maxPathBytes),AY.decode(e)}function MZr(e,t){let n=e.indexOf(0),s=n>=0?e.subarray(0,n):e;if(s.byteLength===0)throw new G("Invalid ar archive empty BSD extended name");return{name:vjn(s,t),byteLength:s.byteLength}}function vZr(e){if(e==="/"||e==="//"||e==="/SYM64/")return e;return e.endsWith("/")?e.slice(0,-1):e}function OZr(e,t,n){let s=e.slice(1);if(!/^\d+$/.test(s))throw new G(`Invalid ar archive member name '${e}'`);let o=Number.parseInt(s,10);if(!Number.isSafeInteger(o)||o<0||o>=t.byteLength)throw new G(`Invalid ar archive long-name offset '${e}'`);let r=o;while(r<t.byteLength&&t[r]!==0&&t[r]!==10)r++;if(r===t.byteLength)throw new G(`Unterminated ar archive long name at offset ${o}`);let i=r;if(t[r]===10&&i>o&&t[i-1]===47)i--;if(i===o)throw new G(`Empty ar archive long name at offset ${o}`);let a=t.subarray(o,i);return{name:vjn(a,n),byteLength:a.byteLength}}function PZr(e){return e==="/"||e==="//"||e==="/SYM64/"||e==="__.SYMDEF"||e==="__.SYMDEF SORTED"}function NZr(e,t,n,s){let o=new Map;for(let r of e){let{name:i,nameByteLength:a}=r;if(/^\/\d+$/.test(i)){if(!t)throw new G(`Ar archive member '${i}' references a missing long-name table`);let c=OZr(i,t,s.limits);i=c.name,a=c.byteLength}else i=vZr(i);if(PZr(i))continue;wo(a,"member path",s.limits.maxPathBytes),fa(r.size,i,s.limits);let l=Lr(i);if(!l)continue;let u=r.mode!==void 0&&(r.mode&kZr)===AZr,p={path:l,isDirectory:u,size:u?0:r.size,...r.mtimeSeconds!==void 0?{mtimeMs:r.mtimeSeconds*1000}:{},...r.mode!==void 0?{mode:r.mode}:{},...!u?{storage:{type:"member",source:new Mjn(n,r.dataOffset)}}:{}};Sc(o,p),cr(o.size,s.limits)}return ZL(o,s.limits),[...o.values()]}function FZr(e){if(!Mgt(e))throw new G("Invalid ar archive signature")}async function t0e(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.size)throw new G(`Invalid ar archive: truncated ${s}`);try{let o=await e.read(t,n);if(o.byteLength!==n-t)throw new G(`Invalid ar archive: truncated ${s}`);return o}catch(o){if(o instanceof G)throw o;throw new G(o instanceof Error?o.message:String(o))}}async function LZr(e,t){if(!Number.isSafeInteger(e.size)||e.size<n0e.length)throw new G("Invalid ar archive signature");FZr(await t0e(e,0,n0e.length,"signature"));let n=[],s,o=0;for(let r=n0e.length;r<e.size;){let i=await t0e(e,r,r+s0e,"member header"),a=xZr(i);o+=s0e,Ns(o,t.limits,"index");let l=r+s0e,u=l+a.physicalSize;if(!Number.isSafeInteger(u)||u>e.size)throw new G("Invalid ar archive: truncated member data");let p=a.rawName,c=Buffer.byteLength(p,"utf-8"),d=l,f=a.physicalSize;if(a.bsdNameLength!==void 0){o+=a.bsdNameLength,Ns(o,t.limits,"index");let m=await t0e(e,l,l+a.bsdNameLength,"BSD member name"),g=MZr(m,t.limits);p=g.name,c=g.byteLength,d+=a.bsdNameLength,f-=a.bsdNameLength}else if(a.rawName==="//")o+=a.physicalSize,Ns(o,t.limits,"index"),s=await t0e(e,l,u,"long-name table");if(n.push({name:p,nameByteLength:c,dataOffset:d,size:f,mtimeSeconds:a.mtimeSeconds,mode:a.mode}),cr(n.length,t.limits),r=u+(a.physicalSize&1),r>e.size)throw new G("Invalid ar archive: missing alignment byte")}return NZr(n,s,e,t)}function Mgt(e){return Dp(e,0,n0e)}var n0e=`!<arch>
|
|
4804
4804
|
`,s0e=60,EZr=16,xjn=58,kZr=61440,AZr=16384,o0e=async(e,t)=>{try{return await LZr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}};var vgt=w(()=>{Lh();e_();Qr();Hp();sf();JA()});function DZr(e){if(!Dp(e,0,r0e)||e.byteLength<r0e.length+Ogt)return;let t=r0e.length;if(e[t+58]!==96||e[t+59]!==10)return;let n=t+_Zr;while(n>t&&e[n-1]===32)n--;let s="";for(let o=t;o<n;o++){let r=e[o];if(r<32||r>126)return;s+=String.fromCharCode(r)}if(s.startsWith("#1/")){let o=s.slice(3);if(!/^\d+$/.test(o))return;let r=Number.parseInt(o,10),i=t+Ogt;if(!Number.isSafeInteger(r)||r<=0||i+r>e.byteLength)return;let a=e.subarray(i,i+r),l=a.indexOf(0);return AY.decode(l>=0?a.subarray(0,l):a)}return s.endsWith("/")?s.slice(0,-1):s}function HZr(e){let t=/^(control|data)\.tar(?:\.(gz|xz|zst|bz2|lzma))?$/.exec(e);if(!t)return;return{kind:t[1],compression:t[2]??"none"}}async function qZr(e,t,n){let s=n.limits.maxInMemorySize,o;switch(t){case"none":o=e;break;case"gz":o=await oW(e,s);break;case"xz":o=await mO(e,s);break;case"zst":o=await gO(e,s);break;case"bz2":o=await fO(e,s);break;case"lzma":o=await OY(e,s);break}return ki(o.byteLength,n.limits),o}function UZr(e){let t=`control/${e.path}`;if(e.storage?.type!=="link")return{...e,path:t};let n=e.storage.targetPath;if(n!==""&&Lr(n)!==n)return{...e,path:t};return{...e,path:t,storage:{...e.storage,targetPath:n?`control/${n}`:"control"}}}async function BZr(e){if(e.isDirectory||e.storage?.type!=="member")throw new G(`Invalid deb archive member '${e.path}'`);return e.storage.source.read(e.size,e.path)}async function WZr(e,t){let n=Math.min(e.size,r0e.length+Ogt+t.limits.maxPathBytes),s;try{s=await e.read(0,n)}catch(i){throw new G(i instanceof Error?i.message:String(i))}if(!Pgt(s))throw new G("Invalid deb archive: first member is not debian-binary");let o=await o0e(e,t);if(o[0]?.path!==Ojn)throw new G("Invalid deb archive: first member is not debian-binary");let r=new Map;for(let i of o){let a=HZr(i.path);if(!a){if(i.path.startsWith("control.tar.")||i.path.startsWith("data.tar."))throw new G(`Unsupported deb tar compression in '${i.path}'`);Sc(r,i);continue}let l=await BZr(i),u=await qZr(l,a.compression,t),p=bae(u,t);for(let c of p)Sc(r,a.kind==="control"?UZr(c):c)}return ZL(r,t.limits),[...r.values()]}function Pgt(e){return DZr(e)===Ojn}var r0e=`!<arch>
|
|
4805
4805
|
`,Ogt=60,_Zr=16,Ojn="debian-binary",Pjn=async(e,t)=>{try{return await WZr(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}};var Njn=w(()=>{Lh();fae();mae();rW();hae();PY();e_();Qr();Hp();sf();e0e();vgt()});import*as lW from"node:path";class _jn{#e=0;#t;constructor(e){this.#t=e}async read(e,t,n,s){Lgt(e,t,n,s),this.#e+=n-t,Ns(this.#e,this.#t,"ISO metadata");let o=await e.read(t,n);if(o.byteLength!==n-t)throw To(`truncated ${s}`);return o}}class Djn{#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async read(e,t){try{let n=new Uint8Array(e),s=0;for(let o of this.#n){if(s+o.size>e)throw To(`invalid multi-extent size for '${t}'`);let r=o.fileUnitSize*this.#t,i=o.interleaveGapSize*this.#t;if(r===0){let u=await Fjn(this.#e,o.start,o.size,t);n.set(u,s),s+=u.byteLength;continue}let{size:a,start:l}=o;while(a>0){let u=Math.min(r,a),p=await Fjn(this.#e,l,u,t);n.set(p,s),s+=u,a-=u,l=TO(l,r+i,"interleaved file offset")}}if(s!==e)throw To(`member '${t}' produced ${s} bytes, expected ${e}`);return n}catch(n){if(n instanceof G)throw n;throw To(`could not extract member '${t}'`)}}}function To(e){return new G(`Invalid ISO 9660 archive: ${e}`)}function l0e(e,t,n){let s=e*t;if(!Number.isSafeInteger(s)||s<0)throw To(`${n} is too large`);return s}function TO(e,t,n){let s=e+t;if(!Number.isSafeInteger(s)||s<0)throw To(`${n} is too large`);return s}function Lgt(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.size)throw To(`truncated or invalid ${s}`)}async function Fjn(e,t,n,s){let o=TO(t,n,"member extent");Lgt(e,t,o,`extent for '${s}'`);let r=await e.read(t,o);if(r.byteLength!==n)throw To(`truncated extent for '${s}'`);return r}function i0e(e,t,n){let s=Rs(e,t);if(s!==rae(e,t+2))throw To(`${n} has mismatched byte orders`);return s}function s_(e,t,n){let s=wn(e,t);if(s!==Fh(e,t+4))throw To(`${n} has mismatched byte orders`);return s}function $Zr(e,t){let n=e[t]+1900,s=e[t+1],o=e[t+2],r=e[t+3],i=e[t+4],a=e[t+5],l=e[t+6],u=l>=128?l-256:l;if(s<1||s>12||o<1||o>31||r>23||i>59||a>60||u<-48||u>52)return;let p=Date.UTC(n,s-1,o,r,i,Math.min(a,59));if(!Number.isFinite(p))return;return p-u*15*60000}function Hjn(e,t,n,s){if(n<34)throw To(`${s} directory record is too short`);let o=e[t];if(o<34||o>n)throw To(`${s} directory record has an invalid length`);let r=e[t+32],i=r%2===0?1:0,a=33+r+i;if(r===0||a>o)throw To(`${s} directory record has an invalid identifier`);let l=s_(e,t+2,`${s} extent location`),u=s_(e,t+10,`${s} data length`);i0e(e,t+28,`${s} volume sequence number`);let p=e[t+26],c=e[t+27];if(p===0!==(c===0))throw To(`${s} has an invalid interleave configuration`);return{extent:l,size:u,extendedAttributeBlocks:e[t+1],mtimeMs:$Zr(e,t+18),flags:e[t+25],fileUnitSize:p,interleaveGapSize:c,identifier:e.subarray(t+33,t+33+r),systemUse:e.subarray(t+a,t+o)}}function Ljn(e,t){s_(e,80,"volume space size"),i0e(e,120,"volume set size"),i0e(e,124,"volume sequence number");let n=i0e(e,128,"logical block size");if(s_(e,132,"path table size"),n!==yC)throw new G(`Unsupported ISO 9660 logical block size ${n} (expected 2048)`);let s=Hjn(e,156,e.byteLength-156,"root");if((s.flags&2)===0||s.size===0||s.identifier.byteLength!==1||s.identifier[0]!==0)throw To("invalid root directory record");return{blockSize:n,root:s,joliet:t}}async function jZr(e,t,n){if(e.size<Ngt+yC)throw To("truncated volume descriptor set");let s=Ngt,o=16,r=new Uint8Array(0),i=0,a,l,u=!1,p=!1,c=!1,d=0;while(!c&&s<e.size){let f=l0e(o,yC,"volume descriptor scan"),m=n.maxIndexSize-d;if(m<yC)throw To("volume descriptor set exceeds metadata limit");let g=Math.floor(Math.min(f,m,e.size-s)/yC);if(g<1)throw To("truncated volume descriptor");let h=g*yC;r=await t.read(e,s,s+h,"volume descriptor set"),i=0;while(i+yC<=r.byteLength){let T=r.subarray(i,i+yC),R=T[0];if(Dp(T,1,"CDROM")||Dp(T,9,"CDROM"))p=!0;if(Dp(T,1,"BEA01")||Dp(T,1,"NSR02")||Dp(T,1,"NSR03")||Dp(T,1,"TEA01"))u=!0;if(Dp(T,1,"CD001")){if(T[6]!==1&&T[6]!==2)throw To("unsupported volume descriptor version");if(R===1)a=Ljn(T,!1);if(R===2&&T[88]===37&&T[89]===47&&[64,67,69].includes(T[90]))l=Ljn(T,!0);if(R===255){c=!0;break}}i+=yC,d+=yC}s+=r.byteLength,o=Math.min(o*2,Math.ceil(n.maxIndexSize/yC))}if(!a&&!l){if(p)throw new G("Unsupported High Sierra CD-ROM filesystem (not ISO 9660)");if(u)throw new G("Unsupported UDF-only image (no ISO 9660 volume descriptor)");throw To("primary volume descriptor not found")}if(!c)throw To("volume descriptor terminator not found");if(l)return{...l,rockRidgeRoot:a?.root};return a}function qjn(e,t){let n;if(t){if(e.byteLength%2!==0)throw To("Joliet identifier has an odd byte length");let s=new Uint16Array(e.byteLength/2);for(let r=0;r<s.length;r++)s[r]=rae(e,r*2);let o=[];for(let r=0;r<s.length;r+=4096)o.push(String.fromCharCode(...s.subarray(r,r+4096)));n=o.join("")}else n=Fgt.decode(e);return n.endsWith(";1")?n.slice(0,-2):n}function Ujn(e){let t=e.systemUse;for(let n=0;n+7<=t.byteLength;){let s=t[n+2];if(s<4||n+s>t.byteLength)return;if(t[n]===83&&t[n+1]===80&&s===7&&t[n+4]===190&&t[n+5]===239)return t[n+6];n+=s}return}async function Bjn(e,t,n,s,o,r){if(t===void 0||t>e.systemUse.byteLength)return{};let i=[e.systemUse.subarray(t)],a=new Set,l=[],u=[],p=!1,c,d;for(let g=0;g<i.length;g++){let h=i[g];for(let T=0;T+4<=h.byteLength;){let R=String.fromCharCode(h[T],h[T+1]),y=h[T+2],C=h[T+3];if(y<4||T+y>h.byteLength)throw To("malformed SUSP record");if(C!==1&&(R==="CE"||R==="NM"||R==="PX"||R==="RE"||R==="CL"||R==="PL"||R==="SL"||R==="ST"))throw To(`unsupported SUSP ${R} version ${C}`);let S=h.subarray(T+4,T+y);if(R==="ST")break;if(R==="CE"){if(S.byteLength<24)throw To("short SUSP CE record");let E=s_(S,0,"SUSP continuation block"),A=s_(S,8,"SUSP continuation offset"),k=s_(S,16,"SUSP continuation length");Ns(k,r,"ISO SUSP continuation");let x=TO(l0e(E,s,"SUSP continuation location"),A,"SUSP continuation location"),M=TO(x,k,"SUSP continuation range"),O=`${x}:${M}`;if(a.has(O))throw To("cyclic SUSP continuation");if(a.size>=GZr)throw To("too many SUSP continuations");a.add(O),i.push(await o.read(n,x,M,"SUSP continuation"))}if(R==="NM"&&S.byteLength>=1){let E=S[0];if((E&6)===0)l.push(Fgt.decode(S.subarray(1)));else if(E&2)l.push(".");else if(E&4)l.push("..")}if(R==="PX"&&S.byteLength>=8)c=s_(S,0,"Rock Ridge PX mode");if(R==="RE"||R==="CL"||R==="PL")d=R;if(R==="SL"&&S.byteLength>=1){let E=1;while(E<S.byteLength){if(E+2>S.byteLength)throw To("malformed Rock Ridge SL component");let A=S[E],k=S[E+1];if(E+=2,E+k>S.byteLength)throw To("malformed Rock Ridge SL component");let x;if(A&8)x="";else if(A&4)x="..";else if(A&2)x=".";else x=Fgt.decode(S.subarray(E,E+k));if(p&&u.length>0)u[u.length-1]+=x;else u.push(x);p=(A&1)!==0,E+=k}}T+=y}}let f=l.length>0?l.join(""):void 0,m;if(u.length>0)m=u[0]===""?`/${u.slice(1).join("/")}`:u.join("/");return{name:f,mode:c,symlink:m,relocation:d}}function Wjn(e,t){for(let n=e;n;n=n.parent)if(n.key===t)return!0;return!1}function zZr(e,t){let n=TO(e.extent,e.extendedAttributeBlocks,"file extent block");return{start:l0e(n,t,"file extent offset"),size:e.size,fileUnitSize:e.fileUnitSize,interleaveGapSize:e.interleaveGapSize}}async function Gjn(e,t,n,s,o){let r=l0e(TO(t.extent,t.extendedAttributeBlocks,"directory extent block"),n,"directory extent offset"),i=TO(r,t.size,"directory extent range"),a=await s.read(e,r,i,"directory extent"),l=[];for(let u=0;u<a.byteLength;){let p=n-u%n,c=a[u];if(c===0){u+=p;continue}if(c>p||c>a.byteLength-u)throw To("directory record crosses a logical block");l.push(Hjn(a,u,c,"member")),cr(l.length,o),u+=c}return l}async function VZr(e,t,n,s,o,r){let i=`${t.extent}:${t.size}`,a=[{record:t,parentPath:"",depth:0,ancestor:{key:i}}],l;while(a.length>0){let u=a.pop();if(u.depth>a0e)throw To(`directory hierarchy exceeds ${a0e} levels`);let p=await Gjn(e,u.record,n,s,o);if(u.depth===0&&p.length>0&&p[0].identifier.byteLength===1&&p[0].identifier[0]===0)l=Ujn(p[0]);for(let c of p){if(c.identifier.byteLength===1&&(c.identifier[0]===0||c.identifier[0]===1))continue;let d=await Bjn(c,l,e,n,s,o);if(d.relocation)throw new G(`Unsupported Rock Ridge relocated directory (${d.relocation})`);let f=d.name??qjn(c.identifier,!1);wo(Buffer.byteLength(f,"utf-8"),"member name",o.maxPathBytes);let m=u.parentPath?`${u.parentPath}/${f}`:f,g=Lr(m);if(!g)continue;if(wo(Buffer.byteLength(g,"utf-8"),"member path",o.maxPathBytes),d.symlink!==void 0){wo(Buffer.byteLength(d.symlink,"utf-8"),"link target",o.maxPathBytes);let R=lW.posix.isAbsolute(d.symlink)?void 0:tf(lW.posix.join(lW.posix.dirname(g),d.symlink));Sc(r,{path:g,isDirectory:!1,size:0,mtimeMs:c.mtimeMs,mode:d.mode,storage:{type:"link",targetPath:R??d.symlink,resolveTarget:R!==void 0}}),cr(r.size,o);continue}let h=r.get(g);if(h&&d.mode!==void 0)r.set(g,{...h,mode:d.mode});if((c.flags&2)===0)continue;let T=`${c.extent}:${c.size}`;if(Wjn(u.ancestor,T))throw To(`cyclic directory at '${g}'`);a.push({record:c,parentPath:g,depth:u.depth+1,ancestor:{key:T,parent:u.ancestor}})}}}async function YZr(e,t){if(!Number.isSafeInteger(e.size)||e.size<0)throw To("invalid source size");let n=new _jn(t.limits),s=await jZr(e,n,t.limits),r={key:`${s.root.extent}:${s.root.size}`},i=[{record:s.root,parentPath:"",depth:0,ancestor:r}],a=new Map,l;while(i.length>0){let u=i.pop();if(u.depth>a0e)throw To(`directory hierarchy exceeds ${a0e} levels`);let p=await Gjn(e,u.record,s.blockSize,n,t.limits);if(u.depth===0&&p.length>0&&p[0].identifier.byteLength===1&&p[0].identifier[0]===0)l=Ujn(p[0]);for(let c=0;c<p.length;){let d=p[c];if(d.identifier.byteLength===1&&(d.identifier[0]===0||d.identifier[0]===1)){c++;continue}let f=[d];if((d.flags&128)!==0){if((d.flags&2)!==0)throw To("multi-extent directory is unsupported");while((f[f.length-1].flags&128)!==0){let S=p[++c];if(!S||S.identifier.byteLength!==d.identifier.byteLength)throw To("unterminated multi-extent file");for(let E=0;E<d.identifier.byteLength;E++)if(S.identifier[E]!==d.identifier[E])throw To("non-contiguous multi-extent file");if((S.flags&-129)!==(d.flags&-129))throw To("inconsistent multi-extent file flags");f.push(S)}}c++;let m=await Bjn(d,l,e,s.blockSize,n,t.limits);if(m.relocation)throw new G(`Unsupported Rock Ridge relocated directory (${m.relocation})`);let g=m.name??qjn(d.identifier,s.joliet);wo(Buffer.byteLength(g,"utf-8"),"member name",t.limits.maxPathBytes);let h=u.parentPath?`${u.parentPath}/${g}`:g,T=Lr(h);if(!T)continue;wo(Buffer.byteLength(T,"utf-8"),"member path",t.limits.maxPathBytes);let R=(d.flags&2)!==0;if(m.symlink!==void 0){wo(Buffer.byteLength(m.symlink,"utf-8"),"link target",t.limits.maxPathBytes);let S=lW.posix.isAbsolute(m.symlink)?void 0:tf(lW.posix.join(lW.posix.dirname(T),m.symlink));Sc(a,{path:T,isDirectory:!1,size:0,mtimeMs:d.mtimeMs,mode:m.mode,storage:{type:"link",targetPath:S??m.symlink,resolveTarget:S!==void 0}}),cr(a.size,t.limits);continue}if(R){Sc(a,{path:T,isDirectory:!0,size:0,mtimeMs:d.mtimeMs,mode:m.mode}),cr(a.size,t.limits);let S=`${d.extent}:${d.size}`;if(Wjn(u.ancestor,S))throw To(`cyclic directory at '${T}'`);i.push({record:d,parentPath:T,depth:u.depth+1,ancestor:{key:S,parent:u.ancestor}});continue}let y=0;for(let S of f)y=TO(y,S.size,"multi-extent member size");fa(y,T,t.limits);let C=y===0?[]:f.map((S)=>zZr(S,s.blockSize));for(let S of C)Lgt(e,S.start,TO(S.start,S.size,"file extent range"),`extent for '${T}'`);Sc(a,{path:T,isDirectory:!1,size:y,mtimeMs:d.mtimeMs,mode:m.mode,storage:{type:"member",source:new Djn(e,s.blockSize,C)}}),cr(a.size,t.limits)}}if(s.rockRidgeRoot)await VZr(e,s.rockRidgeRoot,s.blockSize,n,t.limits,a);return[...a.values()]}function $jn(e){return Dp(e,Ngt+1,"CD001")}var yC=2048,Ngt,a0e=256,GZr=32,Fgt,jjn=async(e,t)=>{try{return await YZr(e,t)}catch(n){if(n instanceof G)throw n;throw To("could not parse image")}};var zjn=w(()=>{Lh();e_();Qr();Hp();sf();Ngt=16*yC,Fgt=new TextDecoder});class Zjn{bytes;pos=0;bit=0;constructor(e){this.bytes=new Uint8Array(e.byteLength+4),this.bytes.set(e)}read(e){if(e===0)return 0;let t=0;for(let n=e;n>0;){if(this.pos>=this.bytes.byteLength-4)o_("truncated compressed data");let s=Math.min(n,8-this.bit);if(t=t*2**s+(this.bytes[this.pos]>>>8-this.bit-s&2**s-1),this.bit+=s,n-=s,this.bit===8)this.bit=0,this.pos++}return t}align(){if(this.bit!==0)this.pos++,this.bit=0}}class LY{#e=new Int32Array(16);#t=new Int32Array(16);#n=new Int32Array(16);#s;#o=!1;constructor(e){this.#s=new Int32Array(e)}build(e,t,n){this.#e.fill(0);for(let i=0;i<n;i++){let a=e[t+i]&15;if(a!==0)this.#e[a]++}let s=0,o=0;for(let i=1;i<=15;i++)s=s+this.#e[i-1]<<1,this.#t[i]=s,this.#n[i]=o,o+=this.#e[i];let r=this.#n.slice();for(let i=0;i<n;i++){let a=e[t+i]&15;if(a!==0)this.#s[r[a]++]=i}this.#o=o!==0}decode(e){if(!this.#o)o_("empty Huffman table");let t=0;for(let n=1;n<=15;n++){t=t<<1|e.read(1);let s=t-this.#t[n];if(s>=0&&s<this.#e[n])return this.#s[this.#n[n]+s]}o_("invalid Huffman symbol")}}class Dgt{#e=new Uint8Array(0);#t=[0,0,0,0];#n=0;#s=0;#o=0;#r=0;#a=new Uint8Array(Vjn);#i=[];#l=[];#u=0;reset(){this.#e=new Uint8Array(0),this.#t=[0,0,0,0],this.#n=0,this.#s=0,this.#o=0,this.#r=0,this.#a.fill(0),this.#i=[],this.#l=[],this.#u=0}decode(e,t,n,s,o){if(o<29)throw new G(`Unsupported RAR4 compression algorithm version ${o}`);if(!s)this.reset();let r=this.#e.byteLength>n?this.#e.subarray(this.#e.byteLength-n):this.#e,i=new Uint8Array(r.byteLength+t+260);i.set(r);let a=r.byteLength,l=a+t,u=a,p=new Zjn(e),c=new LY(u0e),d=new LY(_Y),f=new LY(p0e),m=new LY(_gt),g=[],h=()=>{if(p.align(),p.read(1)!==0)throw new G("Unsupported RAR4 PPMd compressed block");let S=p.read(1)!==0;if(this.#o=0,this.#r=0,!S)this.#a.fill(0);let E=eei(p,this.#a,Vjn),A=0;c.build(E,A,u0e),A+=u0e,d.build(E,A,_Y),A+=_Y,f.build(E,A,p0e),A+=p0e,m.build(E,A,_gt),this.#a.set(E)},T=(S,E)=>{if(S<=0||S>n||S>u)o_("invalid LZ distance");E=Math.min(E,l-u);for(let A=0;A<E;A++)i[u+A]=i[u+A-S];u+=E},R=(S)=>{this.#t[3]=this.#t[2],this.#t[2]=this.#t[1],this.#t[1]=this.#t[0],this.#t[0]=S},y=()=>{let S=p.read(8),E=(S&7)+1;if(E===7)E=p.read(8)+7;else if(E===8)E=p.read(16);let A=new Uint8Array(E);for(let F=0;F<E;F++)A[F]=p.read(8);let k=new e5n(A),x;if((S&128)!==0)if(x=k.readData(),x===0)this.#i=[],this.#l=[];else x--;else x=this.#u;if(x<0||x>this.#i.length)o_("invalid RarVM filter index");this.#u=x;let M=x===this.#i.length,O=k.readData();if((S&64)!==0)O+=258;O+=u-a;let v=(S&32)!==0?k.readData():this.#l[x]??0,P=new Int32Array(7);if(P[3]=245760,P[4]=v,(S&16)!==0){let F=k.read(7);for(let _=0;_<7;_++)if((F&1<<_)!==0)P[_]=k.readData()}let N;if(M){let F=k.readData(),_=new Uint8Array(F);for(let L=0;L<F;L++)_[L]=k.read(8);N=JZr(_),this.#i.push(N),this.#l.push(v)}else N=this.#i[x],this.#l[x]=v;if(N!==1&&N!==2&&N!==6)throw new G(`Unsupported RAR4 RarVM filter type ${N||"unknown"}`);if(O<0||v<0||O+v>t)o_("invalid RarVM filter range");g.push({type:N,start:O,size:v,channels:P[0],fileOffset:P[6]})};h();while(u<l){let S=c.decode(p);if(S<256)i[u++]=S;else if(S>=271){let E=S-271,A=Yjn[E]+3+p.read(Kjn[E]),k=d.decode(p),x=Jjn[k]+1,M=Qjn[k];if(M!==0)if(k>9){if(M>4)x+=p.read(M-4)*16;if(this.#r>0)this.#r--,x+=this.#o;else{let O=f.decode(p);if(O===16)this.#r=15,x+=this.#o;else x+=O,this.#o=O}}else x+=p.read(M);if(x>=8192)A++;if(x>=262144)A++;R(x),this.#n=x,this.#s=A,T(x,A)}else if(S===256)if(p.read(1)!==0)h();else{if(p.read(1)!==0)h();break}else if(S===257)y();else if(S===258){if(this.#s!==0)T(this.#n,this.#s)}else if(S<263){let E=S-259,A=this.#t[E];for(let M=E;M>0;M--)this.#t[M]=this.#t[M-1];this.#t[0]=A;let k=m.decode(p),x=Yjn[k]+2+p.read(Kjn[k]);this.#n=A,this.#s=x,T(A,x)}else{let E=S-263,A=KZr[E]+1+p.read(XZr[E]);R(A),this.#n=A,this.#s=2,T(A,2)}}if(u!==l)o_(`decompressed size mismatch (${u-a} != ${t})`);let C=i.slice(a,l);return QZr(C,g),this.#e=i.slice(Math.max(0,l-n),l),C}}class e5n{#e;#t=0;constructor(e){this.#e=e}read(e){let t=0;for(let n=e;n>0;){let s=this.#t>>>3;if(s>=this.#e.byteLength)o_("truncated RarVM code");let o=this.#t&7,r=Math.min(n,8-o);t=t*2**r+(this.#e[s]>>>8-o-r&2**r-1),this.#t+=r,n-=r}return t}readData(){let e=this.read(2);if(e===0)return this.read(4);if(e===1){let t=this.read(4);if(t===0)return this.read(8)|4294967040|0;return t*16+this.read(4)}if(e===2)return this.read(16);return this.read(16)*65536+this.read(16)}}function JZr(e){let t=sa(e);if(e.byteLength===53&&t===2908186759)return 1;if(e.byteLength===57&&t===1020781950)return 2;if(e.byteLength===29&&t===235276157)return 6;if(e.byteLength===120&&t===929663295)return 3;if(e.byteLength===149&&t===472669640)return 4;if(e.byteLength===216&&t===3162892033)return 5;if(e.byteLength===40&&t===1186579808)return 7;return 0}function QZr(e,t){for(let n of t){let s=e.subarray(n.start,n.start+n.size);if(n.type===6){let r=s.slice(),i=0;for(let a=0;a<n.channels;a++){let l=0;for(let u=a;u<s.byteLength;u+=n.channels)l=l-r[i++]&255,s[u]=l}continue}let o=n.type===2?233:232;for(let r=0;r+4<s.byteLength;){let i=s[r++];if(i!==232&&i!==o)continue;let a=r+(n.fileOffset>>>0),l=ZZr(s,r);if(l<0){if(l+a>=0)Xjn(s,r,l+16777216)}else if(l-16777216<0)Xjn(s,r,l-a);r+=4}}}function ZZr(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function Xjn(e,t,n){e[t]=n,e[t+1]=n>>>8,e[t+2]=n>>>16,e[t+3]=n>>>24}function eei(e,t,n){let s=new Uint8Array(20);for(let i=0;i<20;i++){let a=e.read(4);if(a===15){let l=e.read(4);if(l!==0){l+=2;while(l-- >0&&i<20)s[i++]=0;i--;continue}}s[i]=a}let o=new LY(20);o.build(s,0,20);let r=new Uint8Array(n);for(let i=0;i<n;){let a=o.decode(e);if(a<16)r[i]=a+t[i]&15,i++;else if(a===16||a===17){let l=e.read(a===16?3:7)+(a===16?3:11),u=i===0?0:r[i-1];while(l-- >0&&i<n)r[i++]=u}else{let l=e.read(a===18?3:7)+(a===18?3:11);while(l-- >0&&i<n)r[i++]=0}}return r}function o_(e){throw new G(`Invalid RAR4 archive: ${e}`)}var u0e=299,_Y=60,p0e=17,_gt=28,Vjn,Yjn,Kjn,KZr,XZr,Jjn,Qjn;var t5n=w(()=>{pO();Qr();Vjn=u0e+_Y+p0e+_gt,Yjn=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224],Kjn=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5],KZr=[0,4,8,16,32,64,128,192],XZr=[2,2,3,4,5,6,6,6],Jjn=new Int32Array(_Y),Qjn=new Uint8Array(_Y);{let e=[4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12],t=0,n=0;for(let s=0;s<e.length;s++)for(let o=0;o<e[s];o++)Jjn[n]=t,Qjn[n]=s,t+=2**s,n++}});class r5n{bytes;pos=0;bit=0;blockEnd=0;blockEndBit=0;constructor(e){this.bytes=new Uint8Array(e.byteLength+16),this.bytes.set(e),this.bytes.fill(255,e.byteLength)}read(e){if(e===0)return 0;if(e<0||e>31)dd("invalid bit count");let t=0;for(let n=e;n>0;){if(this.pos>=this.bytes.byteLength-16)dd("truncated compressed data");let s=Math.min(n,8-this.bit);if(t=t*2**s+(this.bytes[this.pos]>>>8-this.bit-s&2**s-1),this.bit+=s,n-=s,this.bit===8)this.bit=0,this.pos++}return t}peek15(){let e=this.pos,t=this.bit,n=this.read(15);return this.pos=e,this.bit=t,n}align(){if(this.bit!==0)this.pos++,this.bit=0}byte(){if(this.bit!==0)dd("unaligned compressed data");if(this.pos>=this.bytes.byteLength-16)dd("truncated compressed data");return this.bytes[this.pos++]}atBlockEnd(){return this.pos>this.blockEnd||this.pos===this.blockEnd&&this.bit>=this.blockEndBit}}class eI{#e;#t;#n;#s;#o;#r;#a=!1;constructor(e,t=15){this.#t=e,this.#e=t,this.#n=new Int32Array(t+1),this.#s=new Int32Array(t+1),this.#o=new Int32Array(t+1),this.#r=new Int32Array(e)}build(e,t=0){this.#n.fill(0);for(let r=0;r<this.#t;r++){let i=e[t+r];if(i>this.#e)dd("invalid Huffman code length");if(i!==0)this.#n[i]++}let n=0,s=0;for(let r=1;r<=this.#e;r++)n=n+this.#n[r-1]<<1,this.#s[r]=n,this.#o[r]=s,s+=this.#n[r];if(s!==0&&n+this.#n[this.#e]!==1<<this.#e)dd("incomplete Huffman table");let o=this.#o.slice();for(let r=0;r<this.#t;r++){let i=e[t+r];if(i!==0)this.#r[o[i]++]=r}this.#a=s!==0}decode(e){if(!this.#a)dd("empty Huffman table");let t=0;for(let n=1;n<=this.#e;n++){t=t<<1|e.read(1);let s=t-this.#s[n];if(s>=0&&s<this.#n[n])return this.#r[this.#o[n]+s]}dd("invalid Huffman symbol")}}class Ugt{#e=new Uint8Array(0);#t=[4294967295,4294967295,4294967295,4294967295];#n=0;#s=new eI(ZA);#o=new eI(uW);#r=new eI(Eae);#a=new eI(qgt);#i=!1;reset(){this.#e=new Uint8Array(0),this.#t=[4294967295,4294967295,4294967295,4294967295],this.#n=0,this.#s=new eI(ZA),this.#o=new eI(uW),this.#r=new eI(Eae),this.#a=new eI(qgt),this.#i=!1}decode(e,t,n,s,o){if(o!==0&&o!==1)throw new G(`Unsupported RAR5 compression algorithm version ${o}`);if(!s)this.reset();if(!Number.isSafeInteger(n)||n<131072)dd("invalid dictionary size");let r=this.#e.byteLength>n?this.#e.subarray(this.#e.byteLength-n):this.#e,i=new Uint8Array(r.byteLength+t+nei);i.set(r);let a=r.byteLength,l=a,u=l+t,p=[],c=new r5n(e),d=this.#s,f=this.#o,m=this.#r,g=this.#a,h=!1,T=()=>{c.align();let C=c.byte(),S=C^c.byte(),E=C>>>3&3;if(E===3)dd("invalid compressed block header");let A=c.byte();S^=A;for(let N=0;N<E;N++){let F=c.byte();S^=F,A+=F*2**(8*(N+1))}if(S!==90)dd("compressed block checksum mismatch");let k=(C&7)+1;if(A+=k>>>3,A===0)dd("empty compressed block");if(A--,k&=7,c.blockEnd=c.pos+A,c.blockEndBit=k,h=(C&64)!==0,(C&128)===0)return;let x=new Uint8Array(20);for(let N=0;N<20;){let F=c.read(4);if(F===15){let _=c.read(4);if(_!==0){N=Math.min(20,N+_+2);continue}}x[N++]=F}let M=new eI(20);M.build(x);let O=o===1?Hgt:Hgt-16,v=new Uint8Array(O);for(let N=0;N<O;){let F=M.decode(c);if(F<16){v[N++]=F;continue}let _=(F-16&1)*4;_+=_+3+c.read(_+3);let L=F<18?N===0?dd("invalid Huffman repeat"):v[N-1]:0,D=Math.min(O,N+_);v.fill(L,N,D),N=D}let P=new Uint8Array(Hgt);if(o===0)P.set(v.subarray(0,ZA+64)),P.set(v.subarray(ZA+64),ZA+uW);else P.set(v);d.build(P),f.build(P,ZA),m.build(P,ZA+uW),g.build(P,ZA+uW+Eae),this.#i=!1;for(let N=0;N<Eae;N++)if(P[ZA+uW+N]!==4)this.#i=!0};T();while(a<u){if(c.atBlockEnd()){if(c.pos>c.blockEnd||c.pos===c.blockEnd&&c.bit>c.blockEndBit)dd("compressed block overread");if(c.align(),h)break;T();continue}let C=d.decode(c);if(C<256){i[a++]=C;continue}if(C===256){let A=(c.read(2)+1)*8,k=0;for(let P=0;P<A;P+=8)k+=c.read(8)*2**P;let x=(c.read(2)+1)*8,M=0;for(let P=0;P<x;P+=8)M+=c.read(8)*2**P;let O=c.read(3),v=O===0?c.read(5)+1:0;if(O>3)throw new G(`Unsupported RAR5 filter type ${O}`);if(M>sei||a-l+k+M>t)dd("invalid filter range");p.push({type:O,channels:v,start:a-l+k,size:M});continue}let S,E=this.#t[0];if(C<262){if(C>=258){let A=C-258;E=this.#t[A];for(let x=A;x>0;x--)this.#t[x]=this.#t[x-1];this.#t[0]=E;let k=g.decode(c);S=k>=8?n5n(c,k):k,S+=2,this.#n=S}else if(S=this.#n,S===0)continue}else{this.#t[3]=this.#t[2],this.#t[2]=this.#t[1],this.#t[1]=this.#t[0];let A=C-262;S=A>=8?n5n(c,A):A,S+=2;let k=f.decode(c);if(k>=4){let x=k-2>>>1;if(k=(2|k&1)*2**x,x<4)k+=c.read(x);else if(S+=tei[x]??3,this.#i)k+=c.read(x-4)*16+m.decode(c);else k+=c.read(x)}E=k+1,this.#t[0]=E,this.#n=S}if(E<=0||E>n||E>a)dd("invalid LZ distance");if(a+S>i.byteLength)dd("invalid LZ match length");for(let A=0;A<S;A++)i[a+A]=i[a+A-E];a+=S}if(a!==u)dd(`decompressed size mismatch (${a-l} != ${t})`);let R=i.slice(l,u);oei(R,p);let y=Math.max(0,u-n);return this.#e=i.slice(y,u),R}}function n5n(e,t){let n=(t>>>2)-1;return((4|t&3)<<n)+e.read(n)}function oei(e,t){for(let n of t){let s=e.subarray(n.start,n.start+n.size);if(n.type===0){let o=s.slice(),r=0;for(let i=0;i<n.channels;i++){let a=0;for(let l=i;l<s.byteLength;l+=n.channels)a=a-o[r++]&255,s[l]=a}}else if(n.type===1||n.type===2)for(let r=0;r+4<s.byteLength;){let i=s[r++];if(i!==232&&(n.type===1||i!==233))continue;let a=n.start+r&16777215,l=s5n(s,r);if(l>>>0<16777216)l-=a;else if(l>>>0>=-a>>>0)l+=16777216;else{r+=4;continue}o5n(s,r,l),r+=4}else for(let o=0;o+3<s.byteLength;o+=4){if(s[o+3]!==235)continue;let r=s5n(s,o),i=(r&4278190080|r-(n.start+o>>2)&16777215)>>>0;o5n(s,o,i)}}}function s5n(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function o5n(e,t,n){e[t]=n,e[t+1]=n>>>8,e[t+2]=n>>>16,e[t+3]=n>>>24}function dd(e){throw new G(`Invalid RAR5 archive: ${e}`)}var ZA=306,uW=80,Eae=16,qgt=44,Hgt,tei,nei=4100,sei=4194304;var i5n=w(()=>{Qr();Hgt=ZA+uW+Eae+qgt,tei=[0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]});class p5n{#e;#t;constructor(e,t){this.#e=e,this.#t=t}async read(e,t){return this.#e.read(this.#t,e,t)}}class c5n{#e;#t;#n;#s=new Map;#o=Promise.resolve();constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n.limits}member(e){return new p5n(this,e)}async read(e,t,n){let s=this.#o.then(async()=>{if(!this.#s.has(e))await this.#r(e)});this.#o=s.catch(()=>{return}),await s;let o=this.#s.get(e);if(!o)throw new G(`Failed to extract RAR member '${n}'`);if(o.byteLength!==t)throw new G(`RAR member '${n}' size mismatch (${o.byteLength} != ${t})`);return o.slice()}async#r(e){let t=this.#t[e];if(!t)throw new G("Invalid RAR member index");let n=e;if(t.solid)while(n>0&&this.#t[n].solid&&this.#t[n-1].format===t.format)n--;let s=new Dgt,o=new Ugt;for(let r=n;r<=e;r++){let i=this.#t[r];if(i.isDirectory)continue;if(fa(i.unpackedSize,i.path,this.#n),i.method===0&&i.packedSize!==i.unpackedSize)wu("stored member size mismatch");if(i.method>5)throw new G(i.format===4?`Unsupported RAR4 compression method 0x${(i.method+48).toString(16)} for '${i.path}'`:`Unsupported RAR5 compression method ${i.method} for '${i.path}'`);if(i.method!==0)ki(i.packedSize+2*i.unpackedSize+2*i.dictionarySize+8192,this.#n);let a=CC(i.dataStart,i.packedSize,this.#e.size,"member data"),l=await this.#e.read(i.dataStart,a),u;if(i.method===0){if(u=l,i.solid)if(i.format===4)s.reset();else o.reset()}else if(i.format===5)u=o.decode(l,i.unpackedSize,i.dictionarySize,i.solid,i.version);else u=s.decode(l,i.unpackedSize,i.dictionarySize,i.solid,i.version);if(u.byteLength!==i.unpackedSize)wu(`member '${i.path}' size mismatch`);if(i.crc!==void 0&&sa(u)!==i.crc)throw new G(`RAR member '${i.path}' CRC32 mismatch`);this.#s.set(r,u.slice())}}}function d5n(e){return Bgt(e)!==void 0}async function rei(e,t){let n=Math.min(e.size,pW.byteLength),s=await e.read(0,n),o=Bgt(s);while(!o&&n<Math.min(e.size,1048576+pW.byteLength)){let l=Math.min(e.size,1048576+pW.byteLength,Math.max(65536,n*2));Ns(l,t.limits,"RAR signature scan");let u=await e.read(n,l),p=new Uint8Array(l);p.set(s),p.set(u,n),s=p,n=l,o=Bgt(s)}if(!o)throw new G("Invalid RAR archive: signature not found");let r=[{start:0,bytes:s}],i=s.byteLength;Ns(i,t.limits,"RAR metadata");let a=o.offset+(o.version===5?pW.byteLength:Wgt.byteLength);while(a<e.size)if(o.version===5){if(a+5>e.size)wu("truncated RAR5 header");let l=await e.read(a,Math.min(e.size,a+16)),u={offset:4},p=Xa(l,u,l.byteLength,"header size");if(p>2097152)wu("RAR5 header exceeds format limit");let c=CC(a,u.offset+p,e.size,"RAR5 header");Ns(i+c-a,t.limits,"RAR metadata");let d=await e.read(a,c);r.push({start:a,bytes:d}),i+=d.byteLength,Ns(i,t.limits,"RAR metadata");let f={offset:u.offset},m=Xa(d,f,d.byteLength,"header type"),g=Xa(d,f,d.byteLength,"header flags");if((g&1)!==0)Xa(d,f,d.byteLength,"extra area size");let h=(g&2)!==0?Xa(d,f,d.byteLength,"data size"):0;if(a=CC(c,h,e.size,"RAR5 data area"),m===4||m===5)break}else{if(a+7>e.size)wu("truncated RAR4 base header");let l=await e.read(a,Math.min(e.size,a+11)),u=l[2],p=Rs(l,3),c=Rs(l,5);if(c<7)wu("invalid RAR4 header size");let d=CC(a,c,e.size,"RAR4 header");Ns(i+d-a,t.limits,"RAR metadata");let f=await e.read(a,d);r.push({start:a,bytes:f}),i+=f.byteLength,Ns(i,t.limits,"RAR metadata");let m=(p&32768)!==0?wn(f,7):0,g=CC(d,m,e.size,"RAR4 data area");if(u===116&&m<=t.limits.maxPathBytes){let h=(p&32768)!==0?11:7;if(h+21<=f.byteLength){let T=f[h+4],R=wn(f,h+17);if(T===3&&(R&61440)===40960)Ns(i+m,t.limits,"RAR metadata"),r.push({start:d,bytes:await e.read(d,g)}),i+=m,Ns(i,t.limits,"RAR metadata")}}if(a=g,u===123||u===115&&(p&128)!==0)break}return r.sort((l,u)=>l.start-u.start||u.bytes.byteLength-l.bytes.byteLength),{marker:o,segments:r}}function iei(e,t){let n=(r,i)=>{let a=0,l=t.length;while(a<l){let u=a+l>>>1;if(t[u].start<=r)a=u+1;else l=u}for(let u=a-1;u>=0;u--){let p=t[u];if(r>=p.start&&i<=p.start+p.bytes.byteLength)return p}wu("RAR parser accessed member payload while indexing")},s=Object.create(null);return new Proxy(s,{get(r,i){if(i==="byteLength"||i==="length")return e;if(i==="subarray")return(a,l=e)=>{let u=n(a,l);return u.bytes.subarray(a-u.start,l-u.start)};if(typeof i==="string"){let a=Number(i);if(Number.isSafeInteger(a)&&a>=0){let l=n(a,a+1);return l.bytes[a-l.start]}}return}})}function aei(e,t,n){let s=[],o=t+pW.byteLength,r=!1;while(o<e.byteLength){if(o+5>e.byteLength)wu("truncated RAR5 header");let i=wn(e,o),a=o+4,l={offset:a},u=Xa(e,l,e.byteLength,"header size");if(u>2097152)wu("RAR5 header exceeds format limit");Ns(u,n.limits,"RAR5 header");let p=l.offset,c=CC(p,u,e.byteLength,"RAR5 header");if(sa(e.subarray(a,c))!==i)wu("RAR5 header CRC32 mismatch");let d={offset:p},f=Xa(e,d,c,"header type"),m=Xa(e,d,c,"header flags"),g=(m&1)!==0?Xa(e,d,c,"extra area size"):0,h=(m&2)!==0?Xa(e,d,c,"data size"):0;if((m&24)!==0)throw new G("Unsupported multi-volume RAR5 archive");let T=c,R=CC(T,h,e.byteLength,"RAR5 data area");if(g>c-d.offset)wu("invalid RAR5 extra area size");let y=c-g;if(f===4)throw new G("Encrypted RAR5 headers are not supported");if(f===1){let C=Xa(e,d,y,"archive flags");if((C&1)!==0)throw new G("Unsupported multi-volume RAR5 archive");if((C&8)!==0)throw new G("Unsupported RAR5 recovery record");if((C&2)!==0)Xa(e,d,y,"volume number");r=!0}else if(f===2||f===3){let C=Xa(e,d,y,"file flags"),S=Xa(e,d,y,"unpacked size");if((C&8)!==0)throw new G("RAR5 member with unknown unpacked size is not supported");let E=Xa(e,d,y,"file attributes"),A;if((C&2)!==0)hg(d.offset,4,y,"RAR5 modification time"),A=wn(e,d.offset)*1000,d.offset+=4;let k;if((C&4)!==0)hg(d.offset,4,y,"RAR5 data CRC32"),k=wn(e,d.offset),d.offset+=4;let x=Xa(e,d,y,"compression information"),M=x&63;if(M===1&&(x&1048576)!==0)M=0;let O=(x&64)!==0,v=x>>>7&7,N=131072*2**(x>>>10&31);if((x&63)===1)N+=N*(x>>>15&31)/32;if(!Number.isSafeInteger(N)||N>n.limits.maxInMemorySize)throw new G(`RAR5 dictionary is too large (${N} bytes)`);let F=Xa(e,d,y,"host OS"),_=Xa(e,d,y,"file name size");wo(_,"member path",n.limits.maxPathBytes),hg(d.offset,_,y,"RAR5 file name");let L;try{L=a5n.decode(e.subarray(d.offset,d.offset+_))}catch{throw new G("Invalid RAR5 UTF-8 member name")}d.offset+=_;let D;for(let q of uei(e,y,c)){let U={offset:q.start};if(q.type===1)throw new G(`Encrypted RAR5 member '${L}' is not supported`);if(q.type===3){let z=Xa(e,U,q.end,"time flags");if((z&2)!==0)if((z&1)!==0)hg(U.offset,4,q.end,"Unix modification time"),A=wn(e,U.offset)*1000;else hg(U.offset,8,q.end,"Windows modification time"),A=dei(e,U.offset)}else if(q.type===5){let z=Xa(e,U,q.end,"redirection type");Xa(e,U,q.end,"redirection flags");let Q=Xa(e,U,q.end,"link target size");if(wo(Q,"link target",n.limits.maxPathBytes),hg(U.offset,Q,q.end,"link target"),z<1||z>5)throw new G(`Unsupported RAR5 redirection type ${z}`);try{D=a5n.decode(e.subarray(U.offset,U.offset+Q))}catch{throw new G("Invalid RAR5 UTF-8 link target")}}}if(f===2){fa(S,L,n.limits);let q=Lr(L);if(q){let U;if(D!==void 0){let Q=m5n(q,D);D=Q.target,U=Q.resolveTarget}let z=(C&1)!==0;s.push({format:5,path:q,dataStart:T,packedSize:h,unpackedSize:S,method:v,version:M,dictionarySize:N,solid:O,crc:k,isDirectory:z,mtimeMs:A,mode:F===1?E:void 0,linkTarget:D,linkResolveTarget:U}),cr(s.length,n.limits)}}else if(L==="RR")throw new G("Unsupported RAR5 recovery record")}else if(f===5){if((Xa(e,d,y,"end flags")&1)!==0)throw new G("Unsupported multi-volume RAR5 archive");break}else if((m&4)===0)throw new G(`Unsupported RAR5 header type ${f}`);o=R}if(!r)wu("RAR5 main header is missing");return s}function lei(e,t,n){let s=[],o=t+Wgt.byteLength,r=!1;while(o<e.byteLength){hg(o,7,e.byteLength,"RAR4 base header");let i=Rs(e,o),a=e[o+2],l=Rs(e,o+3),u=Rs(e,o+5);if(u<7)wu("invalid RAR4 header size");Ns(u,n.limits,"RAR4 header");let p=CC(o,u,e.byteLength,"RAR4 header");if((sa(e.subarray(o+2,p))&65535)!==i)wu("RAR4 header CRC mismatch");let c=0,d=o+7;if((l&32768)!==0)hg(d,4,p,"RAR4 additional size"),c=wn(e,d),d+=4;let f=p,m=CC(f,c,e.byteLength,"RAR4 data area");if(a===115){if((l&1)!==0)throw new G("Unsupported multi-volume RAR4 archive");if((l&64)!==0)throw new G("Unsupported RAR4 recovery record");if((l&128)!==0)throw new G("Encrypted RAR4 headers are not supported");r=!0}else if(a===116){hg(d,21,p,"RAR4 file header");let g=wn(e,d);d+=4;let h=e[d++],T=wn(e,d);d+=4;let R=wn(e,d);d+=4;let y=e[d++],C=e[d++],S=Rs(e,d);d+=2;let E=wn(e,d);d+=4;let A=c,k=g;if((l&256)!==0)hg(d,8,p,"RAR4 high sizes"),A+=wn(e,d)*4294967296,d+=4,k+=wn(e,d)*4294967296,d+=4,m=CC(f,A,e.byteLength,"RAR4 file data");if((l&3)!==0)throw new G("Unsupported multi-volume RAR4 member");if((l&4)!==0)throw new G("Encrypted RAR4 file data is not supported");if(C<48||C>53)throw new G(`Unsupported RAR4 compression method 0x${C.toString(16)}`);wo(S,"member path",n.limits.maxPathBytes),hg(d,S,p,"RAR4 file name");let x=e.subarray(d,d+S),M=(l&512)!==0?pei(x):c0e.decode(x);if(d+=S,(l&1024)!==0)hg(d,8,p,"RAR4 salt"),d+=8;let O=u5n(R);if((l&4096)!==0){hg(d,2,p,"RAR4 extended time flags");let P=Rs(e,d);d+=2;for(let N=0;N<4;N++){let F=P>>>(3-N)*4&15;if((F&8)===0)continue;let _=R;if(N!==0)hg(d,4,p,"RAR4 extended time"),_=wn(e,d),d+=4;let L=u5n(_)+((F&4)!==0?1000:0),D=0,q=F&3;hg(d,q,p,"RAR4 extended time precision");for(let U=0;U<q;U++)D|=e[d++]<<(U+3-q)*8;if(L+=D/1e4,N===0)O=L}}fa(k,M,n.limits);let v=Lr(M);if(v){let P=(l>>>5&7)===7,N=h===3?E:void 0,F,_;if(N!==void 0&&(N&61440)===40960){if(C!==48||A!==k)throw new G(`Unsupported compressed RAR4 symlink '${v}'`);wo(A,"link target",n.limits.maxPathBytes);let L=m5n(v,c0e.decode(e.subarray(f,m)));F=L.target,_=L.resolveTarget}s.push({format:4,path:v,dataStart:f,packedSize:A,unpackedSize:k,method:C-48,version:y,dictionarySize:cei(l),solid:(l&16)!==0,crc:T,isDirectory:P,mtimeMs:O,mode:N,linkTarget:F,linkResolveTarget:_}),cr(s.length,n.limits)}}else if(a===120)throw new G("Unsupported RAR4 recovery record");else if(a===123){if((l&1)!==0)throw new G("Unsupported multi-volume RAR4 archive");break}o=m}if(!r)wu("RAR4 main header is missing");return s}function uei(e,t,n){let s=[],o={offset:t};while(o.offset<n){let r=Xa(e,o,n,"extra record size"),i=o.offset,a=CC(i,r,n,"extra record"),l=Xa(e,o,a,"extra record type");s.push({type:l,start:o.offset,end:a}),o.offset=a}return s}function Xa(e,t,n,s){let o=0,r=1;for(let i=0;i<10;i++){if(t.offset>=n)wu(`truncated ${s}`);let a=e[t.offset++];if(o+=(a&127)*r,!Number.isSafeInteger(o))wu(`${s} is too large`);if((a&128)===0)return o;r*=128}wu(`${s} vint is too long`)}function Bgt(e){let t=Math.min(e.byteLength,1048576+pW.byteLength);for(let n=0;n<t;n++){if(l5n(e,n,pW))return{version:5,offset:n};if(l5n(e,n,Wgt))return{version:4,offset:n}}return}function l5n(e,t,n){if(t+n.byteLength>e.byteLength)return!1;for(let s=0;s<n.byteLength;s++)if(e[t+s]!==n[s])return!1;return!0}function pei(e){let t=e.indexOf(0);if(t<0)return c0e.decode(e);if(++t>=e.byteLength)return c0e.decode(e.subarray(0,t-1));let n=e[t++],s=0,o=0,r=0,i="";while(t<e.byteLength){if(r===0){if(o=e[t++],r=8,t>=e.byteLength)break}let a=o>>>6;if(a===0)i+=String.fromCharCode(e[t++]),s++;else if(a===1)i+=String.fromCharCode(e[t++]+(n<<8)),s++;else if(a===2){if(t+1>=e.byteLength)wu("truncated RAR4 Unicode name");i+=String.fromCharCode(e[t]|e[t+1]<<8),t+=2,s++}else{let l=e[t++];if((l&128)!==0){if(t>=e.byteLength)wu("truncated RAR4 Unicode name correction");let u=e[t++];l=(l&127)+2;for(;l>0&&s<e.byteLength;l--,s++)i+=String.fromCharCode(n<<8|e[s]+u&255)}else{l+=2;for(;l>0&&s<e.byteLength;l--,s++)i+=String.fromCharCode(e[s])}}o=o<<2&255,r-=2}return i}function m5n(e,t){let n=t.replace(/\\/g,"/");if(n.startsWith("/"))return{target:n,resolveTarget:!1};let s=e.split("/");s.pop();for(let o of n.split("/")){if(!o||o===".")continue;if(o===".."){if(s.length===0)return{target:n,resolveTarget:!1};s.pop()}else s.push(o)}return{target:s.join("/"),resolveTarget:!0}}function cei(e){let t=e>>>5&7;return t===7?4194304:65536*2**t}function u5n(e){let t=(e&31)*2,n=e>>>5&63,s=e>>>11&31,o=e>>>16&31,r=e>>>21&15,i=(e>>>25&127)+1980;return new Date(i,r-1,o,s,n,t).getTime()}function dei(e,t){return(wn(e,t)+wn(e,t+4)*4294967296)/1e4-11644473600000}function CC(e,t,n,s){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||t<0)wu(`invalid ${s} range`);let o=e+t;if(!Number.isSafeInteger(o)||o<e||o>n)wu(`truncated ${s}`);return o}function hg(e,t,n,s){CC(e,t,n,s)}function wu(e){throw new G(`Invalid RAR archive: ${e}`)}var Wgt,pW,a5n,c0e,f5n=async(e,t)=>{if(!Number.isSafeInteger(e.size)||e.size<0)throw new G("Archive is too large to read safely");let n=await rei(e,t),s=iei(e.size,n.segments),o=n.marker,r=o.version===5?aei(s,o.offset,t):lei(s,o.offset,t),i=new c5n(e,r,t),a=[];for(let l=0;l<r.length;l++){let u=r[l],p={path:u.path,isDirectory:u.isDirectory,size:u.unpackedSize};if(u.mtimeMs!==void 0)p.mtimeMs=u.mtimeMs;if(u.mode!==void 0)p.mode=u.mode;if(u.linkTarget!==void 0)p.storage={type:"link",targetPath:u.linkTarget,resolveTarget:u.linkResolveTarget??!1};else if(!u.isDirectory)p.storage={type:"member",source:i.member(l)};a.push(p)}return a};var g5n=w(()=>{Lh();pO();Qr();Hp();sf();t5n();i5n();Wgt=Uint8Array.of(82,97,114,33,26,7,0),pW=Uint8Array.of(82,97,114,33,26,7,1,0),a5n=new TextDecoder("utf-8",{fatal:!0}),c0e=new TextDecoder("windows-1252")});function hei(e,t){let n=e%t;return n===0?e:e+t-n}async function kae(e,t,n,s){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<t||n>e.size)throw new G(`Invalid RPM package: truncated ${s}`);let o=await e.read(t,n);if(o.byteLength!==n-t)throw new G(`Invalid RPM package: truncated ${s}`);return o}function S5n(e,t,n){if(e.byteLength!==cW||Fh(e,0)!==fei)throw new G(`Invalid RPM package: corrupt ${n} header magic`);for(let a=4;a<8;a++)if(e[a]!==0)throw new G(`Invalid RPM package: corrupt ${n} header reserved bytes`);let s=Fh(e,8),o=Fh(e,12);cr(s,t.limits);let i=s*Aae+o;if(!Number.isSafeInteger(i))throw new G(`Invalid RPM package: ${n} header is too large`);return Ns(cW+i,t.limits,`RPM ${n} header`),{indexCount:s,dataSize:o,bodySize:i,totalSize:cW+i}}function w5n(e,t,n){let s=t.indexCount*Aae;if(e.byteLength!==t.bodySize)throw new G(`Invalid RPM package: truncated ${n} header`);for(let o=0;o<t.indexCount;o++){let r=o*Aae,i=Fh(e,r),a=Fh(e,r+4),l=Fh(e,r+8),u=Fh(e,r+12);if(l>t.dataSize)throw new G(`Invalid RPM package: tag ${i} points outside header data`);let p=t.dataSize-l,c=0;if(a===1||a===2||a===7)c=1;else if(a===3)c=2;else if(a===4)c=4;else if(a===5)c=8;else if(a===0){if(u!==0)throw new G(`Invalid RPM package: null tag ${i} has values`);continue}else if(a===f0e||a===8||a===9){let d=a===f0e?1:u;if(a===f0e&&u!==1)throw new G(`Invalid RPM package: string tag ${i} has an invalid count`);if(d>p)throw new G(`Invalid RPM package: string tag ${i} exceeds header data`);let f=s+l,m=s+t.dataSize;for(let g=0;g<d;g++){while(f<m&&e[f]!==0)f++;if(f===m)throw new G(`Invalid RPM package: string tag ${i} is not NUL-terminated`);f++}continue}else throw new G(`Invalid RPM package: tag ${i} uses unknown data type ${a}`);if(l%c!==0)throw new G(`Invalid RPM package: tag ${i} data is misaligned`);if(u*c>p)throw new G(`Invalid RPM package: tag ${i} exceeds header data`)}}function Tei(e,t,n,s,o,r,i){if(r!==f0e||o!==1)throw new G(`Invalid RPM package: tag ${i} must contain one string`);let a=t+s,l=t+n,u=a;while(u<l&&e[u]!==0)u++;if(u===l)throw new G(`Invalid RPM package: tag ${i} string is not NUL-terminated`);if(u-a>4096)throw new G(`Invalid RPM package: tag ${i} string is too large`);try{return gei.decode(e.subarray(a,u))}catch{throw new G(`Invalid RPM package: tag ${i} is not valid UTF-8`)}}function Rei(e,t){w5n(e,t,"main");let n=t.indexCount*Aae;if(e.byteLength!==t.bodySize)throw new G("Invalid RPM package: truncated main header");let s={};for(let o=0;o<t.indexCount;o++){let r=o*Aae,i=Fh(e,r),a=Fh(e,r+4),l=Fh(e,r+8),u=Fh(e,r+12);if(l>t.dataSize)throw new G(`Invalid RPM package: tag ${i} points outside header data`);if(i!==h5n&&i!==T5n&&i!==R5n&&i!==y5n&&i!==C5n)continue;let p=Tei(e,n,t.dataSize,l,u,a,i);switch(i){case h5n:s.name=p;break;case T5n:s.version=p;break;case R5n:s.payloadFormat=p;break;case y5n:s.payloadCompressor=p;break;case C5n:s.payloadFlags=p;break}}return s}function yei(e,t){if(e.name&&e.version)return`${e.name}-${e.version}`;return e.name??t}function b5n(e){if(e.byteLength<13||e[0]>224)return!1;let t=(e[1]|e[2]<<8|e[3]<<16|e[4]<<24)>>>0;if(t<4096)return!1;let n=2**Math.ceil(Math.log2(t));return t===n||t===n-n/4}async function Cei(e,t,n,s){let r=t.payloadCompressor?.trim().toLowerCase();if(!r||!["gzip","gz","bzip2","bzip","xz","lzma","zstd","zstdio","none"].includes(r))if(_Pe(e))r="gzip";else if(FPe(e))r="bzip2";else if(GPe(e))r="xz";else if(jPe(e))r="zstd";else if(b5n(e))r="lzma";else if(Tae(e))r="none";else throw new G(`RPM package '${n}' uses unsupported payload compressor '${t.payloadCompressor??"unknown"}'`);switch(r){case"gzip":case"gz":return oW(e,s);case"bzip2":case"bzip":return fO(e,s);case"xz":return mO(e,s);case"zstd":case"zstdio":return gO(e,s);case"lzma":if(!b5n(e))throw new G(`RPM package '${n}' has a malformed LZMA payload`);return OY(e,s);case"none":if(!Tae(e))throw new G(`RPM package '${n}' has an invalid uncompressed CPIO payload`);return e;default:throw new G(`RPM package '${n}' uses unsupported payload compressor '${r}'`)}}async function Sei(e,t){let n=await kae(e,0,d0e+cW,"lead and signature header");if(!Ggt(n))throw new G("Invalid RPM package: bad lead magic");let s=n[4],o=n[6]<<8|n[7];if(s<3||o>1)throw new G("Unsupported RPM package lead version or type");let r=n[78]<<8|n[79];if(r!==mei)throw new G(`Unsupported RPM signature type ${r}; only header signatures are supported`);let i=n.subarray(10,76).indexOf(0),a=n.subarray(10,i<0?76:10+i),l="unknown package";try{let A=new TextDecoder("utf-8",{fatal:!0}).decode(a);if(A)l=A}catch{}let u=S5n(n.subarray(d0e),t,"signature"),p=d0e+u.totalSize,c=hei(p,8),d=await kae(e,d0e+cW,c,"signature header");if(d.byteLength<u.bodySize)throw new G("Invalid RPM package: truncated signature header");w5n(d.subarray(0,u.bodySize),u,"signature");for(let A=u.bodySize;A<d.byteLength;A++)if(d[A]!==0)throw new G("Invalid RPM package: non-zero signature alignment padding");let f=await kae(e,c,c+cW,"main header intro"),m=S5n(f,t,"main");Ns(u.totalSize+m.totalSize,t.limits,"RPM headers");let g=c+cW,h=await kae(e,g,g+m.bodySize,"main header"),T=Rei(h,m),R=yei(T,l);if(T.payloadFormat&&T.payloadFormat.toLowerCase()!=="cpio")throw new G(`RPM package '${R}' uses unsupported payload format '${T.payloadFormat}'`);let y=c+m.totalSize,C=e.size-y;ki(C,t.limits);let S=await kae(e,y,e.size,"payload"),E=await Cei(S,T,R,t.limits.maxInMemorySize);return ki(E.byteLength,t.limits),Rgt(E,t)}function Ggt(e){return e.byteLength>=4&&e[0]===237&&e[1]===171&&e[2]===238&&e[3]===219}var d0e=96,cW=16,Aae=16,fei=2393761793,mei=5,h5n=1000,T5n=1001,R5n=1124,y5n=1125,C5n=1126,f0e=6,gei,E5n=async(e,t)=>{try{return await Sei(e,t)}catch(n){if(n instanceof G)throw n;throw new G(n instanceof Error?n.message:String(n))}};var k5n=w(()=>{Lh();fae();mae();rW();hae();PY();ygt();Qr();Hp();gei=new TextDecoder("utf-8",{fatal:!0})});function A5n(e){switch(e){case 0n:return"Copy";case 3n:return"Delta";case 0x21n:return"LZMA2";case 0x30101n:return"LZMA";case 0x30401n:return"PPMd";case 0x3030103n:return"BCJ x86";case 0x303011bn:return"BCJ2";case 0x6f10701n:return"7zAES";case 0x40108n:return"Deflate";case 0x40109n:return"Deflate64";case 0x40202n:return"BZip2";case 0x3030205n:return"BCJ PowerPC";case 0x3030401n:return"BCJ IA64";case 0x3030501n:return"BCJ ARM";case 0x3030701n:return"BCJ ARM Thumb";case 0x3030805n:return"BCJ SPARC";case 0xan:return"BCJ ARM64";case 0xbn:return"BCJ RISC-V";default:return`method 0x${e.toString(16)}`}}function I5n(e,t){if(t+4>e.byteLength)throw new G("Invalid 7z BCJ properties");return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function bei(e,t){let n=new Uint8Array(256),s=0;for(let o=0;o<e.byteLength;o++){let r=e[o]+n[t+s&255]&255;n[s]=r,e[o]=r,s=s-1&255}}function wei(e,t){let n=[0,1,2,2,3],s=0,o=4294967291;if(e.byteLength<5)return;let r=0,i=e.byteLength-5;while(r<=i){let a=e[r];if(a!==232&&a!==233){r++;continue}let l=t+r>>>0,u=l-o>>>0;if(o=l,u>5)s=0;else for(let p=0;p<u;p++)s=(s&119)<<1>>>0;if(a=e[r+4],(a===0||a===255)&&s>>>1<=4&&s>>>1!==3){let p=I5n(e,r+1),c=0;for(;;){if(c=p-l-5>>>0,s===0)break;let d=n[s>>>1]*8,f=c>>>24-d&255;if(f!==0&&f!==255)break;let m=d===0?4294967295:2**(32-d)-1;p=(c^m)>>>0}e[r+4]=~((c>>>24&1)-1)&255,e[r+3]=c>>>16,e[r+2]=c>>>8,e[r+1]=c,r+=5,s=0}else if(r++,s|=1,a===0||a===255)s|=16}}class m0e{#e;#t;#n;#s;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}read(){return this.#s??=this.#o(),this.#s}async#o(){let e=this.#t;if(e.packedIndices.length!==1||e.packOffsets.length!==1||e.packSizes.length!==1){if(e.coders.find((a)=>a.id===0x303011bn))throw new G("Unsupported 7z coder BCJ2 (multi-input folder)");throw new G("Unsupported 7z folder graph with multiple packed input streams")}let t=e.packOffsets[0],n=e.packSizes[0];if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t+n>this.#e.size)throw new G("Invalid 7z packed-stream range");let s=await this.#e.read(t,t+n);if(e.packCrcs[0]!==void 0&&sa(s)!==e.packCrcs[0])throw new G("Invalid 7z packed-stream CRC32 mismatch");let o=e.packedIndices[0],r=new Set;for(;;){let i=e.coders.findIndex((p)=>o>=p.inputStart&&o<p.inputStart+p.numInputs);if(i<0||r.has(i))throw new G("Invalid 7z folder binding graph");r.add(i);let a=e.coders[i];if(a.numInputs!==1||a.numOutputs!==1)throw new G(`Unsupported 7z coder ${A5n(a.id)} stream topology`);let l=e.unpackSizes[a.outputStart];if(l===void 0)throw new G("Invalid 7z coder unpack size");switch(ki(l,this.#n),a.id){case 0n:if(a.properties.byteLength!==0||s.byteLength!==l)throw new G("Invalid 7z Copy coder size or properties");break;case 0x30101n:s=await gae(a.properties,s,l);break;case 0x21n:if(a.properties.byteLength!==1)throw new G("Invalid 7z LZMA2 coder properties");if(s=await UPe(a.properties[0],s,l),s.byteLength!==l)throw new G("7z LZMA2 coder output size mismatch");break;case 3n:if(a.properties.byteLength!==1||s.byteLength!==l)throw new G("Invalid 7z Delta coder properties or size");s=s.slice(),bei(s,a.properties[0]+1);break;case 0x3030103n:{if(a.properties.byteLength!==0&&a.properties.byteLength!==4)throw new G("Invalid 7z BCJ x86 coder properties");if(s.byteLength!==l)throw new G("7z BCJ x86 coder output size mismatch");let p=a.properties.byteLength===4?I5n(a.properties,0):0;s=s.slice(),wei(s,p);break}case 0x30401n:throw new G("Unsupported 7z coder PPMd");case 0x6f10701n:throw new G("Encrypted 7z archives use unsupported coder 7zAES");default:throw new G(`Unsupported 7z coder ${A5n(a.id)}`)}let u=e.bindPairs.find((p)=>p.output===a.outputStart);if(!u)break;o=u.input}if(r.size!==e.coders.length)throw new G("Unsupported 7z folder graph with disconnected coders");if(e.crc!==void 0&&sa(s)!==e.crc)throw new G("Invalid 7z folder CRC32 mismatch");return s}}var x5n=w(()=>{pO();rW();Qr();Hp()});class RO{bytes;pos=0;constructor(e){this.bytes=e}get remaining(){return this.bytes.byteLength-this.pos}readByte(){if(this.pos>=this.bytes.byteLength)throw new G("Invalid 7z header: truncated data");return this.bytes[this.pos++]}readBytes(e){if(!Number.isSafeInteger(e)||e<0||e>this.remaining)throw new G("Invalid 7z header: truncated or invalid-sized data");let t=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,t}readUInt32(){let e=this.readBytes(4);return(e[0]|e[1]<<8|e[2]<<16|e[3]<<24)>>>0}readUInt64BigInt(){let e=this.readBytes(8),t=0n;for(let n=0;n<8;n++)t|=BigInt(e[n])<<BigInt(n*8);return t}readNumberBigInt(){let e=this.readByte(),t=0n,n=128;for(let s=0;s<8;s++){if((e&n)===0)return t|BigInt(e&n-1)<<BigInt(s*8);t|=BigInt(this.readByte())<<BigInt(s*8),n>>>=1}return t}readNumber(e="number"){let t=this.readNumberBigInt();if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new G(`7z ${e} is too large to read safely`);return Number(t)}skipSizedProperty(){this.readBytes(this.readNumber("property size"))}}function g0e(e,t){let n=Array(t),s=0,o=0;for(let r=0;r<t;r++){if(o===0)s=e.readByte(),o=128;n[r]=(s&o)!==0,o>>>=1}return n}function Ygt(e,t){if(e.readByte()!==0)return Array(t).fill(!0);return g0e(e,t)}function Kgt(e,t){let n=Ygt(e,t),s=Array(t);for(let o=0;o<t;o++)if(n[o])s[o]=e.readUInt32();return{defined:n,values:s}}function jgt(e,t,n){let s=e.readNumber("property ID");if(s!==t)throw new G(`Invalid 7z header: expected ${n} ID 0x${t.toString(16)}, got 0x${s.toString(16)}`)}function Iei(e,t){let n=e.readNumber("folder coder count");if(n===0||n>t.limits.maxEntries)throw new G("Invalid 7z folder coder count");let s=[],o=0,r=0;for(let d=0;d<n;d++){let f=e.readByte();if((f&192)!==0)throw new G("Unsupported 7z coder alternatives or reserved flags");let m=f&15;if(m===0||m>8)throw new G("Invalid 7z coder method ID size");let g=0n;for(let S of e.readBytes(m))g=g<<8n|BigInt(S);let h=(f&16)!==0,T=h?e.readNumber("coder input count"):1,R=h?e.readNumber("coder output count"):1;if(T===0||R===0||o+T>t.limits.maxEntries||r+R>t.limits.maxEntries)throw new G("Invalid or excessive 7z coder stream count");let y=(f&32)!==0?e.readNumber("coder properties size"):0;Ns(y,t.limits,"coder properties");let C=e.readBytes(y).slice();s.push({id:g,properties:C,inputStart:o,outputStart:r,numInputs:T,numOutputs:R}),o+=T,r+=R}let i=r-1;if(i<0||i>o)throw new G("Invalid 7z folder bind-pair count");let a=[],l=new Set,u=new Set;for(let d=0;d<i;d++){let f=e.readNumber("bind input index"),m=e.readNumber("bind output index");if(f>=o||m>=r||l.has(f)||u.has(m))throw new G("Invalid 7z folder bind pair");l.add(f),u.add(m),a.push({input:f,output:m})}let p=o-i,c=[];if(p===1){for(let d=0;d<o;d++)if(!l.has(d))c.push(d)}else for(let d=0;d<p;d++){let f=e.readNumber("packed stream index");if(f>=o||l.has(f))throw new G("Invalid 7z packed stream index");l.add(f),c.push(f)}if(c.length!==p)throw new G("Invalid 7z folder packed-stream map");return{coders:s,bindPairs:a,packedIndices:c,unpackSizes:[],packOffsets:[],packSizes:[],packCrcs:[]}}function Xgt(e){let t=new Set(e.bindPairs.map((o)=>o.output)),s=e.coders.flatMap((o)=>Array.from({length:o.numOutputs},(r,i)=>o.outputStart+i)).filter((o)=>!t.has(o));if(s.length!==1)throw new G("Unsupported 7z folder with multiple final output streams");return s[0]}function xei(e,t,n){t.packPosition=e.readNumber("pack position");let s=e.readNumber("pack stream count");if(s>n.limits.maxEntries)throw new G("7z has too many packed streams");for(;;){let o=e.readNumber("PackInfo property ID");if(o===0)break;if(o===9){if(t.packSizes.length!==0)throw new G("Invalid duplicate 7z pack sizes");for(let r=0;r<s;r++)t.packSizes.push(e.readNumber("packed stream size"))}else if(o===10){if(t.packCrcs.length!==0)throw new G("Invalid duplicate 7z pack CRCs");t.packCrcs=Kgt(e,s).values}else e.skipSizedProperty()}if(t.packSizes.length!==s)throw new G("Invalid 7z PackInfo without complete sizes");if(t.packCrcs.length===0)t.packCrcs=Array(s).fill(void 0)}function Mei(e,t,n){jgt(e,11,"Folder");let s=e.readNumber("folder count");if(s>n.limits.maxEntries)throw new G("7z has too many folders");if(e.readByte()!==0)throw new G("Unsupported 7z external folder definitions");for(let o=0;o<s;o++)t.folders.push(Iei(e,n));jgt(e,12,"CodersUnpackSize");for(let o of t.folders){let r=o.coders.reduce((i,a)=>i+a.numOutputs,0);for(let i=0;i<r;i++)o.unpackSizes.push(e.readNumber("coder unpack size"))}for(;;){let o=e.readNumber("UnpackInfo property ID");if(o===0)break;if(o===10){let r=Kgt(e,s);for(let i=0;i<s;i++)t.folders[i].crc=r.values[i]}else e.skipSizedProperty()}}function vei(e,t){let n=Array(t.folders.length).fill(1),s,o;for(;;){let a=e.readNumber("SubStreamsInfo property ID");if(a===0)break;if(a===13)for(let l=0;l<n.length;l++)n[l]=e.readNumber("folder substream count");else if(a===9){s=[];for(let l=0;l<t.folders.length;l++)for(let u=1;u<n[l];u++)s.push(e.readNumber("substream size"))}else if(a===10){let l=0;for(let u=0;u<n.length;u++)if(n[u]!==1||t.folders[u].crc===void 0)l+=n[u];o=Kgt(e,l)}else e.skipSizedProperty()}let r=0,i=0;for(let a=0;a<t.folders.length;a++){let l=t.folders[a],u=n[a],p=0,c=l.unpackSizes[Xgt(l)];for(let d=0;d<u;d++){let f=d+1===u?c-p:s?.[r++]??(()=>{throw new G("Invalid 7z SubStreamsInfo without sizes")})();if(f<0||p+f>c)throw new G("Invalid 7z substream size total");let m;if(u===1&&l.crc!==void 0)m=l.crc;else m=o?.values[i++];t.substreams.push({folderIndex:a,offset:p,size:f,crc:m}),p+=f}if(p!==c)throw new G("Invalid 7z substream sizes")}}function Oei(e,t){let n=32+e.packPosition,s=[];for(let r of e.packSizes){if(!Number.isSafeInteger(n)||n<0||r<0||n+r>t)throw new G("Invalid 7z packed-stream range");s.push(n),n+=r}let o=0;for(let r of e.folders)for(let i=0;i<r.packedIndices.length;i++){if(o>=e.packSizes.length)throw new G("Invalid 7z folder-to-pack-stream mapping");r.packOffsets.push(s[o]),r.packSizes.push(e.packSizes[o]),r.packCrcs.push(e.packCrcs[o]),o++}if(o!==e.packSizes.length)throw new G("Invalid unused 7z packed streams")}function zgt(e,t,n){let s={packPosition:0,packSizes:[],packCrcs:[],folders:[],substreams:[]};for(;;){let o=e.readNumber("StreamsInfo property ID");if(o===0)break;if(o===6)xei(e,s,n);else if(o===7)Mei(e,s,n);else if(o===8)vei(e,s);else throw new G(`Unsupported 7z StreamsInfo property ID 0x${o.toString(16)}`)}if(s.folders.length>0&&s.substreams.length===0)for(let o=0;o<s.folders.length;o++){let r=s.folders[o];s.substreams.push({folderIndex:o,offset:0,size:r.unpackSizes[Xgt(r)],crc:r.crc})}return Oei(s,t),s}async function M5n(e,t,n){let s=[];for(let o of t.folders){let r=o.unpackSizes[Xgt(o)];Ns(r,n.limits,"decoded header"),ki(r,n.limits),s.push(await new m0e(e,o,n.limits).read())}return s}function Jgt(e,t){let n=e.readByte();if(n===0)return e;if(n!==1)throw new G("Invalid 7z external-property flag");let s=e.readNumber("external property stream index"),o=t[s];if(!o)throw new G("Invalid 7z external property stream index");return new RO(o)}function Pei(e,t,n,s){let o=Jgt(e,n),r=[];for(let i=0;i<t;i++){let a=o.pos;while(o.remaining>=2&&(o.bytes[o.pos]!==0||o.bytes[o.pos+1]!==0))o.pos+=2;if(wo(o.pos-a,"encoded member path",s*2),o.remaining<2)throw new G("Invalid 7z UTF-16 file-name table");let l;try{l=Eei.decode(o.bytes.subarray(a,o.pos))}catch{throw new G("Invalid 7z UTF-16 file name")}o.pos+=2,nf(l,"member path",s),r.push(l)}return r}function Nei(e,t,n){let s=Ygt(e,t),o=Jgt(e,n),r=Array(t);for(let i=0;i<t;i++)if(s[i]){let a=o.readUInt64BigInt(),l=Number(a/10000n)-Aei;if(Number.isFinite(l))r[i]=l}return r}function Fei(e,t,n){let s=Ygt(e,t),o=Jgt(e,n),r=Array(t);for(let i=0;i<t;i++)if(s[i])r[i]=o.readUInt32();return r}function Lei(e,t,n){let s=e.readNumber("file count");cr(s,n.limits);let o={names:Array(s).fill(""),emptyStreams:Array(s).fill(!1),emptyFiles:[],antiFiles:[],mtimes:Array(s),attributes:Array(s)};for(;;){let r=e.readNumber("FilesInfo property ID");if(r===0)break;let i=e.readNumber("FilesInfo property size");Ns(i,n.limits,"file property");let a=new RO(e.readBytes(i));if(r===14)o.emptyStreams=g0e(a,s);else if(r===15)o.emptyFiles=g0e(a,o.emptyStreams.filter(Boolean).length);else if(r===16)o.antiFiles=g0e(a,o.emptyStreams.filter(Boolean).length);else if(r===17)o.names=Pei(a,s,t,n.limits.maxPathBytes);else if(r===20)o.mtimes=Nei(a,s,t);else if(r===21)o.attributes=Fei(a,s,t);else if(r===25)while(a.remaining>0)if(a.readByte()!==0)throw new G("Invalid non-zero 7z dummy property");else a.pos=a.bytes.byteLength;if(a.remaining!==0)throw new G(`Invalid 7z file property 0x${r.toString(16)} length`)}return o}async function _ei(e,t,n){let s=new RO(t);jgt(s,1,"Header");let o=[],r,i;for(;;){let a=s.readNumber("Header property ID");if(a===0)break;if(a===2)for(;;){if(s.readNumber("archive property ID")===0)break;s.skipSizedProperty()}else if(a===3)o=await M5n(e,zgt(s,e.size,n),n);else if(a===4)r=zgt(s,e.size,n);else if(a===5)i=Lei(s,o,n);else throw new G(`Unsupported 7z header property ID 0x${a.toString(16)}`)}if(s.remaining!==0)throw new G("Invalid 7z trailing header data");if(!r)r={packPosition:0,packSizes:[],packCrcs:[],folders:[],substreams:[]};if(!i)i={names:[],emptyStreams:[],emptyFiles:[],antiFiles:[],mtimes:[],attributes:[]};return{streams:r,files:i}}class Vgt{#e;#t;#n;#s;constructor(e,t){this.#e=e,this.#t=t.offset,this.#n=t.size,this.#s=t.crc}async read(e,t){if(e!==this.#n)throw new G(`7z member '${t}' declared size changed during extraction`);let n=await this.#e.read();if(this.#t<0||this.#t+e>n.byteLength)throw new G(`Invalid 7z member '${t}' folder range`);let s=n.subarray(this.#t,this.#t+e);if(this.#s!==void 0&&sa(s)!==this.#s)throw new G(`Invalid 7z member '${t}' CRC32 mismatch`);return s.slice()}}class v5n{async read(e,t){if(e!==0)throw new G(`Invalid empty 7z member '${t}' size`);return new Uint8Array(0)}}function Hei(e,t){let n=t.replace(/\\/g,"/");if(n.startsWith("/"))return{targetPath:n,resolveTarget:!1};let s=e.split("/");s.pop();for(let o of n.split("/")){if(!o||o===".")continue;if(o===".."){if(s.length===0)return{targetPath:n,resolveTarget:!1};s.pop()}else s.push(o)}return{targetPath:s.join("/"),resolveTarget:!0}}async function qei(e,t,n,s){let o=t.folders.map((l)=>new m0e(e,l,s.limits)),r=[],i=0,a=0;for(let l=0;l<n.names.length;l++){let u=n.names[l],p=Lr(u),c=n.emptyStreams[l]??!1,d=c?n.emptyFiles[i]??!1:!1,f=c?n.antiFiles[i]??!1:!1;if(c)i++;let m=c?void 0:t.substreams[a++];if(!c&&!m)throw new G("Invalid 7z file-to-substream mapping");if(!p||f)continue;let g=n.attributes[l],h=g!==void 0&&g>>>16!==0?g>>>16:void 0,T=h!==void 0&&(h&61440)===40960,R=c&&!d||g!==void 0&&(g&16)!==0||h!==void 0&&(h&61440)===16384,y=m?.size??0;fa(y,p,s.limits);let C={path:p,isDirectory:R,size:y,mtimeMs:n.mtimes[l],mode:h};if(T&&m){wo(y,"link target",s.limits.maxPathBytes);let S=new Vgt(o[m.folderIndex],m),E;try{E=kei.decode(await S.read(y,p))}catch(k){if(k instanceof G)throw k;throw new G(`Invalid UTF-8 symlink target in 7z member '${p}'`)}nf(E,"link target",s.limits.maxPathBytes);let A=Hei(p,E);C.storage={type:"link",targetPath:A.targetPath,resolveTarget:A.resolveTarget}}else if(!R)C.storage=m?{type:"member",source:new Vgt(o[m.folderIndex],m)}:{type:"member",source:Dei};r.push(C),cr(r.length,s.limits)}if(a!==t.substreams.length)throw new G("Invalid unused 7z substreams");return r}function Qgt(e){if(e.byteLength<$gt.byteLength)return!1;for(let t=0;t<$gt.byteLength;t++)if(e[t]!==$gt[t])return!1;return!0}var $gt,Eei,kei,Aei=11644473600000,Dei,O5n=async(e,t)=>{try{if(e.size<32)throw new G("Invalid 7z archive: truncated signature header");let n=await e.read(0,32);if(!Qgt(n))throw new G("Invalid 7z archive signature");if(n[6]!==0)throw new G(`Unsupported 7z major version ${n[6]}`);if(sa(n.subarray(12,32))!==new RO(n.subarray(8,12)).readUInt32())throw new G("Invalid 7z start-header CRC32 mismatch");let s=new RO(n.subarray(12)),o=s.readUInt64BigInt(),r=s.readUInt64BigInt(),i=s.readUInt32();if(o>BigInt(Number.MAX_SAFE_INTEGER)||r>BigInt(Number.MAX_SAFE_INTEGER))throw new G("7z header offsets or sizes are too large to read safely");let a=32+Number(o),l=Number(r);if(Ns(l,t.limits,"next header"),!Number.isSafeInteger(a)||a<32||a+l>e.size)throw new G("Invalid 7z next-header range");let u=await e.read(a,a+l);if(sa(u)!==i)throw new G("Invalid 7z next-header CRC32 mismatch");let p=new RO(u).readNumber("next-header ID");if(p===23){let d=new RO(u);d.readNumber();let f=zgt(d,e.size,t);if(d.remaining!==0)throw new G("Invalid 7z encoded-header trailing data");let m=await M5n(e,f,t);if(m.length!==1)throw new G("Invalid 7z encoded header folder count");if(u=m[0],new RO(u).readNumber("decoded-header ID")!==1)throw new G("Invalid decoded 7z header marker")}else if(p!==1)throw new G(`Unsupported 7z next-header ID 0x${p.toString(16)}`);let c=await _ei(e,u,t);return await qei(e,c.streams,c.files,t)}catch(n){if(n instanceof G)throw n;throw new G(`Invalid 7z archive: ${n instanceof Error?n.message:String(n)}`)}};var P5n=w(()=>{pO();Qr();Hp();sf();x5n();$gt=Uint8Array.of(55,122,188,175,39,28),Eei=new TextDecoder("utf-16",{fatal:!0}),kei=new TextDecoder("utf-8",{fatal:!0});Dei=new v5n});import*as dW from"node:path";import*as T0e from"node:zlib";function R0e(e,t){if(e instanceof G)return e;return new G(`${t}: ${e instanceof Error?e.message:String(e)}`)}function h0e(e,t,n,s){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0)throw new G(`Invalid ZIP archive: ${s} has an invalid range`);let o=e+t;if(!Number.isSafeInteger(o)||o>n)throw new G(`Invalid ZIP archive: ${s} exceeds archive size`);return o}function Jei(e){for(let t=e.byteLength-xae;t>=0;t--){if(wn(e,t)!==oht)continue;if(t+xae+Rs(e,t+20)===e.byteLength)return t}throw new G("Invalid ZIP archive: missing end of central directory")}async function Qei(e,t,n,s){let o=s-Iae;if(o<0)return;let r=o>=n?t.subarray(o-n,o-n+Iae):await e.read(o,s);if(r.byteLength!==Iae||wn(r,0)!==F5n)return;if(wn(r,4)!==0||wn(r,16)!==1)throw new G("Multi-volume ZIP archives are not supported");let i=KA(r,8),a=[i],l=o-DY;if(l>=0&&l!==i)a.push(l);for(let u of a){if(u<0||u+DY>e.size)continue;let p=await e.read(u,u+DY);if(p.byteLength!==DY||wn(p,0)!==N5n)continue;let c=KA(p,4);if(c<44||u+12+c!==o)continue;if(wn(p,16)!==0||wn(p,20)!==0)throw new G("Multi-volume ZIP archives are not supported");let d=KA(p,24),f=KA(p,32);if(d!==f)throw new G("Multi-volume ZIP archives are not supported");return{entries:f,size:KA(p,40),offset:KA(p,48),physicalEnd:u,archiveOffset:0}}throw new G("Invalid ZIP archive: missing ZIP64 end of central directory")}async function Zei(e,t){if(t.entries===0)return t.offset;let n=[t.offset],s=t.physicalEnd-t.size;if(s!==t.offset)n.push(s);for(let o of n){if(o<0||o+4>e.size||o+t.size>e.size)continue;let r=await e.read(o,o+4);if(r.byteLength===4&&wn(r,0)===sht)return o}throw new G("Invalid ZIP archive: central directory is out of bounds or malformed")}async function eti(e,t){if(e.size<xae)throw new G("Invalid ZIP archive: missing end of central directory");let n=Math.min(e.size,xae+Bei),s=e.size-n,o=await e.read(s,e.size);if(o.byteLength!==n)throw new G("Invalid ZIP archive: truncated end of central directory");let r=Jei(o),i=s+r,a=Rs(o,r+4),l=Rs(o,r+6),u=Rs(o,r+8),p=Rs(o,r+10),c=wn(o,r+12),d=wn(o,r+16);if(a!==0||l!==0||u!==yO&&p!==yO&&u!==p)throw new G("Multi-volume ZIP archives are not supported");let f=u===yO||p===yO||c===hw||d===hw,m=await Qei(e,o,s,i),g=i;if(m)({entries:p,size:c,offset:d,physicalEnd:g}=m);else if(f)throw new G("Invalid ZIP archive: missing ZIP64 central-directory metadata");if(cr(p,t),Ns(c,t,"ZIP central directory"),p>Math.floor(c/46))throw new G("Invalid ZIP archive: truncated central directory");let h=d,T={entries:p,size:c,offset:d,physicalEnd:g,archiveOffset:0};return T.offset=await Zei(e,T),T.archiveOffset=T.offset-h,h0e(T.offset,T.size,e.size,"central directory"),T}function tti(e,t){let n=0n;for(let r=7;r>=0;r--)n=n<<8n|BigInt(e[t+r]);let s=n/10000n-zei,o=Number(s);return Number.isSafeInteger(o)?o:void 0}function nti(e){if(e.byteLength<4)return;let t=4;while(t+4<=e.byteLength){let n=Rs(e,t),s=Rs(e,t+2),o=t+4+s;if(o>e.byteLength)throw new G("Invalid ZIP archive: malformed NTFS extra field");if(n===1&&s>=8)return tti(e,t+4);t=o}return}function sti(e,t){if(t===0)return;let n=1980+(t>>>9&127),s=(t>>>5&15)-1,o=t&31,r=e>>>11&31,i=e>>>5&63,a=(e&31)*2;if(s<0||s>11||o<1||o>31||r>23||i>59||a>59)return;let l=new Date(n,s,o,r,i,a).getTime();return Number.isFinite(l)?l:void 0}function oti(e,t){let n={},s=0;while(s<e.byteLength){if(s+4>e.byteLength)throw new G("Invalid ZIP archive: truncated extra-field header");let o=Rs(e,s),r=Rs(e,s+2),i=s+4,a=i+r;if(a>e.byteLength)throw new G("Invalid ZIP archive: malformed extra field");let l=e.subarray(i,a);if(o===1)n.zip64=l;else if(o===28789){if(l.byteLength<5)throw new G("Invalid ZIP archive: Unicode path extra field is too small");if(l[0]===1&&wn(l,1)===sa(t))try{n.unicodePath=Yei.decode(l.subarray(5))}catch{}}else if(o===21589){if(l.byteLength<1)throw new G("Invalid ZIP archive: extended timestamp extra field is too small");if((l[0]&1)!==0){if(l.byteLength<5)throw new G("Invalid ZIP archive: extended timestamp extra field is too small");n.mtimeMs=(wn(l,1)|0)*1000}}else if(o===10&&n.mtimeMs===void 0)n.mtimeMs=nti(l);s=a}return n}function rti(e,t,n){if(!(n.uncompressedSize||n.compressedSize||n.localHeaderOffset||n.diskStart))return t;if(!e)throw new G("Invalid ZIP archive: missing ZIP64 extra field");let o=0,r={...t};if(n.uncompressedSize){if(o+8>e.byteLength)throw new G("Invalid ZIP archive: malformed ZIP64 extra field");r.uncompressedSize=KA(e,o),o+=8}if(n.compressedSize){if(o+8>e.byteLength)throw new G("Invalid ZIP archive: malformed ZIP64 extra field");r.compressedSize=KA(e,o),o+=8}if(n.localHeaderOffset){if(o+8>e.byteLength)throw new G("Invalid ZIP archive: malformed ZIP64 extra field");r.localHeaderOffset=KA(e,o),o+=8}if(n.diskStart){if(o+4>e.byteLength)throw new G("Invalid ZIP archive: malformed ZIP64 extra field");r.diskStart=wn(e,o)}return r}async function iti(e,t,n,s){try{switch(t){case 0:return e;case 8:return T0e.inflateRawSync(e,{maxOutputLength:Math.max(n,1)});case 12:return await fO(e,n);case 14:{if(e.byteLength<9||e[2]!==5||e[3]!==0)throw new G(`Invalid ZIP archive: malformed LZMA properties for '${s}'`);return await gae(e.subarray(4,9),e.subarray(9),n)}case 20:case 93:return await gO(e,n);case 95:return await mO(e,n);default:throw new G(`Unsupported ZIP compression method ${t} for '${s}'`)}}catch(o){throw R0e(o,`Failed to decompress ZIP member '${s}'`)}}class D5n{#e;#t;#n;#s;#o;#r;#a;constructor(e,t,n,s,o,r,i){this.#e=e,this.#t=t,this.#n=n,this.#s=s,this.#o=o,this.#r=r,this.#a=i}async read(e,t){try{if(fa(Math.max(e,this.#t),t,this.#a),(this.#s&(eht|tht))!==0||this.#n===99)throw new G(`Encrypted ZIP member '${t}' is not supported`);if(Vei[this.#n]!==!0)throw new G(`Unsupported ZIP compression method ${this.#n} for '${t}'`);let n=h0e(this.#r,30,this.#e.size,`local header for '${t}'`),s=await this.#e.read(this.#r,n);if(s.byteLength!==30||wn(s,0)!==nht)throw new G(`Invalid ZIP archive: malformed local header for '${t}'`);if((Rs(s,6)&(eht|tht))!==0)throw new G(`Encrypted ZIP member '${t}' is not supported`);if(Rs(s,8)!==this.#n)throw new G(`Invalid ZIP archive: local and central compression methods disagree for '${t}'`);let r=this.#r+30+Rs(s,26)+Rs(s,28),i=h0e(r,this.#t,this.#e.size,`data for '${t}'`);if(this.#n===0&&this.#t!==e)throw new G(`Invalid ZIP archive: size mismatch for '${t}' (expected ${e}, got ${this.#t})`);let a=await this.#e.read(r,i);if(a.byteLength!==this.#t)throw new G(`Invalid ZIP archive: truncated data for '${t}'`);let l=await iti(a,this.#n,e,t);if(l.byteLength!==e)throw new G(`Invalid ZIP archive: size mismatch for '${t}' (expected ${e}, got ${l.byteLength})`);if(sa(l)!==this.#o)throw new G(`Invalid ZIP archive: CRC mismatch for '${t}'`);return l}catch(n){throw R0e(n,`Failed to read ZIP member '${t}'`)}}}function ati(e,t,n,s){let o=[],r=0;for(let i=0;i<n.entries;i++){if(r+46>t.byteLength)throw new G("Invalid ZIP archive: truncated central directory");if(wn(t,r)!==sht)throw new G("Invalid ZIP archive: malformed central directory");let a=Rs(t,r+4),l=Rs(t,r+8),u=Rs(t,r+10),p=Rs(t,r+12),c=Rs(t,r+14),d=wn(t,r+16),f=wn(t,r+20),m=wn(t,r+24),g=Rs(t,r+28),h=Rs(t,r+30),T=Rs(t,r+32),R=Rs(t,r+34),y=wn(t,r+38),C=wn(t,r+42),S=r+46,E=S+g,A=E+h,k=A+T;if(!Number.isSafeInteger(k)||k>t.byteLength)throw new G("Invalid ZIP archive: truncated central-directory entry");wo(g,"member path",s.limits.maxPathBytes);let x=t.subarray(S,E),M=oti(t.subarray(E,A),x),O=rti(M.zip64,{compressedSize:f,uncompressedSize:m,localHeaderOffset:C,diskStart:R},{compressedSize:f===hw,uncompressedSize:m===hw,localHeaderOffset:C===hw,diskStart:R===yO});if(O.diskStart!==0)throw new G("Multi-volume ZIP archives are not supported");let v=M.unicodePath??((l&Zgt)!==0?_5n:Kei).decode(x);if(nf(v,"member path",s.limits.maxPathBytes),(l&(eht|tht))!==0||u===99)throw new G(`Encrypted ZIP member '${v}' is not supported`);let P=Lr(v);if(P){fa(Math.max(O.uncompressedSize,O.compressedSize),P,s.limits);let N=a>>>8,F=N===L5n||N===Wei?y>>>16:void 0,_=F===void 0?0:F&Gei,L=H$n(v)||_===$ei||(y&16)!==0,D=_===jei&&!L,q=O.localHeaderOffset+n.archiveOffset;h0e(q,30,e.size,`local header for '${P}'`);let U=new D5n(e,O.compressedSize,u,l,d,q,s.limits),z={path:P,isDirectory:L,size:L?0:O.uncompressedSize,mtimeMs:M.mtimeMs??sti(p,c),mode:F||void 0,storage:L?void 0:{type:"member",source:U}};o.push({entry:z,isSymlink:D}),cr(o.length,s.limits)}r=k}return o}async function lti(e,t){let n=await eti(e,t.limits);if(n.size===0)return[];let s=await e.read(n.offset,n.offset+n.size);if(s.byteLength!==n.size)throw new G("Invalid ZIP archive: truncated central directory");let o=ati(e,s,n,t);for(let r of o){if(!r.isSymlink)continue;if(wo(r.entry.size,"symlink target",t.limits.maxPathBytes),r.entry.storage?.type!=="member")throw new G("Invalid ZIP archive: symlink has no payload");let i=await r.entry.storage.source.read(r.entry.size,r.entry.path),a=_5n.decode(i);nf(a,"symlink target",t.limits.maxPathBytes);let l=a.replace(/\\/g,"/"),p=dW.posix.isAbsolute(l)||/^[A-Za-z]:/.test(l)||l.includes("\x00")?void 0:tf(dW.posix.join(dW.posix.dirname(r.entry.path),l));r.entry.size=0,r.entry.storage={type:"link",targetPath:p===void 0?l:p,resolveTarget:p!==void 0}}return o.map((r)=>r.entry)}function q5n(e){if(e.byteLength<4)return!1;let t=wn(e,0);return t===nht||t===oht||t===Uei}async function U5n(e){try{let t=[],n=[],s=0,o=0,r=0;for(let[c,d]of e){let f=c.replace(/\\/g,"/"),m=Lr(f);if(!m||m!==f.replace(/^\.\//,"")||f.startsWith("/")||/^[A-Za-z]:/.test(f)||f.includes("\x00"))throw new G(`Cannot write unsafe ZIP member path '${c}'`);let g=m,h=Xei.encode(g);if(h.byteLength>yO)throw new G(`ZIP member path '${g}' is too long to write`);if(d.byteLength>=hw)throw new G(`ZIP member '${g}' is too large to write`);let T=d.byteLength===0?void 0:T0e.deflateRawSync(d),R=T&&T.byteLength<d.byteLength?T:d,y=R===d?0:8;if(R.byteLength>=hw||s>=hw)throw new G("ZIP archive is too large to write member offsets safely");let C=sa(d),S=new Uint8Array(30+h.byteLength);Cl(S,0,nht),cd(S,4,20),cd(S,6,Zgt),cd(S,8,y),cd(S,10,0),cd(S,12,33),Cl(S,14,C),Cl(S,18,R.byteLength),Cl(S,22,d.byteLength),cd(S,26,h.byteLength),S.set(h,30),t.push(S,R);let E=new Uint8Array(46+h.byteLength);if(Cl(E,0,sht),cd(E,4,L5n<<8|20),cd(E,6,20),cd(E,8,Zgt),cd(E,10,y),cd(E,12,0),cd(E,14,33),Cl(E,16,C),Cl(E,20,R.byteLength),Cl(E,24,d.byteLength),cd(E,28,h.byteLength),Cl(E,38,2175008768),Cl(E,42,s),E.set(h,46),n.push(E),s+=S.byteLength+R.byteLength,o+=E.byteLength,r++,!Number.isSafeInteger(s+o)||r>hw)throw new G("ZIP archive is too large to write")}if(s>=hw||o>=hw)throw new G("ZIP archive is too large to write member offsets safely");let i=r>=yO,a=xae+(i?DY+Iae:0),l=s+o+a;if(!Number.isSafeInteger(l))throw new G("ZIP archive is too large to write");let u=new Uint8Array(l),p=0;for(let c of t)u.set(c,p),p+=c.byteLength;for(let c of n)u.set(c,p),p+=c.byteLength;if(i){let c=p;Cl(u,p,N5n),ZB(u,p+4,44),cd(u,p+12,45),cd(u,p+14,45),ZB(u,p+24,r),ZB(u,p+32,r),ZB(u,p+40,o),ZB(u,p+48,s),p+=DY,Cl(u,p,F5n),ZB(u,p+8,c),Cl(u,p+16,1),p+=Iae}return Cl(u,p,oht),cd(u,p+8,i?yO:r),cd(u,p+10,i?yO:r),Cl(u,p+12,o),Cl(u,p+16,s),u}catch(t){throw R0e(t,"Failed to encode ZIP archive")}}var nht=67324752,sht=33639248,N5n=101075792,F5n=117853008,oht=101010256,Uei=134695760,xae=22,DY=56,Iae=20,Bei=65535,yO=65535,hw=4294967295,Zgt=2048,eht=1,tht=64,L5n=3,Wei=19,Gei=61440,$ei=16384,jei=40960,zei=11644473600000n,Vei,_5n,Yei,Kei,Xei,H5n=async(e,t)=>{try{return await lti(e,t)}catch(n){throw R0e(n,"Failed to read ZIP archive")}};var rht=w(()=>{Lh();pO();fae();rW();hae();PY();Qr();Hp();sf();JA();Vei={0:!0,8:!0,12:!0,14:!0,20:!0,93:!0,95:!0},_5n=new TextDecoder("utf-8"),Yei=new TextDecoder("utf-8",{fatal:!0}),Kei=new TextDecoder("windows-1252"),Xei=new TextEncoder});import*as W5n from"node:path";function y0e(e){let t=e.toLowerCase();for(let[n,s]of iht)if(t.endsWith(`.${n}`))return s;return}function pti(e){if(!e)return"data";let t=W5n.basename(e.replace(/\\/g,"/")),n=t.toLowerCase();for(let[s]of iht)if(n.length>s.length+1&&n.endsWith(`.${s}`))return t.slice(0,t.length-s.length-1);return t||"data"}class $5n{#e;constructor(e){this.#e=e}async read(){return this.#e}}function Tw(e){return async(t,n)=>{ki(t.size,n.limits);let s=await e(await XA(t),n.limits.maxInMemorySize);if(ki(s.byteLength,n.limits),xgt(s))return bae(s,n);return[{path:pti(n.archivePath),isDirectory:!1,size:s.byteLength,storage:{type:"member",source:new $5n(s)}}]}}function j5n(e){return cti[e]}function z5n(e){for(let[s,o]of dti)if(o(e))return s;let t=e.byteLength-B5n,n=Math.max(0,e.byteLength-B5n-mti);for(let s=t;s>=n;s--)if(wn(e,s)===fti)return"zip";return}var uti,iht,G5n,cti,dti,fti=101010256,B5n=22,mti=65535;var aht=w(()=>{i3n();rgt();Lh();I3n();fae();mae();rW();G3n();hae();PY();ygt();Njn();zjn();Hp();ngt();g5n();k5n();P5n();JA();e0e();vgt();rht();uti={zip:["zip","jar","war","ear","apk","whl","ipa","xpi","vsix","nupkg","cbz"],tar:["tar"],"tar.gz":["tar.gz","tgz"],"tar.bz2":["tar.bz2","tbz2","tbz"],"tar.xz":["tar.xz","txz"],"tar.zst":["tar.zst","tzst"],"tar.Z":["tar.z"],asar:["asar"],rar:["rar","cbr"],"7z":["7z"],iso:["iso"],cab:["cab"],cpio:["cpio"],rpm:["rpm"],ar:["ar","a","lib"],deb:["deb"],lzh:["lzh","lha"],arj:["arj"],gz:["gz"],bz2:["bz2"],xz:["xz"],zst:["zst"],Z:["z"],lzma:["lzma"]},iht=Object.entries(uti).flatMap(([e,t])=>t.map((n)=>[n,e])).sort((e,t)=>t[0].length-e[0].length),G5n=iht.map(([e])=>e.replace(/\./g,"\\.")).join("|");cti={zip:H5n,tar:Ajn,"tar.gz":Tw(oW),"tar.bz2":Tw(fO),"tar.xz":Tw(mO),"tar.zst":Tw(gO),"tar.Z":Tw(fgt),asar:d3n,rar:f5n,"7z":O5n,iso:jjn,cab:A3n,cpio:sjn,rpm:E5n,ar:o0e,deb:Pjn,lzh:J$n,arj:r3n,gz:Tw(oW),bz2:Tw(fO),xz:Tw(mO),zst:Tw(gO),Z:Tw(fgt),lzma:Tw(OY)};dti=[["zip",q5n],["rar",d5n],["7z",Qgt],["cab",k3n],["rpm",Ggt],["arj",sgt],["lzh",tgt],["cpio",Tae],["deb",Pgt],["ar",Mgt],["asar",f3n],["tar.gz",_Pe],["tar.bz2",FPe],["tar.xz",GPe],["tar.zst",jPe],["tar.Z",W3n],["iso",$jn],["tar",xgt]]});import*as r_ from"node:fs/promises";import*as _h from"node:path";function hti(e){if(typeof e!=="string"){if("bytes"in e)return{source:vPe(e.bytes),format:e.format};if("source"in e)return{source:e.source,format:e.format,archivePath:e.path};let n=e.format;return{source:Qmt(e.path),format:n,archivePath:e.path}}let t=y0e(e);if(!t)throw new G(`Unsupported archive format: ${e}`);return{source:Qmt(e),format:t,archivePath:e}}async function fW(e,t={}){let{source:n,format:s,archivePath:o}=hti(e),r={...iae,...t.limits},i={limits:r,archivePath:o},a=await j5n(s)(n,i);return new Xmt(s,a,r)}function HY(e){let t=e.replace(/\\/g,"/"),n=new RegExp(`\\.(?:${G5n})(?=(?::|$))`,"gi"),s=new Set,o=[],r;while(!0){if(r=n.exec(t),r===null)break;let i=r.index+r[0].length,a=e.slice(0,i),l=t.slice(i).replace(/^:+/,""),u=`${a}\x00${l}`;if(s.has(u))continue;s.add(u),o.push({archivePath:a,subPath:l})}return o.sort((i,a)=>a.archivePath.length-i.archivePath.length)}function lht(e){return e.map((t)=>{if(t.isDirectory)return`${t.name}/`;let n=t.size>0?` (${ft(t.size)})`:"";return`${t.name}${n}`})}async function V5n(e,t,n={}){let o=(await fW({bytes:e,format:t})).listDirectory(""),r=n.limit!==void 0&&n.limit>0?o.slice(0,n.limit):o,i=lht(r);return i.length>0?i.join(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@ohmytr/coding-agent",
|
|
4
|
-
"version": "18.0.
|
|
4
|
+
"version": "18.0.4",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/ohmytr/ohmytr",
|
|
7
7
|
"author": "Stencil Labs, Inc.",
|